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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,13ab88b30e0f779d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-27 08:58:45 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out.visi.com!hermes.visi.com!uunet!ash.uu.net!world!news From: Robert A Duff Subject: Re: Efficient Matrix? User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Fri, 27 Dec 2002 16:58:14 GMT Content-Type: text/plain; charset=us-ascii References: <3e0b2a66_4@news.bluewin.ch> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:32333 Date: 2002-12-27T16:58:14+00:00 List-Id: Adrian Knoth writes: > Alvery Grazebrook 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