summaryrefslogtreecommitdiff
path: root/dev-lang/gdl/files/gdl-1.0.6-test_elmhes.patch
blob: 1c72d6566123cfb279c20766dbded4f207b24edc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
From df26eb84206f9fb2aac72c75b020dbbdf9842cc6 Mon Sep 17 00:00:00 2001
From: Alain <38264661+alaingdl@users.noreply.github.com>
Date: Tue, 4 Jun 2024 18:47:10 +0200
Subject: [PATCH] rewriting test_elhmes to assess small numerical changes
 between x86 & M2 (#1840)

Co-authored-by: coulais <alain.coulais@obspm.fr>
---
 testsuite/test_elmhes.pro | 86 ++++++++++++++++++++++++++++++---------
 1 file changed, 67 insertions(+), 19 deletions(-)

diff --git a/testsuite/test_elmhes.pro b/testsuite/test_elmhes.pro
index 2a094a070..3933a17ff 100644
--- a/testsuite/test_elmhes.pro
+++ b/testsuite/test_elmhes.pro
@@ -1,28 +1,76 @@
-pro TEST_ELMHES, test=test, no_exit=no_exit, help=help
+;
+; Initial version Gilles.
+;
+; ---------------------------------------
+; Modifications history :
+;
+; - 2024-May-29 : AC. small cosmetic change due to troubles on M1/M2
+;
+; ---------------------------------------
+;
+pro PRINT_DEBUG, mess, a, exp_a
+print, mess, a, exp_a, ABS(a-exp_a)
+end
+; ---------------------------------------
+;
+pro TEST_ELMHES, test=test, no_exit=no_exit, help=help, $
+                 verbose=verbose, debug=debug
 ;
 if KEYWORD_SET(help) then begin
-   print, 'pro TEST_ELMHES, test=test, no_exit=no_exit, help=help'
+   print, 'pro TEST_ELMHES, test=test, no_exit=no_exit, help=help, $'
+   print, '                 verbose=verbose, debug=debug'
    return
 endif
 ;
 nb_errors=0
-a=findgen(4,4)+0.5
-b=elmhes(a)
-t=total(b) & p=product(b)
-st=string(t,format='(f012.8)')
-pt=string(p,format='(f012.8)')
-if st ne '101.32080078' or pt ne '-00.00000029' then ERRORS_ADD, nb_errors, 'bad result elmhes'
-b=elmhes(a,/no)
-t=total(b) & p=product(b)
-st=string(t,format='(f012.8)')
-pt=string(p,format='(f012.8)')
-if st ne '096.58079529' or pt ne '-00.00000007' then ERRORS_ADD, nb_errors, 'bad result elmhes,/no_balance'
-b=elmhes(a,/column)
-t=total(b) & p=product(b)
-st=string(t,format='(f012.8)')
-pt=string(p,format='(f012.8)')
-if st ne '099.94132233' or pt ne '000.00000553' then ERRORS_ADD, nb_errors, 'bad result elmhes,/column'
-
+eps=1e-5
+;
+a=FINDGEN(4,4)+0.5
+b=ELMHES(a)
+t=TOTAL(b)
+p=PRODUCT(b)
+expect_tot=101.32079315
+expect_prod=0.0
+mess='bad result ELMHES '
+if (ABS(expect_tot-t) GT eps) then ERRORS_ADD, nb_errors, mess+'T'
+if (ABS(expect_prod-p) GT eps) then ERRORS_ADD, nb_errors, mess+'P'
+if KEYWORD_SET(debug) or KEYWORD_SET(verbose) then begin
+   PRINT_DEBUG, 'p :', p, expect_prod
+   PRINT_DEBUG, 't :', t, expect_tot
+endif
+if KEYWORD_SET(debug) then STOP
+;
+; test with /no_balance
+;
+b=ELMHES(a,/no_bal)
+t=TOTAL(b)
+p=PRODUCT(b)
+expect_tot=96.5808
+expect_prod=0.0
+mess='bad result ELMHES, /no_balance : '
+if (ABS(expect_tot-t) GT eps) then ERRORS_ADD, nb_errors, mess+'T'
+if (ABS(expect_prod-p) GT eps) then ERRORS_ADD, nb_errors, mess+'P'
+if KEYWORD_SET(debug) or KEYWORD_SET(verbose) then begin
+   PRINT_DEBUG, 'p :', p, expect_prod
+   PRINT_DEBUG, 't :', t, expect_tot
+endif
+if KEYWORD_SET(debug) then STOP
+;
+; test with /Column
+;
+b=ELMHES(a,/column)
+t=TOTAL(b)
+p=PRODUCT(b)
+expect_tot=99.941322
+expect_prod=0.0
+mess='bad result ELMHES, /column : '
+if (ABS(expect_tot-t) GT eps) then ERRORS_ADD, nb_errors, mess+'T'
+if (ABS(expect_prod-p) GT eps) then ERRORS_ADD, nb_errors, mess+'P'
+if KEYWORD_SET(debug) or KEYWORD_SET(verbose) then begin
+   PRINT_DEBUG, 'p :', p, expect_prod
+   PRINT_DEBUG, 't :', t, expect_tot
+endif
+if KEYWORD_SET(debug) then STOP
 ;
 ; ----------------- final message ----------
 ;