comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Incorrect error?
Date: Mon, 18 Jul 2011 14:39:00 +0200
Date: 2011-07-18T14:39:00+02:00	[thread overview]
Message-ID: <ta9nw414hrgd.1he86onmlgqqm.dlg@40tude.net> (raw)
In-Reply-To: 04f4f840-4ea5-407b-8eb7-1f4016ab4e13@d1g2000yqm.googlegroups.com

On Mon, 18 Jul 2011 03:40:59 -0700 (PDT), AdaMagica wrote:

> Overloading in this way might be seen as unfortunate.
> 
>> 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 you have three vectors, what should A * B * C mean? Even with
> parentheses, it's awkward to read.

There is one or more transpose operation missing, e.g.

   A * Transpose (B) * C
   Transpose (A) * Transpose (B) * C
   Transpose (A) * B * Transpose (C)

etc

> Now image we have a third function
> 
> function "*" (Left, Right : Real_Vector) return Real_Vector;

Ah, but vector product has the x-notation. Was introduction of Unicode in
Ada for nothing? (:-))

   function "�" (Left, Right : Real_Vector) return Real_Matrix;
 
> BTW: What would such a function return for vectors of less or more
> than 3 dimensions?

It is also well defined in mathematics, but the problem is same as with
measurement units. The constraints on the matrix dimensions of the
arguments statically determine the constraints of the result matrix
product. One cannot express this in the Ada's type system, otherwise than
by a massive set of overloaded subprograms, which, like for the case of
measurement units, is not a solution. We need some universal mechanism to
describe such cases based on subtypes with static checks of those when the
constraints are static.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2011-07-18 12:39 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 [this message]
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