comp.lang.ada
 help / color / mirror / Atom feed
From: Jim Paloander <dhmos.altiotis@gmail.com>
Subject: Re: Real_Arrays on heap with overloaded operators and clean syntax
Date: Sun, 22 Jan 2023 22:01:58 -0800 (PST)	[thread overview]
Message-ID: <7ac68f96-7041-4b3c-adbc-547b17735357n@googlegroups.com> (raw)
In-Reply-To: <tqkn2f$3b6l0$1@dont-email.me>

On Monday, January 23, 2023 at 2:14:58 AM UTC+1, Leo Brewin wrote:
> Here is a slight variation on the solution suggested by Gautier. It uses 
> Aad's "rename" syntax so that you can avoid all the .all stuff. I use 
> this construction extensively in my large scale scientific computations. 
> 
> with Ada.Numerics.Generic_Real_Arrays; 
> with Ada.Unchecked_Deallocation;
> 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_ptr, y_ptr : Vector_Access := new Real_Vector (1 .. n); 
> A_ptr : Matrix_Access := new Real_Matrix (1 .. n, 1 .. n); 
> 
> x : Real_Vector renames x_ptr.all; 
> y : Real_Vector renames y_ptr.all; 
> A : Real_Matrix renames A_ptr.all; 
> 
> procedure FreeVector is new 
> Ada.Unchecked_Deallocation (Real_Vector,Vector_Access); 
> procedure FreeMatrix is new 
> Ada.Unchecked_Deallocation (Real_Matrix,Matrix_Access); 
> 
> begin 
> Solve_it (x, y, A); 
> -- Deallocation here 
> FreeVector (x_ptr); 
> FreeVector (y_ptr); 
> FreeMatrix (A_ptr); 
> end;

Thank you very much, would a       for Real_Vector_Access'Storage_Pool use localPool; save you from the need to free the vectors and matrix yourself?

On the other hand, is there any  way of avoiding temporaries? Possibly a modern version of the Real_Array using expression generic syntax or something similar? Since you are using scientific computationas extensively, you must be aware of Fortran. Have you compared Fortran's complex numbers with ADA's for inner products or similar computations to see who is faster? You see, I like a lot of things about ADA, but the syntax is really difficult to follow. Sometimes it gives me the impression that it is more difficult than really needed to be. For example there should be a way for Real_Arrays to allocate memory internally and not on the stack directly like containers. And for containers to provide an indexer Vector(i) and overloaded operators similarly to Real_Vectors. But the fact that they do not give me the impression that this Language although being designed by the army for mission critical applications never realized that modern mission critical need to simplify mathematical calculations providing an easy syntax. I am surprised that after so many years and so many updates to the Standard the designers of the Language did not realized that such mathematical syntax should be simplified to attract more people from scientific computing, who are tired with Fortran 10000 ways of declaring something a variable.

  reply	other threads:[~2023-01-23  6:01 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
2023-01-23  1:14           ` Leo Brewin
2023-01-23  6:01             ` Jim Paloander [this message]
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