Re: [eigen] Index type for PermutationMatrix and Transpositions |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Index type for PermutationMatrix and Transpositions
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 25 Jan 2011 12:22:57 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=w8AefrnvYIdj1Hqrpksuqxb0jTD/vq05zIJg1gTVNCI=; b=pllg8Dohn2OoNDXgGRfFAZm4zgfw7Ua/Y8LaWoxebmQ1gXp4Pd8X/HPQONUtn7cxsK QplbL2A0uDzAUg09ImRmw/ZcWpCkJKNztCQeuuXDKrtnnOoiYntjWev5sDnXB18Xz9id 4YjkKnr/svc1HkBzM1/CHI83x1bjR/RVmz5xA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=pdUl+YT15zRL82l0tTxKYm+9QVf+iTrp7rn5Co5aRNFSRsqN8faXWPR3UtXNg4U48S U/iIg/4N3Jlks/pBgSUisdINMt03K06A6nI2e7Dk8UIIlqzIb+3vkxWbwHZOj50055VE i1uFk4RI81K+qFrfo6uNjkoDqE+1rII5cmN54=
Keep in mind that pointer-size indices also get you better speed... so
i still think that they are a very good default. If you think that
64bit is too much space wasted, why settle for 32bit? you may as well
decide that 16bits or even 8 bits are enough in your case.
2011/1/25 Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>:
> I use PermutationMatrix, and I agree with your changes. I'd rather have to
> specify the IndexType when i really need 64bits (which i doubt will ever
> happen) rather than loose memory (and efficiency) with a big default
>
> Thomas
>
> --
>
> Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>
>
> http://www.freehackers.org/thomas
>
> On Tuesday 25 January 2011 10:11:22 Gael Guennebaud wrote:
>
>> Hi,
>
>>
>
>> 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).
>
>>
>
>> gael
>
>>
>
>>
>
>>