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.219.170 with SMTP id pp10mr10717370pbc.1.1340558054055; Sun, 24 Jun 2012 10:14:14 -0700 (PDT) Path: l9ni15130pbj.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!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: Sun, 24 Jun 2012 12:14:11 -0500 Organization: Aioe.org NNTP Server Message-ID: References: <1xzo3825h9yt7$.45flobqwlel6.dlg@40tude.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-24T12:14:11-05:00 List-Id: 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