Re: [eigen] Valid use case for creating a SparseMatrix? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Valid use case for creating a SparseMatrix?
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Thu, 7 Apr 2011 11:58:17 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=ry4w5yj/TfrK+OJFcYNQw+uxnCSSnmZQuFT64/4V7IM=; b=d+lMMbrpR31uKSEpt72cTkLj9p3mM5eP4+jemQyURalVRD+u0EWovjBo/C+KLUXrY4 I5l8sfqKgbY861AjXlFlbQD854MI1d5XC0S6MznT1+L6q16638/NioPSZsUVWFAJU5vZ kvkzx1L16DSEnZ9naHWBlYtBY/+7wv8Y8qbSA=
- 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; b=Pp8DlRj2nJMsZcsOOhxHYGaDsmVSHq/XTraNEUxHbMG1FBthrPkPTb9+o4JnDRZcQq 5VGoA3QOhwtJkXQqMVILxPEL7ww+uWfukagPwk+aXaTCet8n/cblh82qn+5WXUN4Cb8S Jg+qvJUDkmgIKRWtFsAFK5SqjKR6dw75kcFZw=
another option would be a special version of insert(), like insertAndExpand()
gael
On Thu, Apr 7, 2011 at 11:56 AM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> Hi,
>
>
> why not. We could also make it explicit by allowing Dynamic for the sizes:
>
> SparseMatrix<...> mat(Dynamic,Dynamic)
> // insertions
> mat.finalize();
>
> mat.resize(Dynamic,Dynamic);
> // insertions
> mat.finalize();
>
> And one could make it Dynamic in only one dimension.
>
> gael
>
> what about a conservativeResize(rows,cols) function. You would still
> be responsible of tracking the largest "inner" index, and to call
> conservativeResize() anytime you
>
> On Wed, Apr 6, 2011 at 3:37 PM, Jens Mueller <jens.k.mueller@xxxxxx> wrote:
>> Hi,
>>
>> I know that the Sparse API isn't stable yet. I'm using it though. At the
>> moment I'm filling a sparse matrix and I stumbled over a little problem
>> and I'd like to know what's your view on the matter.
>> When filling the matrix I do not know in advance how many cols/rows it
>> contains. I know that they are sorted such that I can use the
>> SparseMatrix class. Interestingly for the SparseVector I can fill it
>> without knowing the number of values and without specifying the number
>> of cols, rows respectively. Technically SparseMatrix could offer the
>> same. I know this might be rather rare use case. In my case I need to
>> get the data from a text file into Eigen but the file format doesn't
>> give the dimensions of the matrix. So I first parse into std::vector to
>> determine the maximal column index and then convert from there to a
>> SparseMatrix in Eigen. The same holds for the number of rows.
>> Usually a sparse matrix is seen as a special matrix and for a matrix you
>> have to specify the dimensions when declaring it but seen from a data
>> structural point of view (in this case assuming the compress row/col
>> storage format) you don't have to specify the dimensions.
>> SparseMatrix<double> matrix; // I do not know the dimensions here
>> // filling in sorted color major here
>> // this will fix the maximal indices for rows/cols
>> matrix.finalize(); // sets the dimensions appropriately
>>
>> Jens
>>
>>
>>
>