From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:620a:1394:b0:706:50b5:abca with SMTP id k20-20020a05620a139400b0070650b5abcamr1279035qki.465.1674429243988; Sun, 22 Jan 2023 15:14:03 -0800 (PST) X-Received: by 2002:a9d:694e:0:b0:686:516d:6ad5 with SMTP id p14-20020a9d694e000000b00686516d6ad5mr1204441oto.333.1674429243766; Sun, 22 Jan 2023 15:14:03 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 22 Jan 2023 15:14:03 -0800 (PST) In-Reply-To: <6dbff95d-8e30-4a60-ad03-d0aa4cff1583n@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1210:2824:7200:8547:a7ee:d0c8:acc; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG NNTP-Posting-Host: 2a02:1210:2824:7200:8547:a7ee:d0c8:acc References: <9c7cccd9-733f-49a8-b482-087ccb14b58dn@googlegroups.com> <3db6b678-5a45-4b4d-9f6c-e4933b04d6c2n@googlegroups.com> <6dbff95d-8e30-4a60-ad03-d0aa4cff1583n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <49c1bfc5-38aa-4360-81f3-c95f867160een@googlegroups.com> Subject: Re: Real_Arrays on heap with overloaded operators and clean syntax From: Gautier write-only address Injection-Date: Sun, 22 Jan 2023 23:14:03 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2770 Xref: reader01.eternal-september.org comp.lang.ada:64856 List-Id: Note that Real_Arrays does not specify where things are allocated (heap or = stack). Only when you define "x : Real_Vector (1 .. n)", it is on stack. You can al= ways write something like the snippet below. Anyway, after a certain size, you may have to find compromises, like avoidi= ng operators (they do too many allocations & deallocations in the backgroun= d, even assuming elegant heap-allocated objects) and also give up plain mat= rices, against sparse matrices or band-stored matrices, typically for solvi= ng Partial Differential Equations. with Ada.Numerics.Generic_Real_Arrays; procedure Test_Large is type Float_15 is digits 15; package F15_R_A is new Ada.Numerics.Generic_Real_Arrays (Float_15); use F15_R_A; procedure Solve_it (x : in Real_Vector; y : out Real_Vector; A : in Real_Matrix) is begin null; -- Here, the big number-crunching end; =20 n : constant :=3D 10_000; type Vector_Access is access Real_Vector; type Matrix_Access is access Real_Matrix; x, y : Vector_Access :=3D new Real_Vector (1 .. n); A : Matrix_Access :=3D new Real_Matrix (1 .. n, 1 .. n); =20 begin Solve_it (x.all, y.all, A.all); -- !! Deallocation here end;