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,32d9aa9d79729b31 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.228.227 with SMTP id sl3mr16994017pbc.5.1340723182795; Tue, 26 Jun 2012 08:06:22 -0700 (PDT) Path: l9ni22352pbj.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Any easy/build-in construct to extract submatrices from larger matrix? Date: Tue, 26 Jun 2012 08:06:21 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <788af57d-750d-418d-94bb-75c6557e36a9@g4g2000pbn.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1340723182 26986 127.0.0.1 (26 Jun 2012 15:06:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 26 Jun 2012 15:06:22 +0000 (UTC) In-Reply-To: <788af57d-750d-418d-94bb-75c6557e36a9@g4g2000pbn.googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-06-26T08:06:21-07:00 List-Id: On Monday, June 25, 2012 7:48:48 PM UTC-7, Jerry wrote: > Most submatrix needs, including Nasser's example, can be handled by > slices (or slice syntax--not sure what the difference is). Boolean > masks would not often be needed. >=20 > Why doesn't Ada provide this? It seems that one of the Ada design > principles has been to build in commonly used features rather than > force the user to write them, setting up the greater possibility of > mistakes and inefficiencies. Slices exist for 1D arrays; why not for > >1D arrays? I think one of the main reasons is that you couldn't do everything with a 2= -D slice that you could do with a 1-D slice. In particular, parameter pass= ing would be an issue. If you declare a procedure type Some_Array is array (natural range <>) of Something;=20 procedure Proc (A : in out Some_Array); you can pass a slice of some other array Proc (B (7 .. 23)); and the since the elements of the slice are all still contiguous, Proc coul= d treat the parameter the same as it would any other array--it wouldn't hav= e to know whether the actual parameter was an entire array or a slice. Tha= t wouldn't be the case with 2-D slices. Some additional logic in Proc woul= d be needed to deal with non-contiguous slices, and that additional logic w= ould have to be there in Proc whether or not a 2-D slice was actually passe= d to it anywhere. I realize that this may not be important to all programmers, and that they'= d rather have the ability to express what they want and not worry about whe= ther it slows things down ("distributed overhead"). But I think that being= able to generate efficient code was one of the design principles in Ada 83= . -- Adam