public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix PR ada/78845
@ 2016-12-17 11:10 Simon Wright
  2016-12-20 12:14 ` Arnaud Charlet
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Wright @ 2016-12-17 11:10 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 548 bytes --]

The function Ada.Numerics.Generic_Real_Arrays.Inverse is required (ARM G.3.1(72)) to return a matrix with the bounds of the dimension indices swapped, i.e. result'Range(1) == input'Range(2) and vice versa. The present code gets result'Range(1) correct, but result'Range(2) always starts at 1.

Of course, many users would always use ranges starting at 1 and wouldn't see a problem.

2016-12-17  Simon Wright  <simon@pushface.org>

	PR ada/78845
	* a-ngrear.adb (Inverse): call Unit_Matrix with First_1 set to A'First(2)
	and vice versa.


[-- Attachment #2: a-ngrear.adb.diff --]
[-- Type: application/octet-stream, Size: 446 bytes --]

--- a-ngrear.adb-orig	2012-03-07 14:45:51.000000000 +0000
+++ a-ngrear.adb	2016-12-17 09:15:02.000000000 +0000
@@ -498,7 +498,9 @@
    -------------
 
    function Inverse (A : Real_Matrix) return Real_Matrix is
-     (Solve (A, Unit_Matrix (Length (A))));
+     (Solve (A, Unit_Matrix (Length (A),
+                             First_1 => A'First (2),
+                             First_2 => A'First (1))));
 
    ------------
    -- Jacobi --

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Ada] Fix PR ada/78845
  2016-12-17 11:10 [Ada] Fix PR ada/78845 Simon Wright
@ 2016-12-20 12:14 ` Arnaud Charlet
       [not found]   ` <B2185111-5A47-432A-B562-A65199236B25@pushface.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Arnaud Charlet @ 2016-12-20 12:14 UTC (permalink / raw)
  To: Simon Wright; +Cc: gcc-patches, Ed Schonberg

> The function Ada.Numerics.Generic_Real_Arrays.Inverse is required
> (ARM G.3.1(72)) to return a matrix with the bounds of the dimension indices
> swapped, i.e. result'Range(1) == input'Range(2) and vice versa. The
> present code gets result'Range(1) correct, but result'Range(2) always
> starts at 1.
> 
> Of course, many users would always use ranges starting at 1 and wouldn't see a
> problem.
> 
> 2016-12-17  Simon Wright  <simon@pushface.org>
> 
> 	PR ada/78845
> 	* a-ngrear.adb (Inverse): call Unit_Matrix with First_1 set to
> 	A'First(2)
> 	and vice versa.

Patch is OK, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Ada] Fix PR ada/78845
       [not found]   ` <B2185111-5A47-432A-B562-A65199236B25@pushface.org>
@ 2016-12-21  8:52     ` Arnaud Charlet
       [not found]       ` <4D07E255-BDCD-47AC-A546-926E024E2425@pushface.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Arnaud Charlet @ 2016-12-21  8:52 UTC (permalink / raw)
  To: Simon Wright; +Cc: gcc-patches, Ed Schonberg

> >> 2016-12-17  Simon Wright  <simon@pushface.org>
> >> 
> >> 	PR ada/78845
> >> 	* a-ngrear.adb (Inverse): call Unit_Matrix with First_1 set to
> >> 	A'First(2)
> >> 	and vice versa.
> > 
> > Patch is OK, thanks.
> 
> The same problem exists in Ada.Numerics.Generic_Complex_Arrays
> (a-congar.adb). Should I update the PR and this patch?

Yes, please resend an updated patch.

Arno

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Ada] Fix PR ada/78845
       [not found]       ` <4D07E255-BDCD-47AC-A546-926E024E2425@pushface.org>
@ 2016-12-21 15:03         ` Arnaud Charlet
  2017-01-10 11:18           ` Simon Wright
  0 siblings, 1 reply; 6+ messages in thread
From: Arnaud Charlet @ 2016-12-21 15:03 UTC (permalink / raw)
  To: Simon Wright; +Cc: gcc-patches, Ed Schonberg

> > Yes, please resend an updated patch.
> 
> The function Ada.Numerics.Generic_Real_Arrays.Inverse is required
> (ARM G.3.1(72)) to
> return a matrix with the bounds of the dimension indices swapped, i.e.
> result'Range(1) ==
> input'Range(2) and vice versa. The present code gets result'Range(1)
> correct, but
> result'Range(2) always starts at 1.
> 
> Of course, many users would always use ranges starting at 1 and wouldn't see a
> problem.
> 
> The same applies to Ada.Numerics.Complex_Real_Arrays.Inverse (ARM
> G.3.2(140)).

Updated patch OK as well.

> 2016-12-21  Simon Wright  <simon@pushface.org
> <mailto:simon@pushface.org>>
> 
> 	PR ada/78845
> 	* a-ngcoar.adb (Inverse): call Unit_Matrix with First_1 set to
> 	A'First(2)
> 	  and vice versa.
> 	* a-ngrear.adb (Inverse): likewise.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Ada] Fix PR ada/78845
  2016-12-21 15:03         ` Arnaud Charlet
