[eigen] SparseMatrix<> constructor

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,



I'd have a need for such a constructor :

template<typename ValIt, typename Idx1It, typename Idx2It>

SparseMatrix(ValIt vals_begin, ValIt vals_end, Idx1It idx1_begin,

Idx2_begin);



that would be equivalent to :



template<typename SparseType, typename ValIt, typename RowsIt, typename

ColsIt> 

SparseType construct(typename ei_traits<SparseType>::Index rows_size,

typename ei_traits<SparseType>::Index cols_size

, ValIt vals_begin, ValIt vals_end, RowsIt rows_begin, ColsIt cols_begin){



SparseType r(rows_size, cols_size);

{

   RandomSetter<SparseType > setter(r);

   for(; vals_begin != vals_end; ++vals_begin, ++rows_begin,

++cols_begin){

        setter(*rows_begin, *cols_begin)= *vals_begin;

   }

}

return r;

}



Isn't such use case common enough to warrant an appropriate constructor

for SparseMatrix ?



Best Regards,

Bernard



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/