libflame revision_anchor
Functions
bl1_fnorm.c File Reference

(r)

Functions

void bl1_sfnorm (int m, int n, float *a, int a_rs, int a_cs, float *norm)
 
void bl1_dfnorm (int m, int n, double *a, int a_rs, int a_cs, double *norm)
 
void bl1_cfnorm (int m, int n, scomplex *a, int a_rs, int a_cs, float *norm)
 
void bl1_zfnorm (int m, int n, dcomplex *a, int a_rs, int a_cs, double *norm)
 

Function Documentation

◆ bl1_cfnorm()

void bl1_cfnorm ( int  m,
int  n,
scomplex a,
int  a_rs,
int  a_cs,
float norm 
)
122{
123 scomplex* a_ij;
124 float sum;
125 int lda, inca;
126 int n_iter;
127 int n_elem;
128 int i, j;
129
130 // Return early if possible.
131 if ( bl1_zero_dim2( m, n ) ) return;
132
133 // Handle cases where A is a vector separately.
134 if ( bl1_is_vector( m, n ) )
135 {
136 // Initialize with values appropriate for vectors.
137 n_iter = 1;
138 n_elem = bl1_vector_dim( m, n );
139 lda = 1; // multiplied by zero when n_iter == 1; not needed.
141 }
142 else // matrix case
143 {
144 // Initialize with optimal values for column-major storage.
145 n_iter = n;
146 n_elem = m;
147 lda = a_cs;
148 inca = a_rs;
149
150 // An optimization: if A is row-major, then let's access the matrix by
151 // rows instead of by columns for increased spatial locality.
152 if ( bl1_is_row_storage( a_rs, a_cs ) )
153 {
156 }
157 }
158
159 // Initialize the accumulator variable.
160 sum = 0.0F;
161
162 for ( j = 0; j < n_iter; j++ )
163 {
164 for ( i = 0; i < n_elem; i++ )
165 {
166 a_ij = a + i*inca + j*lda;
167 sum += a_ij->real * a_ij->real + a_ij->imag * a_ij->imag;
168 }
169 }
170
171 // Compute the norm and store the result.
172 *norm = ( float ) sqrt( sum );
173}
int i
Definition bl1_axmyv2.c:145
int bl1_is_row_storage(int rs, int cs)
Definition bl1_is.c:95
int bl1_is_vector(int m, int n)
Definition bl1_is.c:106
int bl1_vector_dim(int m, int n)
Definition bl1_vector.c:13
int bl1_vector_inc(trans1_t trans, int m, int n, int rs, int cs)
Definition bl1_vector.c:19
int bl1_zero_dim2(int m, int n)
Definition bl1_is.c:118
@ BLIS1_NO_TRANSPOSE
Definition blis_type_defs.h:54
Definition blis_type_defs.h:133

References bl1_is_row_storage(), bl1_is_vector(), bl1_vector_dim(), bl1_vector_inc(), bl1_zero_dim2(), BLIS1_NO_TRANSPOSE, i, scomplex::imag, and scomplex::real.

Referenced by FLA_Norm_frob().

◆ bl1_dfnorm()

void bl1_dfnorm ( int  m,
int  n,
double a,
int  a_rs,
int  a_cs,
double norm 
)
68{
69 double* a_ij;
70 double sum;
71 int lda, inca;
72 int n_iter;
73 int n_elem;
74 int i, j;
75
76 // Return early if possible.
77 if ( bl1_zero_dim2( m, n ) ) return;
78
79 // Handle cases where A is a vector separately.
80 if ( bl1_is_vector( m, n ) )
81 {
82 // Initialize with values appropriate for vectors.
83 n_iter = 1;
84 n_elem = bl1_vector_dim( m, n );
85 lda = 1; // multiplied by zero when n_iter == 1; not needed.
87 }
88 else // matrix case
89 {
90 // Initialize with optimal values for column-major storage.
91 n_iter = n;
92 n_elem = m;
93 lda = a_cs;
94 inca = a_rs;
95
96 // An optimization: if A is row-major, then let's access the matrix by
97 // rows instead of by columns for increased spatial locality.
99 {
102 }
103 }
104
105 // Initialize the accumulator variable.
106 sum = 0.0;
107
108 for ( j = 0; j < n_iter; j++ )
109 {
110 for ( i = 0; i < n_elem; i++ )
111 {
112 a_ij = a + i*inca + j*lda;
113 sum += (*a_ij) * (*a_ij);
114 }
115 }
116
117 // Compute the norm and store the result.
118 *norm = sqrt( sum );
119}

