35#ifndef _BLAZE_MATH_DENSE_UNIFORMMATRIX_H_
36#define _BLAZE_MATH_DENSE_UNIFORMMATRIX_H_
192template<
typename Type
196 :
public Expression< DenseMatrix< UniformMatrix<Type,SO,Tag>, SO > >
230 template<
typename NewType >
239 template<
size_t NewM
266 constexpr
UniformMatrix(
size_t m,
size_t n, const Type& init );
268 template< typename MT,
bool SO2 >
287 constexpr
ConstReference operator()(
size_t i,
size_t j ) const noexcept;
306 template< typename MT,
bool SO2 > inline
UniformMatrix& operator= ( const
Matrix<MT,SO2>& rhs ) &;
307 template< typename MT,
bool SO2 > inline
UniformMatrix& operator+=( const
Matrix<MT,SO2>& rhs ) &;
308 template< typename MT,
bool SO2 > inline
UniformMatrix& operator-=( const
Matrix<MT,SO2>& rhs ) &;
309 template< typename MT,
bool SO2 > inline
UniformMatrix& operator%=( const
Matrix<MT,SO2>& rhs ) &;
310 template< typename MT,
bool SO2 > inline
UniformMatrix& operator*=( const
Matrix<MT,SO2>& rhs ) &;
312 template< typename ST >
315 template< typename ST >
323 constexpr
size_t rows() const noexcept;
324 constexpr
size_t columns() const noexcept;
325 constexpr
size_t spacing() const noexcept;
326 constexpr
size_t capacity() const noexcept;
327 constexpr
size_t capacity(
size_t i ) const noexcept;
329 inline
size_t nonZeros(
size_t i ) const;
330 constexpr
void reset();
331 constexpr
void clear();
332 constexpr
void resize (
size_t m,
size_t n,
bool preserve=true );
333 constexpr
void extend (
size_t m,
size_t n,
bool preserve=true );
344 template< typename Other > inline
UniformMatrix& scale( const Other& scalar );
358 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
359 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
403template< typename Type
420template<
typename Type
440template<
typename Type
460template<
typename Type
470 if( !IsUniform_v<MT> && !
isUniform( *m ) ) {
474 if(
m_ > 0UL &&
n_ > 0UL ) {
499template<
typename Type
526template<
typename Type
556template<
typename Type
575template<
typename Type
602template<
typename Type
629template<
typename Type
656template<
typename Type
683template<
typename Type
713template<
typename Type
735template<
typename Type
743 using TT =
decltype(
trans( *
this ) );
744 using CT =
decltype(
ctrans( *
this ) );
748 if( !IsUniform_v<MT> && !
isUniform( *rhs ) ) {
752 if( IsSame_v<MT,TT> && (*rhs).isAliased(
this ) ) {
755 else if( IsSame_v<MT,CT> && (*rhs).isAliased(
this ) ) {
760 n_ = (*rhs).columns();
762 if( (*rhs).rows() > 0UL && (*rhs).columns() > 0UL ) {
763 value_ = (*rhs)(0UL,0UL);
782template<
typename Type
792 if( (*rhs).rows() != m_ || (*rhs).columns() != n_ ) {
796 if( !IsUniform_v<MT> && !
isUniform( *rhs ) ) {
800 if( m_ > 0UL && n_ > 0UL ) {
801 value_ += (*rhs)(0UL,0UL);
819template<
typename Type
829 if( (*rhs).rows() != m_ || (*rhs).columns() != n_ ) {
833 if( !IsUniform_v<MT> && !
isUniform( *rhs ) ) {
837 if( m_ > 0UL && n_ > 0UL ) {
838 value_ -= (*rhs)(0UL,0UL);
856template<
typename Type
866 if( (*rhs).rows() != m_ || (*rhs).columns() != n_ ) {
870 if( !IsUniform_v<MT> && !
isUniform( *rhs ) ) {
874 if( m_ > 0UL && n_ > 0UL ) {
875 value_ *= (*rhs)(0UL,0UL);
893template<
typename Type
903 if( (*rhs).rows() != n_ ) {
907 if( !IsUniform_v<MT> && !
isUniform( *rhs ) ) {
911 n_ = (*rhs).columns();
913 if( m_ > 0UL && n_ > 0UL ) {
914 value_ = ( value_ * (*rhs)(0UL,0UL) ) * Type( (*rhs).rows() );
929template<
typename Type
932template<
typename ST >
952template<
typename Type
955template<
typename ST >
981template<
typename Type
996template<
typename Type
1016template<
typename Type
1021 return SO ? m_ : n_;
1031template<
typename Type
1052template<
typename Type
1060 return SO ? m_ : n_;
1074template<
typename Type
1079 if( m_ == 0UL || n_ == 0UL || isDefault<strict>( value_ ) )
1099template<
typename Type
1109 const size_t tmp( SO ? m_ : n_ );
1110 if( tmp == 0UL || isDefault<strict>( value_ ) )
1123template<
typename Type
1142template<
typename Type
1167template<
typename Type
1192template<
typename Type
1197 resize( m_+m, n_+n, preserve );
1208template<
typename Type
1217 swap( value_, m.value_ );
1235template<
typename Type
1254template<
typename Type
1286template<
typename Type
1289template<
typename Other >
1292 if( m_ > 0UL && n_ > 0UL ) {
1319template<
typename Type
1322template<
typename Other >
1325 return static_cast<const void*
>( this ) ==
static_cast<const void*
>( alias );
1340template<
typename Type
1343template<
typename Other >
1346 return static_cast<const void*
>( this ) ==
static_cast<const void*
>( alias );
1360template<
typename Type
1380template<
typename Type
1385 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
1405template<
typename Type
1411 return loada( i, j );
1431template<
typename Type
1446 return set( value_ );
1466template<
typename Type
1481 return set( value_ );
1501template< RelaxationFlag RF,
typename Type,
bool SO,
typename Tag >
1504template<
typename Type,
bool SO,
typename Tag >
1507template<
typename Type,
bool SO,
typename Tag >
1567template<
typename Type
1587template<
typename Type
1639template<
bool SO = defaultStorageOrder,
typename T >
1640constexpr decltype(
auto)
uniform(
size_t m,
size_t n, T&& init )
1657template<
typename Type,
bool SO,
typename Tag >
1658struct IsUniform< UniformMatrix<Type,SO,Tag> >
1675template<
typename Type,
bool SO,
typename Tag >
1676struct IsAligned< UniformMatrix<Type,SO,Tag> >
1693template<
typename T1,
typename T2 >
1694struct AddTraitEval1< T1, T2
1697 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1698 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1700 static constexpr bool SO1 = StorageOrder_v<T1>;
1701 static constexpr bool SO2 = StorageOrder_v<T2>;
1703 static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1704 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1705 ? ( IsSymmetric_v<T1>
1713 using Type = UniformMatrix< AddTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1715 , AddTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1731template<
typename T1,
typename T2 >
1732struct SubTraitEval1< T1, T2
1735 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1736 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1738 static constexpr bool SO1 = StorageOrder_v<T1>;
1739 static constexpr bool SO2 = StorageOrder_v<T2>;
1741 static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1742 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1743 ? ( IsSymmetric_v<T1>
1751 using Type = UniformMatrix< SubTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1753 , SubTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1769template<
typename T1,
typename T2 >
1770struct SchurTraitEval1< T1, T2
1773 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1774 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1776 static constexpr bool SO1 = StorageOrder_v<T1>;
1777 static constexpr bool SO2 = StorageOrder_v<T2>;
1779 static constexpr bool SO = ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1780 ? ( IsSymmetric_v<T1>
1785 using Type = UniformMatrix< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1787 , MultTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1803template<
typename T1,
typename T2 >
1804struct MultTraitEval1< T1, T2
1810 using Type = UniformMatrix< MultTrait_t< ElementType_t<T1>, T2 >
1811 , StorageOrder_v<T1>
1812 , MultTrait_t< TagType_t<T1>, T2 > >;
1815template<
typename T1,
typename T2 >
1816struct MultTraitEval1< T1, T2
1822 using Type = UniformMatrix< MultTrait_t< T1, ElementType_t<T2> >
1823 , StorageOrder_v<T2>
1824 , MultTrait_t< T1, TagType_t<T2> > >;
1827template<
typename T1,
typename T2 >
1828struct MultTraitEval1< T1, T2
1830 IsRowVector_v<T2> &&
1831 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1832 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1834 using Type = UniformMatrix< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1836 , MultTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1839template<
typename T1,
typename T2 >
1840struct MultTraitEval1< T1, T2
1843 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1844 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1846 using MultType = MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >;
1847 using MultTag = MultTrait_t< TagType_t<T1>, TagType_t<T2> >;
1849 using Type = UniformMatrix< AddTrait_t<MultType,MultType>
1850 , StorageOrder_v<T1>
1851 , AddTrait_t<MultTag,MultTag> >;
1867template<
typename T1,
typename T2 >
1868struct KronTraitEval1< T1, T2
1871 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1872 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1874 using Type = UniformMatrix< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1875 , StorageOrder_v<T2>
1876 , MultTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1892template<
typename T1,
typename T2 >
1893struct DivTraitEval1< T1, T2
1896 IsUniform_v<T1> && !IsZero_v<T1> > >
1898 using Type = UniformMatrix< DivTrait_t< ElementType_t<T1>, T2 >
1899 , StorageOrder_v<T1>
1900 , DivTrait_t< TagType_t<T1>, T2 > >;
1916template<
typename T,
typename OP >
1917struct UnaryMapTraitEval1< T, OP
1919 YieldsUniform_v<OP,T> &&
1920 !YieldsZero_v<OP,T> > >
1922 using ElementType =
decltype( std::declval<OP>()( std::declval< ElementType_t<T> >() ) );
1924 using Type = UniformMatrix< EvaluateTrait_t<ElementType>
1926 , MapTrait_t< TagType_t<T>, OP > >;
1934template<
typename T1,
typename T2,
typename OP >
1935struct BinaryMapTraitEval1< T1, T2, OP
1937 IsRowVector_v<T2> &&
1938 YieldsUniform_v<OP,T1,T2> &&
1939 !YieldsZero_v<OP,T1,T2> > >
1941 using ElementType =
decltype( std::declval<OP>()( std::declval< ElementType_t<T1> >()
1942 , std::declval< ElementType_t<T2> >() ) );
1944 using Type = UniformMatrix< EvaluateTrait_t<ElementType>
1946 , MapTrait_t< TagType_t<T1>, TagType_t<T2>, OP > >;
1949template<
typename T1,
typename T2,
typename OP >
1950struct BinaryMapTraitEval1< T1, T2, OP
1953 YieldsUniform_v<OP,T1,T2> &&
1954 !YieldsZero_v<OP,T1,T2> > >
1956 using ElementType =
decltype( std::declval<OP>()( std::declval< ElementType_t<T1> >()
1957 , std::declval< ElementType_t<T2> >() ) );
1959 static constexpr bool SO1 = StorageOrder_v<T1>;
1960 static constexpr bool SO2 = StorageOrder_v<T2>;
1962 static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1963 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1964 ? ( IsSymmetric_v<T1>
1972 using Type = UniformMatrix< EvaluateTrait_t<ElementType>
1974 , MapTrait_t< TagType_t<T1>, TagType_t<T2>, OP > >;
1990template<
typename T,
size_t E >
1991struct ExpandTraitEval1< T, E
1993 IsUniform_v<T> && !IsZero_v<T> > >
1995 using Type = UniformMatrix< ElementType_t<T>
2013template<
typename T,
size_t R0,
size_t R1 >
2014struct RepeatTraitEval1< T, R0, R1,
inf
2016 IsUniform_v<T> && !IsZero_v<T> > >
2018 using Type = UniformMatrix< ElementType_t<T>
2036template<
typename T1,
bool SO,
typename Tag,
typename T2 >
2037struct HighType< UniformMatrix<T1,SO,Tag>, UniformMatrix<T2,SO,Tag> >
2039 using Type = UniformMatrix< typename HighType<T1,T2>::Type, SO, Tag >;
2055template<
typename T1,
bool SO,
typename Tag,
typename T2 >
2056struct LowType< UniformMatrix<T1,SO,Tag>, UniformMatrix<T2,SO,Tag> >
2058 using Type = UniformMatrix< typename LowType<T1,T2>::Type, SO, Tag >;
2074template<
typename MT,
size_t I,
size_t J,
size_t M,
size_t N >
2075struct SubmatrixTraitEval1< MT, I, J, M, N
2078 using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >
2079 , StorageOrder_v<MT>
2096template<
typename MT,
size_t M >
2097struct RowsTraitEval1< MT, M
2100 using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >
2118template<
typename MT,
size_t N >
2119struct ColumnsTraitEval1< MT, N
2122 using Type = UniformMatrix< 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 the alignment flag enumeration.
Header file for run time assertion macros.
Header file for the columns trait.
Header file for the conjugate shim.
Constraint on the data type.
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 HighType type trait.
Header file for the IntegralConstant class template.
Header file for the IsAligned type trait.
Header file for the IsColumnVector type trait.
Header file for the isDefault shim.
Header file for the IsDenseMatrix 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 IsSymmetric type trait.
Header file for the IsVector type trait.
Header file for the IsVectorizable 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 RemoveCVRef type trait.
Header file for the RemoveConst type trait.
Header file for the repeat trait.
Header file for the rows trait.
Header file for all SIMD functionality.
Header file for the Schur product trait.
Header file for the subtraction trait.
Header file for the submatrix trait.
Constraint on the data type.
Constraint on the data type.
Header file for the YieldsZero type trait.
Base class for matrices.
Definition: Matrix.h:85
SIMD characteristics of data types.
Definition: SIMDTrait.h:297
Header file for the DenseMatrix base class.
Header file for the Expression 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_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.
Definition: Vectorizable.h:61
#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
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1501
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:1766
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:118
constexpr bool IsScalar_v
Auxiliary variable template for the IsScalar type trait.
Definition: IsScalar.h:104
constexpr bool IsUniform_v
Auxiliary variable template for the IsUniform type trait.
Definition: IsUniform.h:164
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.
Definition: IsVector.h:125
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
constexpr bool IsDenseMatrix_v
Auxiliary variable template for the IsDenseMatrix type trait.
Definition: IsDenseMatrix.h:124
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
constexpr Infinity inf
Global Infinity instance.
Definition: Infinity.h:1080
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition: Matrix.h:960
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
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:1108
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:1221
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:1195
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
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
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.
Definition: SIMDTrait.h:315
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
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
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
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 dense vectors and matrices.
Header file for the StorageOrder type trait.
Header file for the clear shim.
Header file for the reset shim.
Base class for all expression templates.
Definition: Expression.h:60
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
Header file for the IsZero type trait.
Header file for basic type definitions.