42 #include "AbstractLinAlgPack_SpVectorOp.hpp"
47 template<
int N,
class T>
48 class assert_compile_time {
63 class assert_compile_time<0,double> {
71 % (int)
sizeof(DenseLinAlgPack::value_type))
74 validate_value_stride;
78 % (int)
sizeof(DenseLinAlgPack::index_type))
81 validate_index_stride;
84 void AbstractLinAlgPack::add_elements( SpVector* sv_lhs, value_type alpha,
const DVectorSlice& vs_rhs
87 typedef SpVector::element_type ele_t;
88 const bool assume_sorted = !sv_lhs->nz() || ( sv_lhs->nz() && sv_lhs->is_sorted() );
89 DVectorSlice::const_iterator
92 for(
size_type i = 1; i <= vs_rhs.dim(); ++i )
93 sv_lhs->add_element( ele_t( i + offset, alpha * (*itr++) ) );
96 for(
size_type i = 1; i <= vs_rhs.dim(); ++i, ++itr )
98 sv_lhs->add_element( ele_t( i + offset, alpha * (*itr) ) );
100 sv_lhs->assume_sorted(assume_sorted);
103 void AbstractLinAlgPack::add_elements( SpVector* sv_lhs, value_type alpha,
const SpVectorSlice& sv_rhs
106 typedef SpVector::element_type ele_t;
107 const bool assume_sorted = ( !sv_lhs->nz() || ( sv_lhs->nz() && sv_lhs->is_sorted() ) )
108 && ( !sv_rhs.nz() || ( sv_rhs.nz() || sv_rhs.is_sorted() ) );
110 for( SpVectorSlice::const_iterator itr = sv_rhs.begin(); itr != sv_rhs.end(); ++itr )
111 sv_lhs->add_element( ele_t( itr->index() + sv_rhs.offset() + offset, alpha * (itr->value()) ) );
114 for( SpVectorSlice::const_iterator itr = sv_rhs.begin(); itr != sv_rhs.end(); ++itr )
115 if(itr->value() != 0.0 )
116 sv_lhs->add_element( ele_t( itr->index() + sv_rhs.offset() + offset, alpha * (itr->value()) ) );
118 sv_lhs->assume_sorted(assume_sorted);
Sparse storage element type.