




Scheme Programming Language









reshaping arrays, etc
Hi, Some tensor (or multivariate array) computations are very easy to organize by "reshaping" arrays. [1] Eg if one has a 2 x 3 x 4 x 5 array (stored in colummajor format), it can be reshaped into a 6 x 20 matrix (the underlying elements remain the same, only the mapping from the indices to the flat vector changes. Then one can multiply this matrix by another one, reshape the array again, etc. Transpose/ reshape combinations are also powerful. I would like to find out if Scheme would allow me to do this (I don't mind if it is specific to a particular implementation). I have already seen that some scheme compilers (eg Chicken) have BLAS/LAPACK bindings, so the matrix part is not a problem. I would like to know if "boxed" arrays (say, of doubles) stored in columnmajor format are available in Scheme, and whether those arrays can be reshaped (as outlined above) with little cost (no problem if that happens destructively). Thanks, Tamas [1] For example, I use this one a lot: Paul E. Buis and Wayne R. Dyksen. Efficient Vector and Parallel Manipulation of Tensor Products. ACM Transactions on Mathematical Software, Vol. 22, No. 1, March 1996, Pages 1823.
In article <1176093205.826454.39@l77g2000hsb.googlegroups.com>,
"Tamas" <tkp @gmail.com> wrote: > Hi, > Some tensor (or multivariate array) computations are very easy to > organize by "reshaping" arrays. [1] Eg if one has a 2 x 3 x 4 x 5 > array (stored in colummajor format), it can be reshaped into a 6 x 20 > matrix (the underlying elements remain the same, only the mapping from > the indices to the flat vector changes. Then one can multiply this > matrix by another one, reshape the array again, etc. Transpose/ > reshape combinations are also powerful. > I would like to find out if Scheme would allow me to do this (I don't > mind if it is specific to a particular implementation). I have > already seen that some scheme compilers (eg Chicken) have BLAS/LAPACK > bindings, so the matrix part is not a problem. I would like to know > if "boxed" arrays (say, of doubles) stored in columnmajor format are > available in Scheme, and whether those arrays can be reshaped (as > outlined above) with little cost (no problem if that happens > destructively).
The arraylib egg for Chicken is rowmajor. However, it can perform the reshape operation you want  in rowmajor. I wrote arraylib & columnmajor support is low on my list at the moment. Since many Scheme impls get their array type from SLIB or SRFI25/47/63 I suspect they are all rowmajor. CommonLISP is also rowmajor. SRFI4 has vectors of doubles  f64vector  which can be used with the Chicken BLAS egg. But manipulation of a columnmajor array type  I doubt you will find one.
> Thanks, > Tamas > [1] For example, I use this one a lot: > Paul E. Buis and Wayne R. Dyksen. Efficient Vector and Parallel > Manipulation of Tensor Products. ACM Transactions on Mathematical > Software, Vol. 22, No. 1, March 1996, Pages 1823.





