1
1
!> Matrix and Vector norms
2
2
module la_norms
3
3
use la_constants
4
- use la_blas,only:nrm2
5
- use la_lapack,only:lange
4
+ use la_blas,only: nrm2
5
+ use la_lapack,only: lange
6
6
use la_state_type
7
- use iso_fortran_env,only:real32,real64,real128,int8,int16,int32,int64,stderr => error_unit
8
7
implicit none(type,external)
9
8
private
10
9
@@ -21,14 +20,40 @@ module la_norms
21
20
integer(ilp),parameter :: NORM_MINUSINF = -huge(0_ilp)
22
21
23
22
!> List of *LANGE norm flags
24
- character,parameter :: LANGE_NORM_MAT = 'M' ! maxval(sum(abs(a))) ! over whole matrix: unused
25
- character,parameter :: LANGE_NORM_ONE = '1' ! maxval(sum(abs(a),1)) ! over columns
26
- character,parameter :: LANGE_NORM_INF = 'I' ! maxval(sum(abs(a),2)) ! over rows
27
- character,parameter :: LANGE_NORM_TWO = 'E' ! "Euclidean" or "Frobenius"
23
+ character,parameter :: LANGE_NORM_MAT = 'M' !> maxval(sum(abs(a))) over whole matrix: unused
24
+ character,parameter :: LANGE_NORM_ONE = '1' !> maxval(sum(abs(a),1)) over columns
25
+ character,parameter :: LANGE_NORM_INF = 'I' !> maxval(sum(abs(a),2)) over rows
26
+ character,parameter :: LANGE_NORM_TWO = 'E' !> "Euclidean" or "Frobenius"
28
27
29
- !> Vector norm: function interface
28
+ !> @brief Compute the norm of a vector or matrix using LAPACK-based routines.
29
+ !!
30
+ !! Return one of several scalar norm metrics of a real or complex input array A, that can have any rank.
31
+ !! For generic rank-n arrays, the scalar norm over the whole array is returned by default.
32
+ !! If \f$ n \geq 2 \f$ and the optional input dimension `dim` is specified, a rank \f$ n-1 \f$ array is returned with dimension `dim` collapsed,
33
+ !! containing all 1D array norms evaluated along dimension `dim` only.
34
+ !!
35
+ !! Norm type input is mandatory, and it is provided via the `order` argument. This can be provided as either an integer value or a character string.
36
+ !! Allowed metrics are:
37
+ !! - 1-norm \f$ \sum_i |a_i| \f$: `order = 1` or `order = "1"`
38
+ !! - Euclidean norm \f$ \sqrt{\sum_i a_i^2} \f$: `order = 2` or `order = "2"`
39
+ !! - p-norm \f$ \left( \sum_i |a_i|^p \right)^{1/p} \f$: integer `order >= 3`
40
+ !! - Infinity norm \f$ \max_i |a_i| \f$: `order = huge(0)` or `"inf"`
41
+ !! - Minus-infinity norm \f$ \min_i |a_i| \f$: `order = -huge(0)` or `"-inf"`
42
+ !!
43
+ !! @param[in] a The input vector or matrix. It may have rank 1 (vector) or higher.
44
+ !! @param[in] order The order of the norm to compute, typically one of the allowed metrics.
45
+ !! @param[in] dim (Optional) The dimension along which to compute the norm,
46
+ !! applicable for array norms reducing rank.
47
+ !! @param[out] err (Optional) A state return flag. If an error occurs and `err` is not provided,
48
+ !! the function will stop execution.
49
+ !!
50
+ !! @return The computed norm value. If `dim` is specified, the result is a lower-rank array;
51
+ !! otherwise, it is a scalar.
52
+ !!
53
+ !! @note This interface utilizes LAPACK routines for efficient computation, ensuring numerical stability.
54
+ !! @warning If invalid input values (such as negative norms) are provided, the behavior is undefined.
55
+ !!
30
56
interface norm
31
- !> Scalar norms: real(sp)
32
57
module procedure la_norm_1D_order_char_s
33
58
module procedure la_norm_1D_order_err_char_s
34
59
module procedure la_norm_2D_order_char_s
@@ -43,7 +68,6 @@ module la_norms
43
68
module procedure la_norm_6D_order_err_char_s
44
69
module procedure la_norm_7D_order_char_s
45
70
module procedure la_norm_7D_order_err_char_s
46
- !> Array norms: real(sp)
47
71
module procedure la_norm_2D_to_1D_char_s
48
72
module procedure la_norm_2D_to_1D_err_char_s
49
73
module procedure la_norm_3D_to_2D_char_s
@@ -56,7 +80,6 @@ module la_norms
56
80
module procedure la_norm_6D_to_5D_err_char_s
57
81
module procedure la_norm_7D_to_6D_char_s
58
82
module procedure la_norm_7D_to_6D_err_char_s
59
- !> Scalar norms: real(sp)
60
83
module procedure la_norm_1D_order_int_s
61
84
module procedure la_norm_1D_order_err_int_s
62
85
module procedure la_norm_2D_order_int_s
@@ -71,7 +94,6 @@ module la_norms
71
94
module procedure la_norm_6D_order_err_int_s
72
95
module procedure la_norm_7D_order_int_s
73
96
module procedure la_norm_7D_order_err_int_s
74
- !> Array norms: real(sp)
75
97
module procedure la_norm_2D_to_1D_int_s
76
98
module procedure la_norm_2D_to_1D_err_int_s
77
99
module procedure la_norm_3D_to_2D_int_s
@@ -84,7 +106,6 @@ module la_norms
84
106
module procedure la_norm_6D_to_5D_err_int_s
85
107
module procedure la_norm_7D_to_6D_int_s
86
108
module procedure la_norm_7D_to_6D_err_int_s
87
- !> Scalar norms: real(dp)
88
109
module procedure la_norm_1D_order_char_d
89
110
module procedure la_norm_1D_order_err_char_d
90
111
module procedure la_norm_2D_order_char_d
@@ -99,7 +120,6 @@ module la_norms
99
120
module procedure la_norm_6D_order_err_char_d
100
121
module procedure la_norm_7D_order_char_d
101
122
module procedure la_norm_7D_order_err_char_d
102
- !> Array norms: real(dp)
103
123
module procedure la_norm_2D_to_1D_char_d
104
124
module procedure la_norm_2D_to_1D_err_char_d
105
125
module procedure la_norm_3D_to_2D_char_d
@@ -112,7 +132,6 @@ module la_norms
112
132
module procedure la_norm_6D_to_5D_err_char_d
113
133
module procedure la_norm_7D_to_6D_char_d
114
134
module procedure la_norm_7D_to_6D_err_char_d
115
- !> Scalar norms: real(dp)
116
135
module procedure la_norm_1D_order_int_d
117
136
module procedure la_norm_1D_order_err_int_d
118
137
module procedure la_norm_2D_order_int_d
@@ -127,7 +146,6 @@ module la_norms
127
146
module procedure la_norm_6D_order_err_int_d
128
147
module procedure la_norm_7D_order_int_d
129
148
module procedure la_norm_7D_order_err_int_d
130
- !> Array norms: real(dp)
131
149
module procedure la_norm_2D_to_1D_int_d
132
150
module procedure la_norm_2D_to_1D_err_int_d
133
151
module procedure la_norm_3D_to_2D_int_d
@@ -140,7 +158,6 @@ module la_norms
140
158
module procedure la_norm_6D_to_5D_err_int_d
141
159
module procedure la_norm_7D_to_6D_int_d
142
160
module procedure la_norm_7D_to_6D_err_int_d
143
- !> Scalar norms: real(qp)
144
161
module procedure la_norm_1D_order_char_q
145
162
module procedure la_norm_1D_order_err_char_q
146
163
module procedure la_norm_2D_order_char_q
@@ -155,7 +172,6 @@ module la_norms
155
172
module procedure la_norm_6D_order_err_char_q
156
173
module procedure la_norm_7D_order_char_q
157
174
module procedure la_norm_7D_order_err_char_q
158
- !> Array norms: real(qp)
159
175
module procedure la_norm_2D_to_1D_char_q
160
176
module procedure la_norm_2D_to_1D_err_char_q
161
177
module procedure la_norm_3D_to_2D_char_q
@@ -168,7 +184,6 @@ module la_norms
168
184
module procedure la_norm_6D_to_5D_err_char_q
169
185
module procedure la_norm_7D_to_6D_char_q
170
186
module procedure la_norm_7D_to_6D_err_char_q
171
- !> Scalar norms: real(qp)
172
187
module procedure la_norm_1D_order_int_q
173
188
module procedure la_norm_1D_order_err_int_q
174
189
module procedure la_norm_2D_order_int_q
@@ -183,7 +198,6 @@ module la_norms
183
198
module procedure la_norm_6D_order_err_int_q
184
199
module procedure la_norm_7D_order_int_q
185
200
module procedure la_norm_7D_order_err_int_q
186
- !> Array norms: real(qp)
187
201
module procedure la_norm_2D_to_1D_int_q
188
202
module procedure la_norm_2D_to_1D_err_int_q
189
203
module procedure la_norm_3D_to_2D_int_q
@@ -196,7 +210,6 @@ module la_norms
196
210
module procedure la_norm_6D_to_5D_err_int_q
197
211
module procedure la_norm_7D_to_6D_int_q
198
212
module procedure la_norm_7D_to_6D_err_int_q
199
- !> Scalar norms: complex(sp)
200
213
module procedure la_norm_1D_order_char_c
201
214
module procedure la_norm_1D_order_err_char_c
202
215
module procedure la_norm_2D_order_char_c
@@ -351,7 +364,6 @@ module la_norms
351
364
module procedure la_norm_6D_order_err_int_w
352
365
module procedure la_norm_7D_order_int_w
353
366
module procedure la_norm_7D_order_err_int_w
354
- !> Array norms: complex(qp)
355
367
module procedure la_norm_2D_to_1D_int_w
356
368
module procedure la_norm_2D_to_1D_err_int_w
357
369
module procedure la_norm_3D_to_2D_int_w
0 commit comments