Loading...
Searching...
No Matches
juce::dsp::Matrix< ElementType > Class Template Reference

## 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

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

- juce_dsp/maths/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.
| 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.
| Matrix (const Matrix &)=default
| Creates a copy of another matrix.
| Matrix (Matrix &&) noexcept=default
| Moves a copy of another matrix.
Matrix & | operator= (const Matrix &)=default
| Creates a copy of another matrix.
Matrix & | operator= (Matrix &&) noexcept=default
| Moves another matrix into this one.
size_t | getNumRows () const noexcept
| Returns the number of rows in the matrix.
size_t | getNumColumns () const noexcept
| Returns the number of columns in the matrix.
Array< size_t > | getSize () const noexcept
| Returns an Array of 2 integers with the number of rows and columns in the matrix.
void | clear () noexcept
| Fills the contents of the matrix with zeroes.
Matrix & | swapRows (size_t rowOne, size_t rowTwo) noexcept
| Swaps the contents of two rows in the matrix and returns a reference to itself.
Matrix & | swapColumns (size_t columnOne, size_t columnTwo) noexcept
| Swaps the contents of two columns in the matrix and returns a reference to itself.
ElementType | operator() (size_t row, size_t column) const noexcept
| Returns the value of the matrix at a given row and column (for reading).
ElementType & | operator() (size_t row, size_t column) noexcept
| Returns the value of the matrix at a given row and column (for modifying).
ElementType * | getRawDataPointer () noexcept
| Returns a pointer to the raw data of the matrix object, ordered in row-major order (for modifying).
const ElementType * | getRawDataPointer () const noexcept
| Returns a pointer to the raw data of the matrix object, ordered in row-major order (for reading).
Matrix & | operator+= (const Matrix &other) noexcept
| Addition of two matrices.
Matrix & | operator-= (const Matrix &other) noexcept
| Subtraction of two matrices.
Matrix & | operator*= (ElementType scalar) noexcept
| Scalar multiplication.
Matrix | operator+ (const Matrix &other) const
| Addition of two matrices.
Matrix | operator- (const Matrix &other) const
| Addition of two matrices.
Matrix | operator* (ElementType scalar) const
| Scalar multiplication.
Matrix | operator* (const Matrix &other) const
| Matrix multiplication.
Matrix & | hadarmard (const Matrix &other) noexcept
| Does a hadarmard product with the receiver and other and stores the result in the receiver.
bool | operator== (const Matrix &other) const noexcept
bool | isSquare () const noexcept
| Tells if the matrix is a square matrix.
bool | isVector () const noexcept
| Tells if the matrix is a vector.
bool | isOneColumnVector () const noexcept
| Tells if the matrix is a one column vector.
bool | isOneRowVector () const noexcept
| Tells if the matrix is a one row vector.
bool | isNullMatrix () const noexcept
| Tells if the matrix is a null matrix.
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.
String | toString () const
| Returns a String displaying in a convenient way the matrix contents.
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)
| Creates the identity matrix.
static Matrix | toeplitz (const Matrix &vector, size_t size)
| Creates a Toeplitz Matrix from a vector with a given squared size.
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.
static Matrix | hadarmard (const Matrix &a, const Matrix &b)
| Does a hadarmard product with a and b returns the result.
static bool | compare (const Matrix &a, const Matrix &b, ElementType tolerance=0) noexcept
| Compare to matrices with a given tolerance.

## Constructors and Destructors

## 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.

References clear().

