35 #ifndef _BLAZE_MATH_EXPRESSIONS_MATRIX_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_MATRIX_H_ 108 return *
static_cast<const MatrixType*
>( this );
137 template<
typename VT
140 inline VT&
operator*=( Vector<VT,false>& lhs,
const Matrix<MT,SO>& rhs )
142 ResultType_t<VT> tmp( (~rhs) * (~lhs) );
143 (~lhs) = std::move( tmp );
164 template<
typename VT
167 inline VT&
operator*=( Vector<VT,false>&& lhs,
const Matrix<MT,SO>& rhs )
169 return (~lhs) *= (~rhs);
189 template<
typename VT
192 inline VT&
operator*=( Vector<VT,true>& lhs,
const Matrix<MT,SO>& rhs )
194 ResultType_t<VT> tmp( (~lhs) * (~rhs) );
195 (~lhs) = std::move( tmp );
216 template<
typename VT
219 inline VT&
operator*=( Vector<VT,true>&& lhs,
const Matrix<MT,SO>& rhs )
221 return (~lhs) *= (~rhs);
240 template<
typename MT1
244 inline MT1&
operator*=( Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs )
246 ResultType_t<MT1> tmp( (~lhs) * (~rhs) );
247 (~lhs) = std::move( tmp );
268 template<
typename MT1
272 inline MT1&
operator*=( Matrix<MT1,SO1>&& lhs,
const Matrix<MT2,SO2>& rhs )
274 return (~lhs) *= (~rhs);
291 template<
typename MT,
bool SO >
294 template<
typename MT,
bool SO >
297 template<
typename MT,
bool SO >
300 template<
typename MT,
bool SO >
303 template<
typename MT,
bool SO >
306 template<
typename MT,
bool SO >
309 template<
typename MT,
bool SO >
310 constexpr
size_t rows(
const Matrix<MT,SO>& matrix ) noexcept;
312 template<
typename MT,
bool SO >
313 constexpr
size_t columns(
const Matrix<MT,SO>& matrix ) noexcept;
315 template<
typename MT,
bool SO >
316 constexpr
size_t size(
const Matrix<MT,SO>& matrix ) noexcept;
318 template<
typename MT,
bool SO >
319 size_t capacity(
const Matrix<MT,SO>& matrix ) noexcept;
321 template<
typename MT,
bool SO >
322 size_t capacity(
const Matrix<MT,SO>& matrix,
size_t i ) noexcept;
324 template<
typename MT,
bool SO >
325 size_t nonZeros(
const Matrix<MT,SO>& matrix );
327 template<
typename MT,
bool SO >
328 size_t nonZeros(
const Matrix<MT,SO>& matrix,
size_t i );
330 template<
typename MT,
bool SO >
331 void resize( Matrix<MT,SO>& matrix,
size_t rows,
size_t columns,
bool preserve=
true );
333 template<
typename MT,
bool SO >
336 template<
typename MT,
bool SO >
339 template<
typename MT,
bool SO >
342 template<
typename MT,
bool SO >
345 template<
typename MT,
bool SO >
346 constexpr
bool isEmpty(
const Matrix<MT,SO>& matrix ) noexcept;
348 template<
typename MT,
bool SO >
349 bool isSquare(
const Matrix<MT,SO>& matrix ) noexcept;
351 template<
typename MT1,
bool SO1,
typename MT2,
bool SO2 >
352 bool isSame(
const Matrix<MT1,SO1>& a,
const Matrix<MT2,SO2>& b ) noexcept;
370 template<
typename MT
374 return (~matrix).begin(i);
392 template<
typename MT
396 return (~matrix).begin(i);
414 template<
typename MT
418 return (~matrix).cbegin(i);
436 template<
typename MT
440 return (~matrix).end(i);
458 template<
typename MT
462 return (~matrix).end(i);
480 template<
typename MT
484 return (~matrix).cend(i);
496 template<
typename MT
500 return (~matrix).rows();
512 template<
typename MT
516 return (~matrix).columns();
528 template<
typename MT
532 return (~matrix).rows() * (~matrix).
columns();
544 template<
typename MT
548 return (~matrix).capacity();
566 template<
typename MT
570 return (~matrix).capacity( i );
582 template<
typename MT
586 return (~matrix).nonZeros();
604 template<
typename MT
608 return (~matrix).nonZeros( i );
630 template<
typename MT
632 BLAZE_ALWAYS_INLINE auto resize_backend( Matrix<MT,SO>& matrix,
size_t m,
size_t n,
bool preserve )
633 -> DisableIf_t< IsResizable_v<MT> >
637 if( (~matrix).
rows() != m || (~matrix).
columns() != n ) {
658 template<
typename MT
660 BLAZE_ALWAYS_INLINE auto resize_backend( Matrix<MT,SO>& matrix,
size_t m,
size_t n,
bool preserve )
661 -> EnableIf_t< IsResizable_v<MT> && !IsSquare_v<MT> >
663 (~matrix).
resize( m, n, preserve );
683 template<
typename MT
685 BLAZE_ALWAYS_INLINE auto resize_backend( Matrix<MT,SO>& matrix,
size_t m,
size_t n,
bool preserve )
686 -> EnableIf_t< IsResizable_v<MT> && IsSquare_v<MT> >
692 (~matrix).
resize( m, preserve );
736 template<
typename MT
740 resize_backend( matrix, m, n, preserve );
753 template<
typename MT
756 -> DisableIf_t< IsShrinkable_v<MT> >
772 template<
typename MT
775 -> EnableIf_t< IsShrinkable_v<MT> >
797 template<
typename MT
801 shrinkToFit_backend( matrix );
823 template<
typename MT
849 template<
typename MT
910 template<
typename MT
930 template<
typename MT
934 return size( ~matrix ) == 0UL;
949 template<
typename MT
953 return ( IsSquare_v<MT> || (~matrix).
rows() == (~matrix).
columns() );
988 template<
typename MT1
994 return ( IsSame_v<MT1,MT2> &&
995 reinterpret_cast<const void*>( &a ) == reinterpret_cast<const void*>( &b ) );
1009 template<
typename MT1
1016 (~lhs).assign( ~rhs );
1031 template<
typename MT1
1034 BLAZE_ALWAYS_INLINE auto assign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,!SO>& rhs )
1035 -> DisableIf_t< IsSymmetric_v<MT2> >
1041 (~lhs).assign( ~rhs );
1057 template<
typename MT1
1060 BLAZE_ALWAYS_INLINE auto assign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,!SO>& rhs )
1061 -> EnableIf_t< IsSymmetric_v<MT2> >
1069 (~lhs).assign(
trans( ~rhs ) );
1090 template<
typename MT1
1101 assign_backend( ~lhs, ~rhs );
1117 template<
typename MT1
1120 BLAZE_ALWAYS_INLINE void addAssign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,SO>& rhs )
1124 (~lhs).addAssign( ~rhs );
1140 template<
typename MT1
1143 BLAZE_ALWAYS_INLINE auto addAssign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,!SO>& rhs )
1144 -> DisableIf_t< IsSymmetric_v<MT2> >
1150 (~lhs).addAssign( ~rhs );
1166 template<
typename MT1
1169 BLAZE_ALWAYS_INLINE auto addAssign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,!SO>& rhs )
1170 -> EnableIf_t< IsSymmetric_v<MT2> >
1178 (~lhs).addAssign(
trans( ~rhs ) );
1199 template<
typename MT1
1210 addAssign_backend( ~lhs, ~rhs );
1226 template<
typename MT1
1229 BLAZE_ALWAYS_INLINE void subAssign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,SO>& rhs )
1233 (~lhs).subAssign( ~rhs );
1249 template<
typename MT1
1252 BLAZE_ALWAYS_INLINE auto subAssign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,!SO>& rhs )
1253 -> DisableIf_t< IsSymmetric_v<MT2> >
1259 (~lhs).subAssign( ~rhs );
1275 template<
typename MT1
1278 BLAZE_ALWAYS_INLINE auto subAssign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,!SO>& rhs )
1279 -> EnableIf_t< IsSymmetric_v<MT2> >
1287 (~lhs).subAssign(
trans( ~rhs ) );
1308 template<
typename MT1
1319 subAssign_backend( ~lhs, ~rhs );
1335 template<
typename MT1
1338 BLAZE_ALWAYS_INLINE void schurAssign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,SO>& rhs )
1342 (~lhs).schurAssign( ~rhs );
1358 template<
typename MT1
1361 BLAZE_ALWAYS_INLINE auto schurAssign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,!SO>& rhs )
1362 -> DisableIf_t< IsSymmetric_v<MT2> >
1368 (~lhs).schurAssign( ~rhs );
1384 template<
typename MT1
1387 BLAZE_ALWAYS_INLINE auto schurAssign_backend( Matrix<MT1,SO>& lhs,
const Matrix<MT2,!SO>& rhs )
1388 -> EnableIf_t< IsSymmetric_v<MT2> >
1396 (~lhs).schurAssign(
trans( ~rhs ) );
1417 template<
typename MT1
1428 schurAssign_backend( ~lhs, ~rhs );
1449 template<
typename MT1
1459 (~lhs).multAssign( ~rhs );
1481 template<
typename MT
1484 BLAZE_ALWAYS_INLINE bool trySet(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1513 template<
typename MT
1516 BLAZE_ALWAYS_INLINE bool tryAdd(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1545 template<
typename MT
1548 BLAZE_ALWAYS_INLINE bool trySub(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1577 template<
typename MT
1580 BLAZE_ALWAYS_INLINE bool tryMult(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1611 template<
typename MT
1615 tryMult(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
const ET& value )
1646 template<
typename MT
1649 BLAZE_ALWAYS_INLINE bool tryDiv(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1680 template<
typename MT
1684 tryDiv(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
const ET& value )
1715 template<
typename MT
1752 template<
typename MT
1788 template<
typename MT1
1792 BLAZE_ALWAYS_INLINE bool tryAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
1824 template<
typename MT
1828 BLAZE_ALWAYS_INLINE bool tryAddAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
1861 template<
typename MT
1865 BLAZE_ALWAYS_INLINE bool tryAddAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
1897 template<
typename MT1
1901 BLAZE_ALWAYS_INLINE bool tryAddAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
1933 template<
typename MT
1937 BLAZE_ALWAYS_INLINE bool trySubAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
1971 template<
typename MT
1975 BLAZE_ALWAYS_INLINE bool trySubAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2007 template<
typename MT1
2011 BLAZE_ALWAYS_INLINE bool trySubAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
2043 template<
typename MT
2047 BLAZE_ALWAYS_INLINE bool tryMultAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2081 template<
typename MT
2085 BLAZE_ALWAYS_INLINE bool tryMultAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2117 template<
typename MT1
2121 BLAZE_ALWAYS_INLINE bool trySchurAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
2153 template<
typename MT
2157 BLAZE_ALWAYS_INLINE bool tryDivAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2191 template<
typename MT
2195 BLAZE_ALWAYS_INLINE bool tryDivAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2226 template<
typename MT
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Header file for the UNUSED_PARAMETER function template.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:992
Header file for basic type definitions.
Header file for the IsSame and IsStrictlySame type traits.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
BLAZE_ALWAYS_INLINE constexpr const MatrixType & operator~() const noexcept
Conversion operator for constant matrices.
Definition: Matrix.h:107
const MT::ResultType evaluate(const Matrix< MT, SO > &matrix)
Evaluates the given matrix expression.
Definition: Matrix.h:912
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:482
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:416
Header file for the IsSquare type trait.
Header file for the DisableIf class template.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for the IsShrinkable type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
Header file for the exception macros of the math module.
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
Header file for all forward declarations for expression class templates.
Header file for the EnableIf class template.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:135
BLAZE_ALWAYS_INLINE constexpr MatrixType & operator~() noexcept
Conversion operator for non-constant matrices.
Definition: Matrix.h:97
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
static constexpr bool storageOrder
Storage order of the matrix.
Definition: Matrix.h:89
Header file for run time assertion macros.
constexpr bool isEmpty(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is empty.
Definition: Matrix.h:932
Expression object for sparse matrix-scalar divisions.The SMatScalarMult class represents the compile ...
Definition: Forward.h:121
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:109
Constraint on the data type.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:290
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
Header file for the IsResizable type trait.
System settings for the inline keywords.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the function trace functionality.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825