Blaze  3.6
SparseMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SMP_DEFAULT_SPARSEMATRIX_H_
36 #define _BLAZE_MATH_SMP_DEFAULT_SPARSEMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
45 #include <blaze/util/Assert.h>
46 #include <blaze/util/EnableIf.h>
48 
49 
50 namespace blaze {
51 
52 //=================================================================================================
53 //
54 // GLOBAL FUNCTIONS
55 //
56 //=================================================================================================
57 
58 //*************************************************************************************************
61 template< typename MT1, bool SO1, typename MT2, bool SO2 >
62 auto smpAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
63  -> EnableIf_t< IsSparseMatrix_v<MT1> >;
64 
65 template< typename MT1, bool SO1, typename MT2, bool SO2 >
66 auto smpAddAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
67  -> EnableIf_t< IsSparseMatrix_v<MT1> >;
68 
69 template< typename MT1, bool SO1, typename MT2, bool SO2 >
70 auto smpSubAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
71  -> EnableIf_t< IsSparseMatrix_v<MT1> >;
72 
73 template< typename MT1, bool SO1, typename MT2, bool SO2 >
74 auto smpSchurAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
75  -> EnableIf_t< IsSparseMatrix_v<MT1> >;
77 //*************************************************************************************************
78 
79 
80 //*************************************************************************************************
94 template< typename MT1 // Type of the left-hand side sparse matrix
95  , bool SO1 // Storage order of the left-hand side sparse matrix
96  , typename MT2 // Type of the right-hand side matrix
97  , bool SO2 > // Storage order of the right-hand side matrix
98 inline auto smpAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
99  -> EnableIf_t< IsSparseMatrix_v<MT1> >
100 {
102 
103  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
104  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
105 
106  assign( ~lhs, ~rhs );
107 }
108 //*************************************************************************************************
109 
110 
111 //*************************************************************************************************
125 template< typename MT1 // Type of the left-hand side sparse matrix
126  , bool SO1 // Storage order of the left-hand side sparse matrix
127  , typename MT2 // Type of the right-hand side matrix
128  , bool SO2 > // Storage order of the right-hand side matrix
129 inline auto smpAddAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
130  -> EnableIf_t< IsSparseMatrix_v<MT1> >
131 {
133 
134  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
135  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
136 
137  addAssign( ~lhs, ~rhs );
138 }
139 //*************************************************************************************************
140 
141 
142 //*************************************************************************************************
156 template< typename MT1 // Type of the left-hand side sparse matrix
157  , bool SO1 // Storage order of the left-hand side sparse matrix
158  , typename MT2 // Type of the right-hand side matrix
159  , bool SO2 > // Storage order of the right-hand side matrix
160 inline auto smpSubAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
161  -> EnableIf_t< IsSparseMatrix_v<MT1> >
162 {
164 
165  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
166  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
167 
168  subAssign( ~lhs, ~rhs );
169 }
170 //*************************************************************************************************
171 
172 
173 //*************************************************************************************************
188 template< typename MT1 // Type of the left-hand side sparse matrix
189  , bool SO1 // Storage order of the left-hand side sparse matrix
190  , typename MT2 // Type of the right-hand side matrix
191  , bool SO2 > // Storage order of the right-hand side matrix
192 inline auto smpSchurAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
193  -> EnableIf_t< IsSparseMatrix_v<MT1> >
194 {
196 
197  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
198  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
199 
200  schurAssign( ~lhs, ~rhs );
201 }
202 //*************************************************************************************************
203 
204 } // namespace blaze
205 
206 #endif
Header file for the IsSparseMatrix type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the EnableIf class template.
Header file for the Matrix base class.
Header file for run time assertion macros.
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
#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
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
#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 function trace functionality.