Re: [eigen] SparseMatrix<> constructor |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] SparseMatrix<> constructor
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Thu, 22 Jul 2010 18:10:04 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=7Ag7PA7/CFtbOiSdXitmEPzw4nT9Hhskh+dd/41MFB0=; b=RcNEp0hHcPxzMJlsyC0kil/3oY96b1rKU5aiww/2cPZJfWUSE47F+jcdOP3wsjTany 8fLsH5Kl6CFvpIa0r0jHsd3mtXCQUjRqW7v5u9cKKYGMF8D6KqAogYOnctzw9aZPPfVz 7/difhEpptnOa4toaXgqnuq08tti5KQjnLCRQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=t4+4EdBDgenSDohZs4F2hk6YF5c1OJSNEQW1Rx0DU2dFdHHR/uMBGsXSgoW6s+a3e/ +5y8MFFd/yyUEZgg6rqtv5+RcNNyjP984BPbpEAHs2+7x90/+1EdXZL7Dj5iPkiZmcRY VFbeFJI+Gf5Scmohix6GUgB1UxDCBcmJ3A4qE=
Hello Bernard,
sorry for the delay,
yes such a "triplet" constructor has already been requested/suggested
a few weeks ago. However, I'm still not sure how to expose it:
- via a simple ctor
- via a tiny "TripletSparseWrapper" with some more advanced features....*
or maybe both, the former being implemented on top of the later...
Also, once we have the triplet it is probably more efficient to run a
quick sort on them rather than doing random insertions....
gael
On Fri, Jul 16, 2010 at 2:19 PM, <bernard.hugueney@xxxxxxxxxx> wrote:
>
> 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
>
>
>