comp.lang.ada
 help / color / mirror / Atom feed
From: hnptz@yahoo.de
Subject: Re: matrix manipulation
Date: Mon, 14 Nov 2016 09:39:55 -0800 (PST)
Date: 2016-11-14T09:39:55-08:00	[thread overview]
Message-ID: <055e3e13-93dc-4653-bc20-e09bd6c53bce@googlegroups.com> (raw)
In-Reply-To: <ac89f4e4-0106-42dc-8ec3-a9cfef91f9db@googlegroups.com>

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. 
> > 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;

How to access a single element of matrix A ? Is it A(1)(1) ? I think, I cannot use it as a Matrix anymore applying build in Ada-procedures, like for solving  equations or transposing the matrix. I would have to transform it into 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. 
> > 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;

  reply	other threads:[~2016-11-14 17:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-12 18:16 matrix manipulation hnptz
2016-11-12 19:12 ` Jacob Sparre Andersen
2016-11-12 23:30 ` Stephen Leake
2016-11-14 17:39   ` hnptz [this message]
2016-11-15 17:54     ` Stephen Leake
2016-11-15 18:57 ` Robert Eachus
  -- strict thread matches above, loose matches on Subject: below --
2019-04-27 14:50 hnptz
2019-04-27 15:05 ` mockturtle
2019-04-27 15:21 ` hnptz
2019-04-27 16:37   ` J-P. Rosen
2019-04-27 16:58     ` mockturtle
2019-04-27 22:45 ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox