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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fded8d14c74b14e5 X-Google-Attributes: gid103376,public From: "Diana Webster" Subject: Re: Looking for Ada Technique Name and References Date: 2000/02/21 Message-ID: <88s90i$8mi$1@ns3.arlut.utexas.edu>#1/1 X-Deja-AN: 588099729 References: <88kegp$iso$1@coward.ks.cc.utah.edu> <88kh6q$j4j$1@coward.ks.cc.utah.edu> X-Priority: 3 X-Mimeole: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: news@arlut.utexas.edu X-Trace: ns3.arlut.utexas.edu 951166802 8914 129.116.128.43 (21 Feb 2000 21:00:02 GMT) Organization: Applied Research Laboratories - The University of Texas at Austin X-MSMail-Priority: Normal NNTP-Posting-Date: 21 Feb 2000 21:00:02 GMT Newsgroups: comp.lang.ada Date: 2000-02-21T21:00:02+00:00 List-Id: This technique is called "composition" in mathematics, i.e., the composition of two functions, i.e, sum (average (xnum)). Most programming languages support this. John Halleck wrote in message news:88kh6q$j4j$1@coward.ks.cc.utah.edu... > > John Halleck (nahaj@u.cc.utah.edu) wrote: > > : I would appreciate it if someone could give me the name and a > > : print reference for the following technique. > > > Someone Replied: > > > It is called overloading. > > It uses overloading, but that was not the technique I was trying > to get accross. > > The technique in question is turning the what is normally written > as two function calls (More or less:) > "*" (Transpose (A), B) > into a type mark and a single function call to a special function > that can handle it all more effeciently. > > > > > : Background: > > > > : Many matrix methods are written in the form A := Transpose(B)*C > > : But, actually forming the transpose is expensive, and you are better > > : off just writing a second matrix multiply routine that takes the > > : two matrices and treats the one as a transpose without actually > > : doing the transpose. > > > > : Below is a technique that allows one to write it as one normally > > : sees it written, but lets the Ada compiler do the selection of > > : an appropriate routine. > > > > : Is there a name for this technique? Does it appear already documented > > : somewhere? > > > > : -------------------------------------------------------------------------- ---- > > > > : -- ... > > > > : type Matrix is array (positive range <>, positive range <>) of Float; > > : type Transpose is new Matrix; > > > > : -- ... > > > > : -- This is just a matrix multiply routine. > > : function "*" (Left : Matrix; Right : Matrix) return Matrix; > > > > : -- This routine multiplies the transpose of Left by Right. > > : function "*" (Left : Transpose; Right : Matrix) return Matrix; > > > > : ---------- > > > > : -- Examples: > > : A, B, C, D, E: Matrix; > > > > : -- ... > > > > : A := B * C; -- Matrix multiply. > > : D := Transpose (E) * F; -- D gets the result of multiplying E'F > > : -- (By selecting the appropriate routine. > > > > : ---------------------------------------------------------------------