comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Efficient Matrix?
Date: Fri, 27 Dec 2002 16:58:14 GMT
Date: 2002-12-27T16:58:14+00:00	[thread overview]
Message-ID: <wccadir1jrt.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: slrnb0o8pi.ma5.adi@drcomp.erfurt.thur.de

Adrian Knoth <adi@drcomp.erfurt.thur.de> writes:

> Alvery Grazebrook <nospam@grazebrook.demon.co.uk> wrote:
> 
> >>> type MATRIX is array (POSITIVE range <>, POSITIVE range <>) of BOOLEAN;
> >>> type POINTER_MATRIX is access all MATRIX;
> >>> A : POINTER_MATRIX := new MATRIX(1..10000,1..5000);
> >>
> >>> ideas to optimize this.
> >>   pragma Pack (MATRIX);
> 
> > As you are probably aware, your matrix will take up 5e7 bits, or just
> > under 10 Mbytes of storage, assuming the compiler is efficient in the
> > way it packs the data. 
> 
> I'm not sure whether the compiler packs it at all. It is heap-allocated
> memory (not stack) and it is not a bounded array (the type MATRIX).
> 
> That is why I cancelled my posting you're referring to.

Compilers are required to pack tightly in this case (one bit per Boolean
component).  I.e., Matrix'Component_Size will be 1 if there's a pragma
Pack.  See RM-13.2(9).

It's got nothing to do with the fact that the thing is heap allocated,
nor the fact that the bounds are not known at compile time.
(If the compiler used a different representation for a heap allocated
array than for a stack allocated array, it would have to be continually
translating back and forth.  So compilers don't do that.)

- Bob



  reply	other threads:[~2002-12-27 16:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3e0b2a66_4@news.bluewin.ch>
2002-12-26 22:09 ` Efficient Matrix? Adrian Knoth
2002-12-27  0:23   ` Alvery Grazebrook
2002-12-27  9:53     ` Adrian Knoth
2002-12-27 16:58       ` Robert A Duff [this message]
2002-12-28  1:44         ` Nick Roberts
2002-12-28 13:00         ` Adrian Knoth
2002-12-28 15:21           ` Bill Findlay
2002-12-28 15:48             ` Adrian Knoth
2002-12-28 23:26               ` Adrian Knoth
2002-12-28 16:07             ` Robert A Duff
2002-12-28 17:25               ` Bill Findlay
2002-12-28 17:35                 ` Bill Findlay
2002-12-28 20:51                 ` Robert A Duff
2002-12-28 15:58           ` Robert A Duff
2002-12-28 17:19             ` Adrian Knoth
2002-12-28 19:16               ` James S. Rogers
2002-12-28 20:45               ` Robert A Duff
2002-12-28 22:07                 ` Adrian Knoth
2002-12-28 23:42                   ` Robert A Duff
2002-12-27 12:25 ` Gautier
replies disabled

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