Rust crates for numerical simulation including, but not limited to, real-time (as well as offline) physics, mechanics, and robotics.
2.5k
51
311
Comments
Relax constraints for some operations
May 1, 2020
Many operations expected the numeric type N to implement ClosedAdd and/or ClosedSub.
This commit replaces some of these with the less restrictive Simple{Add,Sub}, which does not require {Add,Sub}Assign.
Porting some ideas for accuracy/robustness from LAPACK
May 2, 2020
I compared a few implementations of LAPACK and nalgebra. Often LAPACK does additional work for handling for exampe overflow or different scales. Would you be interested in having some of those ideas ported to nalgebra? This usually comes with a (potential) performance penalty.
Some examples:
norm_squared vs DNRM2
the QR implemntation vs DGEQR2
I could port something if you are interested? I would start with the QR implementation and the subroutines used.
I ported some ideas from LAPACK's QR implementation, more specifically from ?ORG2R.
As a result I could increase all epsilons in the test by two order of magnitudes. Also the full computation of the Q matrix is now supported, not only the first min(n, m) columns. I added a new method q_columns for this. The current q() method stayed the same.
The main difference in the implementation seems to be that LAPACK applies the scaling of the Householder vectors at a different point in the code.
Breaking changes
The internal representation has changed (is exposed by hidden method qr_internal)
For some inputs some column signs flipped of R and Q.
Some allocations were added, can be found when searching for work. This resulted in additional allocator bounds. See discussion below.
Things to discuss
Currently q_tr_mul borrows self mutably due to an implementation detail although the struct's state will only be changed temporarily inside the method. Ideas to resolve this:
Keep as is
Use interior mutability
Allocate
Change affected gerc and gemv call (possible performance penalty)
This would be a good occasion to implement #672 for QR
The additional work allocations could be done only once by storing a suitable vector in the struct and sharing it. This will result in &mut self or interior mutability.
nalgebra 0.13: pure-rust matrix factorizations, LAPACK integration, and performance improvements
Aug 2, 2017
Please, I would prefer that nobody make announcements on blogs about this (in reddit, hackernews, etc.) before the release on crates.io which will occur during the second half of august.
All the following are currently implemented on the linalg branch of nalgebra.
Since the last large release #218 of nalgebra, I've been working slowly but thoroughly on a few features that makes a step toward making nalgebra more useful for general-purpose linear algebra. This includes three major features:
Pure-rust implementations of some the most common matrix factorization.
Partial integration of Lapack. This is based on previous works on the nalgebra-lapack crate (made by @astraw).
Insertion and removal of rows and columns to matrices.
Of course, all those work on statically-sized matrices as well as dynamically-sized matrices!
I alsow want to note that none of this would have been possible without the amazing typenum crate which allows addition/subtraction/minimum of type-level integers.
Matrix factorizations
This new version of nalgebra will include pure-rust implementations of the following factorization for real matrices ("general matrices" designates real-valued matrices that may be rectangular):
Cholesky decomposition of symmetric definite-positive matrices (+ inverse, square linear system resolution).
Hessenberg decomposition of square matrices.
LU decompostion of general matrices with partial pivoting (+ inversion, determinant, square linear system resolution).
LU decompostion of general matrices with full pivoting (+ inversion, determinant, square linear system resolution).
QR decomposition of general matrices (+ inverse, square linear system resolution).
Real Schur decomposition of general matrices (+ eigenvalues, complex eigenvalues).
Eigendecomposition of symmetric matrices.
Singular Value Decomposition (SVD) of general matrices (+ pseudo-inverse, linear system resolution, rank).
All those are implemented in the linalg folder. Note that as far as I know, the only other crate that implements those factorization in pure-Rust is rulinalg written by @AtheMathmo and @Andlon. Refer to the next post for benchmarks showing the performances of nalgebra compared to rulinalg.
Lapack integration
I'd like to move the nalgebra-lapack crate to the main nalgebra github repository to simplify the task of keeping them in sync. The next nalgebra-lapack version has been updated and I intend to make it contain at least all the decompositions implemented in Rust and expose similar interfaces to the user. It is not finished. Currently, it contains: Cholesky, Hessenberg, LU, QR, Eigendecomposition of real matrices, SVD.
Matrix edition
This adds the ability to resize a matrix or insert/remove rows and columns. For dynamically-sized matrices (allocated on the heap), the pre-existing buffer is reallocated (i.e. the underlying Vec is shrink or expanded.)
The ability to fill different parts of the matrices are added as well:
Fill the lower/upper triangular part with a constant.
Fill the matrix with the identity matrix.
Fill the diagonal with a constant.
Fill a row or column with a constant.
Fill the lower-triangular (resp. upper-triangular) part of the matrix with the content of its upper-triangular (resp. lower-triangular) part to make the matrix symmetric.
Patreon
As a side note, I discovered Patreon only recently so I set up a page for my projects: https://www.patreon.com/sebcrozet Any financial aid is greatly appreciated.
Release date
The release is planed for the second half of august. Indeed, I still have to write documentations (including a new page on the nagebra users guide) and refine the API. Any feedback before the release would be very useful to improve the quality of the actual release.
Poll: rename everything to use full names, e.g., `Iso3` becomes `Isometry3`.
Apr 6, 2016
Currently, nalgebra tends to use 3-letter or 4-letter names for all the algebraic entities (e.g. Vec, Mat, Rot, Quat, etc.) Unfortunately, this naming convention is not very (not at all actually) explicit for some structures like (direct) isometries Iso and the recently added similarity transformations Sim.
Thus, I now think that full names would be much better as they would make the code more readable, and would help users to find what he wants on the documentation. For example, I doubt that anyone reading the documentation would guess at first glance that Sim is a transformation.
So I would like to know if current users would be in favor of full names instead of the current ones! Of course, if the majority seems to agree with this change, it would break every single project using nalgebra.
I am seriously considering transitioning from my cgmath library to nalgebra, seeing as it is now insanely well polished, and it would allow me to use your collision and physics stuff without having to re-invent the wheel. Some of the things I love about cgmath though is:
points as a separate concept to vectors with the following operators:
Users guide | Documentation | Forum Linear algebra library for the Rust programming language. Click this button if you wish to donate to support the
dimforge/nalgebra
Relax constraints for some operations
May 1, 2020
Many operations expected the numeric type
N
to implementClosedAdd
and/orClosedSub
. This commit replaces some of these with the less restrictiveSimple{Add,Sub}
, which does not require{Add,Sub}Assign
.This partially addresses #719.
Porting some ideas for accuracy/robustness from LAPACK
May 2, 2020
I compared a few implementations of LAPACK and nalgebra. Often LAPACK does additional work for handling for exampe overflow or different scales. Would you be interested in having some of those ideas ported to nalgebra? This usually comes with a (potential) performance penalty.
Some examples:
norm_squared
vsDNRM2
DGEQR2
I could port something if you are interested? I would start with the QR implementation and the subroutines used.
Change the QR implementation, inspired by LAPACK
May 9, 2020
I ported some ideas from LAPACK's QR implementation, more specifically from
?ORG2R
.As a result I could increase all epsilons in the test by two order of magnitudes. Also the full computation of the
Q
matrix is now supported, not only the firstmin(n, m)
columns. I added a new methodq_columns
for this. The currentq()
method stayed the same.The main difference in the implementation seems to be that LAPACK applies the scaling of the Householder vectors at a different point in the code.
Breaking changes
qr_internal
)R
andQ
.work
. This resulted in additional allocator bounds. See discussion below.Things to discuss
q_tr_mul
borrows self mutably due to an implementation detail although the struct's state will only be changed temporarily inside the method. Ideas to resolve this:gerc
andgemv
call (possible performance penalty)work
allocations could be done only once by storing a suitable vector in the struct and sharing it. This will result in&mut self
or interior mutability.argsort please like numpy
May 12, 2020
Can we have argsort support please?
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=6e82220f978f5d5fcf7e56d7375fcae4
Docs right handed typo
May 30, 2020
https://docs.rs/nalgebra/0.21.0/nalgebra/geometry/struct.Isometry.html#method.look_at_lh
It says "right handed", but it should say "left handed".
Complex matrix exponential
Jun 14, 2020
I would be nice to implement matrix exponential for complex matrices as well :)
nalgebra 0.13: pure-rust matrix factorizations, LAPACK integration, and performance improvements
Aug 2, 2017
Please, I would prefer that nobody make announcements on blogs about this (in reddit, hackernews, etc.) before the release on crates.io which will occur during the second half of august.
All the following are currently implemented on the linalg branch of nalgebra.
Since the last large release #218 of nalgebra, I've been working slowly but thoroughly on a few features that makes a step toward making nalgebra more useful for general-purpose linear algebra. This includes three major features:
Of course, all those work on statically-sized matrices as well as dynamically-sized matrices! I alsow want to note that none of this would have been possible without the amazing typenum crate which allows addition/subtraction/minimum of type-level integers.
Matrix factorizations
This new version of nalgebra will include pure-rust implementations of the following factorization for real matrices ("general matrices" designates real-valued matrices that may be rectangular):
All those are implemented in the linalg folder. Note that as far as I know, the only other crate that implements those factorization in pure-Rust is rulinalg written by @AtheMathmo and @Andlon. Refer to the next post for benchmarks showing the performances of nalgebra compared to rulinalg.
Lapack integration
I'd like to move the nalgebra-lapack crate to the main nalgebra github repository to simplify the task of keeping them in sync. The next nalgebra-lapack version has been updated and I intend to make it contain at least all the decompositions implemented in Rust and expose similar interfaces to the user. It is not finished. Currently, it contains: Cholesky, Hessenberg, LU, QR, Eigendecomposition of real matrices, SVD.
Matrix edition
This adds the ability to resize a matrix or insert/remove rows and columns. For dynamically-sized matrices (allocated on the heap), the pre-existing buffer is reallocated (i.e. the underlying
Vec
is shrink or expanded.)The ability to fill different parts of the matrices are added as well:
Patreon
As a side note, I discovered Patreon only recently so I set up a page for my projects: https://www.patreon.com/sebcrozet Any financial aid is greatly appreciated.
Release date
The release is planed for the second half of august. Indeed, I still have to write documentations (including a new page on the nagebra users guide) and refine the API. Any feedback before the release would be very useful to improve the quality of the actual release.
Poll: rename everything to use full names, e.g., `Iso3` becomes `Isometry3`.
Apr 6, 2016
Currently,
nalgebra
tends to use 3-letter or 4-letter names for all the algebraic entities (e.g. Vec, Mat, Rot, Quat, etc.) Unfortunately, this naming convention is not very (not at all actually) explicit for some structures like (direct) isometriesIso
and the recently added similarity transformationsSim
.Thus, I now think that full names would be much better as they would make the code more readable, and would help users to find what he wants on the documentation. For example, I doubt that anyone reading the documentation would guess at first glance that
Sim
is a transformation.So I would like to know if current users would be in favor of full names instead of the current ones! Of course, if the majority seems to agree with this change, it would break every single project using
nalgebra
.ngeom library
Oct 2, 2014
I am seriously considering transitioning from my
cgmath
library to nalgebra, seeing as it is now insanely well polished, and it would allow me to use your collision and physics stuff without having to re-invent the wheel. Some of the things I love aboutcgmath
though is:(*) : Point a -> a -> Point a
(/) : Point a -> a -> Point a
(+) : Point a -> Vector a -> Point a
(-) : Point a -> Point a -> Vector a
These things don't really make sense for a linear algebra library, but is it possible that we could have a separate library for these?
Mint integration
Jul 25, 2017
see https://github.com/kvark/mint
Mat4 look_at function
Nov 23, 2014
Is there an equivalent to cgmath's
Matrix4::look_at
function?Implement convolution #520
Feb 10, 2019
https://github.com/rustsim/nalgebra/issues/520
First time contributing to library and relearning rust. Will take any and all advice.