35#ifndef _BLAZE_MATH_EXPRESSIONS_SMATREPEATEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SMATREPEATEXPR_H_
84 :
public MatRepeatExpr< SparseMatrix< SMatRepeatExpr<MT,SO,CRAs...>, SO >, CRAs... >
85 ,
private If_t< IsComputation_v<MT>, Computation, Transformation >
124 template<
typename... RRAs >
141 return sm_( i%
sm_.rows(), j%
sm_.columns() );
169 inline size_t rows() const noexcept {
170 return sm_.rows() * this->
template repetitions<0UL>();
180 return sm_.columns() * this->
template repetitions<1UL>();
190 return sm_.nonZeros() * this->
template repetitions<0UL>() * this->
template repetitions<1UL>();
202 return sm_.nonZeros(i) * this->
template repetitions<0UL>();
204 return sm_.nonZeros(i) * this->
template repetitions<1UL>();
219 using DataType::repetitions;
228 template<
typename T >
229 inline bool canAlias(
const T* alias )
const noexcept {
230 return IsExpression_v<MT> &&
sm_.canAlias( alias );
240 template<
typename T >
241 inline bool isAliased(
const T* alias )
const noexcept {
242 return sm_.isAliased( alias );
274 template<
typename MT2
285 const size_t reps0( rhs.template repetitions<0UL>() );
286 const size_t reps1( rhs.template repetitions<1UL>() );
287 const size_t M( A.rows() );
288 const size_t N( A.columns() );
290 for(
size_t rep0=0UL; rep0<reps0; ++rep0 ) {
291 for(
size_t rep1=0UL; rep1<reps1; ++rep1 ) {
311 template<
typename MT2
331 const size_t reps0( rhs.template repetitions<0UL>() );
332 const size_t reps1( rhs.template repetitions<1UL>() );
333 const size_t M( A.rows() );
334 const size_t N( A.columns() );
336 (*lhs).reserve( reps0*reps1*M*N );
338 if( SO2 == rowMajor )
340 for(
size_t rep0=0UL; rep0<reps0; ++rep0 ) {
341 for(
size_t i=0UL; i<M; ++i ) {
342 for(
size_t rep1=0UL; rep1<reps1; ++rep1 ) {
343 for(
auto element=A.begin(i); element!=A.end(i); ++element ) {
344 (*lhs).append( rep0*M+i, rep1*N+element->index(), element->value(),
true );
347 (*lhs).finalize( rep0*M+i );
353 for(
size_t rep1=0UL; rep1<reps1; ++rep1 ) {
354 for(
size_t j=0UL; j<N; ++j ) {
355 for(
size_t rep0=0UL; rep0<reps0; ++rep0 ) {
356 for(
auto element=A.begin(j); element!=A.end(j); ++element ) {
357 (*lhs).append( rep0*M+element->index(), rep1*N+j, element->value(),
true );
360 (*lhs).finalize( rep1*N+j );
380 template<
typename MT2
382 friend inline void addAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatRepeatExpr& rhs )
389 CompositeType_t<MT> A(
serial( rhs.sm_ ) );
391 const size_t reps0( rhs.template repetitions<0UL>() );
392 const size_t reps1( rhs.template repetitions<1UL>() );
393 const size_t M( A.rows() );
394 const size_t N( A.columns() );
396 for(
size_t rep0=0UL; rep0<reps0; ++rep0 ) {
397 for(
size_t rep1=0UL; rep1<reps1; ++rep1 ) {
421 template<
typename MT2
423 friend inline void subAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatRepeatExpr& rhs )
430 CompositeType_t<MT> A(
serial( rhs.sm_ ) );
432 const size_t reps0( rhs.template repetitions<0UL>() );
433 const size_t reps1( rhs.template repetitions<1UL>() );
434 const size_t M( A.rows() );
435 const size_t N( A.columns() );
437 for(
size_t rep0=0UL; rep0<reps0; ++rep0 ) {
438 for(
size_t rep1=0UL; rep1<reps1; ++rep1 ) {
462 template<
typename MT2
464 friend inline void schurAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatRepeatExpr& rhs )
471 CompositeType_t<MT> A(
serial( rhs.sm_ ) );
473 const size_t reps0( rhs.template repetitions<0UL>() );
474 const size_t reps1( rhs.template repetitions<1UL>() );
475 const size_t M( A.rows() );
476 const size_t N( A.columns() );
478 for(
size_t rep0=0UL; rep0<reps0; ++rep0 ) {
479 for(
size_t rep1=0UL; rep1<reps1; ++rep1 ) {
568 return ReturnType( *sm, m, n );
624 return ReturnType( *sm );
646inline decltype(
auto)
repeat(
const SparseMatrix<MT,SO>& sm,
size_t m,
size_t n )
652 using ReturnType =
const SMatRepeatExpr<MT,SO,R0,R1>;
653 return ReturnType( *sm );
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition: Aliases.h:470
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.
Definition: Aliases.h:310
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the function trace functionality.
Header file for the If class template.
Header file for the IsExpression type trait class.
Header file for the RemoveReference type trait.
Header file for the implementation of the RepeatExprData class template.
Header file for the repeat trait.
Base class for dense matrices.
Definition: DenseMatrix.h:82
Auxiliary class template for the data members of repeater expression classes.
Definition: RepeatExprData.h:65
Expression object for the sparse matrix repeat() function.
Definition: SMatRepeatExpr.h:87
RepeatExprData< 2UL, CRAs... > DataType
The type of the RepeatExprData base class.
Definition: SMatRepeatExpr.h:90
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatRepeatExpr.h:229
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SMatRepeatExpr.h:115
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatRepeatExpr.h:103
Operand operand() const noexcept
Returns the sparse matrix operand.
Definition: SMatRepeatExpr.h:213
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: SMatRepeatExpr.h:251
Operand sm_
Sparse matrix of the repeater expression.
Definition: SMatRepeatExpr.h:258
RepeatTrait_t< MT, CRAs... > ResultType
Result type for expression template evaluations.
Definition: SMatRepeatExpr.h:101
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatRepeatExpr.h:106
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatRepeatExpr.h:200
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatRepeatExpr.h:179
ElementType_t< MT > ElementType
Resulting element type.
Definition: SMatRepeatExpr.h:104
size_t reps_
The number of repetitions.
Definition: SMatRepeatExpr.h:259
ReturnType_t< MT > ReturnType
Return type for expression template evaluations.
Definition: SMatRepeatExpr.h:105
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite data type of the sparse matrix expression.
Definition: SMatRepeatExpr.h:109
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatRepeatExpr.h:138
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatRepeatExpr.h:153
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatRepeatExpr.h:169
SMatRepeatExpr(const MT &sm, RRAs... args) noexcept
Constructor for the SMatRepeatExpr class.
Definition: SMatRepeatExpr.h:125
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatRepeatExpr.h:189
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatRepeatExpr.h:241
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatRepeatExpr.h:102
Base class for sparse matrices.
Definition: SparseMatrix.h:77
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the MatRepeatExpr base class.
Header file for the SparseMatrix base class.
decltype(auto) repeat(const DenseMatrix< MT, SO > &dm, size_t m, size_t n)
Repeats the given dense matrix.
Definition: DMatRepeatExpr.h:543
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.
Definition: StorageOrder.h:84
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition: StorageOrder.h:63
typename RepeatTrait< T, CRAs... >::Type RepeatTrait_t
Auxiliary alias declaration for the RepeatTrait type trait.
Definition: RepeatTrait.h:151
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:181
typename RemoveReference< T >::Type RemoveReference_t
Auxiliary alias declaration for the RemoveReference type trait.
Definition: RemoveReference.h:95
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
constexpr Unchecked unchecked
Global Unchecked instance.
Definition: Check.h:146
Header file for the exception macros of the math module.
Constraints on the storage order of matrix types.
Header file for all forward declarations for expression class templates.
Header file for the serial shim.
Base class for all matrix repeat expression templates.
Definition: MatRepeatExpr.h:69
Header file for basic type definitions.
Submatrix specialization for dense matrices.