libflame revision_anchor
Functions
bl1_randmr.c File Reference

(r)

Functions

void bl1_srandmr (uplo1_t uplo, diag1_t diag, int m, int n, float *a, int a_rs, int a_cs)
 
void bl1_drandmr (uplo1_t uplo, diag1_t diag, int m, int n, double *a, int a_rs, int a_cs)
 
void bl1_crandmr (uplo1_t uplo, diag1_t diag, int m, int n, scomplex *a, int a_rs, int a_cs)
 
void bl1_zrandmr (uplo1_t uplo, diag1_t diag, int m, int n, dcomplex *a, int a_rs, int a_cs)
 

Function Documentation

◆ bl1_crandmr()

void bl1_crandmr ( uplo1_t  uplo,
diag1_t  diag,
int  m,
int  n,
scomplex a,
int  a_rs,
int  a_cs 
)
256{
258 scomplex* ajj;
262 int lda, inca;
263 int n_iter;
264 int n_elem_max;
265 int n_elem;
266 int j;
267
268 // Return early if possible.
269 if ( bl1_zero_dim2( m, n ) ) return;
270
271 // Initialize with optimal values for column-major storage.
272 n_iter = n;
273 n_elem_max = m;
274 lda = a_cs;
275 inca = a_rs;
276
277 // An optimization: if A is row-major, then let's access the matrix by
278 // rows instead of by columns to increase spatial locality.
279 if ( bl1_is_row_storage( a_rs, a_cs ) )
280 {
283 bl1_toggle_uplo( uplo );
284 }
285
286 // Initialize some scalars.
287 one = bl1_c1();
288 zero = bl1_c0();
289 ord = bl1_c0();
290 ord.real = ( float ) bl1_max( m, n );
291
292 if ( bl1_is_upper( uplo ) )
293 {
294 for ( j = 0; j < n_iter; j++ )
295 {
297 a_begin = a + j*lda;
298
299 // Randomize super-diagonal elements.
301 a_begin, inca );
302
303 // Normalize super-diagonal elements by order of the matrix.
305 n_elem,
306 &ord,
307 a_begin, inca );
308
309 // Initialize diagonal and sub-diagonal elements only if there are
310 // elements left in the column (ie: j < n_elem_max).
311 if ( j < n_elem_max )
312 {
313 ajj = a_begin + j*inca;
314
315 // Initialize diagonal element.
316 if ( bl1_is_unit_diag( diag ) ) *ajj = one;
317 else if ( bl1_is_zero_diag( diag ) ) *ajj = zero;
318 else if ( bl1_is_nonunit_diag( diag ) )
319 {
320 // We want positive diagonal elements between 1 and 2.
321 bl1_crands( ajj );
322 bl1_cabsval2( ajj, ajj );
323 bl1_cadd3( ajj, &one, ajj );
324 }
325
326 // Initialize sub-diagonal elements to zero.
327 bl1_csetv( n_elem_max - j - 1,
328 &zero,
329 ajj + inca, inca );
330 }
331 }
332 }
333 else // if ( bl1_is_lower( uplo ) )
334 {
335 for ( j = 0; j < n_iter; j++ )
336 {
338 a_begin = a + j*lda;
339
340 // Initialize super-diagonal to zero.
342 &zero,
343 a_begin, inca );
344
345 // Initialize diagonal and sub-diagonal elements only if there are
346 // elements left in the column (ie: j < n_elem_max).
347 if ( j < n_elem_max )
348 {
349 ajj = a_begin + j*inca;
350
351 // Initialize diagonal element.
352 if ( bl1_is_unit_diag( diag ) ) *ajj = one;
353 else if ( bl1_is_zero_diag( diag ) ) *ajj = zero;
354 else if ( bl1_is_nonunit_diag( diag ) )
355 {
356 // We want positive diagonal elements between 1 and 2.
357 bl1_crands( ajj );
358 bl1_cabsval2( ajj, ajj );
359 bl1_cadd3( ajj, &one, ajj );
360 }
361
362 // Randomize sub-diagonal elements.
363 bl1_crandv( n_elem_max - j - 1,
364 ajj + inca, inca );
365
366 // Normalize sub-diagonal elements by order of the matrix.
368 n_elem_max - j - 1,
369 &ord,
370 ajj + inca, inca );
371
372 }
373 }
374 }
375}
int i
Definition bl1_axmyv2.c:145
void bl1_cinvscalv(conj1_t conj, int n, scomplex *alpha, scomplex *x, int incx)
Definition bl1_invscalv.c:52
int bl1_is_unit_diag(diag1_t diag)
Definition bl1_is.c:78
int bl1_is_zero_diag(diag1_t diag)
Definition bl1_is.c:83
int bl1_is_row_storage(int rs, int cs)
Definition bl1_is.c:95
int bl1_is_upper(uplo1_t uplo)
Definition bl1_is.c:54
int bl1_is_nonunit_diag(diag1_t diag)
Definition bl1_is.c:73
int bl1_zero_dim2(int m, int n)
Definition bl1_is.c:118
scomplex bl1_c1(void)
Definition bl1_constants.c:61
void bl1_csetv(int m, scomplex *sigma, scomplex *x, int incx)
Definition bl1_setv.c:52
void bl1_crands(scomplex *alpha)
Definition bl1_rands.c:23
scomplex bl1_c0(void)
Definition bl1_constants.c:125
void bl1_crandv(int n, scomplex *x, int incx)
Definition bl1_randv.c:39
@ BLIS1_NO_CONJUGATE
Definition blis_type_defs.h:81
Definition blis_type_defs.h:133

