SINTEF / Splipy

Spline modelling made easy.
GNU General Public License v3.0
100 stars 18 forks source link

Add a handy reshape utility function #28

Closed TheBB closed 7 years ago

TheBB commented 7 years ago

I don't know if the docstring explains this well, but basically since IFEM outputs control points in Fortran order for each parameter direction, but still has each control point component stored contiguously, it requires some transpose/reshape shenanigans each time you want to create a Splipy cp array (which is fully C order all the way). Therefore I created this reshape function, which is more or less like numpy's reshape function (has an order argument that can be C or F), but which has an “invisible” extra dimension for components.

IOW,

# From IFEM, 3 in x direction and 2 in y direction
cps = [1,2,3,4,5,6,7,8,9,10,11,12]

cps = splipy.util.reshape(cps, (3,2), order='F')
# => (1,2) ( 7, 8)
#    (3,4) ( 9,10)
#    (5,6) (11,12)
# as expected
VikingScientist commented 7 years ago

Looks good :+1: