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=2.0 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA, REPLYTO_WITHOUT_TO_CC autolearn=no 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.190.104 with SMTP id gp8mr13143489pbc.4.1340630247905; Mon, 25 Jun 2012 06:17:27 -0700 (PDT) Path: l9ni18276pbj.0!nntp.google.com!news1.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.ecp.fr!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: Re: Any easy/build-in construct to extract submatrices from larger matrix? Date: Mon, 25 Jun 2012 08:17:24 -0500 Organization: Aioe.org NNTP Server Message-ID: References: <1xzo3825h9yt7$.45flobqwlel6.dlg@40tude.net> <4fe8231d$0$6633$9b4e6d93@newsspool2.arcor-online.net> Reply-To: nma@12000.org NNTP-Posting-Host: KdJUrTuvv3Zv/s8pPxNluw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-06-25T08:17:24-05:00 List-Id: 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. Actually, I do not think it is too hard to write functions similar to Fortran's pack() and reshape(). The API for these is well defined and these can be implemented in Ada as generic packages. These would provide better solution, as they are general and will work for many different cases, not just the one I had asked about here. Then there will no need for Drop() as it would not be orthogonal to Pack+reshape in terms of functionality, and those do what Drop does and more. When I get better in Ada, will try to do that myself :) I just think functions like these, if they are part of the library, would be better for everyone, so that not every programmer will need to reinvent the wheel. (I wish Ada would be more interested in scientific computation, as I think it has the potential to be really good in that area due to its strong typing) but I think Ada is more interested in system programming. thanks, --Nasser