From: Simon Wright <simon@pushface.org>
Subject: Re: How to pass two dimensional arrays to C
Date: Sun, 30 Jul 2006 12:18:31 +0100
Date: 2006-07-30T12:18:31+01:00 [thread overview]
Message-ID: <m2zmerqr20.fsf@grendel.local> (raw)
In-Reply-To: X2Ryg.107393$1i1.10567@attbi_s72
"Jeffrey R. Carter" <spam.not.jrcarter@acm.not.spam.org> writes:
> So to my mind, and using the notation I've described here, the row
> elements are contiguous. So I don't know whether we agree or
> disagree.
We agree, I think.
I don't remember the last time I wrote anything to do with matrices,
which is some sort of explanation; if you have a 4x4 state transition
table it's not an issue!
with Ada.Text_IO; use Ada.Text_IO;
with System.Storage_Elements; use System.Storage_Elements;
procedure Rows_And_Columns is
package Address_IO is new Modular_IO (Integer_Address); use Address_IO;
type Matrix is array (Integer range <>, Integer range <>) of Integer;
M : Matrix (0 .. 2, 0 .. 3);
begin
for A in M'Range (1) loop
for B in M'Range (2) loop
Put (To_Integer (M (A, B)'Address));
end loop;
New_Line;
end loop;
end Rows_And_Columns;
grendel:~/tmp simon$ ./rows_and_columns
3221223544 3221223548 3221223552 3221223556
3221223560 3221223564 3221223568 3221223572
3221223576 3221223580 3221223584 3221223588
so the last index is the one that has contiguous elements. I guess I
have never looked up 'row-major order' before.
next prev parent reply other threads:[~2006-07-30 11:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-28 11:06 How to pass two dimensional arrays to C Jerry
2006-07-28 12:27 ` Jeffrey Creem
2006-07-28 12:27 ` Dmitry A. Kazakov
2006-07-28 16:53 ` Adam Beneschan
2006-07-28 20:15 ` Jeffrey R. Carter
2006-07-28 20:46 ` Jerry
2006-07-28 21:14 ` Jeffrey Creem
2006-07-28 22:54 ` Björn Persson
2006-07-29 1:14 ` Jeffrey R. Carter
2006-07-29 7:11 ` Simon Wright
2006-07-29 22:12 ` Jeffrey R. Carter
2006-07-30 11:18 ` Simon Wright [this message]
2006-07-30 11:20 ` Simon Wright
2006-07-29 4:19 ` REH
2006-07-29 4:28 ` REH
2006-07-29 4:30 ` REH
2006-08-14 6:59 ` Dave Thompson
2006-07-29 5:47 ` REH
2006-08-02 8:20 ` Jerry
2006-08-02 9:03 ` Dmitry A. Kazakov
2006-08-02 10:22 ` Jerry
2006-08-02 18:25 ` Björn Persson
2006-08-05 1:03 ` Jerry
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox