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 
46 #include <blaze/util/Assert.h>
47 #include <blaze/util/EnableIf.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 // GLOBAL FUNCTIONS
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
62 template< typename MT1, bool SO1, typename MT2, bool SO2 >
63 inline EnableIf_< IsSparseMatrix<MT1> >
64  smpAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
65 
66 template< typename MT1, bool SO1, typename MT2, bool SO2 >
67 inline EnableIf_< IsSparseMatrix<MT1> >
68  smpAddAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
69 
70 template< typename MT1, bool SO1, typename MT2, bool SO2 >
71 inline EnableIf_< IsSparseMatrix<MT1> >
72  smpSubAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
73 
74 template< typename MT1, bool SO1, typename MT2, bool SO2 >
75 inline EnableIf_< IsSparseMatrix<MT1> >
76  smpSchurAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
78 //*************************************************************************************************
79 
80 
81 //*************************************************************************************************
95 template< typename MT1 // Type of the left-hand side sparse matrix
96  , bool SO1 // Storage order of the left-hand side sparse matrix
97  , typename MT2 // Type of the right-hand side matrix
98  , bool SO2 > // Storage order of the right-hand side matrix
99 inline EnableIf_< IsSparseMatrix<MT1> >
101 {
103 
104  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
105  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
106 
107  assign( ~lhs, ~rhs );
108 }
109 //*************************************************************************************************
110 
111 
112 //*************************************************************************************************
126 template< typename MT1 // Type of the left-hand side sparse matrix
127  , bool SO1 // Storage order of the left-hand side sparse matrix
128  , typename MT2 // Type of the right-hand side matrix
129  , bool SO2 > // Storage order of the right-hand side matrix
132 {
134 
135  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
136  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
137 
138  addAssign( ~lhs, ~rhs );
139 }
140 //*************************************************************************************************
141 
142 
143 //*************************************************************************************************
157 template< typename MT1 // Type of the left-hand side sparse matrix
158  , bool SO1 // Storage order of the left-hand side sparse matrix
159  , typename MT2 // Type of the right-hand side matrix
160  , bool SO2 > // Storage order of the right-hand side matrix
163 {
165 
166  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
167  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
168 
169  subAssign( ~lhs, ~rhs );
170 }
171 //*************************************************************************************************
172 
173 
174 //*************************************************************************************************
189 template< typename MT1 // Type of the left-hand side sparse matrix
190  , bool SO1 // Storage order of the left-hand side sparse matrix
191  , typename MT2 // Type of the right-hand side matrix
192  , bool SO2 > // Storage order of the right-hand side matrix
195 {
197 
198  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
199  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
200 
201  schurAssign( ~lhs, ~rhs );
202 }
203 //*************************************************************************************************
204 
205 } // namespace blaze
206 
207 #endif
EnableIf_< IsDenseMatrix< MT1 > > smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:196
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:164
Header file for the IsSparseMatrix type trait.
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:133
Header file for the SparseMatrix base class.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:102
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
Header file for the EnableIf class template.
Header file for the Matrix base class.
Header file for run time assertion macros.
#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
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:101
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the function trace functionality.