MantisBT - OCaml
View Issue Details
0000261OCaml~DO NOT USE (was: OCaml general)public2001-01-16 17:002001-01-23 10:50
administrator 
 
normalminoralways
closedfixed 
 
 
0000261: Feature wish for bigarrays
Hello,

since I am currently interfacing LAPACK with bigarrays, I ran into a
problem that could be easily fixed by adding a new function to "Array2":

Linear least-squares problems (or equations) usually look like this:

  A * x = b

where A is a matrix and x and b are vectors. LAPACK, however, generalizes
this to:

  A * X = B

where all variables stand for matrices. This allows one to handle several
right hand side vectors (b) and solution vectors (x) in one call.

This is a bit annoying when somebody really wants to use one vector
(Array1.t) only: he'd have to copy it into a matrix (Array2.t) for this,
which may require a significant amount of time.

It would be great if there were some kind of inverse function for
"slice_right", which makes an Array2.t out of an Array1.t without copying.
(For completeness, you might want to add a similar inverse function for
"slice_left" for C-layout, which operates on rows instead of columns,
of course).

Best regards,
Markus Mottl

--
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl [^]

No tags attached.
Issue History
2005-11-18 10:13administratorNew Issue
2017-02-23 16:36doligezCategoryOCaml general => -OCaml general
2017-03-03 17:55doligezCategory-OCaml general => -(deprecated) general
2017-03-03 18:01doligezCategory-(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04doligezCategory~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Notes
(0000485)
administrator   
2001-01-23 09:52   
> It would be great if there were some kind of inverse function for
> "slice_right", which makes an Array2.t out of an Array1.t without copying.
> (For completeness, you might want to add a similar inverse function for
> "slice_left" for C-layout, which operates on rows instead of columns,
> of course).

Other users have expressed similar needs (e.g. "flattening" an Array2
into an Array1), so I've added a general "reshape" feature to the
Bigarray module. Basically, it lets you view a big array with a new
number of dimensions and new dimensions, the only constraint being
that the new view has the same number of elements as the original
array. So, in your example, you could "reshape" an 1d array of
dimension N into a 2d array of dimensions (N, 1) or (1, N), depending
on the desired layout.

Best regards,

- Xavier Leroy

(0000486)
administrator   
2001-01-23 10:50   
The new Bigarray.reshape function answers this need. XL, 2001-01-23