127 for ( vector<Index>::iterator j =
mcolptr.begin() + c + 1;
137 return *(
mdata.insert(
mdata.begin()+i, 0 ) );
153 {
return this->
ro(r, c); }
189 for (
Index i=begin; i<end; ++i )
286 vector<Index> mrowind_ref(
mrowind.size());
289 vector<Numeric> mdata_ref(
mdata.size());
292 mrowind.resize(mrowind_ref.size()+rnnz);
293 mdata.resize(mdata_ref.size()+rnnz);
297 vector<Index>::iterator mrowind_it =
mrowind.begin();
298 vector<Numeric>::iterator mdata_it =
mdata.begin();
301 Index colptr_mod = 0;
308 vector<Numeric>::iterator dstart = mdata_ref.begin()+
mcolptr[i];
309 vector<Numeric>::iterator dend = mdata_ref.begin()+
mcolptr[i+1];
310 vector<Index>::iterator rstart = mrowind_ref.begin()+
mcolptr[i];
311 vector<Index>::iterator rend = mrowind_ref.begin()+
mcolptr[i+1];
321 vector<Index>::iterator rpos = find(rstart,rend,r);
322 vector<Numeric>::iterator dpos = dstart+(rpos-rstart);
330 copy(rstart,rend,mrowind_it);
331 copy(dstart,dend,mdata_it);
334 mrowind_it += rend-rstart;
335 mdata_it += dend-dstart;
338 colptr_mod =
mcolptr[i]+(rend-rstart);
344 rpos = find_if(rstart,rend,bind2nd(std::greater<Index>(),r));
345 dpos = dstart+(rpos-rstart);
348 copy(rstart,rpos,mrowind_it);
349 copy(dstart,dpos,mdata_it);
353 mrowind_it += rpos-rstart;
354 mdata_it += dpos-dstart;
367 copy(rpos,rend,mrowind_it);
368 copy(dpos,dend,mdata_it);
371 mrowind_it += rend-rpos;
372 mdata_it += dend-dpos;
375 colptr_mod =
mcolptr[i]+(rend-rstart+1);
382 vector<Index>::iterator rpos = find(rstart,rend,r);
383 vector<Numeric>::iterator dpos = dstart+(rpos-rstart);
388 remove_copy(rstart,rend,mrowind_it, *rpos);
389 remove_copy(dstart,dend,mdata_it, *dpos);
392 mrowind_it += rend-rstart-1;
393 mdata_it += dend-dstart-1;
396 colptr_mod =
mcolptr[i]+(rend-rstart-1);
402 copy(rstart,rend,mrowind_it);
403 copy(dstart,dend,mdata_it);
406 mrowind_it += rend-rstart;
407 mdata_it += dend-dstart;
410 colptr_mod =
mcolptr[i]+(rend-rstart);
415 *(
mcolptr.end()-1) = colptr_mod;
439 mcolptr = vector<Index>( c+1, n);
441 mdata = vector<Numeric>(n,1.0);
445 vector<Index>::iterator rit =
mrowind.begin();
446 vector<Index>::iterator cit =
mcolptr.begin();
447 for(
Index i=0; i<n; i++ ) {
477 mcolptr = vector<Index>(c+1,0);
497 for (
size_t c=0; c<v.
mcolptr.size()-1; ++c)
508 for (
Index i=begin; i<end; ++i )
514 os << setw(3) << r <<
" "
515 << setw(3) << c <<
" "
516 << setw(3) << v.
mdata[i] <<
"\n";
548 for (
Index i=0; i<end; i++)
584 assert( y.
nelem() ==
M.nrows() );
585 assert(
M.ncols() == x.
nelem() );
592 for (
size_t c=0; c<
M.mcolptr.size()-1; ++c)
595 Index begin =
M.mcolptr[c];
600 const Index end =
M.mcolptr[c+1];
603 for (
Index i=begin; i<end; ++i )
609 y[r] +=
M.mdata[i] * x[c];
639 assert( A.
ncols() ==
C.ncols() );
640 assert( B.
ncols() ==
C.nrows() );
646 for (
size_t c=0; c<B.
mcolptr.size()-1; ++c)
657 for (
Index i=begin; i<end; ++i )
664 for (
Index j=0; j<
C.ncols(); j++)
670 A(r,j) += B.
mdata[i] *
C(c,j);
695 if ( B.
mdata.size() == 0)
return;
707 vector<Index>::const_iterator startrow, stoprow;
715 for (
Index i=*startrow; i<=*stoprow; i++)
728 vector<Numeric>::iterator dataA_it = A.
mdata.begin();
729 vector<Index>::iterator rowindA_it = A.
mrowind.begin();
733 for (
size_t c=0; c<A.
mcolptr.size(); ++c)
737 for (
size_t i=0; i<B.
mcolptr.size()-1; i++)
741 vector<Index>::const_iterator elem_it =
755 vector<Numeric>::const_iterator elemdata_it=B.
mdata.begin() + diff;
756 *dataA_it = *elemdata_it;
786 assert( A.
ncols() ==
C.ncols() );
787 assert( B.
ncols() ==
C.nrows() );
803 for (
size_t c=0; c<
C.mcolptr.size()-1; ++c)
809 for (
size_t b=0; b<Bt.
mcolptr.size()-1; ++b)
813 std::set<Index> colintersec;
814 set_intersection(
C.mrowind.begin()+*(
C.mcolptr.begin()+c),
815 C.mrowind.begin()+*(
C.mcolptr.begin()+c+1),
818 inserter(colintersec, colintersec.begin()));
822 if (!colintersec.empty())
825 for (std::set<Index>::iterator i=colintersec.begin();
826 i!=colintersec.end(); ++i)
835 vector<Index>::const_iterator rowindBt_it =
838 vector<Index>::const_iterator rowindC_it =
839 find(
C.mrowind.begin()+*(
C.mcolptr.begin()+c),
840 C.mrowind.begin()+*(
C.mcolptr.begin()+c+1), *i);
842 vector<Numeric>::const_iterator dataBt_it =
844 vector<Numeric>::const_iterator dataC_it =
845 C.mdata.begin()+(rowindC_it-
C.mrowind.begin());
847 tempA += *dataBt_it * *dataC_it;
876 assert( B.
ncols() ==
C.ncols() );
877 assert( B.
nrows() ==
C.nrows() );
883 if (B.
data().size() <
C.data().size())
894 for (
size_t c = 0; c < D->
mcolptr.size()-1; ++c)
925 assert( B.
ncols() ==
C.ncols() );
926 assert( B.
nrows() ==
C.nrows() );
930 for (
size_t c = 0; c <
C.mcolptr.size()-1; ++c)
933 for (
Index i =
C.mcolptr[c]; i <
C.mcolptr[c+1]; ++i)
935 A.
rw(
C.mrowind[i], c) -=
C.mdata[i];