algorithmic modeling for Rhino
Hello,
I import from GH to python a list of integers, lets say:
A=[0,1,2,3,4,5,6,7,8]
and I want to create a 3x3 Matrix:
B=[[0,1,2], [3,4,5], [6,7,8]]
I could easily do that with numpy using reshape:
numpy.reshape(A, (3, 3))
However, I have trouble doing it with Math.NET Numerics.
Any ideas?
Thanks!
M
Tags:
You can use list comprehension. Try:
B= [A[i:i+3] for i in range(0, len(A), 3)]
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by