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,32d9aa9d79729b31 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.220.230 with SMTP id pz6mr9927344pbc.3.1340536239160; Sun, 24 Jun 2012 04:10:39 -0700 (PDT) Path: l9ni14192pbj.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Any easy/build-in construct to extract submatrices from larger matrix? Date: Sun, 24 Jun 2012 13:10:35 +0200 Organization: cbb software GmbH Message-ID: <1xzo3825h9yt7$.45flobqwlel6.dlg@40tude.net> References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: q1gJPV1SC/KP9ydRbYoWiw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-06-24T13:10:35+02:00 List-Id: On Sun, 24 Jun 2012 03:55:08 -0500, Nasser M. Abbasi wrote: > On 6/24/2012 3:24 AM, Dmitry A. Kazakov wrote: >> On Sun, 24 Jun 2012 03:05:37 -0500, Nasser M. Abbasi wrote: >> >>> fyi, modern Fortran has a nice facility to do this, called >>> pack(). It works like this: make up a MASK matrix of same size >>> as A. For those elements we want removed, put in a logical >>> .false at that location. >> >> This looks like a low-level hack with unpredictable results, because it >> does not specify the dimensions and the order of the elements for the >> result matrix. >> > > Pack() returns a vector, not a matrix. That is why reshape() is used. > The order is well defined. Fortran uses Fortran order? (column major). > So I am not sure I understand your "unpredictable results" ? Exactly this. Ada's equivalent would be arrays of aliased elements + pointer arithmetic. An alternative is, again, a pointer + unchecked conversion + renaming to whatever array type. >> If I implemented indicator functions for matrices, with the thingy is, I >> would define an abstract type with multiple implementations including a set >> of indices. A set would be far more effective for sparse matrices than >> Boolean matrix. > > Well. Sounds too advanced for me. Not advanced. An advanced solution is to have the whole set of index and matrix types with the corresponding operations. Ada's type system is not yet capable to handle this. > I was just looking for a little more simple solution. I don't find indicator Boolean matrix + array representation hack simple. And to me the problem is not clear. Are you writing a concrete program or considering a proper way to model matrix lattices in a strongly typed programming language? The difference is huge. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de