Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature wish for bigarrays #2658

Closed
vicuna opened this issue Jan 16, 2001 · 2 comments
Closed

Feature wish for bigarrays #2658

vicuna opened this issue Jan 16, 2001 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jan 16, 2001

Original bug ID: 261
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

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

@vicuna
Copy link
Author

vicuna commented Jan 23, 2001

Comment author: administrator

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

@vicuna
Copy link
Author

vicuna commented Jan 23, 2001

Comment author: administrator

The new Bigarray.reshape function answers this need. XL, 2001-01-23

@vicuna vicuna closed this as completed Jan 23, 2001
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant