35 #ifndef _BLAZE_MATH_DENSE_UNIFORMMATRIX_H_ 36 #define _BLAZE_MATH_DENSE_UNIFORMMATRIX_H_ 183 template<
typename Type
184 ,
bool SO = defaultStorageOrder >
186 :
public Expression< DenseMatrix< UniformMatrix<Type,SO>, SO > >
212 template<
typename NewType >
221 template<
size_t NewM
247 explicit inline constexpr
UniformMatrix(
size_t m,
size_t n );
248 explicit inline constexpr
UniformMatrix(
size_t m,
size_t n, const Type& init );
250 template< typename MT,
bool SO2 >
269 inline constexpr
ConstReference operator()(
size_t i,
size_t j ) const noexcept;
283 inline constexpr
UniformMatrix& operator=( const Type& rhs );
288 template< typename MT,
bool SO2 > inline
UniformMatrix& operator= ( const
Matrix<MT,SO2>& rhs );
289 template< typename MT,
bool SO2 > inline
UniformMatrix& operator+=( const
Matrix<MT,SO2>& rhs );
290 template< typename MT,
bool SO2 > inline
UniformMatrix& operator-=( const
Matrix<MT,SO2>& rhs );
291 template< typename MT,
bool SO2 > inline
UniformMatrix& operator%=( const
Matrix<MT,SO2>& rhs );
292 template< typename MT,
bool SO2 > inline
UniformMatrix& operator*=( const
Matrix<MT,SO2>& rhs );
294 template< typename ST >
297 template< typename ST >
305 inline constexpr
size_t rows() const noexcept;
306 inline constexpr
size_t columns() const noexcept;
307 inline constexpr
size_t spacing() const noexcept;
308 inline constexpr
size_t capacity() const noexcept;
309 inline constexpr
size_t capacity(
size_t i ) const noexcept;
311 inline
size_t nonZeros(
size_t i ) const;
312 inline constexpr
void reset();
313 inline constexpr
void clear();
314 constexpr
void resize (
size_t m,
size_t n,
bool preserve=true );
315 inline constexpr
void extend (
size_t m,
size_t n,
bool preserve=true );
326 template< typename Other > inline
UniformMatrix& scale( const Other& scalar );
340 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
341 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
385 template< typename Type
401 template<
typename Type
420 template<
typename Type
439 template<
typename Type
441 template<
typename MT
448 if( !IsUniform_v<MT> && !
isUniform( ~m ) ) {
452 if(
m_ > 0UL &&
n_ > 0UL ) {
477 template<
typename Type
503 template<
typename Type
532 template<
typename Type
550 template<
typename Type
576 template<
typename Type
602 template<
typename Type
628 template<
typename Type
654 template<
typename Type
683 template<
typename Type
703 template<
typename Type
705 template<
typename MT
709 using TT = decltype(
trans( *
this ) );
710 using CT = decltype(
ctrans( *
this ) );
712 if( !IsUniform_v<MT> && !
isUniform( ~rhs ) ) {
716 if( IsSame_v<MT,TT> && (~rhs).isAliased(
this ) ) {
719 else if( IsSame_v<MT,CT> && (~rhs).isAliased(
this ) ) {
726 if( (~rhs).rows() > 0UL && (~rhs).
columns() > 0UL ) {
727 value_ = (~rhs)(0UL,0UL);
746 template<
typename Type
748 template<
typename MT
752 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ ) {
756 if( !IsUniform_v<MT> && !
isUniform( ~rhs ) ) {
760 if( m_ > 0UL && n_ > 0UL ) {
761 value_ += (~rhs)(0UL,0UL);
779 template<
typename Type
781 template<
typename MT
785 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ ) {
789 if( !IsUniform_v<MT> && !
isUniform( ~rhs ) ) {
793 if( m_ > 0UL && n_ > 0UL ) {
794 value_ -= (~rhs)(0UL,0UL);
812 template<
typename Type
814 template<
typename MT
818 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ ) {
822 if( !IsUniform_v<MT> && !
isUniform( ~rhs ) ) {
826 if( m_ > 0UL && n_ > 0UL ) {
827 value_ *= (~rhs)(0UL,0UL);
845 template<
typename Type
847 template<
typename MT
851 if( (~rhs).
rows() != n_ ) {
855 if( !IsUniform_v<MT> && !
isUniform( ~rhs ) ) {
861 if( m_ > 0UL && n_ > 0UL ) {
862 value_ = ( value_ * (~rhs)(0UL,0UL) ) * Type( (~rhs).rows() );
877 template<
typename Type
879 template<
typename ST >
899 template<
typename Type
901 template<
typename ST >
927 template<
typename Type
941 template<
typename Type
960 template<
typename Type
974 template<
typename Type
994 template<
typename Type
1001 return SO ? m_ : n_;
1011 template<
typename Type
1015 if( m_ == 0UL || n_ == 0UL ||
isDefault( value_ ) )
1034 template<
typename Type
1043 const size_t tmp( SO ? m_ : n_ );
1057 template<
typename Type
1075 template<
typename Type
1099 template<
typename Type
1123 template<
typename Type
1127 resize( m_+m, n_+n, preserve );
1138 template<
typename Type
1146 swap( value_, m.value_ );
1164 template<
typename Type
1182 template<
typename Type
1213 template<
typename Type
1215 template<
typename Other >
1218 if( m_ > 0UL && n_ > 0UL ) {
1245 template<
typename Type
1247 template<
typename Other >
1250 return static_cast<const void*>(
this ) == static_cast<const void*>( alias );
1265 template<
typename Type
1267 template<
typename Other >
1270 return static_cast<const void*>(
this ) == static_cast<const void*>( alias );
1284 template<
typename Type
1303 template<
typename Type
1307 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
1327 template<
typename Type
1332 return loada( i, j );
1352 template<
typename Type
1366 return set( value_ );
1386 template<
typename Type
1400 return set( value_ );
1420 template<
typename Type,
bool SO >
1423 template<
typename Type,
bool SO >
1426 template<
bool RF,
typename Type,
bool SO >
1429 template<
typename Type,
bool SO >
1432 template<
typename Type,
bool SO >
1445 template<
typename Type
1461 template<
typename Type
1500 return ( m.rows() == 0UL && m.columns() == 0UL );
1523 template<
typename Type
1542 template<
typename Type
1593 template<
bool SO = defaultStorageOrder,
typename T >
1594 inline constexpr decltype(
auto)
uniform(
size_t m,
size_t n, T&& init )
1611 template<
typename Type,
bool SO >
1612 struct IsUniform< UniformMatrix<Type,SO> >
1629 template<
typename Type,
bool SO >
1630 struct IsAligned< UniformMatrix<Type,SO> >
1647 template<
typename Type,
bool SO >
1648 struct IsResizable< UniformMatrix<Type,SO> >
1665 template<
typename T1,
typename T2 >
1666 struct AddTraitEval1< T1, T2
1669 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1670 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1672 using ET1 = ElementType_t<T1>;
1673 using ET2 = ElementType_t<T2>;
1675 static constexpr
bool SO1 = StorageOrder_v<T1>;
1676 static constexpr
bool SO2 = StorageOrder_v<T2>;
1678 static constexpr
bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1679 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1680 ? ( IsSymmetric_v<T1>
1688 using Type = UniformMatrix< AddTrait_t<ET1,ET2>, SO >;
1704 template<
typename T1,
typename T2 >
1705 struct SubTraitEval1< T1, T2
1708 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1709 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1711 using ET1 = ElementType_t<T1>;
1712 using ET2 = ElementType_t<T2>;
1714 static constexpr
bool SO1 = StorageOrder_v<T1>;
1715 static constexpr
bool SO2 = StorageOrder_v<T2>;
1717 static constexpr
bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1718 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1719 ? ( IsSymmetric_v<T1>
1727 using Type = UniformMatrix< SubTrait_t<ET1,ET2>, SO >;
1743 template<
typename T1,
typename T2 >
1744 struct SchurTraitEval1< T1, T2
1747 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1748 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1750 using ET1 = ElementType_t<T1>;
1751 using ET2 = ElementType_t<T2>;
1753 static constexpr
bool SO1 = StorageOrder_v<T1>;
1754 static constexpr
bool SO2 = StorageOrder_v<T2>;
1756 static constexpr
bool SO = ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1757 ? ( IsSymmetric_v<T1>
1762 using Type = UniformMatrix< MultTrait_t<ET1,ET2>, SO >;
1778 template<
typename T1,
typename T2 >
1779 struct MultTraitEval1< T1, T2
1785 using ET1 = ElementType_t<T1>;
1787 using Type = UniformMatrix< MultTrait_t<ET1,T2>, StorageOrder_v<T1> >;
1790 template<
typename T1,
typename T2 >
1791 struct MultTraitEval1< T1, T2
1797 using ET2 = ElementType_t<T2>;
1799 using Type = UniformMatrix< MultTrait_t<T1,ET2>, StorageOrder_v<T2> >;
1802 template<
typename T1,
typename T2 >
1803 struct MultTraitEval1< T1, T2
1805 IsRowVector_v<T2> &&
1806 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1807 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1809 using ET1 = ElementType_t<T1>;
1810 using ET2 = ElementType_t<T2>;
1812 using Type = UniformMatrix< MultTrait_t<ET1,ET2>,
false >;
1815 template<
typename T1,
typename T2 >
1816 struct MultTraitEval1< T1, T2
1819 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1820 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1822 using ET1 = ElementType_t<T1>;
1823 using ET2 = ElementType_t<T2>;
1825 using Type = UniformMatrix< MultTrait_t<ET1,ET2>, StorageOrder_v<T1> >;
1841 template<
typename T1,
typename T2 >
1842 struct KronTraitEval1< T1, T2
1845 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1846 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1848 using ET1 = ElementType_t<T1>;
1849 using ET2 = ElementType_t<T2>;
1851 using Type = UniformMatrix< MultTrait_t<ET1,ET2>, StorageOrder_v<T2> >;
1867 template<
typename T1,
typename T2 >
1868 struct DivTraitEval1< T1, T2
1871 IsUniform_v<T1> && !IsZero_v<T1> > >
1873 using ET1 = ElementType_t<T1>;
1875 using Type = UniformMatrix< DivTrait_t<ET1,T2>, StorageOrder_v<T1> >;
1891 template<
typename T,
typename OP >
1892 struct UnaryMapTraitEval1< T, OP
1894 YieldsUniform_v<OP,T> &&
1895 !YieldsZero_v<OP,T> > >
1897 using ET = ElementType_t<T>;
1899 using Type = UniformMatrix< MapTrait_t<ET,OP>, StorageOrder_v<T> >;
1907 template<
typename T1,
typename T2,
typename OP >
1908 struct BinaryMapTraitEval1< T1, T2, OP
1911 YieldsUniform_v<OP,T1,T2> &&
1912 !YieldsZero_v<OP,T1,T2> > >
1914 using ET1 = ElementType_t<T1>;
1915 using ET2 = ElementType_t<T2>;
1917 static constexpr
bool SO1 = StorageOrder_v<T1>;
1918 static constexpr
bool SO2 = StorageOrder_v<T2>;
1920 static constexpr
bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1921 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1922 ? ( IsSymmetric_v<T1>
1930 using Type = UniformMatrix< MapTrait_t<ET1,ET2,OP>, SO >;
1946 template<
typename T
1948 struct ExpandTraitEval1< T, E
1950 IsUniform_v<T> && !IsZero_v<T> > >
1954 using Type = UniformMatrix< ElementType_t<T>, TF >;
1970 template<
typename T1,
bool SO,
typename T2 >
1971 struct HighType< UniformMatrix<T1,SO>, UniformMatrix<T2,SO> >
1973 using Type = UniformMatrix< typename HighType<T1,T2>::Type, SO >;
1989 template<
typename T1,
bool SO,
typename T2 >
1990 struct LowType< UniformMatrix<T1,SO>, UniformMatrix<T2,SO> >
1992 using Type = UniformMatrix< typename LowType<T1,T2>::Type, SO >;
2008 template<
typename MT,
size_t I,
size_t J,
size_t M,
size_t N >
2009 struct SubmatrixTraitEval1< MT, I, J, M, N
2012 using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >, StorageOrder_v<MT> >;
2028 template<
typename MT,
size_t M >
2029 struct RowsTraitEval1< MT, M
2032 using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >,
false >;
2048 template<
typename MT,
size_t N >
2049 struct ColumnsTraitEval1< MT, N
2052 using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >,
true >;
Constraint on the data type.
#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
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
Header file for the alignment flag values.
Header file for the subtraction trait.
Header file for basic type definitions.
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 RemoveCVRef type trait.
Header file for the IsRowVector type trait.
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_t alias declaration provid...
Definition: SIMDTrait.h:315
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.
#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
Header file for the reset shim.
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 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
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes....
Definition: DenseMatrix.h:81
Constraint on the data type.
constexpr bool IsDenseMatrix_v
Auxiliary variable template for the IsDenseMatrix type trait.The IsDenseMatrix_v variable template pr...
Definition: IsDenseMatrix.h:138
Header file for the IsMatrix type trait.
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 LowType type trait.
Header file for the multiplication trait.
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
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1361
#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.
#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
Header file for the DenseMatrix base class.
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Header file for all SIMD functionality.
Constraint on the data type.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
Header file for the IsAligned type trait.
Header file for the default storage order for all vectors of the Blaze library.
Header file for the Kron product trait.
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type,...
Definition: Vectorizable.h:61
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
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:1638
Header file for the IsVector type trait.
Header file for the IsDenseMatrix type trait.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
Header file for the IsVectorizable type trait.
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
Header file for the RemoveConst type trait.
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
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.
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
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:295
#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
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:282
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
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
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:79
Header file for the rows trait.
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
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 IsColumnVector type trait.
constexpr bool IsUniform_v
Auxiliary variable template for the IsUniform type trait.The IsUniform_v variable template provides a...
Definition: IsUniform.h:164
Header file for the IsResizable type trait.
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#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 Expression base class.
Header file for the HighType type trait.
Header file for the clear shim.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825