37template <
typename ElementType>
114 jassert (
row < rows && column < columns);
115 return data.getReference (
static_cast<int> (dataAcceleration.
getReference (
static_cast<int> (
row))) +
static_cast<int> (column));
121 jassert (
row < rows && column < columns);
122 return data.getReference (
static_cast<int> (dataAcceleration.
getReference (
static_cast<int> (
row))) +
static_cast<int> (column));
137 inline Matrix&
operator+= (
const Matrix& other)
noexcept {
return apply (other, [] (ElementType a, ElementType b) {
return a + b; } ); }
140 inline Matrix&
operator-= (
const Matrix& other)
noexcept {
return apply (other, [] (ElementType a, ElementType b) {
return a - b; } ); }
145 std::for_each (begin(), end(), [
scalar] (ElementType&
x) {
x *=
scalar; });
162 inline Matrix&
hadarmard (
const Matrix& other)
noexcept {
return apply (other, [] (ElementType a, ElementType b) {
return a * b; } ); }
207 ElementType* begin()
noexcept {
return data.begin(); }
208 ElementType* end()
noexcept {
return data.end(); }
210 const ElementType* begin() const noexcept {
return &data.getReference (0); }
211 const ElementType* end() const noexcept {
return begin() + data.size(); }
218 data.resize (
static_cast<int> (columns * rows));
219 dataAcceleration.
resize (
static_cast<int> (rows));
221 for (
size_t i = 0; i < rows; ++i)
222 dataAcceleration.
setUnchecked (
static_cast<int> (i), i * columns);
225 template <
typename BinaryOperation>
226 Matrix& apply (
const Matrix& other, BinaryOperation binaryOp)
228 jassert (rows == other.rows && columns == other.columns);
232 for (
auto src : other)
234 *dst = binaryOp (*dst, src);
242 Array<ElementType> data;
243 Array<size_t> dataAcceleration;
245 size_t rows, columns;
248 JUCE_LEAK_DETECTOR (
Matrix)
void setUnchecked(int indexToChange, ParameterType newValue)
void resize(int targetNumItems)
ElementType & getReference(int index) noexcept
Matrix operator-(const Matrix &other) const
Matrix & swapRows(size_t rowOne, size_t rowTwo) noexcept
Matrix & hadarmard(const Matrix &other) noexcept
size_t getNumRows() const noexcept
Matrix(Matrix &&) noexcept=default
static Matrix hadarmard(const Matrix &a, const Matrix &b)
static bool compare(const Matrix &a, const Matrix &b, ElementType tolerance=0) noexcept
Matrix(const Matrix &)=default
bool isOneColumnVector() const noexcept
bool isVector() const noexcept
bool isNullMatrix() const noexcept
Array< size_t > getSize() const noexcept
Matrix & swapColumns(size_t columnOne, size_t columnTwo) noexcept
Matrix(size_t numRows, size_t numColumns)
static Matrix hankel(const Matrix &vector, size_t size, size_t offset=0)
Matrix operator*(ElementType scalar) const
ElementType operator()(size_t row, size_t column) const noexcept
const ElementType * getRawDataPointer() const noexcept
Matrix & operator-=(const Matrix &other) noexcept
Matrix operator+(const Matrix &other) const
static Matrix identity(size_t size)
bool solve(Matrix &b) const noexcept
static Matrix toeplitz(const Matrix &vector, size_t size)
Matrix(size_t numRows, size_t numColumns, const ElementType *dataPointer)
ElementType * getRawDataPointer() noexcept
size_t getNumColumns() const noexcept
bool isSquare() const noexcept
Matrix & operator*=(ElementType scalar) noexcept
bool isOneRowVector() const noexcept
Matrix & operator+=(const Matrix &other) noexcept