44 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_MatrixSymDiagStd.hpp"
45 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_SpVectorClass.hpp"
46 #include "DenseLinAlgPack_DVectorOp.hpp"
47 #include "DenseLinAlgPack_DMatrixOp.hpp"
48 #include "DenseLinAlgPack_AssertOp.hpp"
50 namespace AbstractLinAlgPack {
93 DenseLinAlgPack::Mp_M_assert_sizes( gms_lhs->rows(), gms_lhs->cols(),
BLAS_Cpp::no_trans
96 Vp_StV( &gms_lhs->diag(), alpha, diag_ );
101 ,
const DVectorSlice& vs_rhs2, value_type beta)
const
103 const DVectorSlice
diag = this->
diag();
109 DenseLinAlgPack::Vp_MtV_assert_sizes(
110 vs_lhs->size(), n, n, trans_rhs1, vs_rhs2.size() );
116 if( vs_rhs2.stride() == 1 && vs_lhs->stride() == 1 ) {
119 *d_itr = diag.raw_ptr(),
120 *x_itr = vs_rhs2.raw_ptr();
122 *y_itr = vs_lhs->raw_ptr(),
123 *y_end = y_itr + vs_lhs->size();
126 while( y_itr != y_end )
127 *y_itr++ = alpha * (*d_itr++) * (*x_itr++);
129 else if( beta == 1.0 ) {
130 while( y_itr != y_end )
131 *y_itr++ += alpha * (*d_itr++) * (*x_itr++);
134 for( ; y_itr != y_end; ++y_itr )
135 *y_itr = beta * (*y_itr) + alpha * (*d_itr++) * (*x_itr++);
140 DVectorSlice::const_iterator
141 d_itr = diag.begin(),
142 x_itr = vs_rhs2.begin();
143 DVectorSlice::iterator
144 y_itr = vs_lhs->begin(),
145 y_end = vs_lhs->end();
146 for( ; y_itr != y_end; ++y_itr, ++d_itr, ++x_itr ) {
147 #ifdef LINALGPACK_CHECK_RANGE
152 *y_itr = beta * (*y_itr) + alpha * (*d_itr) * (*x_itr);
159 ,
const SpVectorSlice& sv_rhs2, value_type beta)
const
161 const DVectorSlice diag = this->
diag();
164 DenseLinAlgPack::Vp_MtV_assert_sizes( vs_lhs->size()
165 , n, n, trans_rhs1, sv_rhs2.size() );
178 ; x_itr != sv_rhs2.end()
181 (*vs_lhs)(x_itr->indice() + sv_rhs2.offset())
182 += alpha *
diag(x_itr->indice() + sv_rhs2.offset()) * x_itr->value();
192 ,
const DVectorSlice& vs_rhs2)
const
194 const DVectorSlice diag = this->
diag();
203 DenseLinAlgPack::Vp_MtV_assert_sizes( vs_lhs->size()
204 , n, n, trans_rhs1, vs_rhs2.size() );
206 if( vs_rhs2.stride() == 1 && vs_lhs->stride() == 1 ) {
209 *d_itr = diag.raw_ptr(),
210 *x_itr = vs_rhs2.raw_ptr();
212 *y_itr = vs_lhs->raw_ptr(),
213 *y_end = y_itr + vs_lhs->size();
214 while( y_itr != y_end )
215 *y_itr++ = (*x_itr++) / (*d_itr++);
219 DVectorSlice::const_iterator
220 d_itr = diag.begin(),
221 x_itr = vs_rhs2.begin();
222 DVectorSlice::iterator
223 y_itr = vs_lhs->begin(),
224 y_end = vs_lhs->end();
225 for( ; y_itr != y_end; ++y_itr, ++d_itr, ++x_itr ) {
229 *y_itr = (*x_itr)/(*d_itr);
236 ,
const SpVectorSlice& sv_rhs2)
const
238 const DVectorSlice diag = this->
diag();
249 DenseLinAlgPack::Vp_MtV_assert_sizes( vs_lhs->size()
250 , n, n, trans_rhs1, sv_rhs2.size() );
253 ; x_itr != sv_rhs2.end()
256 (*vs_lhs)(x_itr->indice() + sv_rhs2.offset())
257 = x_itr->value() /
diag(x_itr->indice() + sv_rhs2.offset());
size_type cols() const
Returns this->rows()
void init_diagonal(const Vector &diag)
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
v_lhs *= alpha
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
v_lhs = alpha * v_rhs + v_lhs
MatrixSymDiagStd(const VectorSpace::vec_mut_ptr_t &diag=Teuchos::null, bool unique=true)
Calls this->initialize().
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta) const
bool Mp_StM(MatrixOp *g_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs) const
Add to a mutable matrix lhs.
const element_type * const_iterator
void V_InvMtV(VectorMutable *v_lhs, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2) const
void init_identity(const VectorSpace &space_diag, value_type alpha)
size_type rows() const
Returns 0 if not initalized (this->diag() == NULL).
VectorMutable & diag()
Give non-const access to the diagonal vector.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)