35 #ifndef _BLAZE_MATH_SPARSE_ZEROMATRIX_H_ 36 #define _BLAZE_MATH_SPARSE_ZEROMATRIX_H_ 176 template<
typename Type
177 ,
bool SO = defaultStorageOrder >
179 :
public SparseMatrix< ZeroMatrix<Type,SO>, SO >
205 template<
typename NewType >
214 template<
size_t NewM
232 explicit inline constexpr
ZeroMatrix() noexcept;
233 explicit inline constexpr
ZeroMatrix(
size_t m,
size_t n ) noexcept;
235 template< typename MT,
bool SO2 >
253 inline constexpr
ConstReference operator()(
size_t i,
size_t j ) const noexcept;
265 template< typename MT,
bool SO2 >
276 inline constexpr
size_t rows() const noexcept;
277 inline constexpr
size_t columns() const noexcept;
278 inline constexpr
size_t capacity() const noexcept;
279 inline constexpr
size_t capacity(
size_t i ) const noexcept;
280 inline constexpr
size_t nonZeros() const noexcept;
281 inline constexpr
size_t nonZeros(
size_t i ) const noexcept;
282 inline constexpr
void clear() noexcept;
283 constexpr
void resize(
size_t m,
size_t n ) noexcept;
308 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
309 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
346 template< typename Type,
bool SO >
361 template<
typename Type
376 template<
typename Type
394 template<
typename Type
396 template<
typename MT
402 if( !IsZero_v<MT> && !
isZero( ~m ) ) {
427 template<
typename Type
453 template<
typename Type
481 template<
typename Type
506 template<
typename Type
531 template<
typename Type
556 template<
typename Type
588 template<
typename Type
590 template<
typename MT
595 if( !IsZero_v<MT> && !
isZero( ~rhs ) ) {
599 const size_t m( (~rhs).
rows() );
600 const size_t n( (~rhs).
columns() );
623 template<
typename Type
637 template<
typename Type
651 template<
typename Type
671 template<
typename Type
689 template<
typename Type
709 template<
typename Type
729 template<
typename Type
750 template<
typename Type
766 template<
typename Type
770 const size_t tmp1(
m_ );
774 const size_t tmp2(
n_ );
802 template<
typename Type
830 template<
typename Type
858 template<
typename Type
886 template<
typename Type
890 const size_t tmp(
m_ );
904 template<
typename Type
908 const size_t tmp(
m_ );
935 template<
typename Type
937 template<
typename Other >
957 template<
typename Type
959 template<
typename Other >
979 template<
typename Type
1003 template<
typename Type,
bool SO >
1006 template<
typename Type,
bool SO >
1009 template<
typename Type,
bool SO >
1012 template<
bool RF,
typename Type,
bool SO >
1015 template<
typename Type,
bool SO >
1018 template<
typename Type,
bool SO >
1031 template<
typename Type
1052 template<
typename Type
1068 template<
typename Type
1107 return ( m.rows() == 0UL && m.columns() == 0UL );
1129 template<
typename Type
1148 template<
typename Type
1167 template<
typename Type
1169 inline void erase( ZeroMatrix<Type,SO>& m,
size_t i,
size_t j )
1191 template<
typename Type
1219 template<
typename Type
1255 template<
typename Type
1258 inline void erase( ZeroMatrix<Type,SO>& m, Pred predicate )
1296 template<
typename Type
1300 inline void erase( ZeroMatrix<Type,SO>& m,
size_t i,
Iterator first,
Iterator last, Pred predicate )
1332 template<
typename MT
1334 inline ZeroMatrix<ElementType_t<MT>,SO>
1354 template<
typename Type,
bool SO >
1355 struct IsUniform< ZeroMatrix<Type,SO> >
1372 template<
typename Type,
bool SO >
1373 struct IsZero< ZeroMatrix<Type,SO> >
1390 template<
typename Type,
bool SO >
1391 struct IsResizable< ZeroMatrix<Type,SO> >
1408 template<
typename T1,
typename T2 >
1409 struct AddTraitEval1< T1, T2
1412 !IsZero_v<T1> && IsZero_v<T2> > >
1414 using Type = Rebind_t< ResultType_t<T1>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1417 template<
typename T1,
typename T2 >
1418 struct AddTraitEval1< T1, T2
1421 IsZero_v<T1> && !IsZero_v<T2> > >
1423 using Type = Rebind_t< ResultType_t<T2>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1426 template<
typename T1,
typename T2 >
1427 struct AddTraitEval1< T1, T2
1430 IsZero_v<T1> && IsZero_v<T2> > >
1432 using ET1 = ElementType_t<T1>;
1433 using ET2 = ElementType_t<T2>;
1435 static constexpr
bool SO = ( StorageOrder_v<T1> && StorageOrder_v<T2> );
1437 using Type = ZeroMatrix< AddTrait_t<ET1,ET2>, SO >;
1453 template<
typename T1,
typename T2 >
1454 struct SubTraitEval1< T1, T2
1457 !IsZero_v<T1> && IsZero_v<T2> > >
1459 using Type = Rebind_t< ResultType_t<T1>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1462 template<
typename T1,
typename T2 >
1463 struct SubTraitEval1< T1, T2
1466 IsZero_v<T1> && !IsZero_v<T2> && !IsIdentity_v<T2> > >
1468 using Type = Rebind_t< ResultType_t<T2>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1471 template<
typename T1,
typename T2 >
1472 struct SubTraitEval1< T1, T2
1475 IsZero_v<T1> && IsZero_v<T2> > >
1477 using ET1 = ElementType_t<T1>;
1478 using ET2 = ElementType_t<T2>;
1480 static constexpr
bool SO = ( StorageOrder_v<T1> && StorageOrder_v<T2> );
1482 using Type = ZeroMatrix< SubTrait_t<ET1,ET2>, SO >;
1498 template<
typename T1,
typename T2 >
1499 struct SchurTraitEval1< T1, T2
1504 ( IsStrictlyLower_v<T1> && IsUpper_v<T2> ) ||
1505 ( IsStrictlyUpper_v<T1> && IsLower_v<T2> ) ||
1506 ( IsLower_v<T1> && IsStrictlyUpper_v<T2> ) ||
1507 ( IsUpper_v<T1> && IsStrictlyLower_v<T2> ) ) > >
1509 using ET1 = ElementType_t<T1>;
1510 using ET2 = ElementType_t<T2>;
1512 static constexpr
bool SO1 = StorageOrder_v<T1>;
1513 static constexpr
bool SO2 = StorageOrder_v<T2>;
1515 static constexpr
bool SO = ( IsSparseMatrix_v<T1> ^ IsSparseMatrix_v<T2>
1516 ? ( IsSparseMatrix_v<T1>
1521 using Type = ZeroMatrix< MultTrait_t<ET1,ET2>, SO >;
1537 template<
typename T1,
typename T2 >
1538 struct MultTraitEval1< T1, T2
1541 using Type = ZeroMatrix< MultTrait_t< ElementType_t<T1>, T2 >, StorageOrder_v<T1> >;
1544 template<
typename T1,
typename T2 >
1545 struct MultTraitEval1< T1, T2
1548 using Type = ZeroMatrix< MultTrait_t< T1, ElementType_t<T2> >, StorageOrder_v<T2> >;
1551 template<
typename T1,
typename T2 >
1552 struct MultTraitEval1< T1, T2
1554 IsRowVector_v<T2> &&
1555 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1557 using ET1 = ElementType_t<T1>;
1558 using ET2 = ElementType_t<T2>;
1560 static constexpr
bool SO = IsSparseVector_v<T1> && IsDenseVector_v<T2>;
1562 using Type = ZeroMatrix< MultTrait_t<ET1,ET2>, SO >;
1565 template<
typename T1,
typename T2 >
1566 struct MultTraitEval1< T1, T2
1569 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1571 using ET1 = ElementType_t<T1>;
1572 using ET2 = ElementType_t<T2>;
1574 static constexpr
bool SO = ( IsZero_v<T1> ? StorageOrder_v<T1> : StorageOrder_v<T2> );
1576 using Type = ZeroMatrix< MultTrait_t<ET1,ET2>, SO >;
1592 template<
typename T1,
typename T2 >
1593 struct DivTraitEval1< T1, T2
1598 using ET1 = ElementType_t<T1>;
1600 using Type = ZeroMatrix< DivTrait_t<ET1,T2>, StorageOrder_v<T1> >;
1616 template<
typename T,
typename OP >
1617 struct UnaryMapTraitEval1< T, OP
1619 YieldsZero_v<OP,T> > >
1621 using ET = ElementType_t<T>;
1623 using Type = ZeroMatrix< MapTrait_t<ET,OP>, StorageOrder_v<T> >;
1631 template<
typename T1,
typename T2,
typename OP >
1632 struct BinaryMapTraitEval1< T1, T2, OP
1635 YieldsZero_v<OP,T1,T2> > >
1637 using ET1 = ElementType_t<T1>;
1638 using ET2 = ElementType_t<T2>;
1640 static constexpr
bool SO = StorageOrder_v<T1> && StorageOrder_v<T2>;
1642 using Type = ZeroMatrix< MapTrait_t<ET1,ET2,OP>, SO >;
1658 template<
typename T
1660 struct ExpandTraitEval1< T, E
1666 using Type = ZeroMatrix< ElementType_t<T>, TF >;
1682 template<
typename T1,
bool SO,
typename T2 >
1683 struct HighType< ZeroMatrix<T1,SO>, ZeroMatrix<T2,SO> >
1685 using Type = ZeroMatrix< typename HighType<T1,T2>::Type, SO >;
1701 template<
typename T1,
bool SO,
typename T2 >
1702 struct LowType< ZeroMatrix<T1,SO>, ZeroMatrix<T2,SO> >
1704 using Type = ZeroMatrix< typename LowType<T1,T2>::Type, SO >;
1720 template<
typename MT,
size_t I,
size_t J,
size_t M,
size_t N >
1721 struct SubmatrixTraitEval1< MT, I, J, M, N
1724 using Type = ZeroMatrix< RemoveConst_t< ElementType_t<MT> >, StorageOrder_v<MT> >;
1740 template<
typename MT,
size_t M >
1741 struct RowsTraitEval1< MT, M
1744 using Type = ZeroMatrix< RemoveConst_t< ElementType_t<MT> >,
false >;
1760 template<
typename MT,
size_t N >
1761 struct ColumnsTraitEval1< MT, N
1764 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:534
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
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:216
Header file for auxiliary alias declarations.
Header file for the Schur product trait.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
constexpr size_t nonZeros() const noexcept
Returns the number of non-zero elements in the zero matrix.
Definition: ZeroMatrix.h:691
Header file for the subtraction trait.
Header file for basic type definitions.
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:139
const Type & Reference
Reference to a zero matrix element.
Definition: ZeroMatrix.h:196
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:194
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:591
size_t m_
The current number of rows of the compressed matrix.
Definition: CompressedMatrix.h:3289
Header file for the IsRowVector type trait.
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: ZeroMatrix.h:226
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, a compilation error is created.
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: TrueType.h:61
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
constexpr void swap(ZeroMatrix &m) noexcept
Swapping the contents of two zero matrices.
Definition: ZeroMatrix.h:768
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
constexpr size_t rows() const noexcept
Returns the current number of rows of the zero matrix.
Definition: ZeroMatrix.h:625
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: ZeroMatrix.h:805
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:861
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: ZeroMatrix.h:981
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:137
size_t m_
The current number of rows of the zero matrix.
Definition: ZeroMatrix.h:319
Constraint on the data type.
Header file for the IsMatrix type trait.
Header file for the SparseMatrix base class.
ConstReference at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: ZeroMatrix.h:456
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:673
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:938
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:206
Header file for all forward declarations of the math module.
#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 bool IsColumnVector_v
Auxiliary variable template for the IsColumnVector type trait.The IsColumnVector_v variable template ...
Definition: IsColumnVector.h:143
constexpr ConstReference operator()(size_t i, size_t j) const noexcept
2D-access to the zero matrix elements.
Definition: ZeroMatrix.h:430
#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:731
ZeroMatrix< Type, SO > This
Type of this ZeroMatrix instance.
Definition: ZeroMatrix.h:188
size_t n_
The current number of columns of the zero matrix.
Definition: ZeroMatrix.h:320
constexpr ZeroMatrix & transpose() noexcept
In-place transpose of the matrix.
Definition: ZeroMatrix.h:888
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:833
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:1335
constexpr ZeroMatrix() noexcept
The default constructor for ZeroMatrix.
Definition: ZeroMatrix.h:363
Header file for the IsLower type trait.
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the zero matrix.
Definition: ZeroMatrix.h:653
static const Type zero_
The zero element.
Definition: ZeroMatrix.h:322
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.The IsVector_v variable template provides a c...
Definition: IsVector.h:140
Header file for the default storage order for all vectors of the Blaze library.
const Type & ConstReference
Reference to a constant zero matrix element.
Definition: ZeroMatrix.h:197
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:960
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:611
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.The IsZero_v variable template provides a conve...
Definition: IsZero.h:165
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:752
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:559
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:906
Header file for the IsZero type trait.
#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, a compilation error is created.
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:281
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.
Type ElementType
Type of the zero matrix elements.
Definition: ZeroMatrix.h:193
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:484
size_t n_
The current number of columns of the compressed matrix.
Definition: CompressedMatrix.h:3290
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedMatrix.h:3295
Header file for the StorageOrder type trait.
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:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
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:509
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.
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:639