From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ad3b8638a6e09884 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!r5g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Incorrect error? Date: Mon, 18 Jul 2011 08:58:12 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <4e23f350$0$2573$703f8584@news.kpn.nl> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1311004693 6131 127.0.0.1 (18 Jul 2011 15:58:13 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 18 Jul 2011 15:58:13 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r5g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20222 Date: 2011-07-18T08:58:12-07:00 List-Id: On Jul 18, 1:47=A0am, "ldries46" wrote: > I'm using Ada.Numerics.Generic_Real_Arrays. While Compiling I got the > following error message: > > 65:21 =A0 =A0 expected type "Ada.Numerics.Generic_Real_Arrays.Real_Vector= " from > instance at line 6 > 65:21 =A0 =A0 found type "Ada.Numerics.Generic_Real_Arrays.Real_Matrix" f= rom > 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 :=3D 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 > =A0 =A0ok =A0 =A0 : boolean; > =A0 =A0n =A0 =A0 =A0: integer :=3D 1; > =A0 =A0Volume : float; > =A0 =A0a =A0 =A0 =A0: Real_Vector(0 .. 2); > =A0 =A0b =A0 =A0 =A0: Real_Vector(0 .. 2); > =A0 =A0X0 =A0 =A0 : Real_Vector(0 .. 2); > =A0 =A0X1 =A0 =A0 : Real_Vector(0 .. 2); > =A0 =A0X2 =A0 =A0 : Real_Vector(0 .. 2); > =A0 =A0cross =A0: Real_Vector(0 .. 2); > =A0 =A0nA =A0 =A0 : Real_Vector(0 .. 2); > =A0 =A0p =A0 =A0 =A0: ptrNode_Object; > =A0 =A0TempS =A0: ptrS_Object; > =A0 =A0TempT =A0: ptrTriangle_Object; > begin > =A0 =A0TempS :=3D Obj; > =A0 =A0while n /=3D ObjID loop > =A0 =A0 =A0 n :=3D n + 1; > =A0 =A0 =A0 TempS :=3D TempS.next; > =A0 =A0 =A0 if TempS =3D null then > =A0 =A0 =A0 =A0 =A0declare > =A0 =A0 =A0 =A0 =A0 =A0 NO_NODE_OBJECT : exception; > =A0 =A0 =A0 =A0 =A0begin > =A0 =A0 =A0 =A0 =A0 =A0 raise NO_NODE_OBJECT; > =A0 =A0 =A0 =A0 =A0end; > =A0 =A0 =A0 end if; > =A0 =A0end loop; > =A0 =A0n :=3D TempS.PosFaces(0); > =A0 =A0TempT :=3D stT_Object; > =A0 =A0ok :=3D TempT =3D null; > =A0 =A0while not ok loop > =A0 =A0 =A0 if TempT.nr =3D n then > =A0 =A0 =A0 =A0 =A0ok :=3D true; > =A0 =A0 =A0 else > =A0 =A0 =A0 =A0 =A0TempT :=3D TempT.next; > =A0 =A0 =A0 =A0 =A0ok :=3D TempT =3D null; > =A0 =A0 =A0 end if; > =A0 =A0end loop; > =A0 =A0while n < TempS.PosFaces(1) loop > =A0 =A0 =A0 p :=3D GetPoint(TempT.P1); > =A0 =A0 =A0 X0(0) :=3D p.pRectangular(x); > =A0 =A0 =A0 X0(1) :=3D p.pRectangular(y); > =A0 =A0 =A0 X0(2) :=3D p.pRectangular(z); > =A0 =A0 =A0 p :=3D GetPoint(TempT.P2); > =A0 =A0 =A0 X1(0) :=3D p.pRectangular(x); > =A0 =A0 =A0 X1(1) :=3D p.pRectangular(y); > =A0 =A0 =A0 X1(2) :=3D p.pRectangular(z); > =A0 =A0 =A0 p :=3D GetPoint(TempT.P3); > =A0 =A0 =A0 X2(0) :=3D p.pRectangular(x); > =A0 =A0 =A0 X2(1) :=3D p.pRectangular(y); > =A0 =A0 =A0 X2(2) :=3D p.pRectangular(z); > =A0 =A0 =A0 a :=3D X1 - X0; -- VecSub( a, X1, X0 ); > =A0 =A0 =A0 b :=3D X2 - X0; -- VecSub( b, X2, X0 ); > =A0 =A0 =A0Cross :=3D a * b; -- VecCross( a, b, Cross ); > <---------------- line 65 the cursor is standing just before * > =A0 =A0 =A0 nA :=3D Cross * 0.5; -- VecMultScalar( nA, Cross, 0.5 ); > =A0 =A0 =A0 -- Volume =3D Volume + fabs(VecDot( X0, nA )); > =A0 =A0 =A0 Volume :=3D Volume + X0(0)*nA(0) + X0(1)*nA(1) + X0(2)*nA(2); > =A0 =A0 =A0 n :=3D n + 1; > =A0 =A0end loop; > =A0 =A0Volume :=3D Volume/3.0; > =A0 =A0return Volume; > end Volume;