comp.lang.ada
 help / color / mirror / Atom feed
From: "Nasser M. Abbasi" <nma@12000.org>
Subject: Re: Any easy/build-in construct to extract submatrices from larger matrix?
Date: Sun, 24 Jun 2012 03:55:08 -0500
Date: 2012-06-24T03:55:08-05:00	[thread overview]
Message-ID: <js6kla$ugn$1@speranza.aioe.org> (raw)
In-Reply-To: nrn0zo41ylee.3jz8xvqubzuv$.dlg@40tude.net

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" ?

> 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. I was just looking for a little more
simple solution.

btw, if you think the Fortran solution was short, in Matlab,
this is done like this

EDU>> A=[1 2 3;4 5 6;7 8 9];
EDU>> A(1,:)=[];   % removes row 1
EDU>> A(:,1)=[]    % removes column 1

A =
      5     6
      8     9

And this would also work if A was sparse in Matlab.

regards,
--Nasser



  reply	other threads:[~2012-06-24  8:55 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-24  8:05 Any easy/build-in construct to extract submatrices from larger matrix? Nasser M. Abbasi
2012-06-24  8:24 ` Dmitry A. Kazakov
2012-06-24  8:55   ` Nasser M. Abbasi [this message]
2012-06-24 11:10     ` Dmitry A. Kazakov
2012-06-24 12:16       ` Nasser M. Abbasi
2012-06-24 16:11         ` Dmitry A. Kazakov
2012-06-24 17:14           ` Nasser M. Abbasi
2012-06-24 18:33             ` Dmitry A. Kazakov
2012-06-25  5:44             ` J-P. Rosen
2012-06-25  6:32               ` Nasser M. Abbasi
2012-06-25  7:54                 ` J-P. Rosen
2012-06-25  8:20                   ` Dmitry A. Kazakov
2012-06-25 14:21                   ` Nasser M. Abbasi
2012-06-25  8:36                 ` Georg Bauhaus
2012-06-25 13:17                   ` Nasser M. Abbasi
2012-06-26 11:44                     ` Georg Bauhaus
2012-06-25 16:49                 ` Pascal Obry
2012-06-25 17:36                   ` Nasser M. Abbasi
2012-06-25 18:49                     ` stefan-lucks
2012-06-26  4:41                       ` Nasser M. Abbasi
2012-06-26  7:15                 ` Jacob Sparre Andersen
2012-06-26  9:51                   ` Nasser M. Abbasi
2012-06-25  9:33               ` Simon Wright
2012-06-26  2:48 ` Jerry
2012-06-26  4:19   ` Nasser M. Abbasi
2012-06-26  7:06   ` Nasser M. Abbasi
2012-06-26 12:54     ` Robert A Duff
2012-06-26 15:19       ` Adam Beneschan
2012-06-26 21:14         ` Robert A Duff
2012-06-27 23:42     ` Shark8
2012-06-26  7:10   ` Dmitry A. Kazakov
2012-06-26 15:06   ` Adam Beneschan
2012-06-26 21:19     ` Robert A Duff
2012-06-26 21:40       ` Adam Beneschan
2012-07-03  4:22         ` Randy Brukardt
2012-07-03  8:37           ` Dmitry A. Kazakov
2012-07-05  1:33             ` Randy Brukardt
2012-07-05  7:08               ` Dmitry A. Kazakov
2012-07-06 23:47                 ` Randy Brukardt
2012-07-07  8:22                   ` Dmitry A. Kazakov
2012-07-05 18:56               ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox