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:56:53 +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=gDwpzVzfdweUNIHnbi9KAdjfd6xUqEENpgOsVmUMPlw=; b=WLUMAnQXGn5FmmWWaus/8rzE4k8l5tq08Q/2Ryk0RYxdyCplOpoLC3qA8NjhUzeYTJ xqZM6re35321rnW8t366qOgEYLuratgLl0YJDFcFBJE+4HMqf1Bw8UQGpca0mmDAavjS KkOY5KrUGDYMFTnNdsRN5BZrlnmcE90pDDDQY=
- 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=DjXbL+ycmE8Yi8wFErjWk9FJ7DSXqin/CiUN0OnrAuM5i8rL0XTh+DLZmrUL7sxbkq fbEcxDNI2iKpe8eGOFdrYgA30r0EAhHip5jCUm8Cu2TaTrZMsTV6/vZ/6QvinflnHhCF 5PgDV/NCdTpyYZpIxOfHN6akpLBNsokzT4/r8=
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
>
>
>