56 struct dump_vec_spaces {
62 :vec_space1(_vec_space1),vec_space1_name(_vec_space1_name)
63 ,vec_space2(_vec_space2),vec_space2_name(_vec_space2_name)
66 const char *vec_space1_name;
68 const char *vec_space2_name;
74 std::ostream&
operator<<( std::ostream& o,
const dump_vec_spaces& d )
76 o <<
"Error, " << d.vec_space1_name <<
" at address " << &d.vec_space1
77 <<
" of type \'" <<
typeName(d.vec_space1)
78 <<
"\' with dimension " << d.vec_space1_name <<
".dim() = " << d.vec_space1.dim()
79 <<
" is not compatible with "
80 << d.vec_space2_name <<
" at address " << &d.vec_space2
81 <<
" of type \'" <<
typeName(d.vec_space2)
82 <<
"\' with dimension " << d.vec_space2_name <<
".dim() = " << d.vec_space2.dim();
86 enum EM_VS { SPACE_COLS, SPACE_ROWS };
96 if(M_trans ==
no_trans && M_VS == SPACE_COLS)
98 if(M_trans ==
trans && M_VS == SPACE_COLS)
100 if(M_trans ==
no_trans && M_VS == SPACE_ROWS)
108 #define ASSERT_LHS_ARG(FUNC_NAME,LHS_ARG) \
109 TEUCHOS_TEST_FOR_EXCEPTION( \
110 (LHS_ARG) == NULL, std::invalid_argument \
111 ,FUNC_NAME << " : Error!" \
118 #define ASSERT_VEC_SPACES_NAMES(FUNC_NAME,VS1,VS1_NAME,VS2,VS2_NAME) \
120 const bool is_compatible = (VS1).is_compatible(VS2); \
121 TEUCHOS_TEST_FOR_EXCEPTION( \
122 !is_compatible, VectorSpace::IncompatibleVectorSpaces \
123 ,FUNC_NAME << " : " << dump_vec_spaces(VS1,VS1_NAME,VS2,VS2_NAME) \
127 #define ASSERT_VEC_SPACES(FUNC_NAME,VS1,VS2) \
128 ASSERT_VEC_SPACES_NAMES(FUNC_NAME,VS1,#VS1,VS2,#VS2)
130 #define ASSERT_MAT_VEC_SPACES(FUNC_NAME,M,M_T,M_VS,VS) \
132 std::ostringstream M_VS_name; \
133 M_VS_name << "(" #M << ( M_T == BLAS_Cpp::no_trans ? "" : "'" ) << ")" \
134 << "." << ( M_VS == SPACE_COLS ? "space_cols()" : "space_rows()" ); \
135 ASSERT_VEC_SPACES_NAMES( \
137 ,op(M,M_T,M_VS),M_VS_name.str().c_str() \
142 #define ASSERT_MAT_MAT_SPACES(FUNC_NAME,M1,M1_T,M1_VS,M2,M2_T,M2_VS) \
144 std::ostringstream M1_VS_name, M2_VS_name; \
145 M1_VS_name << "(" #M1 << ( M1_T == BLAS_Cpp::no_trans ? "" : "'" ) << ")" \
146 << "." << ( M1_VS == SPACE_COLS ? "space_cols()" : "space_rows()" ); \
147 M2_VS_name << "(" #M2 << ( M2_T == BLAS_Cpp::no_trans ? "" : "'" ) << ")" \
148 << "." << ( M2_VS == SPACE_COLS ? "space_cols()" : "space_rows()" ); \
149 ASSERT_VEC_SPACES_NAMES( \
151 ,op(M1,M1_T,M1_VS),M1_VS_name.str().c_str() \
152 ,op(M2,M2_T,M2_VS),M2_VS_name.str().c_str() \
158 #ifdef ABSTRACTLINALGPACK_ASSERT_COMPATIBILITY
162 const char func_name[] =
"Vp_V_assert_compatibility(v_lhs,v_rhs)";
164 ASSERT_VEC_SPACES(
"Vp_V_assert_compatibility(v_lhs,v_rhs)",v_lhs->space(),v_rhs.space());
174 const char func_name[] =
"VopV_assert_compatibility(v_rhs1,v_rhs2)";
193 const char func_name[] =
"Mp_M_assert_compatibility(m_lhs,trans_lhs,m_rhs,trans_rhs)";
200 const MatrixOp& m_rhs1, BLAS_Cpp::
Transp trans_rhs1
201 ,const MatrixOp& m_rhs2, BLAS_Cpp::
Transp trans_rhs2 )
203 const char func_name[] =
"MopM_assert_compatibility(m_rhs1,trans_rhs1,m_rhs2,trans_rhs2)";
209 const MatrixOp& m_rhs1, BLAS_Cpp::
Transp trans_rhs1, const Vector& v_rhs2 )
211 const char func_name[] =
"MtV_assert_compatibility(m_rhs1,trans_rhs1,v_rhs2)";
223 ,
const MatrixOp& m_rhs1,
BLAS_Cpp::Transp trans_rhs1,
const Vector& v_rhs2 )
225 const char func_name[] =
"Vp_MtV_assert_compatibility(v_lhs,m_rhs1,trans_rhs1,v_rhs2)";
242 const char func_name[] =
"MtM_assert_compatibility(m_rhs1,trans_rhs1,m_rhs2,trans_rhs2)";
248 MatrixOp* m_lhs, BLAS_Cpp::
Transp trans_lhs
249 ,const MatrixOp& m_rhs1, BLAS_Cpp::
Transp trans_rhs1
250 ,const MatrixOp& m_rhs2, BLAS_Cpp::
Transp trans_rhs2 )
252 const char func_name[] =
"Mp_MtM_assert_compatibility(m_lhs,trans_lhsm_rhs1,trans_rhs1,m_rhs2,trans_rhs2)";
259 #endif // ABSTRACTLINALGPACK_ASSERT_COMPATIBILITY
virtual const VectorSpace & space_rows() const =0
Vector space for vectors that are compatible with the rows of the matrix.
#define ASSERT_MAT_MAT_SPACES(FUNC_NAME, M1, M1_T, M1_VS, M2, M2_T, M2_VS)
std::string typeName(const T &t)
#define ASSERT_VEC_SPACES(FUNC_NAME, VS1, VS2)
void MopM_assert_compatibility(const MatrixOp &m_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &m_rhs2, BLAS_Cpp::Transp trans_rhs2)
op(m_rhs1) op op(m_rhs2)
void MtV_assert_compatibility(const MatrixOp &m_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2)
op(m_rhs1) * v_rhs2
void Vp_V_assert_compatibility(VectorMutable *v_lhs, const Vector &v_rhs)
v_lhs += op v_rhs
void MtM_assert_compatibility(const MatrixOp &m_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &m_rhs2, BLAS_Cpp::Transp trans_rhs2)
op(m_lhs) += op(m_rhs1)
Abstract interface for objects that represent a space for mutable coordinate vectors.
void Mp_MtM_assert_compatibility(MatrixOp *m_lhs, BLAS_Cpp::Transp trans_lhs, const MatrixOp &m_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &m_rhs2, BLAS_Cpp::Transp trans_rhs2)
op(m_lhs) += op(m_rhs1) * op(m_rhs2)
const LAPACK_C_Decl::f_int & M
std::ostream & operator<<(std::ostream &out, const GenPermMatrixSlice &P)
Print the contents of a GenPermMatrixSlice object in machine readable format.
Base class for all matrices that support basic matrix operations.
#define ASSERT_LHS_ARG(FUNC_NAME, LHS_ARG)
SparseVectorSlice< SparseElement< index_type, value_type > > SpVectorSlice
virtual const VectorSpace & space_cols() const =0
Vector space for vectors that are compatible with the columns of the matrix.
void Vp_MtV_assert_compatibility(VectorMutable *v_lhs, const MatrixOp &m_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2)
v_lhs += op(m_rhs1) * v_rhs2
#define ASSERT_MAT_VEC_SPACES(FUNC_NAME, M, M_T, M_VS, VS)
void Mp_M_assert_compatibility(MatrixOp *m_lhs, BLAS_Cpp::Transp trans_lhs, const MatrixOp &m_rhs, BLAS_Cpp::Transp trans_rhs)
op(m_lhs) += op op(m_rhs)
void VopV_assert_compatibility(const Vector &v_rhs1, const Vector &v_rhs2)
v_rhs1 op v_rhs2