|Re: [eigen] Two issues in Sparse/RandomSetter.h|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Two issues in Sparse/RandomSetter.h
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 28 Apr 2010 23:33:28 +0200
- Cc: Rich Washington <rwashington@xxxxxxxxxx>
- 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:cc:content-type; bh=NoYdmC7u129fIziuIra+htriG038mFXThz1eE8g3sP0=; b=wb+yih3PT6Fl+F6MkWSneIG6uL3YOeJ4H4smBG4k7N5D64ks+DzVrn1+S1ofxE3Uq1 b5tIbO8WBa7bfaDdzDL11jNAUorqKGBjbc9+aCyNGIUPf200ZVzkPbIUFgKr6Jk4ncQB +ONOlDDmz27jyri6iye5CzlUxMipWCINXAVHc=
- 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 :cc:content-type; b=rLV+F4RTqsOQ0rBIw97GT19lK1KR2q8Tl7ZzargLMqpl9Iz+pHdDK/h37jMpIje14F 6P+jyB22HXw3AoOExj7s81S4vE3FO+Jnq3+kRcQvrKug7F/bMqWqpIZD22wyl1c0BrO1 1Q69nejho6gL3d46HCIqocpy1qd0aF1FYNV5o=
I'm surprised you are not using the Google's variants and trying to use the GNU hash_map ;)
Anyway, indeed there are some inconsistencies. Actually, the support for GNU hash_map (GnuHashMapTraits) has been removed in favor of the more standard but not yet completely standard std::unordered_map via StdUnorderedMapTraits. The main problem is that the doc and the defaults have not been updated.
So I'd recommend you to use std::unordered_map or one of the more efficient Google's variants. If you really have to use GNU hash_map, then I'd recommend you to define your own traits class outside Eigen.
For the preferred default order, there is indeed an inconsistency too. In my opinion this should be: Dense/Sparse/std::unordered_map/std::map.
I don't have time to fix these inconsistencies right now, so as always patch welcome :)
I'll fill a bug report anyway to not forget about it.
On Wed, Apr 28, 2010 at 10:36 PM, Matthew Hancher <mdh@xxxxxxxxxx>
I'm having a couple of isues with Sparse/RandomSetter.h. This is with eigen 2.0.12 and a pretty standard Ubuntu gcc 4.2.4 installation, FWIW, but the problems appear to exist in tip and not be particularly platform-dependent. I will happily open bug(s) about these, but I'd love a quick sanity-check before I do so.
First, despite efforts to support the GNU hash_map extension, it actually fails to do so. In particular, this innocent-looking sequence of includes:
does not compile, complaining:
.../Sparse/RandomSetter.h:162: error: invalid default argument for a template paramter
The problem is that Sparse/RandomSetter.h never defines GnuHashMapTraits, like it does for the Google hash map variants, so when it tries to use it on line 162 bad things happen. It seems to me that the solution is to define GnuHashMapTraits earlier in that file. I can submit a patch to do this if you think I'm on the right track.
Second, that same template argument is documented (at line 146) as defaulting to GoogleSparseHashMapTraits if the Google sparse_hash_map is available, but in fact the implementation ignores that altogether and instead defaults to GoogleDenseHashMapTraits if that is avilable, which doesn't even appear at all in the documented default preference order. It seems to me that the solution there is to pick one preference order (either Dense/Gnu/Std, Sparse/Gnu/Std, or Sparse/Dense/Gnu/Std) and adjust both the documentation comment and the implementation to use that order. I'll happily submit a patch for that too, if someone who understands the implications of changing the default can tell me what the best order is.