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"
62 namespace LinAlgOpPack {
68 namespace AbstractLinAlgPack {
86 for( size_type j = 1; j <=n; ++j ) {
88 this->
Vp_StMtV( &gms_lhs->
col(j), alpha, trans_rhs, rhs(), 1.0 );
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 );
155 LinAlgOpPack::V_StMtV(&t,a,*
this,M_trans,x);
156 LinAlgOpPack::Vp_MtV( y, P, P_trans, t, b );
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 ) {
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();
449 const size_type
cols = this->
cols();
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)) {
std::ostream & output(std::ostream &out) const
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}.
virtual void Mp_StPtM(DMatrixSlice *gms_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans, BLAS_Cpp::Transp M_trans) const
gms_lhs += alpha * op(P) * op(M_rhs)
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
virtual void Mp_StMtP(DMatrixSlice *gms_lhs, value_type alpha, BLAS_Cpp::Transp M_trans, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans) const
gms_lhs += alpha * op(M_rhs) * op(P_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)
const VectorSpace & space_cols() const
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().
virtual void syr2k(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, DMatrixSliceSym *sym_lhs) const
Perform a specialized rank-2k update of a dense symmetric matrix of the form:
BLAS_Cpp::Uplo uplo() const
bool is_sorted() const
Return true if the sequence is assumed sorted.
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.
virtual void Mp_StM(DMatrixSlice *gms_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs) const
gms_lhs += alpha * op(M_rhs) (BLAS xAXPY)
Interface adding operations specific for a symmetric matrix {abstract}.
virtual value_type transVtMtV(const DVectorSlice &vs_rhs1, BLAS_Cpp::Transp trans_rhs2, const DVectorSlice &vs_rhs3) const
result = vs_rhs1' * op(M_rhs2) * vs_rhs3
virtual void Mp_StMtM(DMatrixSlice *gms_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const DMatrixSlice &gms_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta) const
gms_lhs = alpha * op(M_rhs1) * op(gms_rhs2) + beta * gms_lhs (right) (xGEMM)
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...
index_type dim() const
Returns 0 if uninitialized.
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.
virtual void syrk(BLAS_Cpp::Transp M_trans, value_type alpha, value_type beta, DMatrixSliceSym *sym_lhs) const
Perform a rank-k update of a dense symmetric matrix of the form:
void Mt_S(MatrixOp *mwo_lhs, value_type alpha)
virtual void Vp_StPtMtV(DVectorSlice *vs_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, BLAS_Cpp::Transp M_rhs2_trans, const DVectorSlice &vs_rhs3, value_type beta) const
vs_lhs = alpha * op(P_rhs1) * op(M_rhs2) * vs_rhs3 + beta * vs_rhs
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)
void initialize(size_type dim)
Initialize given the dimension of the vector space.
virtual void Vp_StMtV(DVectorSlice *vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const DVectorSlice &vs_rhs2, value_type beta) const =0
vs_lhs = alpha * op(M_rhs1) * vs_rhs2 + beta * vs_lhs (BLAS xGEMV)
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...
virtual void Mp_StPtMtP(DMatrixSlice *gms_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, BLAS_Cpp::Transp M_trans, const GenPermMatrixSlice &P_rhs2, BLAS_Cpp::Transp P_rhs2_trans) const
gms_lhs += alpha * op(P_rhs1) * op(M_rhs) * op(P_rhs2)
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.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()
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)
const VectorSpace & space_rows() const
Helper class type that simplifies the usage of the MatrixOpGetGMSMutable interface for clients...
DVectorSlice row(size_type i)