comp.lang.ada
 help / color / mirror / Atom feed
From: johnherro@aol.com (John Herro)
Subject: Re: array of matrices
Date: 1996/05/04
Date: 1996-05-04T00:00:00+00:00	[thread overview]
Message-ID: <4mgpab$ep1@newsbf02.news.aol.com> (raw)
In-Reply-To: 4metga$2jo@news2.h1.usa.pipeline.com


boaz@usa.pipeline.com(Boaz Chow) writes:
> type Matrix is array (integer range <>, integer range <>) of integer;
> Your second method [creating an array of
> pointers to type Matirx] looks very good.
> But how can I retrive the size (or dimension)
> of the matrix?
     On the matrix pointed to, use the attribute 'Last with a subscript. 
For example, if we have

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

then the upper bound of the FIRST dimension of the matrix pointed to by
A(2) is
A(2).all'Last(1),
              -
which is 15, and the upper bound of the SECOND dimension of the matrix
pointed to by A(2) is
A(2).all'Last(2),
              -
which is 7.  Similarly, 'First retrieves the lower bound, so in this
example A(2).all'First(1) and A(2).all'First(2) are both 1.  For one last
example, using A(1) instead of A(2), A(1).all'Last(1) is 5.
     The .all may be omitted in all of these, so A(1)'Last(1) means
A(1).all'Last(1).
     I hope this helps.
- John Herro
Software Innovations Technology
http://members.aol.com/AdaTutor
ftp://members.aol.com/AdaTutor




  reply	other threads:[~1996-05-04  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-02  0:00 array of matrices Boaz Chow
1996-05-03  0:00 ` John Herro
1996-05-04  0:00   ` Boaz Chow
1996-05-04  0:00     ` John Herro [this message]
1996-05-10  0:00   ` Ron J Theriault
replies disabled

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