References bl1_is_row_storage(), bl1_is_vector(), bl1_vector_dim(), bl1_vector_inc(), bl1_zero_dim2(), BLIS1_NO_TRANSPOSE, and i.

Referenced by FLA_Norm_frob().

◆ bl1_sfnorm()

void bl1_sfnorm ( int  m,
int  n,
float a,
int  a_rs,
int  a_cs,
float norm 
)
14{
15 float* a_ij;
16 float sum;
17 int lda, inca;
18 int n_iter;
19 int n_elem;
20 int i, j;
21
22 // Return early if possible.
23 if ( bl1_zero_dim2( m, n ) ) return;
24
25 // Handle cases where A is a vector separately.
26 if ( bl1_is_vector( m, n ) )
27 {
28 // Initialize with values appropriate for vectors.
29 n_iter = 1;
30 n_elem = bl1_vector_dim( m, n );
31 lda = 1; // multiplied by zero when n_iter == 1; not needed.
33 }
34 else // matrix case
35 {
36 // Initialize with optimal values for column-major storage.
37 n_iter = n;
38 n_elem = m;
39 lda = a_cs;
40 inca = a_rs;
41
42 // An optimization: if A is row-major, then let's access the matrix by
43 // rows instead of by columns for increased spatial locality.
45 {
48 }
49 }
50
51 // Initialize the accumulator variable.
52 sum = 0.0F;
53
54 for ( j = 0; j < n_iter; j++ )
55 {
56 for ( i = 0; i < n_elem; i++ )
57 {
58 a_ij = a + i*inca + j*lda;
59 sum += (*a_ij) * (*a_ij);
60 }
61 }
62
63 // Compute the norm and store the result.
64 *norm = ( float ) sqrt( sum );
65}

References bl1_is_row_storage(), bl1_is_vector(), bl1_vector_dim(), bl1_vector_inc(), bl1_zero_dim2(), BLIS1_NO_TRANSPOSE, and i.

Referenced by FLA_Norm_frob().

◆ bl1_zfnorm()

void bl1_zfnorm ( int  m,
int  n,
dcomplex a,
int  a_rs,
int  a_cs,
double norm 
)
176{
177 dcomplex* a_ij;
178 double sum;
179 int lda, inca;
180 int n_iter;
181 int n_elem;
182 int i, j;
183
184 // Return early if possible.
185 if ( bl1_zero_dim2( m, n ) ) return;
186
187 // Handle cases where A is a vector separately.
188 if ( bl1_is_vector( m, n ) )
189 {
190 // Initialize with values appropriate for vectors.
191 n_iter = 1;
192 n_elem = bl1_vector_dim( m, n );
193 lda = 1; // multiplied by zero when n_iter == 1; not needed.
195 }
196 else // matrix case
197 {
198 // Initialize with optimal values for column-major storage.
199 n_iter = n;
200 n_elem = m;
201 lda = a_cs;
202 inca = a_rs;
203
204 // An optimization: if A is row-major, then let's access the matrix by
205 // rows instead of by columns for increased spatial locality.
206 if ( bl1_is_row_storage( a_rs, a_cs ) )
207 {
210 }
211 }
212
213 // Initialize the accumulator variable.
214 sum = 0.0;
215
216 for ( j = 0; j < n_iter; j++ )
217 {
218 for ( i = 0; i < n_elem; i++ )
219 {
220 a_ij = a + i*inca + j*lda;
221 sum += a_ij->real * a_ij->real + a_ij->imag * a_ij->imag;
222 }
223 }
224
225 // Compute the norm and store the result.
226 *norm = sqrt( sum );
227}
Definition blis_type_defs.h:138

References bl1_is_row_storage(), bl1_is_vector(), bl1_vector_dim(), bl1_vector_inc(), bl1_zero_dim2(), BLIS1_NO_TRANSPOSE, i, dcomplex::imag, and dcomplex::real.

Referenced by FLA_Norm_frob().