OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce::dsp::Matrix< ElementType > Class Template Reference

#include <juce_Matrix.h>

Public Member Functions

 Matrix (size_t numRows, size_t numColumns)
 
 Matrix (size_t numRows, size_t numColumns, const ElementType *dataPointer)
 
 Matrix (const Matrix &)=default
 
 Matrix (Matrix &&) noexcept=default
 
Matrixoperator= (const Matrix &)=default
 
Matrixoperator= (Matrix &&) noexcept=default
 
size_t getNumRows () const noexcept
 
size_t getNumColumns () const noexcept
 
Array< size_tgetSize () const noexcept
 
void clear () noexcept
 
MatrixswapRows (size_t rowOne, size_t rowTwo) noexcept
 
MatrixswapColumns (size_t columnOne, size_t columnTwo) noexcept
 
ElementType operator() (size_t row, size_t column) const noexcept
 
ElementType & operator() (size_t row, size_t column) noexcept
 
ElementType * getRawDataPointer () noexcept
 
const ElementType * getRawDataPointer () const noexcept
 
Matrixoperator+= (const Matrix &other) noexcept
 
Matrixoperator-= (const Matrix &other) noexcept
 
Matrixoperator*= (ElementType scalar) noexcept
 
Matrix operator+ (const Matrix &other) const
 
Matrix operator- (const Matrix &other) const
 
Matrix operator* (ElementType scalar) const
 
Matrix operator* (const Matrix &other) const
 
Matrixhadarmard (const Matrix &other) noexcept
 
bool operator== (const Matrix &other) const noexcept
 
bool isSquare () const noexcept
 
bool isVector () const noexcept
 
bool isOneColumnVector () const noexcept
 
bool isOneRowVector () const noexcept
 
bool isNullMatrix () const noexcept
 
bool solve (Matrix &b) const noexcept
 
String toString () const
 
ElementType * begin () noexcept
 
ElementType * end () noexcept
 
const ElementType * begin () const noexcept
 
const ElementType * end () const noexcept
 

Static Public Member Functions

static Matrix identity (size_t size)
 
static Matrix toeplitz (const Matrix &vector, size_t size)
 
static Matrix hankel (const Matrix &vector, size_t size, size_t offset=0)
 
static Matrix hadarmard (const Matrix &a, const Matrix &b)
 
static bool compare (const Matrix &a, const Matrix &b, ElementType tolerance=0) noexcept
 

Detailed Description

template<typename ElementType>
class juce::dsp::Matrix< ElementType >

General matrix and vectors class, meant for classic math manipulation such as additions, multiplications, and linear systems of equations solving.

See also
LinearAlgebra

Definition at line 41 of file juce_Matrix.h.

Constructor & Destructor Documentation

◆ Matrix() [1/4]

template<typename ElementType >
juce::dsp::Matrix< ElementType >::Matrix ( size_t  numRows,
size_t  numColumns 
)
inline

Creates a new matrix with a given number of rows and columns.

Definition at line 46 of file juce_Matrix.h.

◆ Matrix() [2/4]

template<typename ElementType >
juce::dsp::Matrix< ElementType >::Matrix ( size_t  numRows,
size_t  numColumns,
const ElementType *  dataPointer 
)
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.

Definition at line 56 of file juce_Matrix.h.

◆ Matrix() [3/4]

template<typename ElementType >
juce::dsp::Matrix< ElementType >::Matrix ( const Matrix< ElementType > &  )
default

Creates a copy of another matrix.

◆ Matrix() [4/4]

template<typename ElementType >
juce::dsp::Matrix< ElementType >::Matrix ( Matrix< ElementType > &&  )
defaultnoexcept

Moves a copy of another matrix.

Member Function Documentation

◆ begin() [1/2]

template<typename ElementType >
const ElementType * juce::dsp::Matrix< ElementType >::begin ( ) const
inlinenoexcept

Definition at line 213 of file juce_Matrix.h.

◆ begin() [2/2]

template<typename ElementType >
ElementType * juce::dsp::Matrix< ElementType >::begin ( )
inlinenoexcept

Definition at line 210 of file juce_Matrix.h.

◆ clear()

template<typename ElementType >
void juce::dsp::Matrix< ElementType >::clear ( )
inlinenoexcept

Fills the contents of the matrix with zeroes.

Definition at line 104 of file juce_Matrix.h.

Referenced by juce::dsp::Matrix< ElementType >::Matrix().

◆ compare()

template<typename ElementType >
bool juce::dsp::Matrix< ElementType >::compare ( const Matrix< ElementType > &  a,
const Matrix< ElementType > &  b,
ElementType  tolerance = 0 
)
staticnoexcept

Compare to matrices with a given tolerance

Definition at line 149 of file juce_Matrix.cpp.

◆ end() [1/2]

