47 #include "AbstractLinAlgPack_MatrixSymDiagSparse.hpp"
48 #include "AbstractLinAlgPack_SpVectorClass.hpp"
49 #include "AbstractLinAlgPack_EtaVector.hpp"
50 #include "AbstractLinAlgPack_AssertOp.hpp"
51 #include "AbstractLinAlgPack_SpVectorOut.hpp"
52 #include "DenseLinAlgPack_DVectorClass.hpp"
53 #include "DenseLinAlgPack_DMatrixAssign.hpp"
54 #include "DenseLinAlgPack_DMatrixClass.hpp"
55 #include "DenseLinAlgPack_DMatrixOp.hpp"
56 #include "DenseLinAlgPack_assert_print_nan_inf.hpp"
57 #include "DenseLinAlgPack_LinAlgOpPack.hpp"
58 #include "Teuchos_Assert.hpp"
63 T my_min(
const T& v1,
const T& v2 ) {
return v1 < v2 ? v1 : v2; }
66 namespace AbstractLinAlgPack {
69 : num_updates_at_once_(0)
83 out <<
"*** Sparse diagonal matrix ***\n"
84 <<
"diag =\n" <<
diag();
95 size_type n = diag.
dim();
99 DenseLinAlgPack::Vp_MtV_assert_sizes( vs_lhs->
dim(), n, n, trans_rhs1, vs_rhs2.
dim() );
109 const size_type i = d_itr->index();
110 (*vs_lhs)(i) = beta * (*vs_lhs)(i) + alpha * d_itr->value() * vs_rhs2(i);
127 using DenseLinAlgPack::nonconst_tri_ele;
130 using DenseLinAlgPack::assert_print_nan_inf;
132 using LinAlgOpPack::V_MtV;
137 DenseLinAlgPack::MtV_assert_sizes(
142 DenseLinAlgPack::Vp_V_assert_sizes(
204 = my_min( num_updates_at_once()
205 ? num_updates_at_once()
212 num_blocks = diag.
nz() / num_updates;
213 if( diag.
nz() % num_updates > 0 )
222 for( size_type k = 1; k <= num_blocks; ++k ) {
224 i1 = (k-1) * num_updates + 1,
225 i2 = my_min( diag.
nz(), i1 + num_updates - 1 );
228 m_itr = diag.
begin() + (i1-1);
229 for( size_type l = 1; l <= i2-i1+1; ++l, ++m_itr ) {
233 , eta( m_itr->
index(), n, std::sqrt(m_itr->
value()) )() );
236 D_update = D(1,m,1,i2-i1+1);
261 ,
const index_type len_Aval
263 ,
const index_type len_Aij
266 ,
const index_type row_offset
267 ,
const index_type col_offset
274 (len_Aval != 0 ? len_Aval != diag.
nz() : Aval != NULL)
275 ,std::invalid_argument
276 ,
"MatrixSymDiagSparse::coor_extract_nonzeros(...): Error!" );
278 (len_Aij != 0 ? len_Aij != diag.
nz() : (Acol != NULL || Acol != NULL) )
279 ,std::invalid_argument
280 ,
"MatrixSymDiagSparse::coor_extract_nonzeros(...): Error!" );
285 FortranTypes::f_dbl_prec
287 for( itr = diag.
begin(), l_Aval = Aval; itr != diag.end(); ++itr ) {
288 *l_Aval++ = itr->
value();
296 for( itr = diag.
begin(), l_Arow = Arow, l_Acol = Acol; itr != diag.end(); ++itr ) {
299 *l_Arow++ = ij + row_offset;
300 *l_Acol++ = ij + col_offset;
difference_type offset() const
Return the offset for the indexes (ith real index = begin()[i-1]->index() + offset()# ...
size_type dim() const
Return the number of elements in the full vector.
virtual const SpVectorSlice diag() const =0
Give access to the sparse diagonal.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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.
BLAS_Cpp::Uplo uplo() const
Base class for all matrices implemented in a shared memory address space.
const index_type & index() const
virtual size_type cols() const
Return the number of columns in the matrix.
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:
DVectorSlice col(size_type j)
void Vp_StMtV(DVectorSlice *vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const DVectorSlice &vs_rhs2, value_type beta) const
Create an eta vector (scaled by alpha = default 1).
void coor_extract_nonzeros(EExtractRegion extract_region, EElementUniqueness element_uniqueness, const index_type len_Aval, value_type Aval[], const index_type len_Aij, index_type Arow[], index_type Acol[], const index_type row_offset, const index_type col_offset) const
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:
MatrixSymDiagSparse()
The default value of num_updates_at_once == 0 is set to allow this class to determine the appropriate...
std::ostream & output(std::ostream &out) const
Transp trans_not(Transp _trans)
Sparse storage element type.
virtual size_type rows() const
Return the number of rows in the matrix.
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
size_type nz() const
Return the number of non-zero elements.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
void Mp_StMtMtM(DMatrixSliceSym *sym_lhs, value_type alpha, EMatRhsPlaceHolder dummy_place_holder, const MatrixOpSerial &mwo_rhs, BLAS_Cpp::Transp mwo_rhs_trans, value_type beta) const
Computes the dense symmetric matrix B += a*op(A')*M*op(A).
index_type num_nonzeros(EExtractRegion extract_region, EElementUniqueness element_uniqueness) const