Usage of ndarray-linalg
Hey folks!
I am trying to use ndarray-linalg to calculate an orthonormal basis and an inverse. Sadly it is 100% non-obvious to how to achieve this.
Is there maybe a guide how to use this lib somewhere? Because most of it's functionality seems to be implemented in non-convential ways (compare to numpy, matlab, etc.), even tho that might be me missunderstanding.
Best, Yatekii
Hey Yatekii!
Could you share the NumPy equivalent of what you are trying to implement? So that we can provide a translation 😄
Oh, silly me, ofc:
sp.linalg.orth(...);
sp.linalg.inv(...);
Basically it's those two for now.
Is there an active chat or the like where you folks hang out? I tried discord and gitter but it seems dead. And unfortunately I missed your workshop at RustFest :(
Communication about ndarray, ndarray-linalg and ndarray-stats happens on GitHub issues and PRs more than anything else, so you are in the right place. I am in that Gitter channel as well, but for questions like this one I think it makes more sense to tackle them in an issue so that the answer is available to everybody for the future 😄
The inverse computation looks like this:
use ndarray::array;
use ndarray_linalg::Inverse;
fn inverse() {
let a = array![
[1., 3.],
[4., 2.]
];
let inverse = a.inv().expect("Failed to invert matrix");
println!("Inverse matrix: {:?}", inverse);
}
I am afraid we don't offer a Rust equivalent of orth right now - can you confirm @termoshtt?
Communication about
ndarray,ndarray-linalgandndarray-statshappens on GitHub issues and PRs more than anything else, so you are in the right place. I am in that Gitter channel as well, but for questions like this one I think it makes more sense to tackle them in an issue so that the answer is available to everybody for the future smile
Oh, I see. I just like chats way more, as you don't loose context all the time as is with GH issues. But I understand the publicity argument :)
The inverse computation looks like this:
use ndarray::array; use ndarray_linalg::Inverse; fn inverse() { let a = array![ [1., 3.], [4., 2.] ]; let inverse = a.inv().expect("Failed to invert matrix"); println!("Inverse matrix: {:?}", inverse); }I am afraid we don't offer a Rust equivalent of
orthright now - can you confirm @termoshtt?
Ok, so this sounds easy. Thank you! I now also see why I couldn't figure this: It's not implemented under Implementors but under Implementations on Foreign Types :/ shame on you rustdoc, why would that be treated differently :D I must have been tired looking at this :/
This https://docs.rs/ndarray-linalg/0.12.0/ndarray_linalg/krylov/trait.Orthogonalizer.html seems to be somewhat of what orth() does. I wish I was more versed with linalg. Because I feel like what I really wanna use is a complete solver instead of bare calls to inv() and orth() as in the numpy code I am translating (this is the code with the specific location fyi: https://github.com/ggventurini/python-deltasigma/blob/master/deltasigma/_simulateDSM_scipy_blas.pyx#L143), but I just don't know enought to read the forumlas with sparse comments like I would read some analysis equations or the likes.
I would have to play around with it a little, but you could probably use Orthogonalizer to do something equivalent to what orth is doing: you just need to append all the columns in A and then call the get_q method.