From: stefan-lucks@see-the.signature
Subject: Re: Incorrect error?
Date: Mon, 18 Jul 2011 11:45:37 +0200
Date: 2011-07-18T11:45:37+02:00 [thread overview]
Message-ID: <Pine.LNX.4.64.1107181119040.1340@medsec1.medien.uni-weimar.de> (raw)
In-Reply-To: <4e23f350$0$2573$703f8584@news.kpn.nl>
On Mon, 18 Jul 2011, ldries46 wrote:
[...]
> a : Real_Vector(0 .. 2);
> b : Real_Vector(0 .. 2);
> cross : Real_Vector(0 .. 2);
> begin
[...]
> Cross := a * b; -- VecCross( a, b, Cross ); <---------------- line 65 the
Why do you expect the product of two vectors to be an vector?
Mathematical convention knows the "inner product" of two vectors (a
single real value) and the "outer product" (a matrix).
Ada.Numerics.Generic_Real_Arrays actually provides both:
function "*" (Left, Right : Real_Vector) return Real'Base;
function "*" (Left, Right : Real_Vector) return Real_Matrix;
So if M is a Real_Matrix(0..2,0..2) and F a float, you can write either
M := a * b; -- outer product
or
F := a * b; -- inner product
but not
Cross := a * b; -- there is no such "*" defined in Ada.Num.Gen_Re_Arr.
Please don't ask me why the inner product is of type "Real'Base", instead
of "Real". I'd like to know that myself. ;-)
BTW, the error messages are not very helpful (at least not until you have
seen many of them and are able to translate them for yourself):
>65:21 expected type "Ada.Numerics.Generic_Real_Arrays.Real_Vector"
> from instance at line 6
>65:21 found type "Ada.Numerics.Generic_Real_Arrays.Real_Matrix" from
> instance at line 6
This really means is that there is no function "*" with two Real_Vector
parameters as the input and returning a Real_Vector in scope.
--
------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------
Stefan dot Lucks at uni minus weimar dot de
------ I love the taste of Cryptanalysis in the morning! ------
next prev parent reply other threads:[~2011-07-18 9:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-18 8:47 Incorrect error? ldries46
2011-07-18 9:45 ` stefan-lucks [this message]
2011-07-18 10:10 ` Georg Bauhaus
2011-07-18 11:46 ` ldries46
2011-07-18 10:40 ` AdaMagica
2011-07-18 12:39 ` Dmitry A. Kazakov
2011-07-18 12:45 ` stefan-lucks
2011-07-18 13:24 ` stefan-lucks
2011-07-18 10:39 ` Nicholas Collin Paul de Glouceſter
2011-07-18 15:58 ` Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox