*** empty log message ***

This commit is contained in:
jiri
2005-02-02 14:49:33 +00:00
parent 2af0920423
commit 10c0143fc4
2 changed files with 45 additions and 24 deletions

View File

@@ -490,15 +490,22 @@ template <class T>
void SparseMat<T>::diagonalof(NRVec<T> &r) const
{
#ifdef DEBUG
if(nn!=mm) laerror("diagonalof() non-square sparse matrix");
if((int)mm!=r.size()) laerror("incompatible vector size in diagonalof()");
#endif
matel<T> *l=list;
r=(T)0;
while(l)
{
if(l->row == l->col) r[l->row]+= l->elem;
l= l->next;
}
if(nn==mm) //square
while(l)
{
if(l->row == l->col) r[l->row]+= l->elem;
l= l->next;
}
else //diagonal of A^TA, assuming it has been simplified (only one entry per position), will be used as preconditioner only anyway
while(l)
{
r[l->col] += l->elem*l->elem *(l->col!=l->row && symmetric?2.:1.);
l= l->next;
}
}