104 const Index end = (*mcolptr)[c+1];
112 Index rowi = (*mrowind)[i];
124 for ( vector<Index>::iterator j =
mcolptr->begin() + c + 1;
134 return *(
mdata->insert(
mdata->begin()+i, 0 ) );
150 {
return this->
ro(r, c); }
176 Index begin = (*mcolptr)[c];
181 const Index end = (*mcolptr)[c+1];
186 for (
Index i=begin; i<end; ++i )
188 Index rowi = (*mrowind)[i];
237 mrowind(new vector<
Index>),
238 mcolptr(new vector<
Index>(c+1,0)),
324 vector<Index> mrowind_ref(
mrowind->size());
326 vector<Numeric> mdata_ref(
mdata->size());
328 mrowind->resize(mrowind_ref.size()+rnnz);
329 mdata->resize(mdata_ref.size()+rnnz);
333 vector<Index>::iterator mrowind_it =
mrowind->begin();
334 vector<Numeric>::iterator mdata_it =
mdata->begin();
337 Index colptr_mod = 0;
344 vector<Numeric>::iterator dstart =
345 mdata_ref.begin()+(*mcolptr)[i];
346 vector<Numeric>::iterator dend =
347 mdata_ref.begin()+(*mcolptr)[i+1];
348 vector<Index>::iterator rstart =
349 mrowind_ref.begin()+(*mcolptr)[i];
350 vector<Index>::iterator rend =
351 mrowind_ref.begin()+(*mcolptr)[i+1];
355 (*mcolptr)[i] = colptr_mod;
361 vector<Index>::iterator rpos = find(rstart,rend,r);
362 vector<Numeric>::iterator dpos = dstart+(rpos-rstart);
370 copy(rstart,rend,mrowind_it);
371 copy(dstart,dend,mdata_it);
374 mrowind_it += rend-rstart;
375 mdata_it += dend-dstart;
378 colptr_mod = (*mcolptr)[i]+(rend-rstart);
384 rpos = find_if(rstart,rend,bind2nd(greater<Index>(),r));
385 dpos = dstart+(rpos-rstart);
388 copy(rstart,rpos,mrowind_it);
389 copy(dstart,dpos,mdata_it);
393 mrowind_it += rpos-rstart;
394 mdata_it += dpos-dstart;
407 copy(rpos,rend,mrowind_it);
408 copy(dpos,dend,mdata_it);
411 mrowind_it += rend-rpos;
412 mdata_it += dend-dpos;
415 colptr_mod = (*mcolptr)[i]+(rend-rstart+1);
422 vector<Index>::iterator rpos = find(rstart,rend,r);
423 vector<Numeric>::iterator dpos = dstart+(rpos-rstart);
428 remove_copy(rstart,rend,mrowind_it, *rpos);
429 remove_copy(dstart,dend,mdata_it, *dpos);
432 mrowind_it += rend-rstart-1;
433 mdata_it += dend-dstart-1;
436 colptr_mod = (*mcolptr)[i]+(rend-rstart-1);
442 copy(rstart,rend,mrowind_it);
443 copy(dstart,dend,mdata_it);
446 mrowind_it += rend-rstart;
447 mdata_it += dend-dstart;
450 colptr_mod = (*mcolptr)[i]+(rend-rstart);
455 *(
mcolptr->end()-1) = colptr_mod;
484 mcolptr =
new vector<Index>( c+1, n);
486 mrowind =
new vector<Index>(n);
488 mdata =
new vector<Numeric>(n,1.0);
492 vector<Index>::iterator rit =
mrowind->begin();
493 vector<Index>::iterator cit =
mcolptr->begin();
494 for(
Index i=0; i<n; i++ ) {
523 mdata =
new vector<Numeric>;
527 mcolptr =
new vector<Index>(c+1,0);
601 for (
size_t c=0; c<v.
mcolptr->size()-1; ++c)
612 for (
Index i=begin; i<end; ++i )
618 os << setw(3) << r <<
" "
619 << setw(3) << c <<
" "
620 << setw(3) << (*v.
mdata)[i] <<
"\n";
652 for (
Index i=0; i<end; i++)
688 assert( y.
nelem() ==
M.nrows() );
689 assert(
M.ncols() == x.
nelem() );
696 for (
size_t c=0; c<
M.mcolptr->size()-1; ++c)
699 Index begin = (*
M.mcolptr)[c];
704 const Index end = (*
M.mcolptr)[c+1];
707 for (
Index i=begin; i<end; ++i )
710 Index r = (*
M.mrowind)[i];
713 y[r] += (*
M.mdata)[i] * x[c];
749 for (
size_t c=0; c<B.
mcolptr->size()-1; ++c)
760 for (
Index i=begin; i<end; ++i )
773 A(r,j) += (*B.
mdata)[i] * C(c,j);
798 if ( B.
mdata->size() == 0)
return;
810 vector<Index>::iterator startrow, stoprow;
818 for (
Index i=*startrow; i<=*stoprow; i++)
831 vector<Numeric>::iterator dataA_it = A.
mdata->begin();
832 vector<Index>::iterator rowindA_it = A.
mrowind->begin();
836 for (
size_t c=0; c<A.
mcolptr->size(); ++c)
840 for (
size_t i=0; i<B.
mcolptr->size()-1; i++)
844 vector<Index>::iterator elem_it =
858 vector<Numeric>::iterator elemdata_it=B.
mdata->begin() + diff;
859 *dataA_it = *elemdata_it;
906 for (
size_t c=0; c<C.
mcolptr->size()-1; ++c)
912 for (
size_t b=0; b<Bt.
mcolptr->size()-1; ++b)
916 set<Index> colintersec;
921 inserter(colintersec, colintersec.begin()));
925 if (!colintersec.empty())
928 for (set<Index>::iterator i=colintersec.begin();
929 i!=colintersec.end(); ++i)
938 vector<Index>::iterator rowindBt_it =
941 vector<Index>::iterator rowindC_it =
945 vector<Numeric>::iterator dataBt_it =
947 vector<Numeric>::iterator dataC_it =
950 tempA += *dataBt_it * *dataC_it;
986 if (B.
data()->size() < C.
data()->size())
997 for (
size_t c = 0; c < D->
mcolptr->size()-1; ++c)
1033 for (
size_t c = 0; c < C.
mcolptr->size()-1; ++c)