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 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.99.5.147 with SMTP id 141mr3000264pgf.3.1478993415548; Sat, 12 Nov 2016 15:30:15 -0800 (PST) X-Received: by 10.157.37.247 with SMTP id q110mr833923ota.5.1478993415508; Sat, 12 Nov 2016 15:30:15 -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!q124no179953itd.0!news-out.google.com!x12ni1812ita.0!nntp.google.com!q124no179947itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 12 Nov 2016 15:30:15 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.218.37.33; posting-account=W2gdXQoAAADxIuhBWhPFjUps3wUp4RhQ NNTP-Posting-Host: 76.218.37.33 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: matrix manipulation From: Stephen Leake Injection-Date: Sat, 12 Nov 2016 23:30:15 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:32296 Date: 2016-11-12T15:30:15-08:00 List-Id: 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. > Application: > 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 first components first, remember their new index and then reconstruct the matrix. declare the matrix as an array of columns: type Column is array (1 .. 10) of float; type Matrix is array (1 .. 10) of Column; A : Matrix := ...; Tmp : Column; Tmp := A (2); A (2) := A (1); A (1) := Tmp;