|[eigen] Re: Index type for PermutationMatrix and Transpositions|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] Re: Index type for PermutationMatrix and Transpositions
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Tue, 25 Jan 2011 10:24:23 +0100
- 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=4RGZrovx+G/zQtY/+Mg7i66xB19AjjmHDKLQjRE2R6E=; b=MZntaqLfcf1pUei5oaByOsQNrncE2UcdlV1jM8+ej7W4T76BeNmfmLzCQY8KK71LFo Kchr6QsXlUQyiGb97XqVkOdTDisCEmgyV/0Tbpyu7ZwIhR/pzflGRXnGPyYm6HAtEGCn JejULvzq7QpmTytsVcG0v31g+88IznqvRcs+s=
- 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=Oesbghekmj7dAUzURfwGlMqRFjMbBguB477GLuDTfCj8zvLE96pYkmUPZAu30YBlD0 V8OLkoa8vEknTRO7YyYYoO1xvBWPbgi4k3/BrswdvgfipD87D7x+MW2R+1lVBGFT2Ppo 43jLU9fCpWfFcC2YEKyHKoFearkdJUiudR/k4=
oops, sorry what I said is not entirely correct. PermutationMatrix
already use "int". The Transpositions class, however, uses DenseIndex.
So I'll just use int everywhere and add a third "typename IndexType"
template argument defaulting to "int" just in case someone want to use
them on very big vectors.
On Tue, Jan 25, 2011 at 10:11 AM, Gael Guennebaud
> when we changed the default index type to "long int" we did not though
> about the PermutationMatrix and Transpositions classes which stores a
> vector of long int and so waste memory in 99.999% of the cases. It is
> pretty obvious to me that the index type should be a template
> parameter of these classes:
> template<int Size, typename IndexType, int MaxSize=Size>
> class PermutationMatrix;
> That's a first for people who directly declare a permutation. So here
> is the first question:
> Shall we specify a default value for the IndexType ? If yes, should it
> be "int" or "DenseIndex" ? I vote for "int". In this case we can also
> move the IndexType template argument at the last place to keep the
> source compatibility.
> Also, in most cases the user does not create a permutation object
> directly but it is declared for him in classes such as *LU<MatrixType>
> or LDLT<MatrixType>, and in this case the logic would be to use
> MatrixType::Index as the index type of the permutation object and
> waste memory (bandwidth) on 64bits systems. Since it is unbelievable
> that one day someone will perform a LU or LDLT dec on a matrix
> requiring 64bits integers for the indices (think about the size of the
> matrix!), I think it is safe to use int there too.
> btw, I'm also in the process of extending these two classes with a
> Base and three derived classes (storage, Map, Wrapper).