Hello BP.
The idea is to transform data types to vector or matrix, under the same command name.
makevector( set[1,2,1,3,4,4,5,5] ) > [1,2,3,4,5] // ok
makevector( poly1[-1,6,-11,6] ) > [-1,6,-11,6] // ok
# resize/transform from matrix to vector
makevector( [[9,8,7],[6,5,4],[3,2,1]] ) >
[9,8,7,6,5,4,3,2,1]
# resize from vector to matrix
matrix( 3, 3, [9,8,7,6,5,4,3,2,1]) >
[[9,8,7],[6,5,4],[3,2,1]]
matrix( 3, 4, [9,8,7,6,5,4,3,2,1]) >
[[9,8,7,6],[5,4,3,2],[1,0,0,0]]
matrix( 2, 4, [9,8,7,6,5,4,3,2,1]) >
[[9,8,7,6],[5,4,3,2]]
resize/transform from matrix <-> vector
Modérateur : xcasadmin
-
- Messages : 558
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
Re: resize/transform from matrix <-> vector
flatten will convert a matrix to a vector. The other commands already work unless I missed something.
-
- Messages : 558
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
Re: resize/transform from matrix <-> vector
To makeMat if the first argument is an array, also make a dimension adjustment
makemat( [9,8,7,6,5,4,3,2,1], 3, 3) >
[[9,8,7],[6,5,4],[3,2,1]]
makemat(([[9,8,7],[6,5,4],[3,2,1]], [1,0], [[10,11],[12,13]]) >
[[9,8,7],[10,11,4],[12,13,1]]
makemat( [9,8,7,6,5,4,3,2,1], 3, 3) >
[[9,8,7],[6,5,4],[3,2,1]]
makemat(([[9,8,7],[6,5,4],[3,2,1]], [1,0], [[10,11],[12,13]]) >
[[9,8,7],[10,11,4],[12,13,1]]
Re: resize/transform from matrix <-> vector
makemat expects a function, not an array, you already have matrix for that, as See also hints if you look at the help of makemat.