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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.157.26.14 with SMTP id a14mr7561666ote.87.1479145195625; Mon, 14 Nov 2016 09:39:55 -0800 (PST) X-Received: by 10.157.20.197 with SMTP id r5mr1149598otr.9.1479145195594; Mon, 14 Nov 2016 09:39:55 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!q124no692636itd.0!news-out.google.com!x12ni120ita.0!nntp.google.com!q124no1641652itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 14 Nov 2016 09:39:55 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=156.67.138.137; posting-account=3Fg1FgoAAACfsmWScNfMD1tGFhR4DU0o NNTP-Posting-Host: 156.67.138.137 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <055e3e13-93dc-4653-bc20-e09bd6c53bce@googlegroups.com> Subject: Re: matrix manipulation From: hnptz@yahoo.de Injection-Date: Mon, 14 Nov 2016 17:39:55 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:32312 Date: 2016-11-14T09:39:55-08:00 List-Id: On Sunday, November 13, 2016 at 12:30:16 AM UTC+1, Stephen Leake wrote: > On Saturday, November 12, 2016 at 12:16:47 PM UTC-6, hn...@yahoo.de wrote= : > > What is an elegant way to program exchange of columns in a matrix.=20 > > Application:=20 > > C is a matrix. Cj be the j-th column of C. > > Sort C1,C2, ..., Cn in non increasing order with respect to their first= component. > > I tried and ended up in a very messy program, as I had to sort the firs= t components first, remember their new index and then reconstruct the matri= x. >=20 > declare the matrix as an array of columns: >=20 > type Column is array (1 .. 10) of float; > type Matrix is array (1 .. 10) of Column; >=20 > A : Matrix :=3D ...; > Tmp : Column; >=20 > Tmp :=3D A (2); > A (2) :=3D A (1); > A (1) :=3D Tmp; How to access a single element of matrix A ? Is it A(1)(1) ? I think, I can= not use it as a Matrix anymore applying build in Ada-procedures, like for s= olving equations or transposing the matrix. I would have to transform it i= nto a 2-dimensional array, right ? On Sunday, November 13, 2016 at 12:30:16 AM UTC+1, Stephen Leake wrote: > On Saturday, November 12, 2016 at 12:16:47 PM UTC-6, hn...@yahoo.de wrote= : > > What is an elegant way to program exchange of columns in a matrix.=20 > > Application:=20 > > C is a matrix. Cj be the j-th column of C. > > Sort C1,C2, ..., Cn in non increasing order with respect to their first= component. > > I tried and ended up in a very messy program, as I had to sort the firs= t components first, remember their new index and then reconstruct the matri= x. >=20 > declare the matrix as an array of columns: >=20 > type Column is array (1 .. 10) of float; > type Matrix is array (1 .. 10) of Column; >=20 > A : Matrix :=3D ...; > Tmp : Column; >=20 > Tmp :=3D A (2); > A (2) :=3D A (1); > A (1) :=3D Tmp;