moduleMatrices and linear algebra
In Into, matrices are used to store many types of data, including matrices and vectors in plain mathematical sense, images, feature vectors, geometrical objects such as rectangles and circles etc.
The matrix library contains the basic matrix classes, matrix arithmetic routines, and linear algebra algorithms.
Lazy evaluation
PiiMatrix<double> A(3,3); A = A * 5 + 3;
The textbook approach to make this work - which is still in use in many libraries - is to implement operator* and operator+ functions that take a matrix and a scalar as parameters and return a matrix. This is equivalent to the following:
PiiMatrix<double> A(3,3); PiiMatrix<double> tmp1 = A * 5; PiiMatrix<double> tmp2 = tmp1 + 3; A = tmp2;
In Into, no temporary matrices need to be created. Instead, the operator functions return matrix concepts that are evaluated only when needed. The following pseudocode shows how this is done:
A * 5 -> MatrixConcept<multiplies, Matrix> MatrixConcept<multiplies, Matrix> + 3 -> MatrixConcept<add, MatrixConcept<multiplies, Matrix>> A = MatrixConcept<add, MatrixConcept<multiplies, Matrix>> -> Matrix
The arithmetic operations never actually evaluate the expression but return a conceptual matrix that performs the evaluation if requested to do so. In this example, the assignment at the end does. This kind of lazy evaluation is used not only by arithmetic operators but also with algorithms such as Pii::transpose() and many functions that work with matrices. The following code doesn't create a single temporary object:
PiiMatrix<int> A(5,5); A += pow(abs(A) - 3, 2) + transpose(A);
Sub-matrices
Linear algebra
The most important functions of the linear algebra libary are
LU decomposition
Singular value decomposition
Namespaces
| namespace |
This namespace contains general-purpose functions, type definitions, and data structures that are independent of other modules and plug-ins. |
Other classes
| class |
A matrix that models the matrix concept by using a binary function that operates on two other matrices. |
| class |
A superclass for classes that implement the matrix concept. |
| class |
A model of the matrix concept that accesses selected elements of another matrix. |
| class |
A two-dimensional array that models the matrix concept. |
| struct |
A structure that stores a value and its location in a matrix. |
| class |
Represents a rotation parallel to a plane spanned by two coordinates axes. |
| class |
A matrix that provides a mutable reference to a PiiMatrix. |
| class |
Transposed matrix. |
| class |
A two-dimensional dynamic array of non-typed data. |
| class |
A matrix that models the matrix concept by applying a unary function to another matrix. |
Add a note
Not a single note added yet. Be the first, add yours.