References bl1_c0(), bl1_c1(), bl1_cinvscalv(), bl1_crands(), bl1_crandv(), bl1_csetv(), bl1_is_nonunit_diag(), bl1_is_row_storage(), bl1_is_unit_diag(), bl1_is_upper(), bl1_is_zero_diag(), bl1_zero_dim2(), BLIS1_NO_CONJUGATE, and scomplex::real.

Referenced by FLA_Random_tri_matrix().

◆ bl1_drandmr()

void bl1_drandmr ( uplo1_t  uplo,
diag1_t  diag,
int  m,
int  n,
double a,
int  a_rs,
int  a_cs 
)
135{
136 double* a_begin;
137 double* ajj;
138 double one;
139 double zero;
140 double ord;
141 int lda, inca;
142 int n_iter;
143 int n_elem_max;
144 int n_elem;
145 int j;
146
147 // Return early if possible.
148 if ( bl1_zero_dim2( m, n ) ) return;
149
150 // Initialize with optimal values for column-major storage.
151 n_iter = n;
152 n_elem_max = m;
153 lda = a_cs;
154 inca = a_rs;
155
156 // An optimization: if A is row-major, then let's access the matrix by
157 // rows instead of by columns to increase spatial locality.
158 if ( bl1_is_row_storage( a_rs, a_cs ) )
159 {
162 bl1_toggle_uplo( uplo );
163 }
164
165 // Initialize some scalars.
166 one = bl1_d1();
167 zero = bl1_d0();
168 ord = ( double ) bl1_max( m, n );
169
170 if ( bl1_is_upper( uplo ) )
171 {
172 for ( j = 0; j < n_iter; j++ )
173 {
175 a_begin = a + j*lda;
176
177 // Randomize super-diagonal elements.
179 a_begin, inca );
180
181 // Normalize super-diagonal elements by order of the matrix.
183 n_elem,
184 &ord,
185 a_begin, inca );
186
187 // Initialize diagonal and sub-diagonal elements only if there are
188 // elements left in the column (ie: j < n_elem_max).
189 if ( j < n_elem_max )
190 {
191 ajj = a_begin + j*inca;
192
193 // Initialize diagonal element.
194 if ( bl1_is_unit_diag( diag ) ) *ajj = one;
195 else if ( bl1_is_zero_diag( diag ) ) *ajj = zero;
196 else if ( bl1_is_nonunit_diag( diag ) )
197 {
198 // We want positive diagonal elements between 1 and 2.
199 bl1_drands( ajj );
200 bl1_dabsval2( ajj, ajj );
201 bl1_dadd3( ajj, &one, ajj );
202 }
203
204 // Initialize sub-diagonal elements to zero.
205 bl1_dsetv( n_elem_max - j - 1,
206 &zero,
207 ajj + inca, inca );
208 }
209 }
210 }
211 else // if ( bl1_is_lower( uplo ) )
212 {
213 for ( j = 0; j < n_iter; j++ )
214 {
216 a_begin = a + j*lda;
217
218 // Initialize super-diagonal to zero.
220 &zero,
221 a_begin, inca );
222
223 // Initialize diagonal and sub-diagonal elements only if there are
224 // elements left in the column (ie: j < n_elem_max).
225 if ( j < n_elem_max )
226 {
227 ajj = a_begin + j*inca;
228
229 // Initialize diagonal element.
230 if ( bl1_is_unit_diag( diag ) ) *ajj = one;
231 else if ( bl1_is_zero_diag( diag ) ) *ajj = zero;
232 else if ( bl1_is_nonunit_diag( diag ) )
233 {
234 // We want positive diagonal elements between 1 and 2.
235 bl1_drands( ajj );
236 bl1_dabsval2( ajj, ajj );
237 bl1_dadd3( ajj, &one, ajj );
238 }
239
240 // Randomize sub-diagonal elements.
241 bl1_drandv( n_elem_max - j - 1,
242 ajj + inca, inca );
243
244 // Normalize sub-diagonal elements by order of the matrix.
246 n_elem_max - j - 1,
247 &ord,
248 ajj + inca, inca );
249
250 }
251 }
252 }
253}
void bl1_dinvscalv(conj1_t conj, int n, double *alpha, double *x, int incx)
Definition bl1_invscalv.c:26
void bl1_dsetv(int m, double *sigma, double *x, int incx)
Definition bl1_setv.c:39
void bl1_drandv(int n, double *x, int incx)
Definition bl1_randv.c:26
void bl1_drands(double *alpha)
Definition bl1_rands.c:18
double bl1_d0(void)
Definition bl1_constants.c:118
double bl1_d1(void)
Definition bl1_constants.c:54

