35 #ifndef _BLAZE_MATH_SPARSE_ZEROMATRIX_H_ 36 #define _BLAZE_MATH_SPARSE_ZEROMATRIX_H_ 178 template<
typename Type
179 ,
bool SO = defaultStorageOrder >
181 :
public Expression< SparseMatrix< ZeroMatrix<Type,SO>, SO > >
207 template<
typename NewType >
216 template<
size_t NewM
234 explicit inline constexpr
ZeroMatrix() noexcept;
235 explicit inline constexpr
ZeroMatrix(
size_t m,
size_t n ) noexcept;
237 template< typename MT,
bool SO2 >
255 inline constexpr
ConstReference operator()(
size_t i,
size_t j ) const noexcept;
267 template< typename MT,
bool SO2 >
278 inline constexpr
size_t rows() const noexcept;
279 inline constexpr
size_t columns() const noexcept;
280 inline constexpr
size_t capacity() const noexcept;
281 inline constexpr
size_t capacity(
size_t i ) const noexcept;
282 inline constexpr
size_t nonZeros() const noexcept;
283 inline constexpr
size_t nonZeros(
size_t i ) const noexcept;
284 inline constexpr
void clear() noexcept;
285 constexpr
void resize(
size_t m,
size_t n ) noexcept;
310 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
311 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
348 template< typename Type,
bool SO >
363 template<
typename Type
378 template<
typename Type
396 template<
typename Type
398 template<
typename MT
404 if( !IsZero_v<MT> && !
isZero( ~m ) ) {
429 template<
typename Type
455 template<
typename Type
483 template<
typename Type
490 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
508 template<
typename Type
515 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
533 template<
typename Type
540 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
558 template<
typename Type
565 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
590 template<
typename Type
592 template<
typename MT
597 if( !IsZero_v<MT> && !
isZero( ~rhs ) ) {
601 const size_t m( (~rhs).
rows() );
602 const size_t n( (~rhs).
columns() );
625 template<
typename Type
639 template<
typename Type
653 template<
typename Type
673 template<
typename Type
679 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
691 template<
typename Type
711 template<
typename Type
717 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
731 template<
typename Type
752 template<
typename Type
768 template<
typename Type
772 const size_t tmp1( m_ );
776 const size_t tmp2( n_ );
804 template<
typename Type
832 template<
typename Type
860 template<
typename Type
888 template<
typename Type
892 const size_t tmp( m_ );
906 template<
typename Type
910 const size_t tmp( m_ );
937 template<
typename Type
939 template<
typename Other >
959 template<
typename Type
961 template<
typename Other >
981 template<
typename Type
1005 template<
typename Type,
bool SO >
1008 template<
typename Type,
bool SO >
1011 template<
typename Type,
bool SO >
1014 template<
bool RF,
typename Type,
bool SO >
1017 template<
typename Type,
bool SO >
1020 template<
typename Type,
bool SO >
1033 template<
typename Type
1054 template<
typename Type
1070 template<
typename Type
1109 return ( m.rows() == 0UL && m.columns() == 0UL );
1131 template<
typename Type
1150 template<
typename Type
1169 template<
typename Type
1171 inline void erase( ZeroMatrix<Type,SO>& m,
size_t i,
size_t j )
1193 template<
typename Type
1195 ,
typename Iterator >
1196 inline Iterator erase( ZeroMatrix<Type,SO>& m,
size_t i, Iterator pos )
1221 template<
typename Type
1223 ,
typename Iterator >
1224 inline Iterator erase( ZeroMatrix<Type,SO>& m,
size_t i, Iterator first, Iterator last )
1257 template<
typename Type
1260 inline void erase( ZeroMatrix<Type,SO>& m, Pred predicate )
1298 template<
typename Type
1302 inline void erase( ZeroMatrix<Type,SO>& m,
size_t i, Iterator first, Iterator last, Pred predicate )
1352 template<
typename T,
bool SO = defaultStorageOrder >
1353 inline constexpr decltype(
auto)
zero(
size_t m,
size_t n ) noexcept
1376 template<
typename MT
1378 inline ZeroMatrix<ElementType_t<MT>,SO>
1398 template<
typename Type,
bool SO >
1399 struct IsUniform< ZeroMatrix<Type,SO> >
1416 template<
typename Type,
bool SO >
1417 struct IsZero< ZeroMatrix<Type,SO> >
1434 template<
typename Type,
bool SO >
1435 struct IsResizable< ZeroMatrix<Type,SO> >
1452 template<
typename T1,
typename T2 >
1453 struct AddTraitEval1< T1, T2
1456 !IsZero_v<T1> && IsZero_v<T2> > >
1458 using Type = Rebind_t< ResultType_t<T1>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1461 template<
typename T1,
typename T2 >
1462 struct AddTraitEval1< T1, T2
1465 IsZero_v<T1> && !IsZero_v<T2> > >
1467 using Type = Rebind_t< ResultType_t<T2>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1470 template<
typename T1,
typename T2 >
1471 struct AddTraitEval1< T1, T2
1474 IsZero_v<T1> && IsZero_v<T2> > >
1476 using ET1 = ElementType_t<T1>;
1477 using ET2 = ElementType_t<T2>;
1479 static constexpr
bool SO = ( StorageOrder_v<T1> && StorageOrder_v<T2> );
1481 using Type = ZeroMatrix< AddTrait_t<ET1,ET2>, SO >;
1497 template<
typename T1,
typename T2 >
1498 struct SubTraitEval1< T1, T2
1501 !IsZero_v<T1> && IsZero_v<T2> > >
1503 using Type = Rebind_t< ResultType_t<T1>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1506 template<
typename T1,
typename T2 >
1507 struct SubTraitEval1< T1, T2
1510 IsZero_v<T1> && !IsZero_v<T2> && !IsIdentity_v<T2> > >
1512 using Type = Rebind_t< ResultType_t<T2>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1515 template<
typename T1,
typename T2 >
1516 struct SubTraitEval1< T1, T2
1519 IsZero_v<T1> && IsZero_v<T2> > >
1521 using ET1 = ElementType_t<T1>;
1522 using ET2 = ElementType_t<T2>;
1524 static constexpr
bool SO = ( StorageOrder_v<T1> && StorageOrder_v<T2> );
1526 using Type = ZeroMatrix< SubTrait_t<ET1,ET2>, SO >;
1542 template<
typename T1,
typename T2 >
1543 struct SchurTraitEval1< T1, T2
1548 ( IsStrictlyLower_v<T1> && IsUpper_v<T2> ) ||
1549 ( IsStrictlyUpper_v<T1> && IsLower_v<T2> ) ||
1550 ( IsLower_v<T1> && IsStrictlyUpper_v<T2> ) ||
1551 ( IsUpper_v<T1> && IsStrictlyLower_v<T2> ) ) > >
1553 using ET1 = ElementType_t<T1>;
1554 using ET2 = ElementType_t<T2>;
1556 static constexpr
bool SO1 = StorageOrder_v<T1>;
1557 static constexpr
bool SO2 = StorageOrder_v<T2>;
1559 static constexpr
bool SO = ( IsSparseMatrix_v<T1> ^ IsSparseMatrix_v<T2>
1560 ? ( IsSparseMatrix_v<T1>
1565 using Type = ZeroMatrix< MultTrait_t<ET1,ET2>, SO >;
1581 template<
typename T1,
typename T2 >
1582 struct MultTraitEval1< T1, T2
1585 using Type = ZeroMatrix< MultTrait_t< ElementType_t<T1>, T2 >, StorageOrder_v<T1> >;
1588 template<
typename T1,
typename T2 >
1589 struct MultTraitEval1< T1, T2
1592 using Type = ZeroMatrix< MultTrait_t< T1, ElementType_t<T2> >, StorageOrder_v<T2> >;
1595 template<
typename T1,
typename T2 >
1596 struct MultTraitEval1< T1, T2
1598 IsRowVector_v<T2> &&
1599 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1601 using ET1 = ElementType_t<T1>;
1602 using ET2 = ElementType_t<T2>;
1604 static constexpr
bool SO = IsSparseVector_v<T1> && IsDenseVector_v<T2>;
1606 using Type = ZeroMatrix< MultTrait_t<ET1,ET2>, SO >;
1609 template<
typename T1,
typename T2 >
1610 struct MultTraitEval1< T1, T2
1613 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1615 using ET1 = ElementType_t<T1>;
1616 using ET2 = ElementType_t<T2>;
1618 static constexpr
bool SO = ( IsZero_v<T1> ? StorageOrder_v<T1> : StorageOrder_v<T2> );
1620 using Type = ZeroMatrix< MultTrait_t<ET1,ET2>, SO >;
1636 template<
typename T1,
typename T2 >
1637 struct KronTraitEval1< T1, T2
1643 using ET1 = ElementType_t<T1>;
1644 using ET2 = ElementType_t<T2>;
1646 static constexpr
bool SO = ( IsZero_v<T2> ? StorageOrder_v<T2> : StorageOrder_v<T1> );
1648 using Type = ZeroMatrix< MultTrait_t<ET1,ET2>, SO >;
1664 template<
typename T1,
typename T2 >
1665 struct DivTraitEval1< T1, T2
1670 using ET1 = ElementType_t<T1>;
1672 using Type = ZeroMatrix< DivTrait_t<ET1,T2>, StorageOrder_v<T1> >;
1688 template<
typename T,
typename OP >
1689 struct UnaryMapTraitEval1< T, OP
1691 YieldsZero_v<OP,T> > >
1693 using ET = ElementType_t<T>;
1695 using Type = ZeroMatrix< MapTrait_t<ET,OP>, StorageOrder_v<T> >;
1703 template<
typename T1,
typename T2,
typename OP >
1704 struct BinaryMapTraitEval1< T1, T2, OP
1707 YieldsZero_v<OP,T1,T2> > >
1709 using ET1 = ElementType_t<T1>;
1710 using ET2 = ElementType_t<T2>;
1712 static constexpr
bool SO = StorageOrder_v<T1> && StorageOrder_v<T2>;
1714 using Type = ZeroMatrix< MapTrait_t<ET1,ET2,OP>, SO >;
1730 template<
typename T
1732 struct ExpandTraitEval1< T, E
1738 using Type = ZeroMatrix< ElementType_t<T>, TF >;
1754 template<
typename T1,
bool SO,
typename T2 >
1755 struct HighType< ZeroMatrix<T1,SO>, ZeroMatrix<T2,SO> >
1757 using Type = ZeroMatrix< typename HighType<T1,T2>::Type, SO >;
1773 template<
typename T1,
bool SO,
typename T2 >
1774 struct LowType< ZeroMatrix<T1,SO>, ZeroMatrix<T2,SO> >
1776 using Type = ZeroMatrix< typename LowType<T1,T2>::Type, SO >;
1792 template<
typename MT,
size_t I,
size_t J,
size_t M,
size_t N >
1793 struct SubmatrixTraitEval1< MT, I, J, M, N
1796 using Type = ZeroMatrix< RemoveConst_t< ElementType_t<MT> >, StorageOrder_v<MT> >;
1812 template<
typename MT,
size_t M >
1813 struct RowsTraitEval1< MT, M
1816 using Type = ZeroMatrix< RemoveConst_t< ElementType_t<MT> >,
false >;
1832 template<
typename MT,
size_t N >
1833 struct ColumnsTraitEval1< MT, N
1836 using Type = ZeroMatrix< RemoveConst_t< ElementType_t<MT> >,
true >;
Efficient implementation of an zero matrix.The ZeroMatrix class template is the representation of an...
Definition: Forward.h:50
constexpr ConstIterator end(size_t i) const noexcept
Returns an iterator just past the last non-zero element of row/column i.
Definition: ZeroMatrix.h:536
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type,...
Definition: Const.h:79
#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
Resize mechanism to obtain a ZeroMatrix with different fixed dimensions.
Definition: ZeroMatrix.h:218
Header file for auxiliary alias declarations.
Header file for the Schur product trait.
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:138
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
constexpr size_t nonZeros() const noexcept
Returns the number of non-zero elements in the zero matrix.
Definition: ZeroMatrix.h:693
Header file for the subtraction trait.
Header file for basic type definitions.
const Type & Reference
Reference to a zero matrix element.
Definition: ZeroMatrix.h:198
Header file for the IsSparseMatrix type trait.
Header file for the isZero shim.
const Type & ReturnType
Return type for expression template evaluations.
Definition: ZeroMatrix.h:196
Header file for the YieldsZero type trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
Header file for the IsRowVector type trait.
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: ZeroMatrix.h:228
Header file for the MAYBE_UNUSED function template.
Header file for the IsIdentity type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
Definition: Volatile.h:79
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: IntegralConstant.h:132
Header file for all forward declarations of the math module.
constexpr void swap(ZeroMatrix &m) noexcept
Swapping the contents of two zero matrices.
Definition: ZeroMatrix.h:770
constexpr size_t rows() const noexcept
Returns the current number of rows of the zero matrix.
Definition: ZeroMatrix.h:627
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: ZeroMatrix.h:807
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
constexpr bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: ZeroMatrix.h:863
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: ZeroMatrix.h:983
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes....
Definition: Forward.h:145
size_t m_
The current number of rows of the zero matrix.
Definition: ZeroMatrix.h:321
Constraint on the data type.
Header file for the IsMatrix type trait.
Header file for the SparseMatrix base class.
decltype(auto) constexpr zero(size_t m, size_t n) noexcept
Creating a zero matrix.
Definition: ZeroMatrix.h:1353
ConstReference at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: ZeroMatrix.h:458
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:677
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
constexpr bool columnMajor
Storage order flag for column-major matrices.
Definition: StorageOrder.h:99
Header file for the ValueIndexPair class.
Header file for the LowType type trait.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
bool canAlias(const Other *alias) const noexcept
Returns whether the matrix can alias with the given address alias.
Definition: ZeroMatrix.h:940
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Rebind mechanism to obtain a ZeroMatrix with different data/element type.
Definition: ZeroMatrix.h:208
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Header file for the IsSMPAssignable type trait.
Header file for the expand trait.
constexpr ConstReference operator()(size_t i, size_t j) const noexcept
2D-access to the zero matrix elements.
Definition: ZeroMatrix.h:432
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
constexpr void clear() noexcept
Clearing the zero matrix.
Definition: ZeroMatrix.h:733
ZeroMatrix< Type, SO > This
Type of this ZeroMatrix instance.
Definition: ZeroMatrix.h:190
size_t n_
The current number of columns of the zero matrix.
Definition: ZeroMatrix.h:322
constexpr ZeroMatrix & transpose() noexcept
In-place transpose of the matrix.
Definition: ZeroMatrix.h:890
ConstIterator lowerBound(size_t i, size_t j) const
Returns an iterator to the first index not less then the given index.
Definition: ZeroMatrix.h:835
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Constraint on the data type.
ZeroMatrix< ElementType_t< MT >, SO > declzero(const Matrix< MT, SO > &m)
Declares the given matrix expression m as zero matrix.
Definition: ZeroMatrix.h:1379
constexpr ZeroMatrix() noexcept
The default constructor for ZeroMatrix.
Definition: ZeroMatrix.h:365
Header file for the IsLower type trait.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the zero matrix.
Definition: ZeroMatrix.h:655
static const Type zero_
The zero element.
Definition: ZeroMatrix.h:324
Header file for the default storage order for all vectors of the Blaze library.
Header file for the Kron product trait.
const Type & ConstReference
Reference to a constant zero matrix element.
Definition: ZeroMatrix.h:199
Header file for the exception macros of the math module.
bool isAliased(const Other *alias) const noexcept
Returns whether the matrix is aliased with the given address alias.
Definition: ZeroMatrix.h:962
Header file for the IsVector type trait.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.The IsZero_v variable template provides a conve...
Definition: IsZero.h:166
Header file for the RemoveConst type trait.
Header file for the IsSparseVector type trait.
constexpr void resize(size_t m, size_t n) noexcept
Changing the size of the zero matrix.
Definition: ZeroMatrix.h:754
constexpr ConstIterator cend(size_t i) const noexcept
Returns an iterator just past the last non-zero element of row/column i.
Definition: ZeroMatrix.h:561
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Header file for the submatrix trait.
Constraint on the data type.
Header file for the columns trait.
constexpr ZeroMatrix & ctranspose() noexcept
In-place conjugate transpose of the matrix.
Definition: ZeroMatrix.h:908
Header file for the IsZero type trait.
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.The IsVector_v variable template provides a c...
Definition: IsVector.h:139
#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
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type,...
Definition: Reference.h:79
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:282
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.
Type ElementType
Type of the zero matrix elements.
Definition: ZeroMatrix.h:195
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the IsDenseVector type trait.
Header file for the rows trait.
constexpr ConstIterator begin(size_t i) const noexcept
Returns an iterator to the first non-zero element of row/column i.
Definition: ZeroMatrix.h:486
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
Header file for the StorageOrder type trait.
Header file for the IntegralConstant class template.
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
constexpr bool IsColumnVector_v
Auxiliary variable template for the IsColumnVector type trait.The IsColumnVector_v variable template ...
Definition: IsColumnVector.h:142
Header file for the IsUpper type trait.
Header file for the IsColumnVector type trait.
Header file for the IsResizable type trait.
constexpr ConstIterator cbegin(size_t i) const noexcept
Returns an iterator to the first non-zero element of row/column i.
Definition: ZeroMatrix.h:511
Header file for the Expression base class.
Header file for the HighType type trait.
Header file for the function trace functionality.
constexpr size_t columns() const noexcept
Returns the current number of columns of the zero matrix.
Definition: ZeroMatrix.h:641