Newer
Older
const std::vector<T>& Mval = M._val[c];
for (unsigned int i=0; i<Mri.size(); i++) {
AddTo(Mri[i]+1,c+1,s*Mval[i]);
}
}
}
return(*this);
}
*/
/*###################################################################
##
## Here starts functions for helper class Accumulator
##
###################################################################*/
template<class T>
T& Accumulator<T>::operator()(unsigned int i)
{
if (!_occ[i]) {
if (_sorted && _no && i < _occi[_no-1]) _sorted = false;
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
_occ[i] = true;
_occi[_no++] = i;
}
return(_val[i]);
}
template<class T>
const Accumulator<T>& Accumulator<T>::ExtractCol(const SpMat<T>& M, unsigned int c)
{
if (_sz != M._m) throw ;
if (c<0 || c>(M._n-1)) throw ;
if (_no) Reset();
const std::vector<unsigned int>& ri = M._ri[c];
const std::vector<T>& val = M._val[c];
for (unsigned int i=0; i<ri.size(); i++) {
_occ[ri[i]] = true;
_val[ri[i]] = val[i];
_occi[_no++] = ri[i];
}
_sorted = true; // Assuming M is sorted (should be)
return(*this);
}
} // End namespace MISCMATHS
#endif // End #ifndef SpMat_h