General matrix and vectors class, meant for classic math manipulation such as additions, multiplications, and linear systems of equations solving. More...
#include <juce_Matrix.h>
Public Member Functions | |
Matrix (size_t numRows, size_t numColumns) | |
Creates a new matrix with a given number of rows and columns. More... | |
Matrix (size_t numRows, size_t numColumns, const ElementType *dataPointer) | |
Creates a new matrix with a given number of rows and columns, with initial data coming from an array, stored in row-major order. More... | |
Matrix (const Matrix &)=default | |
Creates a copy of another matrix. More... | |
Matrix (Matrix &&) noexcept=default | |
Moves a copy of another matrix. More... | |
ElementType * | begin () noexcept |
const ElementType * | begin () const noexcept |
void | clear () noexcept |
Fills the contents of the matrix with zeroes. More... | |
ElementType * | end () noexcept |
const ElementType * | end () const noexcept |
size_t | getNumColumns () const noexcept |
Returns the number of columns in the matrix. More... | |
size_t | getNumRows () const noexcept |
Returns the number of rows in the matrix. More... | |
ElementType * | getRawDataPointer () noexcept |
Returns a pointer to the raw data of the matrix object, ordered in row-major order (for modifying). More... | |
const ElementType * | getRawDataPointer () const noexcept |
Returns a pointer to the raw data of the matrix object, ordered in row-major order (for reading). More... | |
Array< size_t > | getSize () const noexcept |
Returns an Array of 2 integers with the number of rows and columns in the matrix. More... | |
Matrix & | hadarmard (const Matrix &other) noexcept |
Does a hadarmard product with the receiver and other and stores the result in the receiver. More... | |
bool | isNullMatrix () const noexcept |
Tells if the matrix is a null matrix. More... | |
bool | isOneColumnVector () const noexcept |
Tells if the matrix is a one column vector. More... | |
bool | isOneRowVector () const noexcept |
Tells if the matrix is a one row vector. More... | |
bool | isSquare () const noexcept |
Tells if the matrix is a square matrix. More... | |
bool | isVector () const noexcept |
Tells if the matrix is a vector. More... | |
ElementType | operator() (size_t row, size_t column) const noexcept |
Returns the value of the matrix at a given row and column (for reading). More... | |
ElementType & | operator() (size_t row, size_t column) noexcept |
Returns the value of the matrix at a given row and column (for modifying). More... | |
Matrix | operator* (ElementType scalar) const |
Scalar multiplication. More... | |
Matrix | operator* (const Matrix &other) const |
Matrix multiplication. More... | |
Matrix & | operator*= (ElementType scalar) noexcept |
Scalar multiplication. More... | |
Matrix | operator+ (const Matrix &other) const |
Addition of two matrices. More... | |
Matrix & | operator+= (const Matrix &other) noexcept |
Addition of two matrices. More... | |
Matrix | operator- (const Matrix &other) const |
Addition of two matrices. More... | |
Matrix & | operator-= (const Matrix &other) noexcept |
Subtraction of two matrices. More... | |
Matrix & | operator= (const Matrix &)=default |
Creates a copy of another matrix. More... | |
Matrix & | operator= (Matrix &&) noexcept=default |
Moves another matrix into this one. More... | |
bool | operator== (const Matrix &other) const noexcept |
bool | solve (Matrix &b) const noexcept |
Solves a linear system of equations represented by this object and the argument b, using various algorithms depending on the size of the arguments. More... | |
Matrix & | swapColumns (size_t columnOne, size_t columnTwo) noexcept |
Swaps the contents of two columns in the matrix and returns a reference to itself. More... | |
Matrix & | swapRows (size_t rowOne, size_t rowTwo) noexcept |
Swaps the contents of two rows in the matrix and returns a reference to itself. More... | |
String | toString () const |
Returns a String displaying in a convenient way the matrix contents. More... | |
Static Public Member Functions | |
static bool | compare (const Matrix &a, const Matrix &b, ElementType tolerance=0) noexcept |
Compare to matrices with a given tolerance. More... | |
static Matrix | hadarmard (const Matrix &a, const Matrix &b) |
Does a hadarmard product with a and b returns the result. More... | |
static Matrix | hankel (const Matrix &vector, size_t size, size_t offset=0) |
Creates a squared size x size Hankel Matrix from a vector with an optional offset. More... | |
static Matrix | identity (size_t size) |
Creates the identity matrix. More... | |
static Matrix | toeplitz (const Matrix &vector, size_t size) |
Creates a Toeplitz Matrix from a vector with a given squared size. More... | |
Private Member Functions | |
template<typename BinaryOperation > | |
Matrix & | apply (const Matrix &other, BinaryOperation binaryOp) |
void | resize () |
Resizes the matrix. More... | |
Private Attributes | |
size_t | columns |
Array< ElementType > | data |
Array< size_t > | dataAcceleration |
size_t | rows |
General matrix and vectors class, meant for classic math manipulation such as additions, multiplications, and linear systems of equations solving.
{DSP}
|
inline |
Creates a new matrix with a given number of rows and columns.
References juce::dsp::Matrix< ElementType >::clear(), and juce::dsp::Matrix< ElementType >::resize().
Referenced by juce::dsp::Matrix< ElementType >::Matrix().
|
inline |
Creates a new matrix with a given number of rows and columns, with initial data coming from an array, stored in row-major order.
References juce::dsp::Matrix< ElementType >::columns, juce::dsp::Matrix< ElementType >::data, juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::getRawDataPointer(), juce::dsp::Matrix< ElementType >::hankel(), juce::dsp::Matrix< ElementType >::identity(), juce::dsp::Matrix< ElementType >::Matrix(), juce::dsp::Matrix< ElementType >::operator=(), juce::dsp::Matrix< ElementType >::resize(), juce::dsp::Matrix< ElementType >::rows, and juce::dsp::Matrix< ElementType >::toeplitz().
|
default |
Creates a copy of another matrix.
|
defaultnoexcept |
Moves a copy of another matrix.
|
inlineprivate |
References juce::dsp::Matrix< ElementType >::columns, juce::dsp::Matrix< ElementType >::getRawDataPointer(), jassert, and juce::dsp::Matrix< ElementType >::rows.
Referenced by juce::dsp::Matrix< ElementType >::hadarmard(), juce::dsp::Matrix< ElementType >::operator+=(), and juce::dsp::Matrix< ElementType >::operator-=().
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Fills the contents of the matrix with zeroes.
References juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::begin(), juce::dsp::Matrix< ElementType >::data, juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::size(), juce::dsp::Matrix< ElementType >::swapColumns(), juce::dsp::Matrix< ElementType >::swapRows(), and juce::zeromem().
Referenced by juce::dsp::Matrix< ElementType >::Matrix().
|
staticnoexcept |
Compare to matrices with a given tolerance.
Referenced by juce::dsp::Matrix< ElementType >::hadarmard(), and juce::dsp::Matrix< ElementType >::operator==().
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Returns the number of columns in the matrix.
References juce::dsp::Matrix< ElementType >::columns.
|
inlinenoexcept |
Returns the number of rows in the matrix.
References juce::dsp::Matrix< ElementType >::rows.
|
inlinenoexcept |
Returns a pointer to the raw data of the matrix object, ordered in row-major order (for modifying).
References juce::dsp::Matrix< ElementType >::data, and juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::getRawDataPointer().
Referenced by juce::dsp::Matrix< ElementType >::apply().
|
inlinenoexcept |
Returns a pointer to the raw data of the matrix object, ordered in row-major order (for reading).
References juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::begin(), and juce::dsp::Matrix< ElementType >::data.
|
inlinenoexcept |
Returns an Array of 2 integers with the number of rows and columns in the matrix.
References juce::dsp::Matrix< ElementType >::columns, and juce::dsp::Matrix< ElementType >::rows.
|
inlinenoexcept |
Does a hadarmard product with the receiver and other and stores the result in the receiver.
References juce::dsp::Matrix< ElementType >::apply().
Referenced by juce::dsp::Matrix< ElementType >::hadarmard().
|
inlinestatic |
Does a hadarmard product with a and b returns the result.
References juce::dsp::Matrix< ElementType >::compare(), and juce::dsp::Matrix< ElementType >::hadarmard().
|
static |
Creates a squared size x size Hankel Matrix from a vector with an optional offset.
vector | The vector from which the Hankel matrix should be generated. Its number of rows should be at least 2 * (size - 1) + 1 |
size | The size of resulting square matrix. |
offset | An optional offset into the given vector. |
Referenced by juce::dsp::Matrix< ElementType >::Matrix().
|
static |
Creates the identity matrix.
Referenced by juce::dsp::Matrix< ElementType >::Matrix().
|
inlinenoexcept |
Tells if the matrix is a null matrix.
References juce::dsp::Matrix< ElementType >::columns, juce::dsp::Matrix< ElementType >::rows, juce::dsp::Matrix< ElementType >::solve(), and juce::dsp::Matrix< ElementType >::toString().
|
inlinenoexcept |
Tells if the matrix is a one column vector.
References juce::dsp::Matrix< ElementType >::columns.
Referenced by juce::dsp::Matrix< ElementType >::isVector().
|
inlinenoexcept |
Tells if the matrix is a one row vector.
References juce::dsp::Matrix< ElementType >::rows.
Referenced by juce::dsp::Matrix< ElementType >::isVector().
|
inlinenoexcept |
Tells if the matrix is a square matrix.
References juce::dsp::Matrix< ElementType >::columns, and juce::dsp::Matrix< ElementType >::rows.
|
inlinenoexcept |
Tells if the matrix is a vector.
References juce::dsp::Matrix< ElementType >::isOneColumnVector(), and juce::dsp::Matrix< ElementType >::isOneRowVector().
|
inlinenoexcept |
Returns the value of the matrix at a given row and column (for reading).
References juce::dsp::Matrix< ElementType >::columns, juce::dsp::Matrix< ElementType >::data, juce::dsp::Matrix< ElementType >::dataAcceleration, juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::getReference(), jassert, and juce::dsp::Matrix< ElementType >::rows.
|
inlinenoexcept |
Returns the value of the matrix at a given row and column (for modifying).
References juce::dsp::Matrix< ElementType >::columns, juce::dsp::Matrix< ElementType >::data, juce::dsp::Matrix< ElementType >::dataAcceleration, juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::getReference(), jassert, and juce::dsp::Matrix< ElementType >::rows.
|
inline |
Scalar multiplication.
Matrix juce::dsp::Matrix< ElementType >::operator* | ( | const Matrix< ElementType > & | other | ) | const |
Matrix multiplication.
|
inlinenoexcept |
Scalar multiplication.
References juce::dsp::Matrix< ElementType >::begin(), and juce::dsp::Matrix< ElementType >::end().
|
inline |
Addition of two matrices.
|
inlinenoexcept |
Addition of two matrices.
References juce::dsp::Matrix< ElementType >::apply().
|
inline |
Addition of two matrices.
|
inlinenoexcept |
Subtraction of two matrices.
References juce::dsp::Matrix< ElementType >::apply().
|
default |
Creates a copy of another matrix.
Referenced by juce::dsp::Matrix< ElementType >::Matrix().
|
defaultnoexcept |
Moves another matrix into this one.
|
inlinenoexcept |
References juce::dsp::Matrix< ElementType >::compare().
|
inlineprivate |
Resizes the matrix.
References juce::dsp::Matrix< ElementType >::columns, juce::dsp::Matrix< ElementType >::data, juce::dsp::Matrix< ElementType >::dataAcceleration, juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::resize(), juce::dsp::Matrix< ElementType >::rows, and juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::setUnchecked().
Referenced by juce::dsp::Matrix< ElementType >::Matrix().
|
noexcept |
Solves a linear system of equations represented by this object and the argument b, using various algorithms depending on the size of the arguments.
The matrix must be a square matrix N times N, and b must be a vector N times 1, with the coefficients of b. After the execution of the algorithm, the vector b will contain the solution.
Returns true if the linear system of euqations was successfully solved.
Referenced by juce::dsp::Matrix< ElementType >::isNullMatrix().
|
noexcept |
Swaps the contents of two columns in the matrix and returns a reference to itself.
Referenced by juce::dsp::Matrix< ElementType >::clear().
|
noexcept |
Swaps the contents of two rows in the matrix and returns a reference to itself.
Referenced by juce::dsp::Matrix< ElementType >::clear().
|
static |
Creates a Toeplitz Matrix from a vector with a given squared size.
Referenced by juce::dsp::Matrix< ElementType >::Matrix().
String juce::dsp::Matrix< ElementType >::toString | ( | ) | const |
Returns a String displaying in a convenient way the matrix contents.
Referenced by juce::dsp::Matrix< ElementType >::isNullMatrix().
|
private |
Referenced by juce::dsp::Matrix< ElementType >::apply(), juce::dsp::Matrix< ElementType >::getNumColumns(), juce::dsp::Matrix< ElementType >::getSize(), juce::dsp::Matrix< ElementType >::isNullMatrix(), juce::dsp::Matrix< ElementType >::isOneColumnVector(), juce::dsp::Matrix< ElementType >::isSquare(), juce::dsp::Matrix< ElementType >::Matrix(), juce::dsp::Matrix< ElementType >::operator()(), and juce::dsp::Matrix< ElementType >::resize().
|
private |
Referenced by juce::dsp::Matrix< ElementType >::begin(), juce::dsp::Matrix< ElementType >::clear(), juce::dsp::Matrix< ElementType >::end(), juce::dsp::Matrix< ElementType >::getRawDataPointer(), juce::dsp::Matrix< ElementType >::Matrix(), juce::dsp::Matrix< ElementType >::operator()(), and juce::dsp::Matrix< ElementType >::resize().
|
private |
|
private |
Referenced by juce::dsp::Matrix< ElementType >::apply(), juce::dsp::Matrix< ElementType >::getNumRows(), juce::dsp::Matrix< ElementType >::getSize(), juce::dsp::Matrix< ElementType >::isNullMatrix(), juce::dsp::Matrix< ElementType >::isOneRowVector(), juce::dsp::Matrix< ElementType >::isSquare(), juce::dsp::Matrix< ElementType >::Matrix(), juce::dsp::Matrix< ElementType >::operator()(), and juce::dsp::Matrix< ElementType >::resize().