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 12:14:11 -0500
Date: 2012-06-24T12:14:11-05:00	[thread overview]
Message-ID: <js7ht1$56c$1@speranza.aioe.org> (raw)
In-Reply-To: mcrol4yvkaqn.1cyvzd9r1sp8k.dlg@40tude.net

On 6/24/2012 11:11 AM, Dmitry A. Kazakov wrote:
> On Sun, 24 Jun 2012 07:16:50 -0500, Nasser M. Abbasi wrote:
>
>> On 6/24/2012 6:10 AM, Dmitry A. Kazakov wrote:
>>
>>> 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.
>>>
>> I was try to implement, just for fun, finding the adjungate
>> matrix, using the direct algorithm using Ada, as shown here:
>>
>> http://en.wikipedia.org/wiki/Adjugate_matrix
>>
>> it requires finding the cofactors of each element in a 2D matrix.
>
> I suppose that there exist much better numerical methods than doing this as
> described in the definition.
>

Yes, I am sure of this. But it is just for learning purposes.

> If you want a function which would return a submatrix obtained by removing
> the row I and column J:
>

Thanks, Will try it out! You are good in Ada, so can write functions
like this as needed quickly. I think Ada should add more
support for more build-in type functions for matrix/vector operations.

At least, 2D slicing of arrays should be possible? If not, that
mask/pack functionality as in Fortran, should be present in Ada
as part of the library.

> function Exclude (A : Complex_Matrix; I, J : Integer)
>     return Complex_Matrix is
>     AI, AJ : Integer := A'First (1);
> begin
>     return B : Complex_Matrix (1..A'Length (1)-1, 1..A'Length (2)-1) do
>        AI := A'First (1);
>        for BI in B'Range (1) loop
>           if AI = I then
>              AI := AI + 1;
>           end if;
>           AJ := A'First (2);
>           for BJ in B'Range (2) loop
>              if AJ = J then
>                 AJ := AJ + 1;
>              end if;
>              B (BI, BJ) := A (AI, AJ);
>              AJ := AJ + 1;
>           end loop;
>           AI := AI + 1;
>        end loop;
>     end return;
> end Exclude;
>

Thanks again for the function. If I use it in my engineering
HOWTO cheat sheet, will put your name as the credit on it.

regards,
--Nasser



  reply	other threads:[~2012-06-24 17:14 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
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 [this message]
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