template<typename ElementType >
const ElementType * juce::dsp::Matrix< ElementType >::end ( ) const
inlinenoexcept

Definition at line 214 of file juce_Matrix.h.

◆ end() [2/2]

template<typename ElementType >
ElementType * juce::dsp::Matrix< ElementType >::end ( )
inlinenoexcept

Definition at line 211 of file juce_Matrix.h.

◆ getNumColumns()

template<typename ElementType >
size_t juce::dsp::Matrix< ElementType >::getNumColumns ( ) const
inlinenoexcept

Returns the number of columns in the matrix.

Definition at line 96 of file juce_Matrix.h.

◆ getNumRows()

template<typename ElementType >
size_t juce::dsp::Matrix< ElementType >::getNumRows ( ) const
inlinenoexcept

Returns the number of rows in the matrix.

Definition at line 93 of file juce_Matrix.h.

◆ getRawDataPointer() [1/2]

template<typename ElementType >
const ElementType * juce::dsp::Matrix< ElementType >::getRawDataPointer ( ) const
inlinenoexcept

Returns a pointer to the raw data of the matrix object, ordered in row-major order (for reading).

Definition at line 136 of file juce_Matrix.h.

◆ getRawDataPointer() [2/2]

template<typename ElementType >
ElementType * juce::dsp::Matrix< ElementType >::getRawDataPointer ( )
inlinenoexcept

Returns a pointer to the raw data of the matrix object, ordered in row-major order (for modifying).

Definition at line 131 of file juce_Matrix.h.

Referenced by juce::dsp::Matrix< ElementType >::operator*().

◆ getSize()

template<typename ElementType >
Array< size_t > juce::dsp::Matrix< ElementType >::getSize ( ) const
inlinenoexcept

Returns an Array of 2 integers with the number of rows and columns in the matrix.

Definition at line 101 of file juce_Matrix.h.

◆ hadarmard() [1/2]

template<typename ElementType >
static Matrix juce::dsp::Matrix< ElementType >::hadarmard ( const Matrix< ElementType > &  a,
const Matrix< ElementType > &  b 
)
inlinestatic

Does a hadarmard product with a and b returns the result.

Definition at line 168 of file juce_Matrix.h.

◆ hadarmard() [2/2]

template<typename ElementType >
Matrix & juce::dsp::Matrix< ElementType >::hadarmard ( const Matrix< ElementType > &  other)
inlinenoexcept

Does a hadarmard product with the receiver and other and stores the result in the receiver

Definition at line 165 of file juce_Matrix.h.

Referenced by juce::dsp::Matrix< ElementType >::hadarmard().

◆ hankel()

template<typename ElementType >
Matrix< ElementType > juce::dsp::Matrix< ElementType >::hankel ( const Matrix< ElementType > &  vector,
size_t  size,
size_t  offset = 0 
)
static

Creates a squared size x size Hankel Matrix from a vector with an optional offset.

Parameters
vectorThe vector from which the Hankel matrix should be generated. Its number of rows should be at least 2 * (size - 1) + 1
sizeThe size of resulting square matrix.
offsetAn optional offset into the given vector.

Definition at line 62 of file juce_Matrix.cpp.

Referenced by juce::dsp::FilterDesign< FloatType >::designFIRLowpassLeastSquaresMethod().

◆ identity()

template<typename ElementType >
Matrix< ElementType > juce::dsp::Matrix< ElementType >::identity ( size_t  size)
static

Creates the identity matrix

Definition at line 33 of file juce_Matrix.cpp.

Referenced by juce::dsp::FilterDesign< FloatType >::designFIRLowpassLeastSquaresMethod().

◆ isNullMatrix()

template<typename ElementType >
bool juce::dsp::Matrix< ElementType >::isNullMatrix ( ) const
inlinenoexcept

Tells if the matrix is a null matrix

Definition at line 191 of file juce_Matrix.h.

◆ isOneColumnVector()

template<typename ElementType >
bool juce::dsp::Matrix< ElementType >::isOneColumnVector ( ) const
inlinenoexcept

Tells if the matrix is a one column vector

Definition at line 185 of file juce_Matrix.h.

Referenced by juce::dsp::Matrix< ElementType >::isVector().

◆ isOneRowVector()

template<typename ElementType >
bool juce::dsp::Matrix< ElementType >::isOneRowVector ( ) const
inlinenoexcept

Tells if the matrix is a one row vector

Definition at line 188 of file juce_Matrix.h.

Referenced by juce::dsp::Matrix< ElementType >::isVector().

◆ isSquare()

template<typename ElementType >
bool juce::dsp::Matrix< ElementType >::isSquare ( ) const
inlinenoexcept

Tells if the matrix is a square matrix

Definition at line 179 of file juce_Matrix.h.

◆ isVector()

