nalgebra allows several kind of generic programming, either through traits
of the simba crate, or by keeping the various type parameters of the
Matrix<N, R, C, S> structure and the likes. In the end, this allows for:
- Genericity wrt. scalars: the most common kind of abstraction.
This allows you to write code that will work on any scalar group like
i32and fields like
- Dimensional genericity: allows you to write code that will work generically for 2D, 3D, and higher dimensions.
This allows to write code that works with algebraic entities constructed on top
of a generic scalar type, e.g., floating-point numbers like
in some more restrictive cases integers like
u64. This can be
achieved by keeping generic the first type parameter
N of any structure of
nalgebra (including aliases). The mandatory trait bound of
na::Scalar which imposes some simple non-mathematical properties, i.e.,
must copyable, printable (using the
comparable using the equality operator. Other commonly used trait bounds for
na::ComplexField from the
simba crate. This
enables operator overloading and useful mathematical functions for signed
integers and floating point numbers respectively. Note that the
bound does not have to be specified if
Real already is.