Questions tagged [nalgebra]

nalgebra is a linear algebra library written for Rust

nalgebra is a linear algebra library written for Rust targeting:

General-purpose linear algebra (still lacks a lot of features…)
Real-time computer graphics.
Real-time computer physics.
43 questions
1
vote
1 answer

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=79c13e8cf2725d2398dcf1fac61c047c From that example you can see that…
themean
  • 1,313
  • 4
  • 17
  • 33
1
vote
1 answer

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.
Dario
  • 37
  • 8
1
vote
1 answer

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 input parameter. Rust code: use…
0
votes
2 answers

SVD decomposition of nalgebra is incomprehensible

I am trying to compute the SVD of matrices, as a toy example I used a vector. I ran my code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=00110137fbcbda27c95e9d8791bb97cf use nalgebra::*; fn main() { let x =…
Makogan
  • 8,208
  • 7
  • 44
  • 112
0
votes
0 answers

Iterate over matrices of varying shape

I'm implementing MATLAB's ode45 in Rust, but attempting to make a major improvement. If a user of MATLAB's ode45 wants to integrate a matrix and a vector simultaneously, they have to flatten the matrix and append or prepend the vector before…
mcmuffin6o
  • 348
  • 1
  • 9
0
votes
1 answer

How to allocate a static `SMatrix`/`SVector` using nalgebra?

I would like to allocate an SVector as a static variable. It seems that nalgebra's library-provided builders cannot do this, as none of them are const. Is there a workaround? Here's what I tried (this doesn't compile): const C5: SVector
mcmuffin6o
  • 348
  • 1
  • 9
0
votes
0 answers

Element-wise inverse square root of dynamic matrices

Is there a method to use the nalgebra glm methods on dynamically sized matrices The aim is to Find X such that X†SX = I: the current method is X=Us^{-1/2}U† where S=UsU†: // in general these will be dynamically sized and read from a file let N =…
JimGreen
  • 15
  • 4
0
votes
1 answer

Similar function to numpy.dot with nalgebra in Rust

I recently started to use nalgebra, but I can't for the life of me figure out how to do a regular dot product, like below: This is similar to how in Python, you can do this: import numpy as np arr1 = np.array([[1, 2, 3], [4, 5, 6]]) arr2 =…
Ayush Garg
  • 2,234
  • 2
  • 12
  • 28
0
votes
1 answer

How to convert a Matrix4 into a [f32; 4] using nalgebra

I have a Matrix4 representing a transformation. I would like to convert it to a [f32; 16] to use with wgpu. I've not managed to find the right method (if there is one at all).
Nils André
  • 571
  • 5
  • 17
0
votes
1 answer

Is there a way to get Euler angle orders in nalgebra or another Rust library?

I'm trying to convert raw quaternion values to Euler angles in order zyx. I'm trying to use nalgebra rotations to convert, but the in-built conversion only gives angles in order xyz. Is there a way to convert from quat to zyx or from xyz to zyx? Or…
0
votes
1 answer

Rust nalgebra - new_random() throws error for DMatrix

Im trying to port https://github.com/markkraay/mnist-from-scratch to rust as an introduction to ML and the rust programming language. I've decided to use nalgebra instead of rewriting a matrix library. However, im running into an error stating…
0
votes
0 answers

nalgebra, decomposing homogeneous matrix into operations

Does nalgebra have a built in method to decompose a 4x4 homogeneous matrix into its rotation, scaling and translation components? I went through the documentation but I cannot find anything on the topic.
Makogan
  • 8,208
  • 7
  • 44
  • 112
0
votes
0 answers

How can I call complex_eigenvalues on a generically sized nalgebra matrix?

I'm using Rust 1.65.0 and nalgebra 0.31.3. Following this blog post, I would like to write a generic function to compute roots of polynomials, without using dynamic memory allocation: use nalgebra::{Complex, Const, DimSub, SMatrix, ToTypenum}; fn…
Sam Estep
  • 12,974
  • 2
  • 37
  • 75
0
votes
0 answers

How to convert an OMatrix to a vector and use it to populate a single row of a DMatrix in Rust?

I have an OLS fitting function that returns an OMatrix. The return type should always be a one-dimensional vector of coefficients. use std::f64::NAN; use nalgebra::{DMatrix, Dynamic, MatrixSlice, OMatrix, RowVector}; fn ols( x: MatrixSlice
PyRsquared
  • 6,970
  • 11
  • 50
  • 86
0
votes
0 answers

Slicing a `DMatrix` and inserting the elements of that sub-matrix into a new matrix in Rust?

I have a function that takes in a 2-D DMatrix, x as a parameter, operates on slices of x and takes the output of the operation and inserts it into a new output matrix. What I have so far, with code and pseuod-code: use nalgebra::DMatrix; //…
PyRsquared
  • 6,970
  • 11
  • 50
  • 86