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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a0c:ec92:0:b0:534:7a8a:535d with SMTP id u18-20020a0cec92000000b005347a8a535dmr996516qvo.103.1674424588320; Sun, 22 Jan 2023 13:56:28 -0800 (PST) X-Received: by 2002:a9d:6010:0:b0:686:675b:d55b with SMTP id h16-20020a9d6010000000b00686675bd55bmr802959otj.223.1674424588089; Sun, 22 Jan 2023 13:56:28 -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 13:56:27 -0800 (PST) In-Reply-To: <9c7cccd9-733f-49a8-b482-087ccb14b58dn@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=188.150.24.77; posting-account=HFCrOQoAAABZD_f-UUbYHm3lJDIrh-UX NNTP-Posting-Host: 188.150.24.77 References: <9c7cccd9-733f-49a8-b482-087ccb14b58dn@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3db6b678-5a45-4b4d-9f6c-e4933b04d6c2n@googlegroups.com> Subject: Re: Real_Arrays on heap with overloaded operators and clean syntax From: Joakim Strandberg Injection-Date: Sun, 22 Jan 2023 21:56:28 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2670 Xref: reader01.eternal-september.org comp.lang.ada:64848 List-Id: s=C3=B6ndag 22 januari 2023 kl. 22:34:19 UTC+1 skrev dhmos.a...@gmail.com: > Dear ADA lovers,=20 > with stack allocation of Real_Vector ( 1 .. N ) when N >=3D 100,000 I get= STACK_OVERFLOW ERROR while trying to check how fast operator overloading i= s working for an expression=20 >=20 > X :=3D A + B + C + C + A + B, where=20 > A,B,C,X are all Real_Vector ( 1 .. N ).=20 >=20 > So my only option was to allocate on the heap using new. But then I lost = the clean syntax=20 >=20 > X :=3D A + B + C + C + A + B=20 >=20 > and I had to write instead:=20 >=20 > X.all :=3D A.all + B.all + C.all + C.all + A.all + B.all.=20 >=20 > This is really ugly and annoying because when you are using Real_Arrays f= or implementing some linear algebra method who relies heavilly on matrix ve= ctor products and vector updates, you do need to allocate on the heap (size= s are determined in runtime) and you do need a clean syntax. So, is there a= ny way to simplify my life without using the .all or even without declaring= A,B,C,X as access Real_Vector?=20 > Thanks for your time! Easiest solution is probably to declare a new task and specify the stack si= ze using the Storage_Size aspect. Allocate as much stack space as you need = to be able to do the calculations and do all the allocations on the declare= d task, not on the environment task. You will avoid the unnecessary heap al= locations and have nice clean syntax. Best regards, Joakim