References bl1_d0(), bl1_d1(), bl1_dinvscalv(), bl1_drands(), bl1_drandv(), bl1_dsetv(), bl1_is_nonunit_diag(), bl1_is_row_storage(), bl1_is_unit_diag(), bl1_is_upper(), bl1_is_zero_diag(), bl1_zero_dim2(), and BLIS1_NO_CONJUGATE.

Referenced by FLA_Random_tri_matrix().

◆ bl1_srandmr()

void bl1_srandmr ( uplo1_t  uplo,
diag1_t  diag,
int  m,
int  n,
float a,
int  a_rs,
int  a_cs 
)
14{
15 float* a_begin;
16 float* ajj;
17 float one;
18 float zero;
19 float ord;
20 int lda, inca;
21 int n_iter;
22 int n_elem_max;
23 int n_elem;
24 int j;
25
26 // Return early if possible.
27 if ( bl1_zero_dim2( m, n ) ) return;
28
29 // Initialize with optimal values for column-major storage.
30 n_iter = n;
31 n_elem_max = m;
32 lda = a_cs;
33 inca = a_rs;
34
35 // An optimization: if A is row-major, then let's access the matrix by
36 // rows instead of by columns to increase spatial locality.
38 {
41 bl1_toggle_uplo( uplo );
42 }
43
44 // Initialize some scalars.
45 one = bl1_s1();
46 zero = bl1_s0();
47 ord = ( float ) bl1_max( m, n );
48
49 if ( bl1_is_upper( uplo ) )
50 {
51 for ( j = 0; j < n_iter; j++ )
52 {
54 a_begin = a + j*lda;
55
56 // Randomize super-diagonal elements.
58 a_begin, inca );
59
60 // Normalize super-diagonal elements by order of the matrix.
62 n_elem,
63 &ord,
64 a_begin, inca );
65
66 // Initialize diagonal and sub-diagonal elements only if there are
67 // elements left in the column (ie: j < n_elem_max).
68 if ( j < n_elem_max )
69 {
70 ajj = a_begin + j*inca;
71
72 // Initialize diagonal element.
73 if ( bl1_is_unit_diag( diag ) ) *ajj = one;
74 else if ( bl1_is_zero_diag( diag ) ) *ajj = zero;
75 else if ( bl1_is_nonunit_diag( diag ) )
76 {
77 // We want positive diagonal elements between 1 and 2.
78 bl1_srands( ajj );
80 bl1_sadd3( ajj, &one, ajj );
81 }
82
83 // Initialize sub-diagonal elements to zero.
84 bl1_ssetv( n_elem_max - j - 1,
85 &zero,
86 ajj + inca, inca );
87 }
88 }
89 }
90 else // if ( bl1_is_lower( uplo ) )
91 {
92 for ( j = 0; j < n_iter; j++ )
93 {
95 a_begin = a + j*lda;
96
97 // Initialize super-diagonal to zero.
99 &zero,
100 a_begin, inca );
101
102 // Initialize diagonal and sub-diagonal elements only if there are
103 // elements left in the column (ie: j < n_elem_max).
104 if ( j < n_elem_max )
105 {
106 ajj = a_begin + j*inca;
107
108 // Initialize diagonal element.
109 if ( bl1_is_unit_diag( diag ) ) *ajj = one;
110 else if ( bl1_is_zero_diag( diag ) ) *ajj = zero;
111 else if ( bl1_is_nonunit_diag( diag ) )
112 {
113 // We want positive diagonal elements between 1 and 2.
114 bl1_srands( ajj );
115 bl1_sabsval2( ajj, ajj );
116 bl1_sadd3( ajj, &one, ajj );
117 }
118
119 // Randomize sub-diagonal elements.
120 bl1_srandv( n_elem_max - j - 1,
121 ajj + inca, inca );
122
123 // Normalize sub-diagonal elements by order of the matrix.
125 n_elem_max - j - 1,
126 &ord,
127 ajj + inca, inca );
128
129 }
130 }
131 }
132}
void bl1_sinvscalv(conj1_t conj, int n, float *alpha, float *x, int incx)
Definition bl1_invscalv.c:13
void bl1_srandv(int n, float *x, int incx)
Definition bl1_randv.c:13
float bl1_s0(void)
Definition bl1_constants.c:111
void bl1_srands(float *alpha)
Definition bl1_rands.c:13
void bl1_ssetv(int m, float *sigma, float *x, int incx)
Definition bl1_setv.c:26
float bl1_s1(void)
Definition bl1_constants.c:47

