35#ifndef _BLAZE_MATH_SPARSE_ZEROMATRIX_H_
36#define _BLAZE_MATH_SPARSE_ZEROMATRIX_H_
192template<
typename Type
196 :
public Expression< SparseMatrix< ZeroMatrix<Type,SO,Tag>, SO > >
231 template<
typename NewType >
240 template<
size_t NewM
259 constexpr
ZeroMatrix(
size_t m,
size_t n ) noexcept;
261 template< typename MT,
bool SO2 >
279 constexpr
ConstReference operator()(
size_t i,
size_t j ) const noexcept;
291 template< typename MT,
bool SO2 >
302 constexpr
size_t rows() const noexcept;
303 constexpr
size_t columns() const noexcept;
304 constexpr
size_t capacity() const noexcept;
305 constexpr
size_t capacity(
size_t i ) const noexcept;
306 constexpr
size_t nonZeros() const noexcept;
307 constexpr
size_t nonZeros(
size_t i ) const noexcept;
308 constexpr
void clear() noexcept;
309 constexpr
void resize(
size_t m,
size_t n ) noexcept;
334 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
335 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
372template< typename Type
389template<
typename Type
405template<
typename Type
424template<
typename Type
435 if( !IsZero_v<MT> && !
isZero( *m ) ) {
460template<
typename Type
487template<
typename Type
516template<
typename Type
524 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
542template<
typename Type
550 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
568template<
typename Type
576 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
594template<
typename Type
602 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
627template<
typename Type
637 if( !IsZero_v<MT> && !
isZero( *rhs ) ) {
641 const size_t m( (*rhs).rows() );
642 const size_t n( (*rhs).columns() );
665template<
typename Type
680template<
typename Type
695template<
typename Type
716template<
typename Type
723 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
735template<
typename Type
756template<
typename Type
763 BLAZE_USER_ASSERT( i < ( SO ? n_ : m_ ),
"Invalid zero matrix row/column access index" );
777template<
typename Type
799template<
typename Type
816template<
typename Type
821 const size_t tmp1( m_ );
825 const size_t tmp2( n_ );
853template<
typename Type
882template<
typename Type
911template<
typename Type
940template<
typename Type
945 const size_t tmp( m_ );
959template<
typename Type
964 const size_t tmp( m_ );
991template<
typename Type
994template<
typename Other >
1014template<
typename Type
1017template<
typename Other >
1037template<
typename Type
1062template< RelaxationFlag RF,
typename Type,
bool SO,
typename Tag >
1065template<
typename Type,
bool SO,
typename Tag >
1068template<
typename Type,
bool SO,
typename Tag >
1105 return ( m.rows() == 0UL && m.columns() == 0UL );
1127template<
typename Type
1147template<
typename Type
1167template<
typename Type
1170inline void erase( ZeroMatrix<Type,SO,Tag>& m,
size_t i,
size_t j )
1192template<
typename Type
1195 ,
typename Iterator >
1196inline Iterator erase( ZeroMatrix<Type,SO,Tag>& m,
size_t i, Iterator pos )
1221template<
typename Type
1224 ,
typename Iterator >
1225inline Iterator erase( ZeroMatrix<Type,SO,Tag>& m,
size_t i, Iterator first, Iterator last )
1258template<
typename Type
1262inline void erase( ZeroMatrix<Type,SO,Tag>& m, Pred predicate )
1300template<
typename Type
1305inline void erase( ZeroMatrix<Type,SO,Tag>& m,
size_t i, Iterator first, Iterator last, Pred predicate )
1355template<
typename T,
bool SO = defaultStorageOrder >
1356constexpr decltype(
auto)
zero(
size_t m,
size_t n )
noexcept
1379template<
typename MT
1381inline ZeroMatrix<ElementType_t<MT>,SO>
1401template<
typename Type,
bool SO,
typename Tag >
1402struct IsUniform< ZeroMatrix<Type,SO,Tag> >
1419template<
typename Type,
bool SO,
typename Tag >
1420struct IsZero< ZeroMatrix<Type,SO,Tag> >
1437template<
typename T1,
typename T2 >
1438struct AddTraitEval1< T1, T2
1441 !IsZero_v<T1> && IsZero_v<T2> > >
1443 using Type = Rebind_t< ResultType_t<T1>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1446template<
typename T1,
typename T2 >
1447struct AddTraitEval1< T1, T2
1450 IsZero_v<T1> && !IsZero_v<T2> > >
1452 using Type = Rebind_t< ResultType_t<T2>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1455template<
typename T1,
typename T2 >
1456struct AddTraitEval1< T1, T2
1459 IsZero_v<T1> && IsZero_v<T2> > >
1461 using Type = ZeroMatrix< AddTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1462 , ( StorageOrder_v<T1> && StorageOrder_v<T2> )
1463 ,
AddTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1479template<
typename T1,
typename T2 >
1480struct SubTraitEval1< T1, T2
1483 !IsZero_v<T1> && IsZero_v<T2> > >
1485 using Type = Rebind_t< ResultType_t<T1>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1488template<
typename T1,
typename T2 >
1489struct SubTraitEval1< T1, T2
1492 IsZero_v<T1> && !IsZero_v<T2> && !IsIdentity_v<T2> > >
1494 using Type = Rebind_t< ResultType_t<T2>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1497template<
typename T1,
typename T2 >
1498struct SubTraitEval1< T1, T2
1501 IsZero_v<T1> && IsZero_v<T2> > >
1503 using Type = ZeroMatrix< SubTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1504 , ( StorageOrder_v<T1> && StorageOrder_v<T2> )
1505 ,
SubTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1521template<
typename T1,
typename T2 >
1522struct SchurTraitEval1< T1, T2
1527 ( IsStrictlyLower_v<T1> && IsUpper_v<T2> ) ||
1528 ( IsStrictlyUpper_v<T1> && IsLower_v<T2> ) ||
1529 ( IsLower_v<T1> && IsStrictlyUpper_v<T2> ) ||
1530 ( IsUpper_v<T1> && IsStrictlyLower_v<T2> ) ) > >
1532 static constexpr bool SO1 = StorageOrder_v<T1>;
1533 static constexpr bool SO2 = StorageOrder_v<T2>;
1535 static constexpr bool SO = ( IsSparseMatrix_v<T1> ^ IsSparseMatrix_v<T2>
1536 ? ( IsSparseMatrix_v<T1>
1541 using Type = ZeroMatrix< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1543 , MultTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1559template<
typename T1,
typename T2 >
1560struct MultTraitEval1< T1, T2
1563 using Type = ZeroMatrix< MultTrait_t< ElementType_t<T1>, T2 >
1564 , StorageOrder_v<T1>
1565 , MultTrait_t< TagType_t<T1>, T2 > >;
1568template<
typename T1,
typename T2 >
1569struct MultTraitEval1< T1, T2
1572 using Type = ZeroMatrix< MultTrait_t< T1, ElementType_t<T2> >
1573 , StorageOrder_v<T2>
1574 , MultTrait_t< T1, TagType_t<T2> > >;
1577template<
typename T1,
typename T2 >
1578struct MultTraitEval1< T1, T2
1580 IsRowVector_v<T2> &&
1581 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1583 using Type = ZeroMatrix< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1584 , ( IsSparseVector_v<T1> && IsDenseVector_v<T2> )
1588template<
typename T1,
typename T2 >
1589struct MultTraitEval1< T1, T2
1592 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1594 using MultType = MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >;
1595 using MultTag = MultTrait_t< TagType_t<T1>, TagType_t<T2> >;
1597 using Type = ZeroMatrix< AddTrait_t<MultType,MultType>
1598 , ( IsZero_v<T1> ? StorageOrder_v<T1> : StorageOrder_v<T2> )
1599 , AddTrait_t<MultTag,MultTag> >;
1615template<
typename T1,
typename T2 >
1616struct KronTraitEval1< T1, T2
1622 using Type = ZeroMatrix< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1623 , ( IsZero_v<T2> ? StorageOrder_v<T2> : StorageOrder_v<T1> )
1640template<
typename T1,
typename T2 >
1641struct DivTraitEval1< T1, T2
1646 using Type = ZeroMatrix< DivTrait_t< ElementType_t<T1>, T2 >
1647 , StorageOrder_v<T1>
1648 , DivTrait_t< TagType_t<T1>, T2 > >;
1664template<
typename T,
typename OP >
1665struct UnaryMapTraitEval1< T, OP
1667 YieldsZero_v<OP,T> > >
1669 using ElementType =
decltype( std::declval<OP>()( std::declval< ElementType_t<T> >() ) );
1671 using Type = ZeroMatrix< EvaluateTrait_t<ElementType>
1673 , MapTrait_t< TagType_t<T>, OP > >;
1681template<
typename T1,
typename T2,
typename OP >
1682struct BinaryMapTraitEval1< T1, T2, OP
1685 YieldsZero_v<OP,T1,T2> > >
1687 using ElementType =
decltype( std::declval<OP>()( std::declval< ElementType_t<T1> >()
1688 , std::declval< ElementType_t<T2> >() ) );
1690 using Type = ZeroMatrix< EvaluateTrait_t<ElementType>
1691 , ( StorageOrder_v<T1> && StorageOrder_v<T2> )
1692 ,
MapTrait_t< TagType_t<T1>, TagType_t<T2>, OP > >;
1710struct ExpandTraitEval1< T, E
1714 using Type = ZeroMatrix< ElementType_t<T>
1732template<
typename T,
size_t R0,
size_t R1 >
1733struct RepeatTraitEval1< T, R0, R1,
inf
1737 using Type = ZeroMatrix< ElementType_t<T>
1755template<
typename T,
bool SO,
typename Tag >
1756struct DeclStrLowTrait< ZeroMatrix<T,SO,Tag> >
1758 using Type = ZeroMatrix<T,SO,Tag>;
1774template<
typename T,
bool SO,
typename Tag >
1775struct DeclStrUppTrait< ZeroMatrix<T,SO,Tag> >
1777 using Type = ZeroMatrix<T,SO,Tag>;
1793template<
typename T1,
bool SO,
typename Tag,
typename T2 >
1794struct HighType< ZeroMatrix<T1,SO,Tag>, ZeroMatrix<T2,SO,Tag> >
1796 using Type = ZeroMatrix< typename HighType<T1,T2>::Type, SO, Tag >;
1812template<
typename T1,
bool SO,
typename Tag,
typename T2 >
1813struct LowType< ZeroMatrix<T1,SO,Tag>, ZeroMatrix<T2,SO,Tag> >
1815 using Type = ZeroMatrix< typename LowType<T1,T2>::Type, SO, Tag >;
1831template<
typename MT,
size_t I,
size_t J,
size_t M,
size_t N >
1832struct SubmatrixTraitEval1< MT, I, J, M, N
1835 using Type = ZeroMatrix< RemoveConst_t< ElementType_t<MT> >
1836 , StorageOrder_v<MT>
1853template<
typename MT,
size_t M >
1854struct RowsTraitEval1< MT, M
1857 using Type = ZeroMatrix< RemoveConst_t< ElementType_t<MT> >
1875template<
typename MT,
size_t N >
1876struct ColumnsTraitEval1< MT, N
1879 using Type = ZeroMatrix< RemoveConst_t< ElementType_t<MT> >
Header file for the addition trait.
Header file for auxiliary alias declarations.
typename ResultType_t< T >::TagType TagType_t
Alias declaration for nested TagType type definitions.
Definition: Aliases.h:530
Header file for run time assertion macros.
Header file for the columns trait.
Constraint on the data type.
Header file for the declstrlow trait.
Header file for the declstrupp trait.
Header file for the division trait.
Header file for the EnableIf class template.
Header file for the EvaluateTrait class template.
Header file for the expand trait.
Header file for the function trace functionality.
Header file for the HighType type trait.
Header file for the IntegralConstant class template.
Header file for the IsColumnVector type trait.
Header file for the IsDenseVector type trait.
Header file for the IsIdentity type trait.
Header file for the IsLower type trait.
Header file for the IsMatrix type trait.
Header file for the IsRowVector type trait.
Header file for the IsSMPAssignable type trait.
Header file for the IsScalar type trait.
Header file for the IsSparseMatrix type trait.
Header file for the IsSparseVector type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsUpper type trait.
Header file for the IsVector type trait.
Header file for the Kron product trait.
Header file for the LowType type trait.
Header file for the map trait.
Header file for the MAYBE_UNUSED function template.
Header file for the multiplication trait.
Constraint on the data type.
Constraint on the data type.
Header file for the relaxation flag enumeration.
Header file for the RemoveConst type trait.
Header file for the repeat trait.
Header file for the rows trait.
Header file for the Schur product trait.
Header file for the subtraction trait.
Header file for the submatrix trait.
Header file for the ValueIndexPair class.
Constraint on the data type.
Header file for the YieldsZero type trait.
Base class for matrices.
Definition: Matrix.h:85
Index-value-pair for sparse vectors and matrices.
Definition: ValueIndexPair.h:75
Efficient implementation of an zero matrix.
Definition: ZeroMatrix.h:197
constexpr size_t rows() const noexcept
Returns the current number of rows of the zero matrix.
Definition: ZeroMatrix.h:668
constexpr ConstIterator begin(size_t i) const noexcept
Returns an iterator to the first non-zero element of row/column i.
Definition: ZeroMatrix.h:520
size_t n_
The current number of columns of the zero matrix.
Definition: ZeroMatrix.h:346
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:886
constexpr void clear() noexcept
Clearing the zero matrix.
Definition: ZeroMatrix.h:780
bool canAlias(const Other *alias) const noexcept
Returns whether the matrix can alias with the given address alias.
Definition: ZeroMatrix.h:995
constexpr ZeroMatrix() noexcept
The default constructor for ZeroMatrix.
Definition: ZeroMatrix.h:392
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:572
const Type & Reference
Reference to a zero matrix element.
Definition: ZeroMatrix.h:222
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: ZeroMatrix.h:915
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the zero matrix.
Definition: ZeroMatrix.h:698
constexpr ZeroMatrix & transpose() noexcept
In-place transpose of the matrix.
Definition: ZeroMatrix.h:943
constexpr ConstIterator cbegin(size_t i) const noexcept
Returns an iterator to the first non-zero element of row/column i.
Definition: ZeroMatrix.h:546
constexpr ZeroMatrix & ctranspose() noexcept
In-place conjugate transpose of the matrix.
Definition: ZeroMatrix.h:962
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: ZeroMatrix.h:857
constexpr size_t nonZeros() const noexcept
Returns the number of non-zero elements in the zero matrix.
Definition: ZeroMatrix.h:738
constexpr size_t columns() const noexcept
Returns the current number of columns of the zero matrix.
Definition: ZeroMatrix.h:683
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:598
const Type & ConstReference
Reference to a constant zero matrix element.
Definition: ZeroMatrix.h:223
constexpr void swap(ZeroMatrix &m) noexcept
Swapping the contents of two zero matrices.
Definition: ZeroMatrix.h:819
constexpr void resize(size_t m, size_t n) noexcept
Changing the size of the zero matrix.
Definition: ZeroMatrix.h:802
static const Type zero_
The zero element.
Definition: ZeroMatrix.h:348
Type ElementType
Type of the zero matrix elements.
Definition: ZeroMatrix.h:217
constexpr ConstReference operator()(size_t i, size_t j) const noexcept
2D-access to the zero matrix elements.
Definition: ZeroMatrix.h:464
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: ZeroMatrix.h:1040
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: ZeroMatrix.h:252
size_t m_
The current number of rows of the zero matrix.
Definition: ZeroMatrix.h:345
bool isAliased(const Other *alias) const noexcept
Returns whether the matrix is aliased with the given address alias.
Definition: ZeroMatrix.h:1018
ConstReference at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: ZeroMatrix.h:491
Tag TagType
Tag type of this ZeroMatrix instance.
Definition: ZeroMatrix.h:218
const Type & ReturnType
Return type for expression template evaluations.
Definition: ZeroMatrix.h:219
ZeroMatrix< Type, SO, Tag > This
Type of this ZeroMatrix instance.
Definition: ZeroMatrix.h:205
Header file for the Expression base class.
Header file for the SparseMatrix base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.
Definition: Volatile.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.
Definition: Pointer.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition: Const.h:79
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TAG(A, B)
Data type constraint.
Definition: SameTag.h:68
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.
Definition: Reference.h:79
bool isZero(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a zero matrix.
Definition: DenseMatrix.h:1819
typename MapTrait< Args... >::Type MapTrait_t
Auxiliary alias declaration for the MapTrait class template.
Definition: MapTrait.h:131
typename AddTrait< T1, T2 >::Type AddTrait_t
Auxiliary alias declaration for the AddTrait class template.
Definition: AddTrait.h:163
typename SubTrait< T1, T2 >::Type SubTrait_t
Auxiliary alias declaration for the SubTrait class template.
Definition: SubTrait.h:163
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.
Definition: MultTrait.h:165
constexpr bool IsScalar_v
Auxiliary variable template for the IsScalar type trait.
Definition: IsScalar.h:104
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.
Definition: IsVector.h:125
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.
Definition: IsZero.h:166
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.
Definition: IsMatrix.h:124
constexpr bool IsColumnVector_v
Auxiliary variable template for the IsColumnVector type trait.
Definition: IsColumnVector.h:126
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
constexpr Infinity inf
Global Infinity instance.
Definition: Infinity.h:1080
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:644
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:660
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
BoolConstant< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
ZeroMatrix< ElementType_t< MT >, SO > declzero(const Matrix< MT, SO > &m)
Declares the given matrix expression m as zero matrix.
Definition: ZeroMatrix.h:1382
constexpr decltype(auto) zero(size_t m, size_t n) noexcept
Creating a zero matrix.
Definition: ZeroMatrix.h:1356
constexpr void swap(ZeroMatrix< Type, SO, Tag > &a, ZeroMatrix< Type, SO, Tag > &b) noexcept
Swapping the contents of two zero matrices.
Definition: ZeroMatrix.h:1150
constexpr bool isDefault(const ZeroMatrix< Type, SO, Tag > &m) noexcept
Returns whether the given zero matrix is in default state.
Definition: ZeroMatrix.h:1103
constexpr bool isIntact(const ZeroMatrix< Type, SO, Tag > &m) noexcept
Returns whether the invariants of the given zero matrix are intact.
Definition: ZeroMatrix.h:1130
Header file for the exception macros of the math module.
Header file for all forward declarations of the math module.
constexpr bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
constexpr bool columnMajor
Storage order flag for column-major matrices.
Definition: StorageOrder.h:99
Header file for all forward declarations for sparse vectors and matrices.
Header file for the StorageOrder type trait.
Header file for the isZero shim.
Base class for all expression templates.
Definition: Expression.h:60
Rebind mechanism to obtain a ZeroMatrix with different data/element type.
Definition: ZeroMatrix.h:232
Resize mechanism to obtain a ZeroMatrix with different fixed dimensions.
Definition: ZeroMatrix.h:242
Header file for the default storage order for all vectors of the Blaze library.
Header file for the IsZero type trait.
Header file for basic type definitions.