Referenced by compare(), hadarmard(), hadarmard(), hankel(), identity(), Matrix(), Matrix(), operator*(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator=(), operator=(), operator==(), solve(), swapColumns(), swapRows(), and toeplitz().

## 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.

## Matrix() [3/4]

template<typename ElementType>

juce::dsp::Matrix< ElementType >::Matrix | ( | const Matrix< ElementType > & |  | ) |

default

Creates a copy of another matrix.

References Matrix().

## Matrix() [4/4]

template<typename ElementType>

juce::dsp::Matrix< ElementType >::Matrix | ( | Matrix< ElementType > && |  | ) |

default noexcept

Moves a copy of another matrix.

References Matrix().

## Member Functions

## operator=() [1/2]

template<typename ElementType>

Matrix & juce::dsp::Matrix< ElementType >::operator= | ( | const Matrix< ElementType > & |  | ) |

default

Creates a copy of another matrix.

References Matrix().

## operator=() [2/2]

template<typename ElementType>

Matrix & juce::dsp::Matrix< ElementType >::operator= | ( | Matrix< ElementType > && |  | ) |

default noexcept

Moves another matrix into this one.

References Matrix().

## identity()

template<typename ElementType>

Matrix juce::dsp::Matrix< ElementType >::identity | ( | size_t | size | ) |

static

Creates the identity matrix.

References identity(), and Matrix().

Referenced by identity().

## toeplitz()

template<typename ElementType>

Matrix 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.

References Matrix(), and toeplitz().

Referenced by toeplitz().

## hankel()

template<typename ElementType>

Matrix 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

  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.

References hankel(), and Matrix().

Referenced by hankel().

## getNumRows()

template<typename ElementType>

size_t juce::dsp::Matrix< ElementType >::getNumRows | ( |  | ) | const

inline noexcept

Returns the number of rows in the matrix.

References getNumRows().

Referenced by getNumRows().

## getNumColumns()

template<typename ElementType>

size_t juce::dsp::Matrix< ElementType >::getNumColumns | ( |  | ) | const

inline noexcept

Returns the number of columns in the matrix.

## getSize()

template<typename ElementType>

Array< size_t > juce::dsp::Matrix< ElementType >::getSize | ( |  | ) | const

inline noexcept

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

## clear()

template<typename ElementType>

void juce::dsp::Matrix< ElementType >::clear | ( |  | ) |

inline noexcept

Fills the contents of the matrix with zeroes.

References juce::zeromem().

Referenced by Matrix().

## swapRows()

template<typename ElementType>

Matrix & 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.

References Matrix().

## swapColumns()

template<typename ElementType>

Matrix & 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.

References Matrix().

## operator()() [1/2]

template<typename ElementType>

ElementType juce::dsp::Matrix< ElementType >::operator() | ( | size_t | row,
|  | size_t | column ) const

inline noexcept

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

References juce::column, jassert, and juce::row.

## operator()() [2/2]

template<typename ElementType>

ElementType & juce::dsp::Matrix< ElementType >::operator() | ( | size_t | row,
|  | size_t | column )

inline noexcept

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

References juce::column, jassert, and juce::row.

## getRawDataPointer() [1/2]

template<typename ElementType>

ElementType * juce::dsp::Matrix< ElementType >::getRawDataPointer | ( |  | ) |

inline noexcept

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

## getRawDataPointer() [2/2]

template<typename ElementType>

const ElementType * juce::dsp::Matrix< ElementType >::getRawDataPointer | ( |  | ) | const

inline noexcept

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

## operator+=()

template<typename ElementType>

Matrix & juce::dsp::Matrix< ElementType >::operator+= | ( | const Matrix< ElementType > & | other | ) |

inline noexcept

Addition of two matrices.

References Matrix().

## operator-=()

template<typename ElementType>

Matrix & juce::dsp::Matrix< ElementType >::operator-= | ( | const Matrix< ElementType > & | other | ) |

inline noexcept

Subtraction of two matrices.

References Matrix().

## operator*=()

template<typename ElementType>

Matrix & juce::dsp::Matrix< ElementType >::operator*= | ( | ElementType | scalar | ) |

inline noexcept

Scalar multiplication.

References begin(), end(), Matrix(), and x.

## operator+()

template<typename ElementType>

Matrix juce::dsp::Matrix< ElementType >::operator+ | ( | const Matrix< ElementType > & | other | ) | const

inline

Addition of two matrices.

References Matrix().

## operator-()

template<typename ElementType>

Matrix juce::dsp::Matrix< ElementType >::operator- | ( | const Matrix< ElementType > & | other | ) | const

inline

Addition of two matrices.

References Matrix().

## operator*() [1/2]

template<typename ElementType>

Matrix juce::dsp::Matrix< ElementType >::operator* | ( | ElementType | scalar | ) | const

inline

Scalar multiplication.

References Matrix().

## operator*() [2/2]

template<typename ElementType>

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

Matrix multiplication.

References Matrix().

## hadarmard() [1/2]

template<typename ElementType>

Matrix & juce::dsp::Matrix< ElementType >::hadarmard | ( | const Matrix< ElementType > & | other | ) |

inline noexcept

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

References Matrix().

Referenced by hadarmard().

## hadarmard() [2/2]

template<typename ElementType>

Matrix juce::dsp::Matrix< ElementType >::hadarmard | ( | const Matrix< ElementType > & | a,
|  | const Matrix< ElementType > & | b )

inline static

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

References hadarmard(), and Matrix().

## compare()

template<typename ElementType>

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

static noexcept

Compare to matrices with a given tolerance.

References Matrix().

Referenced by operator==().

## operator==()

template<typename ElementType>

bool juce::dsp::Matrix< ElementType >::operator== | ( | const Matrix< ElementType > & | other | ) | const

inline noexcept

References compare(), and Matrix().

## isSquare()

template<typename ElementType>

bool juce::dsp::Matrix< ElementType >::isSquare | ( |  | ) | const

inline noexcept

Tells if the matrix is a square matrix.

## isVector()

template<typename ElementType>

bool juce::dsp::Matrix< ElementType >::isVector | ( |  | ) | const

inline noexcept

Tells if the matrix is a vector.

References isOneColumnVector(), and isOneRowVector().

## isOneColumnVector()

template<typename ElementType>

bool juce::dsp::Matrix< ElementType >::isOneColumnVector | ( |  | ) | const

inline noexcept

Tells if the matrix is a one column vector.

Referenced by isVector().

## isOneRowVector()

template<typename ElementType>

bool juce::dsp::Matrix< ElementType >::isOneRowVector | ( |  | ) | const

inline noexcept

Tells if the matrix is a one row vector.

Referenced by isVector().

## isNullMatrix()

template<typename ElementType>

bool juce::dsp::Matrix< ElementType >::isNullMatrix | ( |  | ) | const

inline noexcept

Tells if the matrix is a null matrix.

## 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.

References Matrix().

## toString()

template<typename ElementType>

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

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

## begin() [1/2]

template<typename ElementType>

ElementType * juce::dsp::Matrix< ElementType >::begin | ( |  | ) |

inline noexcept

Referenced by end(), and operator*=().

## end() [1/2]

template<typename ElementType>

ElementType * juce::dsp::Matrix< ElementType >::end | ( |  | ) |

inline noexcept

Referenced by operator*=().

## begin() [2/2]

template<typename ElementType>

const ElementType * juce::dsp::Matrix< ElementType >::begin | ( |  | ) | const

inline noexcept

## end() [2/2]

template<typename ElementType>

const ElementType * juce::dsp::Matrix< ElementType >::end | ( |  | ) | const

inline noexcept

References begin().

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited