From: Adam Beneschan <adam@irvine.com>
Subject: Re: Incorrect error?
Date: Mon, 18 Jul 2011 08:58:12 -0700 (PDT)
Date: 2011-07-18T08:58:12-07:00 [thread overview]
Message-ID: <e3b87ad4-76b4-4907-9e7c-674c23ea310b@r5g2000prf.googlegroups.com> (raw)
In-Reply-To: 4e23f350$0$2573$703f8584@news.kpn.nl
On Jul 18, 1:47 am, "ldries46" <bertus.dr...@planet.nl> wrote:
> I'm using Ada.Numerics.Generic_Real_Arrays. While Compiling I got the
> following error message:
>
> 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
>
> As can be seen Cross, a and b declared as Real_Vector .
> What do I do wrong?
As others have said, you're trying to do something that isn't
defined. There is no "*" operation in Generic_Real_Arrays that takes
two Real_Vector arguments and returns a Real_Vector.
However, I think the error message GNAT is reporting is wrong, and
this should be reported as a GNAT bug. It's no wonder you were
confused. If there were just one function like this:
function Product (Left : Real_Vector; Right : Real_Matrix) return
Real_Vector;
and you tried
Cross := Product (A, B);
GNAT would say "expected type Real_Matrix ... found type Real_Vector",
which is pretty clear. Changing "Product" to "*" and using it as an
operator causes GNAT to generate a different message "there is no
applicable operator". But in the actual package, there are eight
definitions of "*", and the error message GNAT produces doesn't make
sense for any of them, since it's implying that you're actually using
a Real_Matrix as a parameter, when of course you aren't.
-- Adam
> L. Dries
>
> Code:
>
> package Float_Arrays is new Ada.Numerics.Generic_Real_Arrays (float);
> use Float_Arrays;
>
> function Volume (ObjID : integer; Obj : ptrS_Object) return float is
> ok : boolean;
> n : integer := 1;
> Volume : float;
> a : Real_Vector(0 .. 2);
> b : Real_Vector(0 .. 2);
> X0 : Real_Vector(0 .. 2);
> X1 : Real_Vector(0 .. 2);
> X2 : Real_Vector(0 .. 2);
> cross : Real_Vector(0 .. 2);
> nA : Real_Vector(0 .. 2);
> p : ptrNode_Object;
> TempS : ptrS_Object;
> TempT : ptrTriangle_Object;
> begin
> TempS := Obj;
> while n /= ObjID loop
> n := n + 1;
> TempS := TempS.next;
> if TempS = null then
> declare
> NO_NODE_OBJECT : exception;
> begin
> raise NO_NODE_OBJECT;
> end;
> end if;
> end loop;
> n := TempS.PosFaces(0);
> TempT := stT_Object;
> ok := TempT = null;
> while not ok loop
> if TempT.nr = n then
> ok := true;
> else
> TempT := TempT.next;
> ok := TempT = null;
> end if;
> end loop;
> while n < TempS.PosFaces(1) loop
> p := GetPoint(TempT.P1);
> X0(0) := p.pRectangular(x);
> X0(1) := p.pRectangular(y);
> X0(2) := p.pRectangular(z);
> p := GetPoint(TempT.P2);
> X1(0) := p.pRectangular(x);
> X1(1) := p.pRectangular(y);
> X1(2) := p.pRectangular(z);
> p := GetPoint(TempT.P3);
> X2(0) := p.pRectangular(x);
> X2(1) := p.pRectangular(y);
> X2(2) := p.pRectangular(z);
> a := X1 - X0; -- VecSub( a, X1, X0 );
> b := X2 - X0; -- VecSub( b, X2, X0 );
> Cross := a * b; -- VecCross( a, b, Cross );
> <---------------- line 65 the cursor is standing just before *
> nA := Cross * 0.5; -- VecMultScalar( nA, Cross, 0.5 );
> -- Volume = Volume + fabs(VecDot( X0, nA ));
> Volume := Volume + X0(0)*nA(0) + X0(1)*nA(1) + X0(2)*nA(2);
> n := n + 1;
> end loop;
> Volume := Volume/3.0;
> return Volume;
> end Volume;
prev parent reply other threads:[~2011-07-18 15:58 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
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 [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox