struct NRsparseCol { Int nrows; Int nvals; VecInt row_ind; VecDoub val; NRsparseCol(Int m,Int nnvals) : nrows(m), nvals(nnvals), row_ind(nnvals,0),val(nnvals,0.0) {} NRsparseCol() : nrows(0),nvals(0),row_ind(),val() {} void resize(Int m, Int nnvals) { nrows = m; nvals = nnvals; row_ind.assign(nnvals,0); val.assign(nnvals,0.0); } }; struct NRsparseMat { Int nrows; Int ncols; Int nvals; VecInt col_ptr; VecInt row_ind; VecDoub val; NRsparseMat(); NRsparseMat(Int m,Int n,Int nnvals); VecDoub ax(const VecDoub &x) const; VecDoub atx(const VecDoub &x) const; NRsparseMat transpose() const; }; NRsparseMat::NRsparseMat() : nrows(0),ncols(0),nvals(0),col_ptr(), row_ind(),val() {} NRsparseMat::NRsparseMat(Int m,Int n,Int nnvals) : nrows(m),ncols(n), nvals(nnvals),col_ptr(n+1,0),row_ind(nnvals,0),val(nnvals,0.0) {} VecDoub NRsparseMat::ax(const VecDoub &x) const { VecDoub y(nrows,0.0); for (Int j=0;jcol_ptr[j]=nvals; for (i=AT.col_ptr[j];irow_ind[nvals]=h; nvals++; } } } } adat->col_ptr[m]=nvals; for (j=0;jcol_ptr[j]; Int size=adat->col_ptr[j+1]-i; if (size > 1) { VecInt col(size,&adat->row_ind[i]); sort(col); for (k=0;krow_ind[i+k]=col[k]; } } } void ADAT::updateD(const VecDoub &D) { Int h,i,j,k,l,m=a.nrows,n=a.ncols; VecDoub temp(n),temp2(m,0.0); for (i=0;icol_ptr[i];jcol_ptr[i+1];j++) { k=adat->row_ind[j]; adat->val[j]=temp2[k]; temp2[k]=0.0; } } } NRsparseMat & ADAT::ref() { return *adat; } ADAT::~ADAT() { delete adat; }