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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a21dfb63457ea960 X-Google-Attributes: gid103376,public From: boaz@usa.pipeline.com(Boaz Chow) Subject: Re: array of matrices Date: 1996/05/04 Message-ID: <4metga$2jo@news2.h1.usa.pipeline.com>#1/1 X-Deja-AN: 152928220 references: <4mdjbq$df7@newsbf02.news.aol.com> x-pipeuser: boaz x-pipehub: usa.pipeline.com organization: Pipeline USA newsgroups: comp.lang.ada x-pipegcos: (Boaz Chow) Date: 1996-05-04T00:00:00+00:00 List-Id: I have figured out the first method. This is what I have done : type Matrix_Size is array (1..50, 1..50) of integer; type Matrix is record I : integer; J : integer; Info : Matrix_Size; end record; type test_array is (integer range <>) of Matrix; A : test_array(6); Your second method looks very good. But how can I retrive the size (or dimension) of the matrix? On May 03, 1996 14:30:18 in article , 'johnherro@aol.com (John Herro)' wrote: >boaz@usa.pipeline.com(Boaz Chow) writes: >> type Matrix is array (integer range <>, integer range <>) of integer; >> I want to set up a variable for array (1..N) of Matrix; >> I know this won't work: A : array (1..N) of Matrix; >You're right. You can't directly set up an array of an unconstarined >type. There are two things you can do. One is to allow for the largest >possible matrix for every element in the array, and keep track of the >number of rows and columns actually used: > >type Square15 is array(1 .. 15, 1 .. 15) of Integer; >type Matrix is >record >Data : Square15; >Rows : Integer; >Columns : Integer; >end record; >... >A : array(1 .. N) of Matrix; >... >A(1).Rows := 5; >A(1).Columns := 15; >A(2).Rows := 15; >A(2).Columns := 7; >... > >This has the disadvantage of using more memory than you actually need, but >is perhaps a bit simpler than the second way. The second way is to >declare an array of *pointers*. Each pointer can point to a different >size matrix: > >type Matrix is array(Integer range <>, Integer range <>) of Integer; >type Ptr is access Matrix; >... >A : array(1 .. N) of Ptr; >... >A(1) := new Matrix(1 .. 5, 1 .. 15); >A(2) := new Matrix(1 .. 15, 1 .. 7); >... > >I hope this helps. >- John Herro >Software Innovations Technology >http://members.aol.com/AdaTutor >ftp://members.aol.com/AdaTutor -- ______ Meow \ OO / _/ :(__ =) U \\ http://www.sci.csupomona.edu/~cchow