Grasshopper

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

Views: 849

Replies to This Discussion

You can use list comprehension. Try:


B= [A[i:i+3] for i in range(0, len(A), 3)]

Thanks!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service