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.219.170 with SMTP id pp10mr10598655pbc.1.1340554289523; Sun, 24 Jun 2012 09:11:29 -0700 (PDT) Path: l9ni14976pbj.0!nntp.google.com!news2.google.com!goblin3!goblin.stu.neva.ru!usenet.pasdenom.info!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 18:11:27 +0200 Organization: cbb software GmbH Message-ID: References: <1xzo3825h9yt7$.45flobqwlel6.dlg@40tude.net> 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-24T18:11:27+02:00 List-Id: 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. > Hence needed a simply way to obtain a submatrix from the main > matrix. If you want a function which would return a submatrix obtained by removing the row I and column J: 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; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de