Questions tagged [nalgebra]
nalgebra is a linear algebra library written for Rust
20
questions
-1
votes
0
answers
34
views
Rust: Efficient transpose product matrix
I need to compute M x M.transpose() for matrix with thousands of columns but very few rows (around 300).
The easiest natural way is:
let mtm = &M * M.transpose()
... but it seems to be poorly ...
0
votes
0
answers
25
views
Is there a way to convert rust nalgebra matrix into ndarray
I am using ode_solvers::dopri5::Dopri5 and it returns a nalgebra matrix is it possible for me to convert this to ndarray or whould it be easyer to implement rk45 myself to solve my ode's in this ...
1
vote
2
answers
36
views
How do I reduce repeated generic specification?
In this example, I repeat na::SVector<f64, NumStates> a bunch, can I define a type
type StateVector = na::SVector<f64, NumStates>;
like this? I get an error that associated type defaults ...
0
votes
1
answer
44
views
Rust: nalgebra transpose
I've started to practice rust.
I've run the program and got:
VecStorage { data: [1.0, 88.0, 87.0, 1.0, 70.0, 77.0, 1.0, 80.0, 79.0, 1.0, 82.0, 85.0, 1.0, 90.0, 97.0, 1.0, 100.0, 98.0], nrows: Dynamic {...
0
votes
0
answers
48
views
How to satisfy trait bounds on nalgebra SVD
I have the following working code:
use nalgebra::{DMatrix, SVector, RealField, convert};
pub fn polyfit<T: RealField, const N: usize>(
x_values: &[T; N],
y_values: &[T; N],
...
0
votes
1
answer
78
views
nalgebra apply function to every element of a vector
sorry if this is a noob question but is it posible to apply a function to every element in a nalgebra vector?
if I for example have a vector like this:
type Vector2x1 = SVector<f32, 2>;
let ...
0
votes
1
answer
177
views
Rust nalgebra inverse matrix
Does anyone no a simple way to get the inverse of a matrix using the Rust nalgebra::Matrix ?
I'm trying to do this the same way as with the C++ Eigen library but clearly not working.
#cargo.toml
[...
0
votes
0
answers
45
views
nalgebra OVector vs SVector?
What's the difference between OVector and SVector in nalgebra?
Why is there no SPoint?
3
votes
0
answers
93
views
Rust trait bound bloat / lack of inheritance
I'm trying to wrap the nalgebra and/or ndarray Rust crates into an abstract LinearOperator trait and corresponding AdjointableOperator etc. traits. The problem is that I get significant “trait bound ...
1
vote
1
answer
55
views
nalgebra convention about roll pitch yaw
I write small ray tracer to learn rust language. I decided to use nalgebra as library for vectors and so on.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=...
0
votes
0
answers
88
views
Is it possible to expose nalgebra matrix types to python via pyo3 in rust
I'm able to expose simple functions written in Rust to python using pyo3 but can see no way to expose complex "eigen" / matrix types. Does anyone know if this is possible?
lib.rs
extern ...
1
vote
3
answers
351
views
How do I create an nalgebra static matrix by copying from a dynamic matrix view?
I'm trying to create a na::Matrix2x3 by copying from the first two rows of a na::Matrix3. The result will be stored in a struct.
I don't know how to do this and the documentation is confusing. I tried ...
3
votes
2
answers
95
views
Extract original slice from SliceStorage and SliceStorageMut
I am working on some software where I am managing a buffer of floats in a Vec<T> where T is either an f32 or f64. I sometimes need to interpret this buffer, or sections of it, as a mathematical ...
2
votes
1
answer
190
views
Why is Rust unable to figure out the correct `from_iterator` to use when constructing a nalgebra::MatrixN?
I have a struct defined as:
use nalgebra::{
allocator::Allocator, DefaultAllocator, Dim, DimName, MatrixN, RowVectorN, VectorN, U1,
}; // 0.22.0
pub struct Filter<Order: Dim + DimName>
...
1
vote
1
answer
277
views
How do I get a (1.0, 1.0, 1.0) Vector3 from the nalgebra crate?
I'm trying to create a Vector3 from the nalgebra crate with components (1.0, 1.0, 1.0). I can't find what I need from the documentation, and my IDE's suggestions don't help.
1
vote
1
answer
414
views
How to convert from nalgebra::Matrix to Eigen::MatrixXf correctly?
I have a DLL written in C++ and I need to call a function called print_matrix(Eigen::MatrixXf *m) from a Rust program.
I created the a 4x3 mactrix and the function in question takes a pointer as its ...
1
vote
1
answer
397
views
nalgebra: Implementing a function for a generic MatrixMN
I'm trying to implement the exp function for a generic square MatrixMN
pub fn exp<N, R>(m: &MatrixMN<N, R, R>, k: usize) -> MatrixMN<N, R, R>
where
N: Scalar + One + Zero,...
0
votes
1
answer
282
views
How to average two points in nalgebra?
I have a triangle ABC, and I want to generate triangle DEF.
Triangle DEF is created using the centre of all edges of ABC. Nalgebra doesn't seem to allow me to do add points together, only vectors.
...
0
votes
0
answers
479
views
How do I rotate an object so that it's always facing the mouse position?
I'm using ggez to make a game with some friends, and I'm trying to have our character rotate to face the pointer at all times. I know so far that I need to get an angle value (f32) in radians, and I ...
0
votes
2
answers
293
views
Is there a good way to do an overlapping copy in ndarray in rust?
Here's what I tried
use ndarray::{arr2, s};
let mut a = arr2(&[[1, 2, 3],
[4, 5, 6]]);
let b = arr2(&[[2, 3, 3],
[5, 6, 6]]);
a.slice_mut(s![.., ..2])....