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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,32d9aa9d79729b31 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.219.170 with SMTP id pp10mr16648228pbc.1.1340711067373; Tue, 26 Jun 2012 04:44:27 -0700 (PDT) Path: l9ni21803pbj.0!nntp.google.com!news2.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 26 Jun 2012 13:44:23 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Any easy/build-in construct to extract submatrices from larger matrix? References: <1xzo3825h9yt7$.45flobqwlel6.dlg@40tude.net> <4fe8231d$0$6633$9b4e6d93@newsspool2.arcor-online.net> In-Reply-To: Message-ID: <4fe9a099$0$6567$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 26 Jun 2012 13:44:25 CEST NNTP-Posting-Host: 5cdb75c0.newsspool4.arcor-online.net X-Trace: DXC=ZNJe4`XUd^EFJ3]dH>I?oE4IUKJLh>_cHTX3jMA@IZ0cX<\4K X-Complaints-To: usenet-abuse@arcor.de Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Date: 2012-06-26T13:44:25+02:00 List-Id: On 25.06.12 15:17, Nasser M. Abbasi wrote: > On 6/25/2012 3:36 AM, Georg Bauhaus wrote: >> On 25.06.12 08:32, Nasser M. Abbasi wrote: >>> >>> In Mathematica for example, I do this whole operation in one line: >>> >>> --------------------------- >>> Table[ReplacePart[A,{{i},{i,_},{_,j}}:>Sequence[]],{i,nRow},{j,nCol}]; >>> --------------------------- >>> >>> That is all. This generates all submatrices from A as needed >>> in this problem :) >> > >> What if, as is usually the case, you'd have "primitive" array routines >> like Pick, Take, Drop, Transpose, and then (this is what it looks >> like here) implement the removals at i, j like like this: >> >> Shrunk := Transpose (Drop (i, Transpose (Drop (j, Matrix)))); >> > > Yes, that would help. Transpose is there already in Ada. (good). > Drop? I did not find this. googled for it. I assume this is just > an example then. It is fairly easy to write, indeed. Nevertheless, I believe that such operations should be a little higher level than Fortran's pack. The latter seems good for implementing the operations, provided the language allows (re-)attaching dimensions to a lump of data. I am not sure that Ada's index type based array indexing is the best model for such flexibility at all levels. It certainly does not seem strictly necessary to implement some "primitive" operations. Nevertheless, Iverson's A Programming Language, and more specifically, introductory work based on it (things that I can hope to understand in finite time :), and language work based on it (APL, J, possibly S and R), reveal a good set of "primitive" operations on arrays, functional style. Some of these are in Ada already, for example, array concatenation "&", and (some) indexing. Some can be built using a container/iterator approach, I think, for example, applying a function to all elements, either updating the array, or producing a new one. There are simpler ways to do that, though, even in Ada 83, but they may be a little less flexible for STL style algorithm work. Just a guess. Array operations are again interesting for automatic parallelism in the small, now that consumer hardware has a small array of vector hardware.