Re: [eigen] Map questions |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Map questions
- From: "Gael Guennebaud" <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 29 Oct 2008 23:41:14 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=XnSv4wB/Xx9G93IJwjRm7tByvUq3PhymfpRmxqO6qg0=; b=lZ/AFGAKrmOmGspfjc1VbDpoFjQLPjlSIGfvBWw39v0blnvbebx+w17rgxqmIEAnMS rEpStMzNYiBHqGCAQ+OB2+FqDsvfFRurVlEVMASbxs3TgwQIhNLQBRL29fhom7YdSStp j1MEzf10TzO/5lupZMllZeslui7wRZhDx/WsE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=fE4jG9sBGJJGuS9yIrDXfuQN74hzToV1Ckd0eK86i/6+jkZ7P2kEncdK16QpglwYti fguZXpkk2m1NUYvOPRFy/NBcafgehquyNd4XST0+0SvTvhxuuaGr+KihKij14OF0H27X NZIlNMcz00uvSZMo9hs7wrjN1go6QVS1S4/rs=
On Wed, Oct 29, 2008 at 11:28 PM, Benoît Jacob <jacob@xxxxxxxxxxxxxxx> wrote:
>> indeed, "Map<Vector3d>(a) = v;" seems to be equivalent to
>> "Map<Vector3d> a = v;" that is very unfortunate...
>
> Ah thanks for the explanation, I was puzzled.
>
> Maybe we can at least block this form by disabling the default constructor for
> class Map (private inheritance trick)? I mean, in the "Map<Vector3d> a = v;"
> construction, the constructor used for A must be the default constructor
> (then followed by operator=) since there is no Map constructor taking v as
> argument. Right?
indeed, but that does not solve anything, I mean the compilation error
is still the same. (it complains a is already defined)
>> I could keep going like this forever, but nothing is really good and
>> intuitive. Perhaps this is a good motivation to resurrect the
>> Matrix::Map static functions.... ???
>
> The idea behind letting the user construct named Map objects versus a static
> method, was that it makes the user's code lighter when using a Map object
> repeatedly. If you have a buffer that you want to map as a vector and use
> that repeatedly, it is much ligher to do "Map<Vector3d> m(buffer);" and use m
> henceforth. So I think we want to keep supporting created named Map objects
> as part of our public API (and keep considering this the recommended way in
> the documentation).
>
> I mean, we can always reintroduce the static methods, that would indeed offer
> an nice alternative in the situation where a Map object is used only once,
> but that doesn't solve the problem for other users who want a permanent Map
> object.
adding Map functions to Matrix does not change the current API, it
just extend it. On the other hand I agree they are redundant in most
cases, and having such two ways to express the same thing might be a
bit confusing.
perhaps we could rename the type Map to MapType, and define Map as a
global static function, or something in that direction....
>
> On Wednesday 29 October 2008 22:51:34 Gael Guennebaud wrote:
>> Hi,
>>
>> On Wed, Oct 29, 2008 at 9:01 PM, Cristóvão Sousa <crisjss@xxxxxxxxx> wrote:
>> > Hi,
>> >
>> > I would like to do something like
>> >
>> > Vector3d v;
>> > // v = something;
>> > double a[3];
>> > Map<Vector3d>(a) = v;
>>
>> indeed, "Map<Vector3d>(a) = v;" seems to be equivalent to
>> "Map<Vector3d> a = v;" that is very unfortunate...
>>
>> Actually the following variants works:
>>
>> Map<Vector3d>(a,3) = v;
>>
>> (Map<Vector3d>(a)) = v;
>>
>> Map<Vector3d>(a).operator=(v);
>>
>> Map<Vector3d>(a).lazyAssign(v);
>>
>> Map<Vector3d> _a(a); _a = v;
>>
>> Map<Vector3d>(a).start<3>() = v;
>>
>> ...
>>
>> I could keep going like this forever, but nothing is really good and
>> intuitive. Perhaps this is a good motivation to resurrect the
>> Matrix::Map static functions.... ??? or find something else....
>>
>> > Another thing that could be a little bug:
>> > it is currently possible to do
>> >
>> > const double a[3]={1,2,3};
>> > Map<Vector3d>(a).setZero();
>> >
>> > , which discards the const qualifier of a.
>>
>> ok, I'll check later if we can do something for that, but there is
>> nothing urgent here.
>>
>> cheers,
>> gael.
>
>
>
> ---
>
>