35 #ifndef _BLAZE_MATH_EXPRESSIONS_MATRIX_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_MATRIX_H_ 98 return *static_cast<MatrixType*>(
this );
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 >
292 typename MT::Iterator
begin( Matrix<MT,SO>& matrix,
size_t i );
294 template<
typename MT,
bool SO >
295 typename MT::ConstIterator
begin(
const Matrix<MT,SO>& matrix,
size_t i );
297 template<
typename MT,
bool SO >
298 typename MT::ConstIterator
cbegin(
const Matrix<MT,SO>& matrix,
size_t i );
300 template<
typename MT,
bool SO >
301 typename MT::Iterator
end( Matrix<MT,SO>& matrix,
size_t i );
303 template<
typename MT,
bool SO >
304 typename MT::ConstIterator
end(
const Matrix<MT,SO>& matrix,
size_t i );
306 template<
typename MT,
bool SO >
307 typename MT::ConstIterator
cend(
const Matrix<MT,SO>& matrix,
size_t i );
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 >
343 const typename MT::ResultType
evaluate(
const Matrix<MT,SO>& matrix );
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
914 const typename MT::ResultType tmp( ~matrix );
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 )
1515 template<
typename MT
1519 trySet(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
const ET& value )
1550 template<
typename MT
1553 BLAZE_ALWAYS_INLINE bool tryAdd(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1584 template<
typename MT
1588 tryAdd(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
const ET& value )
1619 template<
typename MT
1622 BLAZE_ALWAYS_INLINE bool trySub(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1653 template<
typename MT
1657 trySub(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
const ET& value )
1688 template<
typename MT
1691 BLAZE_ALWAYS_INLINE bool tryMult(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1722 template<
typename MT
1726 tryMult(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
const ET& value )
1757 template<
typename MT
1760 BLAZE_ALWAYS_INLINE bool tryDiv(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1791 template<
typename MT
1795 tryDiv(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
const ET& value )
1826 template<
typename MT
1828 BLAZE_ALWAYS_INLINE bool tryShift(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
int count )
1859 template<
typename MT
1862 tryShift(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
int count )
1893 template<
typename MT
1896 BLAZE_ALWAYS_INLINE bool tryBitand(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1927 template<
typename MT
1931 tryBitand(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
const ET& value )
1962 template<
typename MT
1965 BLAZE_ALWAYS_INLINE bool tryBitor(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
1996 template<
typename MT
2000 tryBitor(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
const ET& value )
2031 template<
typename MT
2034 BLAZE_ALWAYS_INLINE bool tryBitxor(
const Matrix<MT,SO>& mat,
size_t i,
size_t j,
const ET& value )
2065 template<
typename MT
2069 tryBitxor(
const Matrix<MT,SO>& mat,
size_t row,
size_t column,
size_t m,
size_t n,
const ET& value )
2100 template<
typename MT
2137 template<
typename MT
2173 template<
typename MT1
2177 BLAZE_ALWAYS_INLINE bool tryAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
2209 template<
typename MT
2213 BLAZE_ALWAYS_INLINE bool tryAddAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2246 template<
typename MT
2250 BLAZE_ALWAYS_INLINE bool tryAddAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2282 template<
typename MT1
2286 BLAZE_ALWAYS_INLINE bool tryAddAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
2318 template<
typename MT
2322 BLAZE_ALWAYS_INLINE bool trySubAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2356 template<
typename MT
2360 BLAZE_ALWAYS_INLINE bool trySubAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2392 template<
typename MT1
2396 BLAZE_ALWAYS_INLINE bool trySubAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
2428 template<
typename MT
2432 BLAZE_ALWAYS_INLINE bool tryMultAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2466 template<
typename MT
2470 BLAZE_ALWAYS_INLINE bool tryMultAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2502 template<
typename MT1
2506 BLAZE_ALWAYS_INLINE bool trySchurAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
2538 template<
typename MT
2542 BLAZE_ALWAYS_INLINE bool tryDivAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2576 template<
typename MT
2580 BLAZE_ALWAYS_INLINE bool tryDivAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2612 template<
typename MT
2616 BLAZE_ALWAYS_INLINE bool tryShiftAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2649 template<
typename MT
2653 BLAZE_ALWAYS_INLINE bool tryShiftAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2685 template<
typename MT1
2689 BLAZE_ALWAYS_INLINE bool tryShiftAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
2721 template<
typename MT
2725 BLAZE_ALWAYS_INLINE bool tryBitandAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2759 template<
typename MT
2763 BLAZE_ALWAYS_INLINE bool tryBitandAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2795 template<
typename MT1
2799 BLAZE_ALWAYS_INLINE bool tryBitandAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
2831 template<
typename MT
2835 BLAZE_ALWAYS_INLINE bool tryBitorAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2869 template<
typename MT
2873 BLAZE_ALWAYS_INLINE bool tryBitorAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2905 template<
typename MT1
2909 BLAZE_ALWAYS_INLINE bool tryBitorAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
2941 template<
typename MT
2945 BLAZE_ALWAYS_INLINE bool tryBitxorAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
2979 template<
typename MT
2983 BLAZE_ALWAYS_INLINE bool tryBitxorAssign(
const Matrix<MT,SO>& lhs,
const Vector<VT,TF>& rhs,
3015 template<
typename MT1
3019 BLAZE_ALWAYS_INLINE bool tryBitxorAssign(
const Matrix<MT1,SO1>& lhs,
const Matrix<MT2,SO2>& rhs,
3050 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
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.
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
Header file for the MAYBE_UNUSED function template.
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
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 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.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
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 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:137
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,...
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:127
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
Header file for all forward declarations for expression class templates.
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:114
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:494
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,...
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