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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2a34b7ad6c6a0774 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Efficiency of code generated by Ada compilers Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1jn1a4o.1dfllwo1uin3imN%csampson@inetworld.net> <1jn36d6.se2f0g1edjjnyN%csampson@inetworld.net> <61f149b9-00ff-40cd-9698-01e69fdc5c0f@v15g2000yqe.googlegroups.com> <1fwir3k681b8x.unwo52g4gt32.dlg@40tude.net> Date: Mon, 16 Aug 2010 16:09:10 +0200 Message-ID: <1etv7lg9vhv75$.1wsmzfmjtatxz$.dlg@40tude.net> NNTP-Posting-Date: 16 Aug 2010 16:09:06 CEST NNTP-Posting-Host: f8102b8e.newsspool3.arcor-online.net X-Trace: DXC=7\7Ud1gN=UQ\9P[:DUn00QMcF=Q^Z^V3X4Fo<]lROoRQ8kF On Mon, 16 Aug 2010 06:29:42 -0700 (PDT), Elias Salom�o Helou Neto wrote: > Well, in such a case C could do the job, right? Everything is Turing-Complete... > Encapsulating the low- > level array implementation within well designed classes, possibly > templated ones, would be a much better idea, would not? > > What I meant from the beginning was to possibly write code such as > (sorry for the C++ syntax): > > Matrix< 3, double > volumeImage( 100, 100, 100 ); > Matrix< 2, char > asciiArt( 50, 75 ); > > asciiArt( 10, 10 ) = a; > volumeImage( 1, 2, 3 ) = 5.7; Well, maybe, but it is already done in Ada. Furthermore, the compiler "knows" about arrays and can apply array-specific optimizations or take advantage of array-specific processor instructions. Not that optimization is my concern, but it seemingly is yours. > Where those two or three dimensional members/constructors were > automatically generated by the compiler by using "template > metaprogramming". It will be possible with C++0x. It is already > possible by using the experimental implementation of the new standard > in GCC. I don't see any gain, because this is trivial compared to the real challenges of modeling linear algebraic types. Consider description of the types on which the matrix multiplication is defined. E.g.: NxMxK * KxM = N. Here NxM denotes matrix with dimensions N and M. Is it one type or many types or many subtypes? Templates give no choice but many different unrelated types, when dimensionality is a parameter. Not my choice. Now you have a combinatorial explosion of overloaded variants. Generate them, all possible multiplication operation profiles for 4D, 3D, 2D, 1D matrices. Make the constraint on matrix size in given dimension statically enforced with an appropriate (understandable!) error messages when sizes are statically known. Allow unconstrained matrices as well. Generate aggregates for each matrix type. Provide matrix slicing operations for all types of matrices (e.g. column from matrix, row from matrix, submatrix from matrix etc). Have fun! -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de