masonium / linxal

linear algebra package for rust
MIT License
37 stars 3 forks source link

Ndarray planning #2

Open bluss opened 7 years ago

bluss commented 7 years ago

Hi, very cool project. This matches what I wanted to do for ndarray and I'm happy that you've done it. (Use Lapack). Do tell me if there are any issues that need to be fixed on the ndarray side.

Right now I'm working on issue https://github.com/bluss/rust-ndarray/issues/6 which is transitioning from Ix2 = (usize, usize) to Ix2 = [usize; 2] and so on. There's a choice of either using plain arrays, or using a custom type for dimensions.. with a custom type one can define more operations, including index + index addition or things like that.. What do think about that?

masonium commented 7 years ago

I haven't run into any issues with ndarray; it's been great to work with so far. I did have to write one bit of unsafe code to construct a slice when the array is stored in a lapack-appropriate format. (I don't think that's a generally useful notion outside of this library, though, and giving slices arbitrarily is probably a bad idea, so I wouldn't change anything.)

The dimension change sounds good to me. I don't really do any dimension manipulation right now, besides getting the individual components, so I don't have much insight into the tradeoffs of a custom type.

bluss commented 7 years ago

ok! it's probably going to impact the higher dimensional cases more. It could be semi-annoying that the D = usize for 1-dimensional arrays is going to be [usize; 1] or even Dim<[usize; 1]> instead, but there should be enough accessor methods and/or conversion traits and other methods to make it easy to use.

bluss commented 7 years ago

By the way, are you aware of ndarray-linalg (and conversely is the author of that project [cc @termoshtt ] aware of this project?) Both seem to have gone public this month.

termoshtt commented 7 years ago

Hi, it was my unfortunate that I cannot find this project before I start to create my crate. This project is much neat than mine, and I'm considering to switch to this. But my private projects depends on mine, so I have to manage it for a while.

bluss commented 7 years ago

Right now I'm working on moving the layout information into a field in the array or array view. First as an implementation detail and then when it all works, we can put it in the public API.

First goal is that an array will be able to answer:

If there are k input arrays (or NdProducer) it should be possible to get the same information about them as a whole (their common layout). I'm hoping this is just going to be bit and of all their bitflag fields.

Second goal is that the layout information includes which dimensions are the inner dimensions (stride=1), again we get this information from k inputs and use it in Zip.

masonium commented 7 years ago

Does a matrix count as, e.g. C-contiguous if only the inner-axis is contiguous, or does the entire storage need to be contiguous? The former definition certainly aligns better with LAPACK.

bluss commented 7 years ago

Good point. Initially it only keeps track of entirely contiguous matrices, it should be able to answer both. Tracking layout information correctly turns out to be harder than anticipated, actually, so I didn't finish this in the latest attempt.