@ 2017-01-10 11:18           ` Simon Wright
  2017-01-10 12:02             ` Arnaud Charlet
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Wright @ 2017-01-10 11:18 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: gcc-patches, Ed Schonberg

[-- Attachment #1: Type: text/plain, Size: 1029 bytes --]

On 21 Dec 2016, at 14:52, Arnaud Charlet <charlet@adacore.com> wrote:
> 
>>> Yes, please resend an updated patch.
>> 
>> The function Ada.Numerics.Generic_Real_Arrays.Inverse is required
>> (ARM G.3.1(72)) to
>> return a matrix with the bounds of the dimension indices swapped, i.e.
>> result'Range(1) ==
>> input'Range(2) and vice versa. The present code gets result'Range(1)
>> correct, but
>> result'Range(2) always starts at 1.
>> 
>> Of course, many users would always use ranges starting at 1 and wouldn't see a
>> problem.
>> 
>> The same applies to Ada.Numerics.Complex_Real_Arrays.Inverse (ARM
>> G.3.2(140)).
> 
> Updated patch OK as well.
> 
>> 2016-12-21  Simon Wright  <simon@pushface.org
>> <mailto:simon@pushface.org>>
>> 
>> 	PR ada/78845
>> 	* a-ngcoar.adb (Inverse): call Unit_Matrix with First_1 set to
>> 	A'First(2)
>> 	  and vice versa.
>> 	* a-ngrear.adb (Inverse): likewise.

Can the patch be committed, please, when convenient?

(patch reposted below for convenience)



[-- Attachment #2: pr78845.diff --]
[-- Type: application/octet-stream, Size: 902 bytes --]

--- a-ngcoar.adb-orig	2016-12-21 11:28:40.000000000 +0000
+++ a-ngcoar.adb	2016-12-21 11:29:35.000000000 +0000
@@ -1154,7 +1154,9 @@
    -------------
 
    function Inverse (A : Complex_Matrix) return Complex_Matrix is
-     (Solve (A, Unit_Matrix (Length (A))));
+     (Solve (A, Unit_Matrix (Length (A),
+                             First_1 => A'First (2),
+                             First_2 => A'First (1))));
 
    -------------
    -- Modulus --
--- a-ngrear.adb-orig	2012-03-07 14:45:51.000000000 +0000
+++ a-ngrear.adb	2016-12-17 09:15:02.000000000 +0000
@@ -498,7 +498,9 @@
    -------------
 
    function Inverse (A : Real_Matrix) return Real_Matrix is
-     (Solve (A, Unit_Matrix (Length (A))));
+     (Solve (A, Unit_Matrix (Length (A),
+                             First_1 => A'First (2),
+                             First_2 => A'First (1))));
 
    ------------
    -- Jacobi --

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Ada] Fix PR ada/78845
  2017-01-10 11:18           ` Simon Wright
@ 2017-01-10 12:02             ` Arnaud Charlet
  0 siblings, 0 replies; 6+ messages in thread
From: Arnaud Charlet @ 2017-01-10 12:02 UTC (permalink / raw)
  To: Simon Wright; +Cc: gcc-patches, Ed Schonberg

> >> 2016-12-21  Simon Wright  <simon@pushface.org
> >> <mailto:simon@pushface.org>>
> >> 
> >> 	PR ada/78845
> >> 	* a-ngcoar.adb (Inverse): call Unit_Matrix with First_1 set to
> >> 	A'First(2)
> >> 	  and vice versa.
> >> 	* a-ngrear.adb (Inverse): likewise.
> 
> Can the patch be committed, please, when convenient?

Yes, will do it when convenient :-) Feel free to find someone with write
access in the meantime if you're in a hurry.

Arno

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-10 12:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-17 11:10 [Ada] Fix PR ada/78845 Simon Wright
2016-12-20 12:14 ` Arnaud Charlet
     [not found]   ` <B2185111-5A47-432A-B562-A65199236B25@pushface.org>
2016-12-21  8:52     ` Arnaud Charlet
     [not found]       ` <4D07E255-BDCD-47AC-A546-926E024E2425@pushface.org>
2016-12-21 15:03         ` Arnaud Charlet
2017-01-10 11:18           ` Simon Wright
2017-01-10 12:02             ` Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).