References bl1_is_nonunit_diag(), bl1_is_row_storage(), bl1_is_unit_diag(), bl1_is_upper(), bl1_is_zero_diag(), bl1_s0(), bl1_s1(), bl1_sinvscalv(), bl1_srands(), bl1_srandv(), bl1_ssetv(), bl1_zero_dim2(), and BLIS1_NO_CONJUGATE.

Referenced by FLA_Random_tri_matrix().

◆ bl1_zrandmr()

void bl1_zrandmr ( uplo1_t  uplo,
diag1_t  diag,
int  m,
int  n,
dcomplex a,
int  a_rs,
int  a_cs 
)
378{
380 dcomplex* ajj;
384 int lda, inca;
385 int n_iter;
386 int n_elem_max;
387 int n_elem;
388 int j;
389
390 // Return early if possible.
391 if ( bl1_zero_dim2( m, n ) ) return;
392
393 // Initialize with optimal values for column-major storage.
394 n_iter = n;
395 n_elem_max = m;
396 lda = a_cs;
397 inca = a_rs;
398
399 // An optimization: if A is row-major, then let's access the matrix by
400 // rows instead of by columns to increase spatial locality.
401 if ( bl1_is_row_storage( a_rs, a_cs ) )
402 {
405 bl1_toggle_uplo( uplo );
406 }
407
408 // Initialize some scalars.
409 one = bl1_z1();
410 zero = bl1_z0();
411 ord = bl1_z0();
412 ord.real = ( double ) bl1_max( m, n );
413
414 if ( bl1_is_upper( uplo ) )
415 {
416 for ( j = 0; j < n_iter; j++ )
417 {
419 a_begin = a + j*lda;
420
421 // Randomize super-diagonal elements.
423 a_begin, inca );
424
425 // Normalize super-diagonal elements by order of the matrix.
427 n_elem,
428 &ord,
429 a_begin, inca );
430
431 // Initialize diagonal and sub-diagonal elements only if there are
432 // elements left in the column (ie: j < n_elem_max).
433 if ( j < n_elem_max )
434 {
435 ajj = a_begin + j*inca;
436
437 // Initialize diagonal element.
438 if ( bl1_is_unit_diag( diag ) ) *ajj = one;
439 else if ( bl1_is_zero_diag( diag ) ) *ajj = zero;
440 else if ( bl1_is_nonunit_diag( diag ) )
441 {
442 // We want positive diagonal elements between 1 and 2.
443 bl1_zrands( ajj );
444 bl1_zabsval2( ajj, ajj );
445 bl1_zadd3( ajj, &one, ajj );
446 }
447
448 // Initialize sub-diagonal elements to zero.
449 bl1_zsetv( n_elem_max - j - 1,
450 &zero,
451 ajj + inca, inca );
452 }
453 }
454 }
455 else // if ( bl1_is_lower( uplo ) )
456 {
457 for ( j = 0; j < n_iter; j++ )
458 {
460 a_begin = a + j*lda;
461
462 // Initialize super-diagonal to zero.
464 &zero,
465 a_begin, inca );
466
467 // Initialize diagonal and sub-diagonal elements only if there are
468 // elements left in the column (ie: j < n_elem_max).
469 if ( j < n_elem_max )
470 {
471 ajj = a_begin + j*inca;
472
473 // Initialize diagonal element.
474 if ( bl1_is_unit_diag( diag ) ) *ajj = one;
475 else if ( bl1_is_zero_diag( diag ) ) *ajj = zero;
476 else if ( bl1_is_nonunit_diag( diag ) )
477 {
478 // We want positive diagonal elements between 1 and 2.
479 bl1_zrands( ajj );
480 bl1_zabsval2( ajj, ajj );
481 bl1_zadd3( ajj, &one, ajj );
482 }
483
484 // Randomize sub-diagonal elements.
485 bl1_zrandv( n_elem_max - j - 1,
486 ajj + inca, inca );
487
488 // Normalize sub-diagonal elements by order of the matrix.
490 n_elem_max - j - 1,
491 &ord,
492 ajj + inca, inca );
493
494 }
495 }
496 }
497}
void bl1_zinvscalv(conj1_t conj, int n, dcomplex *alpha, dcomplex *x, int incx)
Definition bl1_invscalv.c:78
dcomplex bl1_z0(void)
Definition bl1_constants.c:133
void bl1_zsetv(int m, dcomplex *sigma, dcomplex *x, int incx)
Definition bl1_setv.c:66
dcomplex bl1_z1(void)
Definition bl1_constants.c:69
void bl1_zrands(dcomplex *alpha)
Definition bl1_rands.c:29
void bl1_zrandv(int n, dcomplex *x, int incx)
Definition bl1_randv.c:52
Definition blis_type_defs.h:138

References bl1_is_nonunit_diag(), bl1_is_row_storage(), bl1_is_unit_diag(), bl1_is_upper(), bl1_is_zero_diag(), bl1_z0(), bl1_z1(), bl1_zero_dim2(), bl1_zinvscalv(), bl1_zrands(), bl1_zrandv(), bl1_zsetv(), BLIS1_NO_CONJUGATE, and dcomplex::real.

Referenced by FLA_Random_tri_matrix().