69 return ele != NULL ? ele->
value() : 0.0;
118 if( vec_list.size() ) {
119 for( vec_list_t::const_iterator itr = vec_list.begin(); itr != vec_list.end(); ++itr ) {
121 op_v_trans = ( M_trans == itr->v_trans_ ?
no_trans :
trans );
123 r = ( M_trans ==
no_trans ? itr->r_l_ : itr->c_l_ ),
124 c = ( M_trans ==
no_trans ? itr->c_l_ : itr->r_l_ );
125 if( itr->rng_G_.full_range() ) {
159 if( mat_list.size() ) {
160 for( mat_list_t::const_iterator itr = mat_list.begin(); itr != mat_list.end(); ++itr ) {
162 rl =
rows(itr->r_l_,itr->c_l_,M_trans),
163 ru =
rows(itr->r_u_,itr->c_u_,M_trans),
164 cl =
cols(itr->r_l_,itr->c_l_,M_trans),
165 cu =
cols(itr->r_u_,itr->c_u_,M_trans);
167 op_P_trans = ( M_trans == itr->P_trans_ ?
no_trans :
trans ),
168 op_A_trans = ( M_trans == itr->A_trans_ ?
no_trans :
trans ),
169 op_Q_trans = ( M_trans == itr->Q_trans_ ?
no_trans :
trans );
170 if( itr->rng_P_.full_range() && itr->rng_Q_.full_range() ) {
184 if( itr->A_ == NULL ) {
210 if( !itr->rng_P_.full_range() && !itr->rng_Q_.full_range() ) {
214 itr->A_trans_==
no_trans ? itr->rng_P_ : itr->rng_Q_
215 ,itr->A_trans_==
no_trans ? itr->rng_Q_ : itr->rng_P_ )
235 CompSubEntry(
enum EByRowCol by_row_col)
236 : by_row_col_(by_row_col)
238 bool operator()(
const T& e1,
const T& e2 )
247 EByRowCol by_row_col_;
254 namespace AbstractLinAlgPack {
263 namespace rcp = MemMngPack;
268 if(matrix_list_.size()) {
269 matrix_list_.erase(matrix_list_.begin(),matrix_list_.end());
271 if(vector_list_.size()) {
272 vector_list_.erase(vector_list_.begin(),vector_list_.end());
317 namespace rcp = MemMngPack;
331 vector_list_.push_back(
333 row_offset+1,col_offset+1,beta,
Range1D()
335 ,v,v_release,v_trans ) );
341 vector_list_.erase(itr);
408 namespace rcp = MemMngPack;
411 using RangePack::full_range;
414 alpha == 0.0, std::invalid_argument
415 ,
"MatrixComposite::add_matrix(...) : Error!" );
417 A == NULL, std::invalid_argument
418 ,
"MatrixComposite::add_matrix(...) : Error!" );
423 opA_rows =
rows(A_rows,A_cols,A_trans),
424 opA_cols =
cols(A_rows,A_cols,A_trans);
426 rng_P = full_range(rng_P_in,1,opA_rows),
427 rng_Q = full_range(rng_Q_in,1,opA_cols);
429 opPopAopQ_rows = rng_P.
size(),
430 opPopAopQ_cols = rng_Q.size();
433 row_offset + opPopAopQ_rows >
rows_, std::invalid_argument
434 ,
"MatrixComposite::add_matrix(...) : Error!" );
436 col_offset + opPopAopQ_cols >
cols_, std::invalid_argument
437 ,
"MatrixComposite::add_matrix(...) : Error!" );
441 matrix_list_.push_back(
443 row_offset+1,row_offset+opPopAopQ_rows
444 ,col_offset+1,col_offset+opPopAopQ_cols
469 namespace rcp = MemMngPack;
474 alpha == 0.0, std::invalid_argument
475 ,
"MatrixComposite::add_matrix(...) : Error!" );
477 A == NULL, std::invalid_argument
478 ,
"MatrixComposite::add_matrix(...) : Error!" );
483 opA_rows =
rows(A_rows,A_cols,A_trans),
484 opA_cols =
cols(A_rows,A_cols,A_trans);
487 row_offset + opA_rows >
rows_, std::invalid_argument
488 ,
"MatrixComposite::add_matrix(...) : Error!" );
490 col_offset + opA_cols >
cols_, std::invalid_argument
491 ,
"MatrixComposite::add_matrix(...) : Error!" );
495 matrix_list_.push_back(
497 row_offset+1,row_offset+opA_rows
498 ,col_offset+1,col_offset+opA_cols
518 namespace rcp = MemMngPack;
530 opP_rows =
rows(P_rows,P_cols,P_trans),
531 opP_cols =
cols(P_rows,P_cols,P_trans);
536 matrix_list_.push_back(
538 row_offset+1,row_offset+opP_rows,col_offset+1,col_offset+opP_cols,alpha
551 matrix_list_.erase(itr);
560 !space_cols.
get(), std::invalid_argument
561 ,
"MatrixComposite::finish_construction(...): Error, space_cols.get() can not be NULL" );
563 !space_rows.
get(), std::invalid_argument
564 ,
"MatrixComposite::finish_construction(...): Error, space_rows.get() can not be NULL" );
566 space_cols->dim() !=
rows_, std::invalid_argument
567 ,
"MatrixComposite::finish_construction(...): Error, space_colss->dim() = " << space_cols->dim()
568 <<
" != rows = " <<
rows_ <<
" where cols was passed to this->reinitialize(...)" );
570 space_rows->dim() !=
cols_, std::invalid_argument
571 ,
"MatrixComposite::finish_construction(...): Error, space_rows->dim() = " << space_rows->dim()
572 <<
" != cols = " <<
cols_ <<
" where cols was passed to this->reinitialize(...)" );
583 return vector_list_.size();
586 MatrixComposite::vector_list_t::iterator
589 return vector_list_.begin();
592 MatrixComposite::vector_list_t::iterator
595 return vector_list_.end();
598 MatrixComposite::vector_list_t::const_iterator
601 return vector_list_.begin();
604 MatrixComposite::vector_list_t::const_iterator
607 return vector_list_.end();
612 return matrix_list_.size();
615 MatrixComposite::matrix_list_t::iterator
618 return matrix_list_.begin();
621 MatrixComposite::matrix_list_t::iterator
624 return matrix_list_.end();
627 MatrixComposite::matrix_list_t::const_iterator
630 return matrix_list_.begin();
633 MatrixComposite::matrix_list_t::const_iterator
636 return matrix_list_.end();
655 {
for(matrix_list_t::const_iterator itr = matrix_list_.begin(); itr != matrix_list_.end(); ++itr) {
656 if( itr->A_ != NULL )
659 nz += (*itr->P_).
nz();
661 {
for(vector_list_t::const_iterator itr = vector_list_.begin(); itr != vector_list_.end(); ++itr) {
703 #ifdef PROFILE_HACK_ENABLED
708 Vp_StMtV_imp(y,a,
rows_,
cols_,matrix_list_,vector_list_,M_trans,x,b);
716 #ifdef PROFILE_HACK_ENABLED
721 Vp_StMtV_imp(y,a,
rows_,
cols_,matrix_list_,vector_list_,M_trans,x,b);
731 #ifdef PROFILE_HACK_ENABLED
745 #ifdef PROFILE_HACK_ENABLED
758 !fully_constructed, std::logic_error
759 ,
"MatrixComposite::assert_fully_constructed() : Error, not fully constructed!");
element_type * lookup_element(size_type i)
virtual mat_ptr_t sub_view(const Range1D &row_rng, const Range1D &col_rng) const
Create a transient constant sub-matrix view of this matrix (if supported).
void remove_vector(vector_list_t::iterator itr)
Remove a sub-vector.
virtual vec_ptr_t sub_view(const Range1D &rng) const
Create an abstract view of a vector object .
virtual vec_mut_ptr_t sub_view(const Range1D &rng)
Create a mutable abstract view of a vector object.
Matrix list entry for a sub-matrix.
void assert_fully_constructed() const
std::deque< SubMatrixEntry > matrix_list_t
Warning! This could be changed to some other STL container!
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
RTOp_index_type index_type
matrix_list_t::iterator matrices_begin()
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
v_lhs *= alpha
RTOp_value_type value_type
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Index size() const
Return the size of the range (ubound() - lbound() + 1)
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
v_lhs = alpha * v_rhs + v_lhs
void add_matrix(size_type row_offset, size_type col_offset, value_type alpha, const GenPermMatrixSlice *P, const release_resource_ptr_t &P_release, BLAS_Cpp::Transp P_trans, const MatrixOp *A, const release_resource_ptr_t &A_release, BLAS_Cpp::Transp A_trans, const GenPermMatrixSlice *Q, const release_resource_ptr_t &Q_release, BLAS_Cpp::Transp Q_trans)
Add a sub-matrix alpha*op(P)*op(A)*op(Q).
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return rows of a possible transposed matrix.
mat_ptr_t sub_view(const Range1D &row_rng, const Range1D &col_rng) const
vector_list_t::iterator vectors_begin()
Helper class that takes care of timing.
virtual void finish_construction(const VectorSpace::space_ptr_t &space_cols, const VectorSpace::space_ptr_t &space_rows)
Call to finish the construction process.
std::deque< SubVectorEntry > vector_list_t
Warning! This could be changed to some other STL container!
virtual size_type cols() const
Return the number of columns in the matrix.
vector_list_t::iterator vectors_end()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
. One-based subregion index range class.
RTOp_index_type size_type
Abstract interface for objects that represent a space for mutable coordinate vectors.
Vector list entry for a sub-vector.
matrix_list_t::iterator matrices_end()
void Vp_StPtMtV(VectorMutable *vs_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, BLAS_Cpp::Transp M_rhs2_trans, const Vector &v_rhs3, value_type beta) const
const VectorSpace & space_cols() const
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta=1.0)
v_lhs = alpha * op(M_rhs1) * v_rhs2 + beta * v_lhs (BLAS xGEMV)
const f_int f_dbl_prec a[]
Base class for all matrices that support basic matrix operations.
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
result = v_rhs1' * v_rhs2
MatrixComposite(size_type rows=0, size_type cols=0)
Construct.
static const Range1D Invalid
Range1D(INVALID)
void reinitialize(size_type rows=0, size_type cols=0)
Initialize a sized (on unsized) zero matrix to start with.
virtual index_type dim() const
Return the dimension of this vector.
virtual value_type get_ele(index_type i) const
Fetch an element in the vector.
Abstract interface for mutable coordinate vectors {abstract}.
Sparse storage element type.
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
virtual size_type rows() const
Return the number of rows in the matrix.
void remove_matrix(matrix_list_t::iterator itr)
Remove a sub-matrix.
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return columns of a possible transposed matrix.
RangePack::Range1D Range1D
const f_int f_dbl_prec const f_int f_int const f_int f_int const f_dbl_prec & u
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
void add_vector(size_type row_offset, size_type col_offset, value_type beta, const GenPermMatrixSlice *G, const release_resource_ptr_t &G_release, BLAS_Cpp::Transp G_trans, const Vector *v, const release_resource_ptr_t &v_release, BLAS_Cpp::Transp v_trans)
Add a sub-vector beta*op(op(G)*v).
const VectorSpace & space_rows() const
Concrete matrix type to represent general permutation (mapping) matrices.
friend void Vp_StPtMtV(VectorMutable *v_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const MatrixOp &M_rhs2, BLAS_Cpp::Transp M_rhs2_trans, const Vector &v_rhs3, value_type beta)
void Vp_StMtV(VectorMutable *vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta) const