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
3
votes
0 answers

How to Append matrices together in nalgebra Rust?

Suppose I have a matrix [[1,0],[0,1]] and [[2,0],[0,2]] I want to figure out a way to combine these 2 matrices into [[1,0,2,0],[0,1,0,2]]. I cannot find the appropriate constructor in the documentation:…
3
votes
0 answers

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 bloat”, having to specify even internal…
3
votes
3 answers

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 clone(), into(), from(...), etc., but nothing…
Daniel
  • 510
  • 3
  • 15
3
votes
2 answers

Extract original slice from SliceStorage and SliceStorageMut

I am working on some software where I am managing a buffer of floats in a Vec where T is either an f32 or f64. I sometimes need to interpret this buffer, or sections of it, as a mathematical vector. To this end, I am taking advantage of…
Wil
  • 115
  • 6
2
votes
1 answer

Error multiplying matrix by vector with generic sizing using nalgebra

Running into what seems like an odd issue when trying to multiply a square matrix A with X rows and X columns by a vector x with X rows, constructed from a struct with generic sizing. Just a basic A*x = b operation. The end goal is to have a struct…
2
votes
1 answer

rust nalgebra, how to modify a matrix block?

I am using nalgebra and trying to do the following: Given a large dense amtrix, e.g. a 5x5. I want to grab a block of that matrix, e.e.g a 4x5 sublock, and treat that block as a matrix. I want to perform scalar multiplication and vector addition on…
Makogan
  • 8,208
  • 7
  • 44
  • 112
2
votes
1 answer

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 where DefaultAllocator: Allocator
Tim
  • 4,560
  • 2
  • 40
  • 64
2
votes
1 answer

nalgebra: Implementing a function for a generic MatrixMN

I'm trying to implement the exp function for a generic square MatrixMN pub fn exp(m: &MatrixMN, k: usize) -> MatrixMN where N: Scalar + One + Zero, R: DimName + DimNameAdd, ::Value: Mul<
Fredrik Jansson
  • 3,764
  • 3
  • 30
  • 33
1
vote
1 answer

How to assign the column of one matrix to another, nalgebra?

I am using nalgebra and I want to modify one matrix by setting it as the columns of another with compatible dimensions, like this: let zero: T = convert(0.0); let mut basis = DMatrix::from_element(rows, rank, zero); // matrix is an input…
Makogan
  • 8,208
  • 7
  • 44
  • 112
1
vote
1 answer

nalgebra type annotations for converting Matrix to DMatrix

I'm trying to convert a static matrix into a dynamic matrix using a function. Reason being is that I'm comparing two matrices for unit-testing. Thus the test_value from the test, and the benchmark matrices have to be the same element wise. They will…
dim_voly
  • 478
  • 2
  • 10
  • 20
1
vote
0 answers

Use nalgebra with float types from rug

Is it possible to replace the rust f64 fundamental type with rug::Float types? If so, which traits must be implemented in order to call svd() on a nalgebra matrix?
1
vote
0 answers

Calculate matrix null space through rust nalgebra library

How can I get the basis of the null space (kernel) of a matrix through the rust nalgebra lib?
GeauxEric
  • 2,814
  • 6
  • 26
  • 33
1
vote
0 answers

Nalgerba, how is the axis angle represented for a unit quaternion?

The docs for nalgebra say fn new(axisangle: Vector3) -> UnitQuaternion[−] Creates a new unit quaternion from the axis-angle representation of a rotation. That's great, except, that's not an axis angle, that's just an axis. Most axis angle…
Makogan
  • 8,208
  • 7
  • 44
  • 112
1
vote
0 answers

Compiler does not believe that my trait bound is enforcing the trait that it has to be enforcing

I am trying to compile code such as the following: lib.rs use nalgebra::ComplexField; use num::FromPrimitive; use bacon_sci::polynomial; use bacon_sci::polynomial::Polynomial; fn foo () -> Polynomial where R: FromPrimitive +…
Zistack
  • 516
  • 3
  • 10
1
vote
2 answers

How do I reduce repeated generic specification?

In this example, I repeat na::SVector a bunch, can I define a type type StateVector = na::SVector; like this? I get an error that associated type defaults are unstable. Is there another way? use nalgebra as na; pub…
Matt Oslin
  • 11
  • 1
1
2 3