comp.lang.ada
 help / color / mirror / Atom feed
From: Gautier write-only address <gautier_niouzes@hotmail.com>
Subject: Re: Real_Arrays on heap with overloaded operators and clean syntax
Date: Sun, 22 Jan 2023 15:14:03 -0800 (PST)	[thread overview]
Message-ID: <49c1bfc5-38aa-4360-81f3-c95f867160een@googlegroups.com> (raw)
In-Reply-To: <6dbff95d-8e30-4a60-ad03-d0aa4cff1583n@googlegroups.com>

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 always write something like the snippet below.
Anyway, after a certain size, you may have to find compromises, like avoiding operators (they do too many allocations & deallocations in the background, even assuming elegant heap-allocated objects) and also give up plain matrices, against sparse matrices or band-stored matrices, typically for solving 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;
  
  n : constant := 10_000;

  type Vector_Access is access Real_Vector;
  type Matrix_Access is access Real_Matrix;

  x, y : Vector_Access := new Real_Vector (1 .. n);
  A    : Matrix_Access := new Real_Matrix (1 .. n, 1 .. n);
  
begin
  Solve_it (x.all, y.all, A.all);
  --  !! Deallocation here
end;

  parent reply	other threads:[~2023-01-22 23:14 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-22 21:34 Real_Arrays on heap with overloaded operators and clean syntax Jim Paloander
2023-01-22 21:56 ` Joakim Strandberg
2023-01-22 22:07   ` Jim Paloander
2023-01-22 22:42     ` Joakim Strandberg
2023-01-22 22:49       ` Jim Paloander
2023-01-22 23:11         ` Joakim Strandberg
2023-01-22 23:14         ` Gautier write-only address [this message]
2023-01-23  1:14           ` Leo Brewin
2023-01-23  6:01             ` Jim Paloander
2023-01-23  8:39     ` G.B.
2023-01-22 22:13 ` Dmitry A. Kazakov
2023-01-22 22:36   ` Jim Paloander
2023-01-23  8:28     ` Dmitry A. Kazakov
2023-01-24  1:04       ` Jim Paloander
2023-01-24 10:42         ` J-P. Rosen
2023-01-25  9:52           ` Jim Paloander
2023-01-25 12:21             ` J-P. Rosen
2023-01-25 22:41               ` Gautier write-only address
2023-01-26 19:08                 ` Jim Paloander
2023-01-22 23:18 ` Rod Kay
2023-01-22 23:20   ` Jim Paloander
2023-01-22 23:34     ` Rod Kay
2023-01-22 23:53       ` Joakim Strandberg
2023-01-23  7:50         ` Egil H H
2023-01-23  8:51           ` J-P. Rosen
2023-01-23  6:34       ` Rod Kay
2023-01-23  6:56         ` Jim Paloander
2023-01-23  7:31           ` Rod Kay
2023-01-24 19:47 ` Gautier write-only address
2023-01-24 23:02   ` Gautier write-only address
2023-01-25  9:50     ` Jim Paloander
2023-01-26 20:39 ` Jerry
2023-01-26 21:52   ` Jim Paloander
2023-02-02 21:59     ` Jerry
replies disabled

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