49 #include "AbstractLinAlgPack_MultiVectorMutable.hpp"
50 #include "AbstractLinAlgPack_MatrixSymDiag.hpp"
51 #include "AbstractLinAlgPack_VectorMutable.hpp"
52 #include "AbstractLinAlgPack_AssertOp.hpp"
53 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
54 #include "Teuchos_Workspace.hpp"
55 #include "Teuchos_Assert.hpp"
62 to_trans(AbstractLinAlgPack::EApplyBy apply_by)
64 return ( apply_by == AbstractLinAlgPack::APPLY_BY_ROW
76 ,
const AbstractLinAlgPack::size_type k
77 ,AbstractLinAlgPack::EApplyBy apply_by
80 return ( apply_by == AbstractLinAlgPack::APPLY_BY_ROW
90 ,
const AbstractLinAlgPack::size_type k
91 ,AbstractLinAlgPack::EApplyBy apply_by
94 return ( apply_by == AbstractLinAlgPack::APPLY_BY_ROW
105 const AbstractLinAlgPack::value_type &a
110 ,
const AbstractLinAlgPack::value_type &b
131 *Cmv =
dynamic_cast<MultiVectorMutable*
>(C);
133 *D =
dynamic_cast<const MatrixSymDiag*
>(&D_mwo);
134 if( !Cmv || !D || !(Cmv->access_by() & ( C_trans ==
no_trans ? MV::COL_ACCESS : MV::ROW_ACCESS ))
143 const Vector &D_diag = D->diag();
146 for(
size_type j = 1; j <= opC_cols; ++j ) {
150 opC_col_j = ( C_trans ==
no_trans ? Cmv->col(j) : Cmv->row(j) );
151 Vt_S( opC_col_j.get(), b );
159 namespace AbstractLinAlgPack {
164 return Teuchos::null;
173 return Teuchos::null;
177 EApplyBy apply_by,
const RTOpPack::RTOp& prim_op
178 ,
const size_t num_multi_vecs,
const MultiVector* multi_vecs[]
181 ,
const index_type prim_first_ele_in,
const index_type prim_sub_dim_in,
const index_type prim_global_offset_in
182 ,
const index_type sec_first_ele_in,
const index_type sec_sub_dim_in
192 prim_dim = ( apply_by == APPLY_BY_ROW ?
rows() :
cols() ),
193 sec_dim = ( apply_by == APPLY_BY_ROW ?
cols() :
rows() ),
194 prim_sub_dim = ( prim_sub_dim_in != 0 ? prim_sub_dim_in : prim_dim ),
195 sec_sub_dim = ( sec_sub_dim_in != 0 ? sec_sub_dim_in : sec_dim );
204 Workspace<MultiVector::vec_ptr_t> vecs_s(wss,num_multi_vecs);
205 Workspace<const Vector*> vecs(wss,num_multi_vecs);
206 Workspace<MultiVectorMutable::vec_mut_ptr_t> targ_vecs_s(wss,num_targ_multi_vecs);
207 Workspace<VectorMutable*> targ_vecs(wss,num_targ_multi_vecs);
209 {
for(size_type j = sec_first_ele_in; j <= sec_first_ele_in - 1 + sec_sub_dim; ++j) {
211 {
for(size_type k = 0; k < num_multi_vecs; ++k) {
212 vecs_s[k] = vec( *multi_vecs[k], j, apply_by );
213 vecs[k] = vecs_s[k].get();
215 {
for(size_type k = 0; k < num_targ_multi_vecs; ++k) {
216 targ_vecs_s[k] = vec( targ_multi_vecs[k], j, apply_by );
217 targ_vecs[k] = targ_vecs_s[k].get();
220 AbstractLinAlgPack::apply_op(
222 ,num_multi_vecs, num_multi_vecs ? &vecs[0] : NULL
223 ,num_targ_multi_vecs, num_targ_multi_vecs ? &targ_vecs[0] : NULL
224 ,reduct_objs ? reduct_objs[j-1] : NULL
225 ,prim_first_ele_in, prim_sub_dim_in, prim_global_offset_in
236 EApplyBy apply_by,
const RTOpPack::RTOp& prim_op,
const RTOpPack::RTOp& sec_op
237 ,
const size_t num_multi_vecs,
const MultiVector* multi_vecs[]
240 ,
const index_type prim_first_ele_in,
const index_type prim_sub_dim_in,
const index_type prim_global_offset_in
241 ,
const index_type sec_first_ele_in,
const index_type sec_sub_dim_in
251 prim_dim = ( apply_by == APPLY_BY_ROW ?
rows() :
cols() ),
252 sec_dim = ( apply_by == APPLY_BY_ROW ?
cols() :
rows() ),
253 sec_sub_dim = ( sec_sub_dim_in != 0 ? sec_sub_dim_in : sec_dim );
258 Workspace<Teuchos::RCP<RTOpPack::ReductTarget> > rcp_reduct_objs(wss,sec_sub_dim);
259 Workspace<RTOpPack::ReductTarget*> reduct_objs(wss,sec_sub_dim);
260 for(index_type k = 0; k < sec_sub_dim; ++k) {
261 rcp_reduct_objs[k] = prim_op.reduct_obj_create();
262 reduct_objs[k] = &*rcp_reduct_objs[k];
268 ,num_multi_vecs, multi_vecs
269 ,num_targ_multi_vecs, targ_multi_vecs
271 ,prim_first_ele_in, prim_sub_dim_in, prim_global_offset_in
272 ,sec_first_ele_in, sec_sub_dim_in
277 for(index_type k = 0; k < sec_sub_dim; ++k) {
278 sec_op.reduce_reduct_objs( *reduct_objs[k], Teuchos::ptr(reduct_obj) );
330 void AbstractLinAlgPack::apply_op(
332 ,
const RTOpPack::RTOp &primary_op
333 ,
const size_t num_multi_vecs
334 ,
const MultiVector* multi_vecs[]
335 ,
const size_t num_targ_multi_vecs
336 ,MultiVectorMutable* targ_multi_vecs[]
338 ,
const index_type primary_first_ele
339 ,
const index_type primary_sub_dim
340 ,
const index_type primary_global_offset
341 ,
const index_type secondary_first_ele
342 ,
const index_type secondary_sub_dim
346 multi_vecs[0]->apply_op(
348 ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
349 ,reduct_objs,primary_first_ele,primary_sub_dim,primary_global_offset
350 ,secondary_first_ele,secondary_sub_dim
352 else if(num_targ_multi_vecs)
353 targ_multi_vecs[0]->apply_op(
355 ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
356 ,reduct_objs,primary_first_ele,primary_sub_dim,primary_global_offset
357 ,secondary_first_ele,secondary_sub_dim
361 void AbstractLinAlgPack::apply_op(
363 ,
const RTOpPack::RTOp &primary_op
364 ,
const RTOpPack::RTOp &secondary_op
365 ,
const size_t num_multi_vecs
366 ,
const MultiVector* multi_vecs[]
367 ,
const size_t num_targ_multi_vecs
368 ,MultiVectorMutable* targ_multi_vecs[]
370 ,
const index_type primary_first_ele
371 ,
const index_type primary_sub_dim
372 ,
const index_type primary_global_offset
373 ,
const index_type secondary_first_ele
374 ,
const index_type secondary_sub_dim
378 multi_vecs[0]->apply_op(
379 apply_by,primary_op,secondary_op
380 ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
381 ,reduct_obj,primary_first_ele,primary_sub_dim,primary_global_offset
382 ,secondary_first_ele,secondary_sub_dim
384 else if(num_targ_multi_vecs)
385 targ_multi_vecs[0]->apply_op(
386 apply_by,primary_op,secondary_op
387 ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
388 ,reduct_obj,primary_first_ele,primary_sub_dim,primary_global_offset
389 ,secondary_first_ele,secondary_sub_dim
mat_ptr_t clone() const
Returns this->mv_clone().
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
v_lhs *= alpha
virtual access_by_t access_by() const =0
Return a bit field for the types of access that are the most convenient.
mat_ptr_t sub_view(const Range1D &row_rng, const Range1D &col_rng) const
Returns this->mv_sub_view(row_rng,col_rng) casted to a MatrixOp.
bool Mp_StMtM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &mwo_rhs1, BLAS_Cpp::Transp trans_rhs1, BLAS_Cpp::Transp trans_rhs2, value_type beta) const
Provides a specialized implementation for mwo_rhs1 of type MatrixSymDiag.
virtual size_type cols() const
Return the number of columns in the matrix.
Teuchos::RCP< const MultiVector > multi_vec_ptr_t
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)
void ele_wise_prod(const value_type &alpha, const Vector &v_rhs1, const Vector &v_rhs2, VectorMutable *v_lhs)
v_lhs(i) += alpha * v_rhs1(i) * v_rhs2(i), i = 1,,,dim.
Base class for all matrices that support basic matrix operations.
Interface for a collection of non-mutable vectors (multi-vector, matrix).
virtual vec_mut_ptr_t row(index_type i)=0
Get a mutable row vector.
Interface to all diagonal matrices {abstract}.
virtual multi_vec_ptr_t mv_sub_view(const Range1D &row_rng, const Range1D &col_rng) const
Returns a sub-view of the multi vector.
Transp trans_not(Transp _trans)
Interface for a collection of mutable vectors (multi-vector, matrix).
friend void apply_op(EApplyBy apply_by, const RTOpPack::RTOp &primary_op, const size_t num_multi_vecs, const MultiVector *multi_vecs[], const size_t num_targ_multi_vecs, MultiVectorMutable *targ_multi_vecs[], RTOpPack::ReductTarget *reduct_objs[], const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset, const index_type secondary_first_ele, const index_type secondary_sub_dim)
virtual size_type rows() const
Return the number of rows in the matrix.
virtual multi_vec_ptr_t mv_clone() const
Clone the non-const multi-vector object.
virtual vec_ptr_t col(index_type j) const =0
Get a non-mutable column vector.
virtual vec_mut_ptr_t col(index_type j)=0
Get a mutable column vector.
virtual vec_ptr_t row(index_type i) const =0
Get a non-mutable row vector.
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()