46 #include "AbstractLinAlgPack_MatrixOpSerial.hpp" 47 #include "AbstractLinAlgPack_VectorDenseEncap.hpp" 48 #include "AbstractLinAlgPack_MatrixOpGetGMSMutable.hpp" 49 #include "AbstractLinAlgPack_MatrixOpGetGMSTri.hpp" 50 #include "AbstractLinAlgPack_MatrixSymOpGetGMSSymMutable.hpp" 51 #include "AbstractLinAlgPack_SpVectorOp.hpp" 52 #include "AbstractLinAlgPack_GenPermMatrixSliceOp.hpp" 53 #include "AbstractLinAlgPack_EtaVector.hpp" 54 #include "AbstractLinAlgPack_GenPermMatrixSlice.hpp" 55 #include "AbstractLinAlgPack_LinAlgOpPackHack.hpp" 56 #include "DenseLinAlgPack_DMatrixClass.hpp" 57 #include "DenseLinAlgPack_DMatrixOut.hpp" 58 #include "DenseLinAlgPack_AssertOp.hpp" 59 #include "Teuchos_Workspace.hpp" 60 #include "Teuchos_dyn_cast.hpp" 86 for( size_type j = 1; j <=n; ++j ) {
88 this->
Vp_StMtV( &gms_lhs->
col(j), alpha, trans_rhs, rhs(), 1.0 );
98 TEUCHOS_TEST_FOR_EXCEPT(
true);
107 TEUCHOS_TEST_FOR_EXCEPT(
true);
117 TEUCHOS_TEST_FOR_EXCEPT(
true);
125 Vp_MtV_assert_sizes( vs_lhs->
dim(),
rows(),
cols(), trans_rhs1, sv_rhs2.
dim() );
126 if( !sv_rhs2.
nz() ) {
128 if(beta==0.0) *vs_lhs = 0.0;
134 const DVectorSlice vs_rhs2 = AbstractLinAlgPack::dense_view(sv_rhs2);
135 this->
Vp_StMtV( vs_lhs, alpha, trans_rhs1, vs_rhs2, beta );
140 this->
Vp_StMtV( vs_lhs, alpha, trans_rhs1, v_rhs2(), beta );
150 using Teuchos::Workspace;
151 Teuchos::WorkspaceStore* wss = Teuchos::get_default_workspace_store().get();
155 LinAlgOpPack::V_StMtV(&t,a,*
this,M_trans,x);
156 LinAlgOpPack::Vp_MtV( y, P, P_trans, t, b );
164 using Teuchos::Workspace;
165 Teuchos::WorkspaceStore* wss = Teuchos::get_default_workspace_store().get();
169 LinAlgOpPack::V_StMtV(&t,a,*
this,M_trans,x);
170 LinAlgOpPack::Vp_MtV( y, P, P_trans, t, b );
176 DenseLinAlgPack::Vp_MtV_assert_sizes( x1.
dim(),
rows(),
cols(), M_trans, x2.
dim() );
178 this->
Vp_StMtV( &tmp(), 1.0, M_trans, x2, 0.0 );
185 DenseLinAlgPack::Vp_MtV_assert_sizes( x1.
dim(),
rows(),
cols(), M_trans, x2.
dim() );
186 if( !x1.
nz() || !x2.
nz() ) {
191 const DVectorSlice x1_d = AbstractLinAlgPack::dense_view(x1);
192 return this->
transVtMtV( x1_d, M_trans, x1_d );
195 this->
Vp_StMtV( &tmp(), 1.0, M_trans, x2, 0.0 );
245 M_rows = this->
rows(),
246 M_cols = this->
cols(),
248 DenseLinAlgPack::MtM_assert_sizes(
250 , P1_in.
rows(), P1_in.
cols(), P1_trans );
251 DenseLinAlgPack::MtM_assert_sizes(
252 M_rows, M_cols, M_trans_in
253 , P2_in.
rows(), P2_in.
cols(), P2_trans );
254 DenseLinAlgPack::Mp_M_assert_sizes(
259 reorder_P1_P2 = (
rows( P1_in.
rows(), P1_in.
cols(), P1_trans )
262 &P1 = reorder_P1_P2 ? P2_in : P1_in,
263 &P2 = reorder_P1_P2 ? P1_in : P2_in;
265 M_trans = reorder_P1_P2 ?
trans_not(M_trans_in) : M_trans_in;
275 i_k = P1_trans ==
no_trans ? P1_itr->row_i() : P1_itr->col_j(),
276 j_k = P1_trans ==
no_trans ? P1_itr->col_j() : P1_itr->row_i();
283 if( S->
uplo() == BLAS_Cpp::upper )
288 if( S->
uplo() == BLAS_Cpp::upper )
311 for( size_type j = 1; j <= C->
cols(); ++j )
328 for( size_type i = 1; i <= C->
rows(); ++i )
330 , DenseLinAlgPack::row(A,A_trans,i) , b );
345 if( size_A < size_B ) {
361 TEUCHOS_TEST_FOR_EXCEPT(
true);
367 TEUCHOS_TEST_FOR_EXCEPT(
true);
374 TEUCHOS_TEST_FOR_EXCEPT(
true);
380 TEUCHOS_TEST_FOR_EXCEPT(
true);
392 using Teuchos::Workspace;
393 Teuchos::WorkspaceStore* wss = Teuchos::get_default_workspace_store().get();
398 M_rows = this->
rows(),
399 M_cols = this->
cols(),
400 opM_rows =
rows( M_rows, M_cols, M_trans ),
401 opM_cols =
cols( M_rows, M_cols, M_trans ),
403 DenseLinAlgPack::Mp_MtM_assert_sizes(
405 ,M_rows, M_cols, M_trans
416 Workspace<value_type> t1_ws(wss,opM_cols),
419 t2(&t2_ws[0],t2_ws.size());
420 for( size_type j = 1; j <= opM_rows; ++j ) {
422 LinAlgOpPack::V_MtV(&t1,*
this,
trans_not(M_trans),e_j());
423 LinAlgOpPack::V_MtV(&t2,*
this,M_trans,t1);
425 if( S->
uplo() == BLAS_Cpp::upper )
430 if( S->
uplo() == BLAS_Cpp::upper )
441 const size_type
rows = this->
rows();
442 if(space_cols_.dim() !=
rows)
443 space_cols_.initialize(rows);
449 const size_type
cols = this->
cols();
450 if(space_rows_.dim() !=
cols)
451 space_rows_.initialize(cols);
455 std::ostream& MatrixOpSerial::output(std::ostream& out)
const {
519 ,
const Vector& v_rhs2, value_type beta)
const 523 this->
Vp_StMtV( &vs_lhs(), alpha, trans_rhs1, vs_rhs2(), beta );
531 this->
Vp_StMtV( &vs_lhs(), alpha, trans_rhs1, sv_rhs2, beta );
538 ,
const Vector& v_rhs3, value_type beta)
const 542 this->
Vp_StPtMtV( &vs_lhs(), alpha, P_rhs1, P_rhs1_trans, M_rhs2_trans, vs_rhs3(), beta );
552 this->
Vp_StPtMtV( &vs_lhs(), alpha, P_rhs1, P_rhs1_trans, M_rhs2_trans, sv_rhs3, beta );
557 ,
const Vector& v_rhs3)
const 561 return this->
transVtMtV(vs_rhs1(),trans_rhs2,vs_rhs3());
577 M_trans,alpha,P1,P1_trans,P2,P2_trans,beta
591 if(
const MatrixOpGetGMS* mwo_gms_rhs2 = dynamic_cast<const MatrixOpGetGMS*>(&mwo_rhs2)) {
597 if(
const MatrixSymOpGetGMSSym* mwo_sym_gms_rhs2 = dynamic_cast<const MatrixSymOpGetGMSSym*>(&mwo_rhs2)) {
603 if(
const MatrixOpGetGMSTri* mwo_tri_gms_rhs2 = dynamic_cast<const MatrixOpGetGMSTri*>(&mwo_rhs2)) {
friend void syr2k(const MatrixOp &M, BLAS_Cpp::Transp M_trans, value_type alpha, const GenPermMatrixSlice &P1, BLAS_Cpp::Transp P1_trans, const GenPermMatrixSlice &P2, BLAS_Cpp::Transp P2_trans, value_type beta, MatrixSymOp *symwo_lhs)
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
size_type dim() const
Return the number of elements in the full vector.
void Mp_StMtM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &mwo_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &mwo_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta=1.0)
mwo_lhs = alpha * op(mwo_rhs1) * op(mwo_rhs2) + beta * mwo_lhs (right) (xGEMM).
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
v_lhs *= alpha
Mix-in interface that allows the extraction of a const DenseLinAlgPack::DMatrixSliceTri view of an no...
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=1.0)
v_lhs = alpha * op(P_rhs1) * op(M_rhs2) * v_rhs3 + beta * v_rhs
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
v_lhs = alpha * v_rhs + v_lhs
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
void assign(VectorMutable *v_lhs, const V &V_rhs)
v_lhs = V_rhs.
Abstract interface that allows the extraction of a non-const DenseLinAlgPack::DMatrixSliceSym view of...
const_iterator end() const
Return the end of this->const_iterator_begin().
BLAS_Cpp::Uplo uplo() const
bool is_sorted() const
Return true if the sequence is assumed sorted.
value_type transVtMtV(const Vector &v_rhs1, const MatrixOp &M_rhs2, BLAS_Cpp::Transp trans_rhs2, const Vector &v_rhs3)
result = v_rhs1' * op(M_rhs2) * v_rhs3
friend void Mp_StPtMtP(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs, const GenPermMatrixSlice &P_rhs2, BLAS_Cpp::Transp P_rhs2_trans)
Base class for all matrices implemented in a shared memory address space.
Interface adding operations specific for a symmetric matrix {abstract}.
void syr2k(const MatrixOp &M, BLAS_Cpp::Transp M_trans, value_type alpha, const GenPermMatrixSlice &P1, BLAS_Cpp::Transp P1_trans, const GenPermMatrixSlice &P2, BLAS_Cpp::Transp P2_trans, value_type beta, MatrixSymOp *symwo_lhs)
symwo_lhs += alpha*op(P1')*op(M)*op(P2) + alpha*op(P2')*op(M')*op(P1) + beta*symwo_lhs ...
void Mp_StPtMtP(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs, const GenPermMatrixSlice &P_rhs2, BLAS_Cpp::Transp P_rhs2_trans)
mwo_lhs += alpha * op(P_rhs1) * op(M_rhs) * op(P_rhs2).
virtual size_type cols() const
Return the number of columns in the matrix.
This is a full random access iterator for accessing row and colunmn indices.
Abstract interface for objects that represent a space for mutable coordinate vectors.
const_iterator begin() const
Return a random access iterator for accessing which row and column that each nonzero 1...
friend void Mp_StMtM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &mwo_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &mwo_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta)
Extract a constant DenseLinAlgPack::DVectorSlice view of a Vector object.
Helper class type that simplifies the usage of the MatrixSymOpGetGMSSymMutable interface for clients...
void syrk(const MatrixOp &mwo_rhs, BLAS_Cpp::Transp M_trans, value_type alpha, value_type beta, MatrixSymOp *sym_lhs)
Perform a rank-k update of a symmetric matrix of the form:
void Mp_StMtP(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp M_trans, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans)
mwo_lhs += alpha * op(M_rhs) * op(P_rhs).
void Mp_StPtM(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans, const MatrixOp &M_rhs, BLAS_Cpp::Transp M_trans)
mwo_lhs += alpha * op(P) * op(M_rhs).
Create an eta vector (scaled by alpha = default 1).
void Mp_StM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
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)
void uninitialized_resize(size_type size, size_type nz, size_type max_nz, difference_type offset=0)
Resize to #size# with a max_nz# uninitialized non-zero elements.
friend void Mp_StM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
Abstract interface that allows the extraction of a const DMatrixSlice view of an abstract matrix...
Helper class type that simplifies the usage of the MatrixOpGetGMS interface for clients.
EOverLap overlap(const SparseVectorSlice< T_Element > &sv) const
Base class for all matrices that support basic matrix operations.
void Mt_S(MatrixOp *mwo_lhs, value_type alpha)
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
result = v_rhs1' * v_rhs2
Abstract interface that allows the extraction of a const DenseLinAlgPack::DMatrixSliceSym view of an ...
Transp trans_not(Transp _trans)
friend void Mp_StMtP(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp M_trans, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans)
Abstract interface that allows the extraction of a non-const DMatrixSlice view of an abstract matrix...
Abstract interface for mutable coordinate vectors {abstract}.
void initialize(index_type index, value_type value)
Initialize.
Extract a non-const DenseLinAlgPack::DVectorSlice view of a VectorMutable object. ...
virtual size_type rows() const
Return the number of rows in the matrix.
friend void syrk(const MatrixOp &mwo_rhs, BLAS_Cpp::Transp M_trans, value_type alpha, value_type beta, MatrixSymOp *sym_lhs)
DVectorSlice col(size_type j)
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
iterator begin()
Returns iterator that iterates forward through the nonzero elements.
size_type nz() const
Return the number of non-zero elements.
Concrete matrix type to represent general permutation (mapping) matrices.
friend void Mp_StPtM(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans, const MatrixOp &M_rhs, BLAS_Cpp::Transp M_trans)
Helper class type that simplifies the usage of the MatrixOpGetGMSMutable interface for clients...
DVectorSlice row(size_type i)