template<typename ElementType >
bool juce::dsp::Matrix< ElementType >::isVector ( ) const
inlinenoexcept

Tells if the matrix is a vector

Definition at line 182 of file juce_Matrix.h.

◆ operator()() [1/2]

template<typename ElementType >
ElementType juce::dsp::Matrix< ElementType >::operator() ( size_t  row,
size_t  column 
) const
inlinenoexcept

Returns the value of the matrix at a given row and column (for reading).

Definition at line 115 of file juce_Matrix.h.

◆ operator()() [2/2]

template<typename ElementType >
ElementType & juce::dsp::Matrix< ElementType >::operator() ( size_t  row,
size_t  column 
)
inlinenoexcept

Returns the value of the matrix at a given row and column (for modifying).

Definition at line 122 of file juce_Matrix.h.

◆ operator*() [1/2]

template<typename ElementType >
Matrix< ElementType > juce::dsp::Matrix< ElementType >::operator* ( const Matrix< ElementType > &  other) const

Matrix multiplication

Definition at line 114 of file juce_Matrix.cpp.

◆ operator*() [2/2]

template<typename ElementType >
Matrix juce::dsp::Matrix< ElementType >::operator* ( ElementType  scalar) const
inline

Scalar multiplication

Definition at line 159 of file juce_Matrix.h.

◆ operator*=()

template<typename ElementType >
Matrix & juce::dsp::Matrix< ElementType >::operator*= ( ElementType  scalar)
inlinenoexcept

Scalar multiplication

Definition at line 146 of file juce_Matrix.h.

◆ operator+()

template<typename ElementType >
Matrix juce::dsp::Matrix< ElementType >::operator+ ( const Matrix< ElementType > &  other) const
inline

Addition of two matrices

Definition at line 153 of file juce_Matrix.h.

◆ operator+=()

template<typename ElementType >
Matrix & juce::dsp::Matrix< ElementType >::operator+= ( const Matrix< ElementType > &  other)
inlinenoexcept

Addition of two matrices

Definition at line 140 of file juce_Matrix.h.

◆ operator-()

template<typename ElementType >
Matrix juce::dsp::Matrix< ElementType >::operator- ( const Matrix< ElementType > &  other) const
inline

Addition of two matrices

Definition at line 156 of file juce_Matrix.h.

◆ operator-=()

template<typename ElementType >
Matrix & juce::dsp::Matrix< ElementType >::operator-= ( const Matrix< ElementType > &  other)
inlinenoexcept

Subtraction of two matrices

Definition at line 143 of file juce_Matrix.h.

◆ operator=() [1/2]

template<typename ElementType >
Matrix & juce::dsp::Matrix< ElementType >::operator= ( const Matrix< ElementType > &  )
default

Creates a copy of another matrix.

◆ operator=() [2/2]

template<typename ElementType >
Matrix & juce::dsp::Matrix< ElementType >::operator= ( Matrix< ElementType > &&  )
defaultnoexcept

Moves another matrix into this one

◆ operator==()

template<typename ElementType >
bool juce::dsp::Matrix< ElementType >::operator== ( const Matrix< ElementType > &  other) const
inlinenoexcept

Definition at line 175 of file juce_Matrix.h.

◆ solve()

template<typename ElementType >
bool juce::dsp::Matrix< ElementType >::solve ( Matrix< ElementType > &  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.

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 equations was successfully solved.

Definition at line 166 of file juce_Matrix.cpp.

◆ swapColumns()

template<typename ElementType >
Matrix< ElementType > & juce::dsp::Matrix< ElementType >::swapColumns ( size_t  columnOne,
size_t  columnTwo 
)
noexcept

Swaps the contents of two columns in the matrix and returns a reference to itself.

Definition at line 81 of file juce_Matrix.cpp.

◆ swapRows()

template<typename ElementType >
Matrix< ElementType > & juce::dsp::Matrix< ElementType >::swapRows ( size_t  rowOne,
size_t  rowTwo 
)
noexcept

Swaps the contents of two rows in the matrix and returns a reference to itself.

Definition at line 97 of file juce_Matrix.cpp.

◆ toeplitz()

template<typename ElementType >
Matrix< ElementType > juce::dsp::Matrix< ElementType >::toeplitz ( const Matrix< ElementType > &  vector,
size_t  size 
)
static

Creates a Toeplitz Matrix from a vector with a given squared size

Definition at line 44 of file juce_Matrix.cpp.

Referenced by juce::dsp::FilterDesign< FloatType >::designFIRLowpassLeastSquaresMethod().

◆ toString()

template<typename ElementType >
String juce::dsp::Matrix< ElementType >::toString ( ) const

Returns a String displaying in a convenient way the matrix contents.

Definition at line 279 of file juce_Matrix.cpp.


The documentation for this class was generated from the following files: