1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "blas_extended.h"
4 #include "blas_extended_test.h"
5
BLAS_ssymv_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,float * alpha,int alpha_flag,float * beta,int beta_flag,float * a,int lda,float * x,int incx,float * y,int incy,int * seed,double * head_r_true,double * tail_r_true)6 void BLAS_ssymv_testgen(int norm, enum blas_order_type order,
7 enum blas_uplo_type uplo,
8 int n, int randomize,
9 float *alpha, int alpha_flag, float *beta,
10 int beta_flag, float *a, int lda, float *x, int incx,
11 float *y, int incy, int *seed, double *head_r_true,
12 double *tail_r_true)
13
14 /*
15 * Purpose
16 * =======
17 *
18 * Generates the test inputs to BLAS_ssymv{_x}
19 *
20 * Arguments
21 * =========
22 *
23 * norm (input) int
24 * = -1: the vectors are scaled with norms near underflow.
25 * = 0: the vectors have norms of order 1.
26 * = 1: the vectors are scaled with norms near overflow.
27 *
28 * order (input) enum blas_side_type
29 * storage format of the matrices
30 *
31 * uplo (input) enum blas_uplo_type
32 * which half of the symvetric matrix a is to be stored.
33 *
34 * n (input) int
35 * sizes of symmetrical matrix a, size of vectors x, y:
36 * matrix a is n-by-n.
37 *
38 * randomize (input) int
39 * if 0, entries in matrices A, x will be chosen for
40 * maximum cancellation, but with less randomness.
41 * if 1, every entry in the matrix A, x will be
42 * random.
43 *
44 * alpha (input/output) float*
45 * if alpha_flag = 1, alpha is input.
46 * if alpha_flag = 0, alpha is output.
47 *
48 * alpha_flag (input) int
49 * = 0: alpha is free, and is output.
50 * = 1: alpha is fixed on input.
51 *
52 * beta (input/output) float*
53 * if beta_flag = 1, beta is input.
54 * if beta_flag = 0, beta is output.
55 *
56 * beta_flag (input) int
57 * = 0: beta is free, and is output.
58 * = 1: beta is fixed on input.
59 *
60 * a (input/output) float*
61 *
62 * lda (input) lda
63 * leading dimension of matrix A.
64 *
65 * x (input/output) float*
66 *
67 * incx (input) int
68 * stride of vector x.
69 *
70 * y (input/output) float*
71 * generated vector y that will be used as an input to SYMV.
72 *
73 * incy (input) int
74 * leading dimension of vector y.
75 *
76 * seed (input/output) int *
77 * seed for the random number generator.
78 *
79 * double (output) *head_r_true
80 * the leading part of the truth in double-double.
81 *
82 * double (output) *tail_r_true
83 * the trailing part of the truth in double-double
84 *
85 */
86 {
87
88 int i, j;
89 int yi;
90 int xi;
91 int aij, ai, ri;
92 int incyi, incri;
93 int incxi, incx_veci, x_starti, y_starti;
94 int incaij, incai;
95 int inca;
96 int n_i;
97
98 float y_elem;
99 float a_elem;
100 float x_elem;
101 double head_r_true_elem, tail_r_true_elem;
102
103 float *a_vec;
104 float *x_vec;
105
106 float *y_i = y;
107 float *alpha_i = alpha;
108 float *beta_i = beta;
109 float *a_i = a;
110 float *x_i = x;
111
112 n_i = n;
113
114 /*x_vec, a_vec must have stride of 1 */
115 inca = 1;
116
117
118 a_vec = (float *) blas_malloc(n_i * sizeof(float));
119 if (n_i > 0 && a_vec == NULL) {
120 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
121 }
122 for (i = 0; i < n_i; i += inca) {
123 a_vec[i] = 0.0;
124 }
125
126 incyi = incy;
127
128 if (incyi < 0) {
129 y_starti = (-n + 1) * incyi;
130 } else {
131 y_starti = 0;
132 }
133
134
135
136 incri = 1;
137
138
139 incxi = incx;
140 incx_veci = 1;
141
142
143
144 if (incxi < 0) {
145 x_starti = (-n + 1) * incxi;
146 } else {
147 x_starti = 0;
148 }
149
150 x_vec = (float *) blas_malloc(n_i * sizeof(float));
151 if (n_i > 0 && x_vec == NULL) {
152 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
153 };
154 for (i = 0; i < n_i; i += incx_veci) {
155 x_vec[i] = 0.0;
156 }
157
158 if (randomize == 0) {
159 /* First fill in the first row of A and all of x */
160
161 BLAS_sdot_testgen(n_i, 0, 0, norm, blas_no_conj,
162 alpha, alpha_flag, beta, beta_flag,
163 x_vec, a_vec, seed, &y_elem,
164 &head_r_true_elem, &tail_r_true_elem);
165
166 yi = y_starti;
167 ri = 0;
168 y_i[yi] = y_elem;
169 head_r_true[ri] = head_r_true_elem;
170 tail_r_true[ri] = tail_r_true_elem;
171
172 /* Copy a_vec to first row of A */
173 ssy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
174
175 /* commit x_vec to x */
176 scopy_vector(x_vec, n_i, 1, x_i, incx);
177
178 /* Fill in rest of matrix A */
179 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
180 yi += incyi) {
181 ssy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
182 BLAS_sdot_testgen(n_i, i, n_i - i, norm,
183 blas_no_conj, alpha, 1,
184 beta, 1, x_vec, a_vec, seed,
185 &y_elem, &head_r_true_elem, &tail_r_true_elem);
186
187 ssy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
188
189 /*commits an element to the generated y */
190 y_i[yi] = y_elem;
191 head_r_true[ri] = head_r_true_elem;
192 tail_r_true[ri] = tail_r_true_elem;
193 }
194
195 } else {
196
197
198
199
200
201
202
203 /* randomly select alpha, beta */
204 if (alpha_flag == 0) {
205 y_elem = xrand(seed);
206 alpha_i[0] = y_elem;
207 }
208 if (beta_flag == 0) {
209 y_elem = xrand(seed);
210 beta_i[0] = y_elem;
211 }
212
213
214 /*set a, x randomly */
215
216 if (order == blas_colmajor) {
217 incai = 1;
218 incaij = lda;
219 } else {
220 incai = lda;
221 incaij = 1;
222 }
223
224 incxi = incx;
225
226
227 if (incxi < 0) {
228 x_starti = (-n + 1) * incxi;
229 } else {
230 x_starti = 0;
231 }
232
233
234
235
236 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
237 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
238 a_elem = xrand(seed);
239 a_i[aij] = a_elem;
240 }
241 }
242
243 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
244 x_elem = xrand(seed);
245 x_i[xi] = x_elem;
246 }
247
248 /* now compute appropriate y vector */
249
250 /* get x */
251 scopy_vector(x_i, n_i, incx, x_vec, 1);
252
253
254 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
255 ssy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
256
257
258 BLAS_sdot_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
259 beta, 1, x_vec, a_vec, seed,
260 &y_elem, &head_r_true_elem, &tail_r_true_elem);
261
262 y_i[yi] = y_elem;
263 head_r_true[ri] = head_r_true_elem;
264 tail_r_true[ri] = tail_r_true_elem;
265 }
266
267
268
269 }
270
271 blas_free(a_vec);
272 blas_free(x_vec);
273 }
BLAS_dsymv_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,double * alpha,int alpha_flag,double * beta,int beta_flag,double * a,int lda,double * x,int incx,double * y,int incy,int * seed,double * head_r_true,double * tail_r_true)274 void BLAS_dsymv_testgen(int norm, enum blas_order_type order,
275 enum blas_uplo_type uplo,
276 int n, int randomize,
277 double *alpha, int alpha_flag, double *beta,
278 int beta_flag, double *a, int lda, double *x,
279 int incx, double *y, int incy, int *seed,
280 double *head_r_true, double *tail_r_true)
281
282 /*
283 * Purpose
284 * =======
285 *
286 * Generates the test inputs to BLAS_dsymv{_x}
287 *
288 * Arguments
289 * =========
290 *
291 * norm (input) int
292 * = -1: the vectors are scaled with norms near underflow.
293 * = 0: the vectors have norms of order 1.
294 * = 1: the vectors are scaled with norms near overflow.
295 *
296 * order (input) enum blas_side_type
297 * storage format of the matrices
298 *
299 * uplo (input) enum blas_uplo_type
300 * which half of the symvetric matrix a is to be stored.
301 *
302 * n (input) int
303 * sizes of symmetrical matrix a, size of vectors x, y:
304 * matrix a is n-by-n.
305 *
306 * randomize (input) int
307 * if 0, entries in matrices A, x will be chosen for
308 * maximum cancellation, but with less randomness.
309 * if 1, every entry in the matrix A, x will be
310 * random.
311 *
312 * alpha (input/output) double*
313 * if alpha_flag = 1, alpha is input.
314 * if alpha_flag = 0, alpha is output.
315 *
316 * alpha_flag (input) int
317 * = 0: alpha is free, and is output.
318 * = 1: alpha is fixed on input.
319 *
320 * beta (input/output) double*
321 * if beta_flag = 1, beta is input.
322 * if beta_flag = 0, beta is output.
323 *
324 * beta_flag (input) int
325 * = 0: beta is free, and is output.
326 * = 1: beta is fixed on input.
327 *
328 * a (input/output) double*
329 *
330 * lda (input) lda
331 * leading dimension of matrix A.
332 *
333 * x (input/output) double*
334 *
335 * incx (input) int
336 * stride of vector x.
337 *
338 * y (input/output) double*
339 * generated vector y that will be used as an input to SYMV.
340 *
341 * incy (input) int
342 * leading dimension of vector y.
343 *
344 * seed (input/output) int *
345 * seed for the random number generator.
346 *
347 * double (output) *head_r_true
348 * the leading part of the truth in double-double.
349 *
350 * double (output) *tail_r_true
351 * the trailing part of the truth in double-double
352 *
353 */
354 {
355
356 int i, j;
357 int yi;
358 int xi;
359 int aij, ai, ri;
360 int incyi, incri;
361 int incxi, incx_veci, x_starti, y_starti;
362 int incaij, incai;
363 int inca;
364 int n_i;
365
366 double y_elem;
367 double a_elem;
368 double x_elem;
369 double head_r_true_elem, tail_r_true_elem;
370
371 double *a_vec;
372 double *x_vec;
373
374 double *y_i = y;
375 double *alpha_i = alpha;
376 double *beta_i = beta;
377 double *a_i = a;
378 double *x_i = x;
379
380 n_i = n;
381
382 /*x_vec, a_vec must have stride of 1 */
383 inca = 1;
384
385
386 a_vec = (double *) blas_malloc(n_i * sizeof(double));
387 if (n_i > 0 && a_vec == NULL) {
388 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
389 }
390 for (i = 0; i < n_i; i += inca) {
391 a_vec[i] = 0.0;
392 }
393
394 incyi = incy;
395
396 if (incyi < 0) {
397 y_starti = (-n + 1) * incyi;
398 } else {
399 y_starti = 0;
400 }
401
402
403
404 incri = 1;
405
406
407 incxi = incx;
408 incx_veci = 1;
409
410
411
412 if (incxi < 0) {
413 x_starti = (-n + 1) * incxi;
414 } else {
415 x_starti = 0;
416 }
417
418 x_vec = (double *) blas_malloc(n_i * sizeof(double));
419 if (n_i > 0 && x_vec == NULL) {
420 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
421 };
422 for (i = 0; i < n_i; i += incx_veci) {
423 x_vec[i] = 0.0;
424 }
425
426 if (randomize == 0) {
427 /* First fill in the first row of A and all of x */
428
429 BLAS_ddot_testgen(n_i, 0, 0, norm, blas_no_conj,
430 alpha, alpha_flag, beta, beta_flag,
431 x_vec, a_vec, seed, &y_elem,
432 &head_r_true_elem, &tail_r_true_elem);
433
434 yi = y_starti;
435 ri = 0;
436 y_i[yi] = y_elem;
437 head_r_true[ri] = head_r_true_elem;
438 tail_r_true[ri] = tail_r_true_elem;
439
440 /* Copy a_vec to first row of A */
441 dsy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
442
443 /* commit x_vec to x */
444 dcopy_vector(x_vec, n_i, 1, x_i, incx);
445
446 /* Fill in rest of matrix A */
447 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
448 yi += incyi) {
449 dsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
450 BLAS_ddot_testgen(n_i, i, n_i - i, norm,
451 blas_no_conj, alpha, 1,
452 beta, 1, x_vec, a_vec, seed,
453 &y_elem, &head_r_true_elem, &tail_r_true_elem);
454
455 dsy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
456
457 /*commits an element to the generated y */
458 y_i[yi] = y_elem;
459 head_r_true[ri] = head_r_true_elem;
460 tail_r_true[ri] = tail_r_true_elem;
461 }
462
463 } else {
464
465
466
467
468
469
470
471 /* randomly select alpha, beta */
472 if (alpha_flag == 0) {
473 y_elem = xrand(seed);
474 alpha_i[0] = y_elem;
475 }
476 if (beta_flag == 0) {
477 y_elem = xrand(seed);
478 beta_i[0] = y_elem;
479 }
480
481
482 /*set a, x randomly */
483
484 if (order == blas_colmajor) {
485 incai = 1;
486 incaij = lda;
487 } else {
488 incai = lda;
489 incaij = 1;
490 }
491
492 incxi = incx;
493
494
495 if (incxi < 0) {
496 x_starti = (-n + 1) * incxi;
497 } else {
498 x_starti = 0;
499 }
500
501
502
503
504 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
505 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
506 a_elem = xrand(seed);
507 a_i[aij] = a_elem;
508 }
509 }
510
511 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
512 x_elem = xrand(seed);
513 x_i[xi] = x_elem;
514 }
515
516 /* now compute appropriate y vector */
517
518 /* get x */
519 dcopy_vector(x_i, n_i, incx, x_vec, 1);
520
521
522 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
523 dsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
524
525
526 BLAS_ddot_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
527 beta, 1, x_vec, a_vec, seed,
528 &y_elem, &head_r_true_elem, &tail_r_true_elem);
529
530 y_i[yi] = y_elem;
531 head_r_true[ri] = head_r_true_elem;
532 tail_r_true[ri] = tail_r_true_elem;
533 }
534
535
536
537 }
538
539 blas_free(a_vec);
540 blas_free(x_vec);
541 }
BLAS_csymv_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,void * a,int lda,void * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)542 void BLAS_csymv_testgen(int norm, enum blas_order_type order,
543 enum blas_uplo_type uplo,
544 int n, int randomize,
545 void *alpha, int alpha_flag, void *beta,
546 int beta_flag, void *a, int lda, void *x, int incx,
547 void *y, int incy, int *seed, double *head_r_true,
548 double *tail_r_true)
549
550 /*
551 * Purpose
552 * =======
553 *
554 * Generates the test inputs to BLAS_csymv{_x}
555 *
556 * Arguments
557 * =========
558 *
559 * norm (input) int
560 * = -1: the vectors are scaled with norms near underflow.
561 * = 0: the vectors have norms of order 1.
562 * = 1: the vectors are scaled with norms near overflow.
563 *
564 * order (input) enum blas_side_type
565 * storage format of the matrices
566 *
567 * uplo (input) enum blas_uplo_type
568 * which half of the symvetric matrix a is to be stored.
569 *
570 * n (input) int
571 * sizes of symmetrical matrix a, size of vectors x, y:
572 * matrix a is n-by-n.
573 *
574 * randomize (input) int
575 * if 0, entries in matrices A, x will be chosen for
576 * maximum cancellation, but with less randomness.
577 * if 1, every entry in the matrix A, x will be
578 * random.
579 *
580 * alpha (input/output) void*
581 * if alpha_flag = 1, alpha is input.
582 * if alpha_flag = 0, alpha is output.
583 *
584 * alpha_flag (input) int
585 * = 0: alpha is free, and is output.
586 * = 1: alpha is fixed on input.
587 *
588 * beta (input/output) void*
589 * if beta_flag = 1, beta is input.
590 * if beta_flag = 0, beta is output.
591 *
592 * beta_flag (input) int
593 * = 0: beta is free, and is output.
594 * = 1: beta is fixed on input.
595 *
596 * a (input/output) void*
597 *
598 * lda (input) lda
599 * leading dimension of matrix A.
600 *
601 * x (input/output) void*
602 *
603 * incx (input) int
604 * stride of vector x.
605 *
606 * y (input/output) void*
607 * generated vector y that will be used as an input to SYMV.
608 *
609 * incy (input) int
610 * leading dimension of vector y.
611 *
612 * seed (input/output) int *
613 * seed for the random number generator.
614 *
615 * double (output) *head_r_true
616 * the leading part of the truth in double-double.
617 *
618 * double (output) *tail_r_true
619 * the trailing part of the truth in double-double
620 *
621 */
622 {
623
624 int i, j;
625 int yi;
626 int xi;
627 int aij, ai, ri;
628 int incyi, incri;
629 int incxi, incx_veci, x_starti, y_starti;
630 int incaij, incai;
631 int inca;
632 int n_i;
633
634 float y_elem[2];
635 float a_elem[2];
636 float x_elem[2];
637 double head_r_true_elem[2], tail_r_true_elem[2];
638
639 float *a_vec;
640 float *x_vec;
641
642 float *y_i = (float *) y;
643 float *alpha_i = (float *) alpha;
644 float *beta_i = (float *) beta;
645 float *a_i = (float *) a;
646 float *x_i = (float *) x;
647
648 n_i = n;
649
650 /*x_vec, a_vec must have stride of 1 */
651 inca = 1;
652 inca *= 2;
653
654 a_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
655 if (n_i > 0 && a_vec == NULL) {
656 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
657 }
658 for (i = 0; i < n_i; i += inca) {
659 a_vec[i] = 0.0;
660 a_vec[i + 1] = 0.0;
661 }
662
663 incyi = incy;
664 incyi *= 2;
665 if (incyi < 0) {
666 y_starti = (-n + 1) * incyi;
667 } else {
668 y_starti = 0;
669 }
670
671
672
673 incri = 1;
674 incri *= 2;
675
676 incxi = incx;
677 incx_veci = 1;
678 incx_veci *= 2;
679 incxi *= 2;
680
681 if (incxi < 0) {
682 x_starti = (-n + 1) * incxi;
683 } else {
684 x_starti = 0;
685 }
686
687 x_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
688 if (n_i > 0 && x_vec == NULL) {
689 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
690 };
691 for (i = 0; i < n_i; i += incx_veci) {
692 x_vec[i] = 0.0;
693 x_vec[i + 1] = 0.0;
694 }
695
696 if (randomize == 0) {
697 /* First fill in the first row of A and all of x */
698
699 BLAS_cdot_testgen(n_i, 0, 0, norm, blas_no_conj,
700 alpha, alpha_flag, beta, beta_flag,
701 x_vec, a_vec, seed, y_elem,
702 head_r_true_elem, tail_r_true_elem);
703
704 yi = y_starti;
705 ri = 0;
706 y_i[yi] = y_elem[0];
707 y_i[yi + 1] = y_elem[1];
708 head_r_true[ri] = head_r_true_elem[0];
709 head_r_true[ri + 1] = head_r_true_elem[1];
710 tail_r_true[ri] = tail_r_true_elem[0];
711 tail_r_true[ri + 1] = tail_r_true_elem[1];
712
713 /* Copy a_vec to first row of A */
714 csy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
715
716 /* commit x_vec to x */
717 ccopy_vector(x_vec, n_i, 1, x_i, incx);
718
719 /* Fill in rest of matrix A */
720 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
721 yi += incyi) {
722 csy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
723 BLAS_cdot_testgen(n_i, i, n_i - i, norm,
724 blas_no_conj, alpha, 1,
725 beta, 1, x_vec, a_vec, seed,
726 y_elem, head_r_true_elem, tail_r_true_elem);
727
728 csy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
729
730 /*commits an element to the generated y */
731 y_i[yi] = y_elem[0];
732 y_i[yi + 1] = y_elem[1];
733 head_r_true[ri] = head_r_true_elem[0];
734 head_r_true[ri + 1] = head_r_true_elem[1];
735 tail_r_true[ri] = tail_r_true_elem[0];
736 tail_r_true[ri + 1] = tail_r_true_elem[1];
737 }
738
739 } else {
740
741
742
743
744
745
746
747 /* randomly select alpha, beta */
748 if (alpha_flag == 0) {
749 y_elem[0] = xrand(seed);
750 y_elem[1] = xrand(seed);
751 alpha_i[0] = y_elem[0];
752 alpha_i[0 + 1] = y_elem[1];
753 }
754 if (beta_flag == 0) {
755 y_elem[0] = xrand(seed);
756 y_elem[1] = xrand(seed);
757 beta_i[0] = y_elem[0];
758 beta_i[0 + 1] = y_elem[1];
759 }
760
761
762 /*set a, x randomly */
763
764 if (order == blas_colmajor) {
765 incai = 1;
766 incaij = lda;
767 } else {
768 incai = lda;
769 incaij = 1;
770 }
771
772 incxi = incx;
773 incxi *= 2;
774
775 if (incxi < 0) {
776 x_starti = (-n + 1) * incxi;
777 } else {
778 x_starti = 0;
779 }
780
781 incai *= 2;
782 incaij *= 2;
783
784 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
785 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
786 a_elem[0] = xrand(seed);
787 a_elem[1] = xrand(seed);
788 a_i[aij] = a_elem[0];
789 a_i[aij + 1] = a_elem[1];
790 }
791 }
792
793 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
794 x_elem[0] = xrand(seed);
795 x_elem[1] = xrand(seed);
796 x_i[xi] = x_elem[0];
797 x_i[xi + 1] = x_elem[1];
798 }
799
800 /* now compute appropriate y vector */
801
802 /* get x */
803 ccopy_vector(x_i, n_i, incx, x_vec, 1);
804
805
806 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
807 csy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
808
809
810 BLAS_cdot_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
811 beta, 1, x_vec, a_vec, seed,
812 y_elem, head_r_true_elem, tail_r_true_elem);
813
814 y_i[yi] = y_elem[0];
815 y_i[yi + 1] = y_elem[1];
816 head_r_true[ri] = head_r_true_elem[0];
817 head_r_true[ri + 1] = head_r_true_elem[1];
818 tail_r_true[ri] = tail_r_true_elem[0];
819 tail_r_true[ri + 1] = tail_r_true_elem[1];
820 }
821
822
823
824 }
825
826 blas_free(a_vec);
827 blas_free(x_vec);
828 }
BLAS_zsymv_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,void * a,int lda,void * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)829 void BLAS_zsymv_testgen(int norm, enum blas_order_type order,
830 enum blas_uplo_type uplo,
831 int n, int randomize,
832 void *alpha, int alpha_flag, void *beta,
833 int beta_flag, void *a, int lda, void *x, int incx,
834 void *y, int incy, int *seed, double *head_r_true,
835 double *tail_r_true)
836
837 /*
838 * Purpose
839 * =======
840 *
841 * Generates the test inputs to BLAS_zsymv{_x}
842 *
843 * Arguments
844 * =========
845 *
846 * norm (input) int
847 * = -1: the vectors are scaled with norms near underflow.
848 * = 0: the vectors have norms of order 1.
849 * = 1: the vectors are scaled with norms near overflow.
850 *
851 * order (input) enum blas_side_type
852 * storage format of the matrices
853 *
854 * uplo (input) enum blas_uplo_type
855 * which half of the symvetric matrix a is to be stored.
856 *
857 * n (input) int
858 * sizes of symmetrical matrix a, size of vectors x, y:
859 * matrix a is n-by-n.
860 *
861 * randomize (input) int
862 * if 0, entries in matrices A, x will be chosen for
863 * maximum cancellation, but with less randomness.
864 * if 1, every entry in the matrix A, x will be
865 * random.
866 *
867 * alpha (input/output) void*
868 * if alpha_flag = 1, alpha is input.
869 * if alpha_flag = 0, alpha is output.
870 *
871 * alpha_flag (input) int
872 * = 0: alpha is free, and is output.
873 * = 1: alpha is fixed on input.
874 *
875 * beta (input/output) void*
876 * if beta_flag = 1, beta is input.
877 * if beta_flag = 0, beta is output.
878 *
879 * beta_flag (input) int
880 * = 0: beta is free, and is output.
881 * = 1: beta is fixed on input.
882 *
883 * a (input/output) void*
884 *
885 * lda (input) lda
886 * leading dimension of matrix A.
887 *
888 * x (input/output) void*
889 *
890 * incx (input) int
891 * stride of vector x.
892 *
893 * y (input/output) void*
894 * generated vector y that will be used as an input to SYMV.
895 *
896 * incy (input) int
897 * leading dimension of vector y.
898 *
899 * seed (input/output) int *
900 * seed for the random number generator.
901 *
902 * double (output) *head_r_true
903 * the leading part of the truth in double-double.
904 *
905 * double (output) *tail_r_true
906 * the trailing part of the truth in double-double
907 *
908 */
909 {
910
911 int i, j;
912 int yi;
913 int xi;
914 int aij, ai, ri;
915 int incyi, incri;
916 int incxi, incx_veci, x_starti, y_starti;
917 int incaij, incai;
918 int inca;
919 int n_i;
920
921 double y_elem[2];
922 double a_elem[2];
923 double x_elem[2];
924 double head_r_true_elem[2], tail_r_true_elem[2];
925
926 double *a_vec;
927 double *x_vec;
928
929 double *y_i = (double *) y;
930 double *alpha_i = (double *) alpha;
931 double *beta_i = (double *) beta;
932 double *a_i = (double *) a;
933 double *x_i = (double *) x;
934
935 n_i = n;
936
937 /*x_vec, a_vec must have stride of 1 */
938 inca = 1;
939 inca *= 2;
940
941 a_vec = (double *) blas_malloc(n_i * sizeof(double) * 2);
942 if (n_i > 0 && a_vec == NULL) {
943 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
944 }
945 for (i = 0; i < n_i; i += inca) {
946 a_vec[i] = 0.0;
947 a_vec[i + 1] = 0.0;
948 }
949
950 incyi = incy;
951 incyi *= 2;
952 if (incyi < 0) {
953 y_starti = (-n + 1) * incyi;
954 } else {
955 y_starti = 0;
956 }
957
958
959
960 incri = 1;
961 incri *= 2;
962
963 incxi = incx;
964 incx_veci = 1;
965 incx_veci *= 2;
966 incxi *= 2;
967
968 if (incxi < 0) {
969 x_starti = (-n + 1) * incxi;
970 } else {
971 x_starti = 0;
972 }
973
974 x_vec = (double *) blas_malloc(n_i * sizeof(double) * 2);
975 if (n_i > 0 && x_vec == NULL) {
976 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
977 };
978 for (i = 0; i < n_i; i += incx_veci) {
979 x_vec[i] = 0.0;
980 x_vec[i + 1] = 0.0;
981 }
982
983 if (randomize == 0) {
984 /* First fill in the first row of A and all of x */
985
986 BLAS_zdot_testgen(n_i, 0, 0, norm, blas_no_conj,
987 alpha, alpha_flag, beta, beta_flag,
988 x_vec, a_vec, seed, y_elem,
989 head_r_true_elem, tail_r_true_elem);
990
991 yi = y_starti;
992 ri = 0;
993 y_i[yi] = y_elem[0];
994 y_i[yi + 1] = y_elem[1];
995 head_r_true[ri] = head_r_true_elem[0];
996 head_r_true[ri + 1] = head_r_true_elem[1];
997 tail_r_true[ri] = tail_r_true_elem[0];
998 tail_r_true[ri + 1] = tail_r_true_elem[1];
999
1000 /* Copy a_vec to first row of A */
1001 zsy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
1002
1003 /* commit x_vec to x */
1004 zcopy_vector(x_vec, n_i, 1, x_i, incx);
1005
1006 /* Fill in rest of matrix A */
1007 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
1008 yi += incyi) {
1009 zsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
1010 BLAS_zdot_testgen(n_i, i, n_i - i, norm,
1011 blas_no_conj, alpha, 1,
1012 beta, 1, x_vec, a_vec, seed,
1013 y_elem, head_r_true_elem, tail_r_true_elem);
1014
1015 zsy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
1016
1017 /*commits an element to the generated y */
1018 y_i[yi] = y_elem[0];
1019 y_i[yi + 1] = y_elem[1];
1020 head_r_true[ri] = head_r_true_elem[0];
1021 head_r_true[ri + 1] = head_r_true_elem[1];
1022 tail_r_true[ri] = tail_r_true_elem[0];
1023 tail_r_true[ri + 1] = tail_r_true_elem[1];
1024 }
1025
1026 } else {
1027
1028
1029
1030
1031
1032
1033
1034 /* randomly select alpha, beta */
1035 if (alpha_flag == 0) {
1036 y_elem[0] = xrand(seed);
1037 y_elem[1] = xrand(seed);
1038 alpha_i[0] = y_elem[0];
1039 alpha_i[0 + 1] = y_elem[1];
1040 }
1041 if (beta_flag == 0) {
1042 y_elem[0] = xrand(seed);
1043 y_elem[1] = xrand(seed);
1044 beta_i[0] = y_elem[0];
1045 beta_i[0 + 1] = y_elem[1];
1046 }
1047
1048
1049 /*set a, x randomly */
1050
1051 if (order == blas_colmajor) {
1052 incai = 1;
1053 incaij = lda;
1054 } else {
1055 incai = lda;
1056 incaij = 1;
1057 }
1058
1059 incxi = incx;
1060 incxi *= 2;
1061
1062 if (incxi < 0) {
1063 x_starti = (-n + 1) * incxi;
1064 } else {
1065 x_starti = 0;
1066 }
1067
1068 incai *= 2;
1069 incaij *= 2;
1070
1071 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
1072 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
1073 a_elem[0] = xrand(seed);
1074 a_elem[1] = xrand(seed);
1075 a_i[aij] = a_elem[0];
1076 a_i[aij + 1] = a_elem[1];
1077 }
1078 }
1079
1080 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
1081 x_elem[0] = xrand(seed);
1082 x_elem[1] = xrand(seed);
1083 x_i[xi] = x_elem[0];
1084 x_i[xi + 1] = x_elem[1];
1085 }
1086
1087 /* now compute appropriate y vector */
1088
1089 /* get x */
1090 zcopy_vector(x_i, n_i, incx, x_vec, 1);
1091
1092
1093 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
1094 zsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
1095
1096
1097 BLAS_zdot_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
1098 beta, 1, x_vec, a_vec, seed,
1099 y_elem, head_r_true_elem, tail_r_true_elem);
1100
1101 y_i[yi] = y_elem[0];
1102 y_i[yi + 1] = y_elem[1];
1103 head_r_true[ri] = head_r_true_elem[0];
1104 head_r_true[ri + 1] = head_r_true_elem[1];
1105 tail_r_true[ri] = tail_r_true_elem[0];
1106 tail_r_true[ri + 1] = tail_r_true_elem[1];
1107 }
1108
1109
1110
1111 }
1112
1113 blas_free(a_vec);
1114 blas_free(x_vec);
1115 }
BLAS_csymv_s_s_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,float * a,int lda,float * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)1116 void BLAS_csymv_s_s_testgen(int norm, enum blas_order_type order,
1117 enum blas_uplo_type uplo,
1118 int n, int randomize,
1119 void *alpha, int alpha_flag, void *beta,
1120 int beta_flag, float *a, int lda, float *x,
1121 int incx, void *y, int incy, int *seed,
1122 double *head_r_true, double *tail_r_true)
1123
1124 /*
1125 * Purpose
1126 * =======
1127 *
1128 * Generates the test inputs to BLAS_csymv_s_s{_x}
1129 *
1130 * Arguments
1131 * =========
1132 *
1133 * norm (input) int
1134 * = -1: the vectors are scaled with norms near underflow.
1135 * = 0: the vectors have norms of order 1.
1136 * = 1: the vectors are scaled with norms near overflow.
1137 *
1138 * order (input) enum blas_side_type
1139 * storage format of the matrices
1140 *
1141 * uplo (input) enum blas_uplo_type
1142 * which half of the symvetric matrix a is to be stored.
1143 *
1144 * n (input) int
1145 * sizes of symmetrical matrix a, size of vectors x, y:
1146 * matrix a is n-by-n.
1147 *
1148 * randomize (input) int
1149 * if 0, entries in matrices A, x will be chosen for
1150 * maximum cancellation, but with less randomness.
1151 * if 1, every entry in the matrix A, x will be
1152 * random.
1153 *
1154 * alpha (input/output) void*
1155 * if alpha_flag = 1, alpha is input.
1156 * if alpha_flag = 0, alpha is output.
1157 *
1158 * alpha_flag (input) int
1159 * = 0: alpha is free, and is output.
1160 * = 1: alpha is fixed on input.
1161 *
1162 * beta (input/output) void*
1163 * if beta_flag = 1, beta is input.
1164 * if beta_flag = 0, beta is output.
1165 *
1166 * beta_flag (input) int
1167 * = 0: beta is free, and is output.
1168 * = 1: beta is fixed on input.
1169 *
1170 * a (input/output) float*
1171 *
1172 * lda (input) lda
1173 * leading dimension of matrix A.
1174 *
1175 * x (input/output) float*
1176 *
1177 * incx (input) int
1178 * stride of vector x.
1179 *
1180 * y (input/output) void*
1181 * generated vector y that will be used as an input to SYMV.
1182 *
1183 * incy (input) int
1184 * leading dimension of vector y.
1185 *
1186 * seed (input/output) int *
1187 * seed for the random number generator.
1188 *
1189 * double (output) *head_r_true
1190 * the leading part of the truth in double-double.
1191 *
1192 * double (output) *tail_r_true
1193 * the trailing part of the truth in double-double
1194 *
1195 */
1196 {
1197
1198 int i, j;
1199 int yi;
1200 int xi;
1201 int aij, ai, ri;
1202 int incyi, incri;
1203 int incxi, incx_veci, x_starti, y_starti;
1204 int incaij, incai;
1205 int inca;
1206 int n_i;
1207
1208 float y_elem[2];
1209 float a_elem;
1210 float x_elem;
1211 double head_r_true_elem[2], tail_r_true_elem[2];
1212
1213 float *a_vec;
1214 float *x_vec;
1215
1216 float *y_i = (float *) y;
1217 float *alpha_i = (float *) alpha;
1218 float *beta_i = (float *) beta;
1219 float *a_i = a;
1220 float *x_i = x;
1221
1222 n_i = n;
1223
1224 /*x_vec, a_vec must have stride of 1 */
1225 inca = 1;
1226
1227
1228 a_vec = (float *) blas_malloc(n_i * sizeof(float));
1229 if (n_i > 0 && a_vec == NULL) {
1230 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1231 }
1232 for (i = 0; i < n_i; i += inca) {
1233 a_vec[i] = 0.0;
1234 }
1235
1236 incyi = incy;
1237 incyi *= 2;
1238 if (incyi < 0) {
1239 y_starti = (-n + 1) * incyi;
1240 } else {
1241 y_starti = 0;
1242 }
1243
1244
1245
1246 incri = 1;
1247 incri *= 2;
1248
1249 incxi = incx;
1250 incx_veci = 1;
1251
1252
1253
1254 if (incxi < 0) {
1255 x_starti = (-n + 1) * incxi;
1256 } else {
1257 x_starti = 0;
1258 }
1259
1260 x_vec = (float *) blas_malloc(n_i * sizeof(float));
1261 if (n_i > 0 && x_vec == NULL) {
1262 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1263 };
1264 for (i = 0; i < n_i; i += incx_veci) {
1265 x_vec[i] = 0.0;
1266 }
1267
1268 if (randomize == 0) {
1269 /* First fill in the first row of A and all of x */
1270
1271 BLAS_cdot_s_s_testgen(n_i, 0, 0, norm, blas_no_conj,
1272 alpha, alpha_flag, beta, beta_flag,
1273 x_vec, a_vec, seed, y_elem,
1274 head_r_true_elem, tail_r_true_elem);
1275
1276 yi = y_starti;
1277 ri = 0;
1278 y_i[yi] = y_elem[0];
1279 y_i[yi + 1] = y_elem[1];
1280 head_r_true[ri] = head_r_true_elem[0];
1281 head_r_true[ri + 1] = head_r_true_elem[1];
1282 tail_r_true[ri] = tail_r_true_elem[0];
1283 tail_r_true[ri + 1] = tail_r_true_elem[1];
1284
1285 /* Copy a_vec to first row of A */
1286 ssy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
1287
1288 /* commit x_vec to x */
1289 scopy_vector(x_vec, n_i, 1, x_i, incx);
1290
1291 /* Fill in rest of matrix A */
1292 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
1293 yi += incyi) {
1294 ssy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
1295 BLAS_cdot_s_s_testgen(n_i, i, n_i - i, norm,
1296 blas_no_conj, alpha, 1,
1297 beta, 1, x_vec, a_vec, seed,
1298 y_elem, head_r_true_elem, tail_r_true_elem);
1299
1300 ssy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
1301
1302 /*commits an element to the generated y */
1303 y_i[yi] = y_elem[0];
1304 y_i[yi + 1] = y_elem[1];
1305 head_r_true[ri] = head_r_true_elem[0];
1306 head_r_true[ri + 1] = head_r_true_elem[1];
1307 tail_r_true[ri] = tail_r_true_elem[0];
1308 tail_r_true[ri + 1] = tail_r_true_elem[1];
1309 }
1310
1311 } else {
1312
1313 float *aa_vec;
1314 float *xx_vec;
1315
1316 aa_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
1317 if (n_i > 0 && aa_vec == NULL) {
1318 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1319 }
1320 xx_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
1321 if (n_i > 0 && xx_vec == NULL) {
1322 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1323 }
1324
1325 /* randomly select alpha, beta */
1326 if (alpha_flag == 0) {
1327 y_elem[0] = (float) xrand(seed);
1328 y_elem[1] = (float) xrand(seed);
1329 alpha_i[0] = y_elem[0];
1330 alpha_i[0 + 1] = y_elem[1];
1331 }
1332 if (beta_flag == 0) {
1333 y_elem[0] = (float) xrand(seed);
1334 y_elem[1] = (float) xrand(seed);
1335 beta_i[0] = y_elem[0];
1336 beta_i[0 + 1] = y_elem[1];
1337 }
1338
1339
1340 /*set a, x randomly */
1341
1342 if (order == blas_colmajor) {
1343 incai = 1;
1344 incaij = lda;
1345 } else {
1346 incai = lda;
1347 incaij = 1;
1348 }
1349
1350 incxi = incx;
1351
1352
1353 if (incxi < 0) {
1354 x_starti = (-n + 1) * incxi;
1355 } else {
1356 x_starti = 0;
1357 }
1358
1359
1360
1361
1362 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
1363 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
1364 a_elem = (float) xrand(seed);
1365 a_i[aij] = a_elem;
1366 }
1367 }
1368
1369 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
1370 x_elem = (float) xrand(seed);
1371 x_i[xi] = x_elem;
1372 }
1373
1374 /* now compute appropriate y vector */
1375
1376 /* get x */
1377 scopy_vector(x_i, n_i, incx, x_vec, 1);
1378 {
1379 /* promote to complex */
1380 int r;
1381 for (r = 0; r < n_i; r++) {
1382 xx_vec[2 * r] = x_vec[r];
1383 xx_vec[2 * r + 1] = 0.0;
1384 }
1385 }
1386
1387 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
1388 ssy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
1389 {
1390 /* promote to complex */
1391 int r;
1392 for (r = 0; r < n_i; r++) {
1393 aa_vec[2 * r] = a_vec[r];
1394 aa_vec[2 * r + 1] = 0.0;
1395 }
1396 }
1397
1398 BLAS_cdot_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
1399 beta, 1,
1400 xx_vec,
1401 aa_vec,
1402 seed, y_elem, head_r_true_elem, tail_r_true_elem);
1403
1404 y_i[yi] = y_elem[0];
1405 y_i[yi + 1] = y_elem[1];
1406 head_r_true[ri] = head_r_true_elem[0];
1407 head_r_true[ri + 1] = head_r_true_elem[1];
1408 tail_r_true[ri] = tail_r_true_elem[0];
1409 tail_r_true[ri + 1] = tail_r_true_elem[1];
1410 }
1411
1412 blas_free(aa_vec);
1413 blas_free(xx_vec);
1414 }
1415
1416 blas_free(a_vec);
1417 blas_free(x_vec);
1418 }
BLAS_csymv_s_c_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,float * a,int lda,void * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)1419 void BLAS_csymv_s_c_testgen(int norm, enum blas_order_type order,
1420 enum blas_uplo_type uplo,
1421 int n, int randomize,
1422 void *alpha, int alpha_flag, void *beta,
1423 int beta_flag, float *a, int lda, void *x,
1424 int incx, void *y, int incy, int *seed,
1425 double *head_r_true, double *tail_r_true)
1426
1427 /*
1428 * Purpose
1429 * =======
1430 *
1431 * Generates the test inputs to BLAS_csymv_s_c{_x}
1432 *
1433 * Arguments
1434 * =========
1435 *
1436 * norm (input) int
1437 * = -1: the vectors are scaled with norms near underflow.
1438 * = 0: the vectors have norms of order 1.
1439 * = 1: the vectors are scaled with norms near overflow.
1440 *
1441 * order (input) enum blas_side_type
1442 * storage format of the matrices
1443 *
1444 * uplo (input) enum blas_uplo_type
1445 * which half of the symvetric matrix a is to be stored.
1446 *
1447 * n (input) int
1448 * sizes of symmetrical matrix a, size of vectors x, y:
1449 * matrix a is n-by-n.
1450 *
1451 * randomize (input) int
1452 * if 0, entries in matrices A, x will be chosen for
1453 * maximum cancellation, but with less randomness.
1454 * if 1, every entry in the matrix A, x will be
1455 * random.
1456 *
1457 * alpha (input/output) void*
1458 * if alpha_flag = 1, alpha is input.
1459 * if alpha_flag = 0, alpha is output.
1460 *
1461 * alpha_flag (input) int
1462 * = 0: alpha is free, and is output.
1463 * = 1: alpha is fixed on input.
1464 *
1465 * beta (input/output) void*
1466 * if beta_flag = 1, beta is input.
1467 * if beta_flag = 0, beta is output.
1468 *
1469 * beta_flag (input) int
1470 * = 0: beta is free, and is output.
1471 * = 1: beta is fixed on input.
1472 *
1473 * a (input/output) float*
1474 *
1475 * lda (input) lda
1476 * leading dimension of matrix A.
1477 *
1478 * x (input/output) void*
1479 *
1480 * incx (input) int
1481 * stride of vector x.
1482 *
1483 * y (input/output) void*
1484 * generated vector y that will be used as an input to SYMV.
1485 *
1486 * incy (input) int
1487 * leading dimension of vector y.
1488 *
1489 * seed (input/output) int *
1490 * seed for the random number generator.
1491 *
1492 * double (output) *head_r_true
1493 * the leading part of the truth in double-double.
1494 *
1495 * double (output) *tail_r_true
1496 * the trailing part of the truth in double-double
1497 *
1498 */
1499 {
1500
1501 int i, j;
1502 int yi;
1503 int xi;
1504 int aij, ai, ri;
1505 int incyi, incri;
1506 int incxi, incx_veci, x_starti, y_starti;
1507 int incaij, incai;
1508 int inca;
1509 int n_i;
1510
1511 float y_elem[2];
1512 float a_elem;
1513 float x_elem[2];
1514 double head_r_true_elem[2], tail_r_true_elem[2];
1515
1516 float *a_vec;
1517 float *x_vec;
1518
1519 float *y_i = (float *) y;
1520 float *alpha_i = (float *) alpha;
1521 float *beta_i = (float *) beta;
1522 float *a_i = a;
1523 float *x_i = (float *) x;
1524
1525 n_i = n;
1526
1527 /*x_vec, a_vec must have stride of 1 */
1528 inca = 1;
1529
1530
1531 a_vec = (float *) blas_malloc(n_i * sizeof(float));
1532 if (n_i > 0 && a_vec == NULL) {
1533 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1534 }
1535 for (i = 0; i < n_i; i += inca) {
1536 a_vec[i] = 0.0;
1537 }
1538
1539 incyi = incy;
1540 incyi *= 2;
1541 if (incyi < 0) {
1542 y_starti = (-n + 1) * incyi;
1543 } else {
1544 y_starti = 0;
1545 }
1546
1547
1548
1549 incri = 1;
1550 incri *= 2;
1551
1552 incxi = incx;
1553 incx_veci = 1;
1554 incx_veci *= 2;
1555 incxi *= 2;
1556
1557 if (incxi < 0) {
1558 x_starti = (-n + 1) * incxi;
1559 } else {
1560 x_starti = 0;
1561 }
1562
1563 x_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
1564 if (n_i > 0 && x_vec == NULL) {
1565 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1566 };
1567 for (i = 0; i < n_i; i += incx_veci) {
1568 x_vec[i] = 0.0;
1569 x_vec[i + 1] = 0.0;
1570 }
1571
1572 if (randomize == 0) {
1573 /* First fill in the first row of A and all of x */
1574
1575 BLAS_cdot_c_s_testgen(n_i, 0, 0, norm, blas_no_conj,
1576 alpha, alpha_flag, beta, beta_flag,
1577 x_vec, a_vec, seed, y_elem,
1578 head_r_true_elem, tail_r_true_elem);
1579
1580 yi = y_starti;
1581 ri = 0;
1582 y_i[yi] = y_elem[0];
1583 y_i[yi + 1] = y_elem[1];
1584 head_r_true[ri] = head_r_true_elem[0];
1585 head_r_true[ri + 1] = head_r_true_elem[1];
1586 tail_r_true[ri] = tail_r_true_elem[0];
1587 tail_r_true[ri + 1] = tail_r_true_elem[1];
1588
1589 /* Copy a_vec to first row of A */
1590 ssy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
1591
1592 /* commit x_vec to x */
1593 ccopy_vector(x_vec, n_i, 1, x_i, incx);
1594
1595 /* Fill in rest of matrix A */
1596 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
1597 yi += incyi) {
1598 ssy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
1599 BLAS_cdot_c_s_testgen(n_i, i, n_i - i, norm,
1600 blas_no_conj, alpha, 1,
1601 beta, 1, x_vec, a_vec, seed,
1602 y_elem, head_r_true_elem, tail_r_true_elem);
1603
1604 ssy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
1605
1606 /*commits an element to the generated y */
1607 y_i[yi] = y_elem[0];
1608 y_i[yi + 1] = y_elem[1];
1609 head_r_true[ri] = head_r_true_elem[0];
1610 head_r_true[ri + 1] = head_r_true_elem[1];
1611 tail_r_true[ri] = tail_r_true_elem[0];
1612 tail_r_true[ri + 1] = tail_r_true_elem[1];
1613 }
1614
1615 } else {
1616
1617 float *aa_vec;
1618
1619
1620 aa_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
1621 if (n_i > 0 && aa_vec == NULL) {
1622 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1623 }
1624
1625
1626 /* randomly select alpha, beta */
1627 if (alpha_flag == 0) {
1628 y_elem[0] = (float) xrand(seed);
1629 y_elem[1] = (float) xrand(seed);
1630 alpha_i[0] = y_elem[0];
1631 alpha_i[0 + 1] = y_elem[1];
1632 }
1633 if (beta_flag == 0) {
1634 y_elem[0] = (float) xrand(seed);
1635 y_elem[1] = (float) xrand(seed);
1636 beta_i[0] = y_elem[0];
1637 beta_i[0 + 1] = y_elem[1];
1638 }
1639
1640
1641 /*set a, x randomly */
1642
1643 if (order == blas_colmajor) {
1644 incai = 1;
1645 incaij = lda;
1646 } else {
1647 incai = lda;
1648 incaij = 1;
1649 }
1650
1651 incxi = incx;
1652 incxi *= 2;
1653
1654 if (incxi < 0) {
1655 x_starti = (-n + 1) * incxi;
1656 } else {
1657 x_starti = 0;
1658 }
1659
1660
1661
1662
1663 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
1664 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
1665 a_elem = (float) xrand(seed);
1666 a_i[aij] = a_elem;
1667 }
1668 }
1669
1670 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
1671 x_elem[0] = (float) xrand(seed);
1672 x_elem[1] = (float) xrand(seed);
1673 x_i[xi] = x_elem[0];
1674 x_i[xi + 1] = x_elem[1];
1675 }
1676
1677 /* now compute appropriate y vector */
1678
1679 /* get x */
1680 ccopy_vector(x_i, n_i, incx, x_vec, 1);
1681
1682
1683 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
1684 ssy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
1685 {
1686 /* promote to complex */
1687 int r;
1688 for (r = 0; r < n_i; r++) {
1689 aa_vec[2 * r] = a_vec[r];
1690 aa_vec[2 * r + 1] = 0.0;
1691 }
1692 }
1693
1694 BLAS_cdot_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
1695 beta, 1,
1696 x_vec,
1697 aa_vec,
1698 seed, y_elem, head_r_true_elem, tail_r_true_elem);
1699
1700 y_i[yi] = y_elem[0];
1701 y_i[yi + 1] = y_elem[1];
1702 head_r_true[ri] = head_r_true_elem[0];
1703 head_r_true[ri + 1] = head_r_true_elem[1];
1704 tail_r_true[ri] = tail_r_true_elem[0];
1705 tail_r_true[ri + 1] = tail_r_true_elem[1];
1706 }
1707
1708 blas_free(aa_vec);
1709
1710 }
1711
1712 blas_free(a_vec);
1713 blas_free(x_vec);
1714 }
BLAS_csymv_c_s_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,void * a,int lda,float * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)1715 void BLAS_csymv_c_s_testgen(int norm, enum blas_order_type order,
1716 enum blas_uplo_type uplo,
1717 int n, int randomize,
1718 void *alpha, int alpha_flag, void *beta,
1719 int beta_flag, void *a, int lda, float *x,
1720 int incx, void *y, int incy, int *seed,
1721 double *head_r_true, double *tail_r_true)
1722
1723 /*
1724 * Purpose
1725 * =======
1726 *
1727 * Generates the test inputs to BLAS_csymv_c_s{_x}
1728 *
1729 * Arguments
1730 * =========
1731 *
1732 * norm (input) int
1733 * = -1: the vectors are scaled with norms near underflow.
1734 * = 0: the vectors have norms of order 1.
1735 * = 1: the vectors are scaled with norms near overflow.
1736 *
1737 * order (input) enum blas_side_type
1738 * storage format of the matrices
1739 *
1740 * uplo (input) enum blas_uplo_type
1741 * which half of the symvetric matrix a is to be stored.
1742 *
1743 * n (input) int
1744 * sizes of symmetrical matrix a, size of vectors x, y:
1745 * matrix a is n-by-n.
1746 *
1747 * randomize (input) int
1748 * if 0, entries in matrices A, x will be chosen for
1749 * maximum cancellation, but with less randomness.
1750 * if 1, every entry in the matrix A, x will be
1751 * random.
1752 *
1753 * alpha (input/output) void*
1754 * if alpha_flag = 1, alpha is input.
1755 * if alpha_flag = 0, alpha is output.
1756 *
1757 * alpha_flag (input) int
1758 * = 0: alpha is free, and is output.
1759 * = 1: alpha is fixed on input.
1760 *
1761 * beta (input/output) void*
1762 * if beta_flag = 1, beta is input.
1763 * if beta_flag = 0, beta is output.
1764 *
1765 * beta_flag (input) int
1766 * = 0: beta is free, and is output.
1767 * = 1: beta is fixed on input.
1768 *
1769 * a (input/output) void*
1770 *
1771 * lda (input) lda
1772 * leading dimension of matrix A.
1773 *
1774 * x (input/output) float*
1775 *
1776 * incx (input) int
1777 * stride of vector x.
1778 *
1779 * y (input/output) void*
1780 * generated vector y that will be used as an input to SYMV.
1781 *
1782 * incy (input) int
1783 * leading dimension of vector y.
1784 *
1785 * seed (input/output) int *
1786 * seed for the random number generator.
1787 *
1788 * double (output) *head_r_true
1789 * the leading part of the truth in double-double.
1790 *
1791 * double (output) *tail_r_true
1792 * the trailing part of the truth in double-double
1793 *
1794 */
1795 {
1796
1797 int i, j;
1798 int yi;
1799 int xi;
1800 int aij, ai, ri;
1801 int incyi, incri;
1802 int incxi, incx_veci, x_starti, y_starti;
1803 int incaij, incai;
1804 int inca;
1805 int n_i;
1806
1807 float y_elem[2];
1808 float a_elem[2];
1809 float x_elem;
1810 double head_r_true_elem[2], tail_r_true_elem[2];
1811
1812 float *a_vec;
1813 float *x_vec;
1814
1815 float *y_i = (float *) y;
1816 float *alpha_i = (float *) alpha;
1817 float *beta_i = (float *) beta;
1818 float *a_i = (float *) a;
1819 float *x_i = x;
1820
1821 n_i = n;
1822
1823 /*x_vec, a_vec must have stride of 1 */
1824 inca = 1;
1825 inca *= 2;
1826
1827 a_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
1828 if (n_i > 0 && a_vec == NULL) {
1829 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1830 }
1831 for (i = 0; i < n_i; i += inca) {
1832 a_vec[i] = 0.0;
1833 a_vec[i + 1] = 0.0;
1834 }
1835
1836 incyi = incy;
1837 incyi *= 2;
1838 if (incyi < 0) {
1839 y_starti = (-n + 1) * incyi;
1840 } else {
1841 y_starti = 0;
1842 }
1843
1844
1845
1846 incri = 1;
1847 incri *= 2;
1848
1849 incxi = incx;
1850 incx_veci = 1;
1851
1852
1853
1854 if (incxi < 0) {
1855 x_starti = (-n + 1) * incxi;
1856 } else {
1857 x_starti = 0;
1858 }
1859
1860 x_vec = (float *) blas_malloc(n_i * sizeof(float));
1861 if (n_i > 0 && x_vec == NULL) {
1862 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1863 };
1864 for (i = 0; i < n_i; i += incx_veci) {
1865 x_vec[i] = 0.0;
1866 }
1867
1868 if (randomize == 0) {
1869 /* First fill in the first row of A and all of x */
1870
1871 BLAS_cdot_s_c_testgen(n_i, 0, 0, norm, blas_no_conj,
1872 alpha, alpha_flag, beta, beta_flag,
1873 x_vec, a_vec, seed, y_elem,
1874 head_r_true_elem, tail_r_true_elem);
1875
1876 yi = y_starti;
1877 ri = 0;
1878 y_i[yi] = y_elem[0];
1879 y_i[yi + 1] = y_elem[1];
1880 head_r_true[ri] = head_r_true_elem[0];
1881 head_r_true[ri + 1] = head_r_true_elem[1];
1882 tail_r_true[ri] = tail_r_true_elem[0];
1883 tail_r_true[ri + 1] = tail_r_true_elem[1];
1884
1885 /* Copy a_vec to first row of A */
1886 csy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
1887
1888 /* commit x_vec to x */
1889 scopy_vector(x_vec, n_i, 1, x_i, incx);
1890
1891 /* Fill in rest of matrix A */
1892 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
1893 yi += incyi) {
1894 csy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
1895 BLAS_cdot_s_c_testgen(n_i, i, n_i - i, norm,
1896 blas_no_conj, alpha, 1,
1897 beta, 1, x_vec, a_vec, seed,
1898 y_elem, head_r_true_elem, tail_r_true_elem);
1899
1900 csy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
1901
1902 /*commits an element to the generated y */
1903 y_i[yi] = y_elem[0];
1904 y_i[yi + 1] = y_elem[1];
1905 head_r_true[ri] = head_r_true_elem[0];
1906 head_r_true[ri + 1] = head_r_true_elem[1];
1907 tail_r_true[ri] = tail_r_true_elem[0];
1908 tail_r_true[ri + 1] = tail_r_true_elem[1];
1909 }
1910
1911 } else {
1912
1913
1914 float *xx_vec;
1915
1916
1917 xx_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
1918 if (n_i > 0 && xx_vec == NULL) {
1919 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1920 }
1921
1922 /* randomly select alpha, beta */
1923 if (alpha_flag == 0) {
1924 y_elem[0] = xrand(seed);
1925 y_elem[1] = xrand(seed);
1926 alpha_i[0] = y_elem[0];
1927 alpha_i[0 + 1] = y_elem[1];
1928 }
1929 if (beta_flag == 0) {
1930 y_elem[0] = xrand(seed);
1931 y_elem[1] = xrand(seed);
1932 beta_i[0] = y_elem[0];
1933 beta_i[0 + 1] = y_elem[1];
1934 }
1935
1936
1937 /*set a, x randomly */
1938
1939 if (order == blas_colmajor) {
1940 incai = 1;
1941 incaij = lda;
1942 } else {
1943 incai = lda;
1944 incaij = 1;
1945 }
1946
1947 incxi = incx;
1948
1949
1950 if (incxi < 0) {
1951 x_starti = (-n + 1) * incxi;
1952 } else {
1953 x_starti = 0;
1954 }
1955
1956 incai *= 2;
1957 incaij *= 2;
1958
1959 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
1960 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
1961 a_elem[0] = xrand(seed);
1962 a_elem[1] = xrand(seed);
1963 a_i[aij] = a_elem[0];
1964 a_i[aij + 1] = a_elem[1];
1965 }
1966 }
1967
1968 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
1969 x_elem = xrand(seed);
1970 x_i[xi] = x_elem;
1971 }
1972
1973 /* now compute appropriate y vector */
1974
1975 /* get x */
1976 scopy_vector(x_i, n_i, incx, x_vec, 1);
1977 {
1978 /* promote to complex */
1979 int r;
1980 for (r = 0; r < n_i; r++) {
1981 xx_vec[2 * r] = x_vec[r];
1982 xx_vec[2 * r + 1] = 0.0;
1983 }
1984 }
1985
1986 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
1987 csy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
1988
1989
1990 BLAS_cdot_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
1991 beta, 1,
1992 xx_vec,
1993 a_vec,
1994 seed, y_elem, head_r_true_elem, tail_r_true_elem);
1995
1996 y_i[yi] = y_elem[0];
1997 y_i[yi + 1] = y_elem[1];
1998 head_r_true[ri] = head_r_true_elem[0];
1999 head_r_true[ri + 1] = head_r_true_elem[1];
2000 tail_r_true[ri] = tail_r_true_elem[0];
2001 tail_r_true[ri + 1] = tail_r_true_elem[1];
2002 }
2003
2004
2005 blas_free(xx_vec);
2006 }
2007
2008 blas_free(a_vec);
2009 blas_free(x_vec);
2010 }
BLAS_zsymv_d_d_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,double * a,int lda,double * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)2011 void BLAS_zsymv_d_d_testgen(int norm, enum blas_order_type order,
2012 enum blas_uplo_type uplo,
2013 int n, int randomize,
2014 void *alpha, int alpha_flag, void *beta,
2015 int beta_flag, double *a, int lda, double *x,
2016 int incx, void *y, int incy, int *seed,
2017 double *head_r_true, double *tail_r_true)
2018
2019 /*
2020 * Purpose
2021 * =======
2022 *
2023 * Generates the test inputs to BLAS_zsymv_d_d{_x}
2024 *
2025 * Arguments
2026 * =========
2027 *
2028 * norm (input) int
2029 * = -1: the vectors are scaled with norms near underflow.
2030 * = 0: the vectors have norms of order 1.
2031 * = 1: the vectors are scaled with norms near overflow.
2032 *
2033 * order (input) enum blas_side_type
2034 * storage format of the matrices
2035 *
2036 * uplo (input) enum blas_uplo_type
2037 * which half of the symvetric matrix a is to be stored.
2038 *
2039 * n (input) int
2040 * sizes of symmetrical matrix a, size of vectors x, y:
2041 * matrix a is n-by-n.
2042 *
2043 * randomize (input) int
2044 * if 0, entries in matrices A, x will be chosen for
2045 * maximum cancellation, but with less randomness.
2046 * if 1, every entry in the matrix A, x will be
2047 * random.
2048 *
2049 * alpha (input/output) void*
2050 * if alpha_flag = 1, alpha is input.
2051 * if alpha_flag = 0, alpha is output.
2052 *
2053 * alpha_flag (input) int
2054 * = 0: alpha is free, and is output.
2055 * = 1: alpha is fixed on input.
2056 *
2057 * beta (input/output) void*
2058 * if beta_flag = 1, beta is input.
2059 * if beta_flag = 0, beta is output.
2060 *
2061 * beta_flag (input) int
2062 * = 0: beta is free, and is output.
2063 * = 1: beta is fixed on input.
2064 *
2065 * a (input/output) double*
2066 *
2067 * lda (input) lda
2068 * leading dimension of matrix A.
2069 *
2070 * x (input/output) double*
2071 *
2072 * incx (input) int
2073 * stride of vector x.
2074 *
2075 * y (input/output) void*
2076 * generated vector y that will be used as an input to SYMV.
2077 *
2078 * incy (input) int
2079 * leading dimension of vector y.
2080 *
2081 * seed (input/output) int *
2082 * seed for the random number generator.
2083 *
2084 * double (output) *head_r_true
2085 * the leading part of the truth in double-double.
2086 *
2087 * double (output) *tail_r_true
2088 * the trailing part of the truth in double-double
2089 *
2090 */
2091 {
2092
2093 int i, j;
2094 int yi;
2095 int xi;
2096 int aij, ai, ri;
2097 int incyi, incri;
2098 int incxi, incx_veci, x_starti, y_starti;
2099 int incaij, incai;
2100 int inca;
2101 int n_i;
2102
2103 double y_elem[2];
2104 double a_elem;
2105 double x_elem;
2106 double head_r_true_elem[2], tail_r_true_elem[2];
2107
2108 double *a_vec;
2109 double *x_vec;
2110
2111 double *y_i = (double *) y;
2112 double *alpha_i = (double *) alpha;
2113 double *beta_i = (double *) beta;
2114 double *a_i = a;
2115 double *x_i = x;
2116
2117 n_i = n;
2118
2119 /*x_vec, a_vec must have stride of 1 */
2120 inca = 1;
2121
2122
2123 a_vec = (double *) blas_malloc(n_i * sizeof(double));
2124 if (n_i > 0 && a_vec == NULL) {
2125 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2126 }
2127 for (i = 0; i < n_i; i += inca) {
2128 a_vec[i] = 0.0;
2129 }
2130
2131 incyi = incy;
2132 incyi *= 2;
2133 if (incyi < 0) {
2134 y_starti = (-n + 1) * incyi;
2135 } else {
2136 y_starti = 0;
2137 }
2138
2139
2140
2141 incri = 1;
2142 incri *= 2;
2143
2144 incxi = incx;
2145 incx_veci = 1;
2146
2147
2148
2149 if (incxi < 0) {
2150 x_starti = (-n + 1) * incxi;
2151 } else {
2152 x_starti = 0;
2153 }
2154
2155 x_vec = (double *) blas_malloc(n_i * sizeof(double));
2156 if (n_i > 0 && x_vec == NULL) {
2157 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2158 };
2159 for (i = 0; i < n_i; i += incx_veci) {
2160 x_vec[i] = 0.0;
2161 }
2162
2163 if (randomize == 0) {
2164 /* First fill in the first row of A and all of x */
2165
2166 BLAS_zdot_d_d_testgen(n_i, 0, 0, norm, blas_no_conj,
2167 alpha, alpha_flag, beta, beta_flag,
2168 x_vec, a_vec, seed, y_elem,
2169 head_r_true_elem, tail_r_true_elem);
2170
2171 yi = y_starti;
2172 ri = 0;
2173 y_i[yi] = y_elem[0];
2174 y_i[yi + 1] = y_elem[1];
2175 head_r_true[ri] = head_r_true_elem[0];
2176 head_r_true[ri + 1] = head_r_true_elem[1];
2177 tail_r_true[ri] = tail_r_true_elem[0];
2178 tail_r_true[ri + 1] = tail_r_true_elem[1];
2179
2180 /* Copy a_vec to first row of A */
2181 dsy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
2182
2183 /* commit x_vec to x */
2184 dcopy_vector(x_vec, n_i, 1, x_i, incx);
2185
2186 /* Fill in rest of matrix A */
2187 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
2188 yi += incyi) {
2189 dsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
2190 BLAS_zdot_d_d_testgen(n_i, i, n_i - i, norm,
2191 blas_no_conj, alpha, 1,
2192 beta, 1, x_vec, a_vec, seed,
2193 y_elem, head_r_true_elem, tail_r_true_elem);
2194
2195 dsy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
2196
2197 /*commits an element to the generated y */
2198 y_i[yi] = y_elem[0];
2199 y_i[yi + 1] = y_elem[1];
2200 head_r_true[ri] = head_r_true_elem[0];
2201 head_r_true[ri + 1] = head_r_true_elem[1];
2202 tail_r_true[ri] = tail_r_true_elem[0];
2203 tail_r_true[ri + 1] = tail_r_true_elem[1];
2204 }
2205
2206 } else {
2207
2208 double *aa_vec;
2209 double *xx_vec;
2210
2211 aa_vec = (double *) blas_malloc(n_i * sizeof(double) * 2);
2212 if (n_i > 0 && aa_vec == NULL) {
2213 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2214 }
2215 xx_vec = (double *) blas_malloc(n_i * sizeof(double) * 2);
2216 if (n_i > 0 && xx_vec == NULL) {
2217 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2218 }
2219
2220 /* randomly select alpha, beta */
2221 if (alpha_flag == 0) {
2222 y_elem[0] = (float) xrand(seed);
2223 y_elem[1] = (float) xrand(seed);
2224 alpha_i[0] = y_elem[0];
2225 alpha_i[0 + 1] = y_elem[1];
2226 }
2227 if (beta_flag == 0) {
2228 y_elem[0] = (float) xrand(seed);
2229 y_elem[1] = (float) xrand(seed);
2230 beta_i[0] = y_elem[0];
2231 beta_i[0 + 1] = y_elem[1];
2232 }
2233
2234
2235 /*set a, x randomly */
2236
2237 if (order == blas_colmajor) {
2238 incai = 1;
2239 incaij = lda;
2240 } else {
2241 incai = lda;
2242 incaij = 1;
2243 }
2244
2245 incxi = incx;
2246
2247
2248 if (incxi < 0) {
2249 x_starti = (-n + 1) * incxi;
2250 } else {
2251 x_starti = 0;
2252 }
2253
2254
2255
2256
2257 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
2258 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
2259 a_elem = (float) xrand(seed);
2260 a_i[aij] = a_elem;
2261 }
2262 }
2263
2264 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
2265 x_elem = (float) xrand(seed);
2266 x_i[xi] = x_elem;
2267 }
2268
2269 /* now compute appropriate y vector */
2270
2271 /* get x */
2272 dcopy_vector(x_i, n_i, incx, x_vec, 1);
2273 {
2274 /* promote to complex */
2275 int r;
2276 for (r = 0; r < n_i; r++) {
2277 xx_vec[2 * r] = x_vec[r];
2278 xx_vec[2 * r + 1] = 0.0;
2279 }
2280 }
2281
2282 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
2283 dsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
2284 {
2285 /* promote to complex */
2286 int r;
2287 for (r = 0; r < n_i; r++) {
2288 aa_vec[2 * r] = a_vec[r];
2289 aa_vec[2 * r + 1] = 0.0;
2290 }
2291 }
2292
2293 BLAS_zdot_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
2294 beta, 1,
2295 xx_vec,
2296 aa_vec,
2297 seed, y_elem, head_r_true_elem, tail_r_true_elem);
2298
2299 y_i[yi] = y_elem[0];
2300 y_i[yi + 1] = y_elem[1];
2301 head_r_true[ri] = head_r_true_elem[0];
2302 head_r_true[ri + 1] = head_r_true_elem[1];
2303 tail_r_true[ri] = tail_r_true_elem[0];
2304 tail_r_true[ri + 1] = tail_r_true_elem[1];
2305 }
2306
2307 blas_free(aa_vec);
2308 blas_free(xx_vec);
2309 }
2310
2311 blas_free(a_vec);
2312 blas_free(x_vec);
2313 }
BLAS_zsymv_d_z_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,double * a,int lda,void * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)2314 void BLAS_zsymv_d_z_testgen(int norm, enum blas_order_type order,
2315 enum blas_uplo_type uplo,
2316 int n, int randomize,
2317 void *alpha, int alpha_flag, void *beta,
2318 int beta_flag, double *a, int lda, void *x,
2319 int incx, void *y, int incy, int *seed,
2320 double *head_r_true, double *tail_r_true)
2321
2322 /*
2323 * Purpose
2324 * =======
2325 *
2326 * Generates the test inputs to BLAS_zsymv_d_z{_x}
2327 *
2328 * Arguments
2329 * =========
2330 *
2331 * norm (input) int
2332 * = -1: the vectors are scaled with norms near underflow.
2333 * = 0: the vectors have norms of order 1.
2334 * = 1: the vectors are scaled with norms near overflow.
2335 *
2336 * order (input) enum blas_side_type
2337 * storage format of the matrices
2338 *
2339 * uplo (input) enum blas_uplo_type
2340 * which half of the symvetric matrix a is to be stored.
2341 *
2342 * n (input) int
2343 * sizes of symmetrical matrix a, size of vectors x, y:
2344 * matrix a is n-by-n.
2345 *
2346 * randomize (input) int
2347 * if 0, entries in matrices A, x will be chosen for
2348 * maximum cancellation, but with less randomness.
2349 * if 1, every entry in the matrix A, x will be
2350 * random.
2351 *
2352 * alpha (input/output) void*
2353 * if alpha_flag = 1, alpha is input.
2354 * if alpha_flag = 0, alpha is output.
2355 *
2356 * alpha_flag (input) int
2357 * = 0: alpha is free, and is output.
2358 * = 1: alpha is fixed on input.
2359 *
2360 * beta (input/output) void*
2361 * if beta_flag = 1, beta is input.
2362 * if beta_flag = 0, beta is output.
2363 *
2364 * beta_flag (input) int
2365 * = 0: beta is free, and is output.
2366 * = 1: beta is fixed on input.
2367 *
2368 * a (input/output) double*
2369 *
2370 * lda (input) lda
2371 * leading dimension of matrix A.
2372 *
2373 * x (input/output) void*
2374 *
2375 * incx (input) int
2376 * stride of vector x.
2377 *
2378 * y (input/output) void*
2379 * generated vector y that will be used as an input to SYMV.
2380 *
2381 * incy (input) int
2382 * leading dimension of vector y.
2383 *
2384 * seed (input/output) int *
2385 * seed for the random number generator.
2386 *
2387 * double (output) *head_r_true
2388 * the leading part of the truth in double-double.
2389 *
2390 * double (output) *tail_r_true
2391 * the trailing part of the truth in double-double
2392 *
2393 */
2394 {
2395
2396 int i, j;
2397 int yi;
2398 int xi;
2399 int aij, ai, ri;
2400 int incyi, incri;
2401 int incxi, incx_veci, x_starti, y_starti;
2402 int incaij, incai;
2403 int inca;
2404 int n_i;
2405
2406 double y_elem[2];
2407 double a_elem;
2408 double x_elem[2];
2409 double head_r_true_elem[2], tail_r_true_elem[2];
2410
2411 double *a_vec;
2412 double *x_vec;
2413
2414 double *y_i = (double *) y;
2415 double *alpha_i = (double *) alpha;
2416 double *beta_i = (double *) beta;
2417 double *a_i = a;
2418 double *x_i = (double *) x;
2419
2420 n_i = n;
2421
2422 /*x_vec, a_vec must have stride of 1 */
2423 inca = 1;
2424
2425
2426 a_vec = (double *) blas_malloc(n_i * sizeof(double));
2427 if (n_i > 0 && a_vec == NULL) {
2428 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2429 }
2430 for (i = 0; i < n_i; i += inca) {
2431 a_vec[i] = 0.0;
2432 }
2433
2434 incyi = incy;
2435 incyi *= 2;
2436 if (incyi < 0) {
2437 y_starti = (-n + 1) * incyi;
2438 } else {
2439 y_starti = 0;
2440 }
2441
2442
2443
2444 incri = 1;
2445 incri *= 2;
2446
2447 incxi = incx;
2448 incx_veci = 1;
2449 incx_veci *= 2;
2450 incxi *= 2;
2451
2452 if (incxi < 0) {
2453 x_starti = (-n + 1) * incxi;
2454 } else {
2455 x_starti = 0;
2456 }
2457
2458 x_vec = (double *) blas_malloc(n_i * sizeof(double) * 2);
2459 if (n_i > 0 && x_vec == NULL) {
2460 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2461 };
2462 for (i = 0; i < n_i; i += incx_veci) {
2463 x_vec[i] = 0.0;
2464 x_vec[i + 1] = 0.0;
2465 }
2466
2467 if (randomize == 0) {
2468 /* First fill in the first row of A and all of x */
2469
2470 BLAS_zdot_z_d_testgen(n_i, 0, 0, norm, blas_no_conj,
2471 alpha, alpha_flag, beta, beta_flag,
2472 x_vec, a_vec, seed, y_elem,
2473 head_r_true_elem, tail_r_true_elem);
2474
2475 yi = y_starti;
2476 ri = 0;
2477 y_i[yi] = y_elem[0];
2478 y_i[yi + 1] = y_elem[1];
2479 head_r_true[ri] = head_r_true_elem[0];
2480 head_r_true[ri + 1] = head_r_true_elem[1];
2481 tail_r_true[ri] = tail_r_true_elem[0];
2482 tail_r_true[ri + 1] = tail_r_true_elem[1];
2483
2484 /* Copy a_vec to first row of A */
2485 dsy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
2486
2487 /* commit x_vec to x */
2488 zcopy_vector(x_vec, n_i, 1, x_i, incx);
2489
2490 /* Fill in rest of matrix A */
2491 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
2492 yi += incyi) {
2493 dsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
2494 BLAS_zdot_z_d_testgen(n_i, i, n_i - i, norm,
2495 blas_no_conj, alpha, 1,
2496 beta, 1, x_vec, a_vec, seed,
2497 y_elem, head_r_true_elem, tail_r_true_elem);
2498
2499 dsy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
2500
2501 /*commits an element to the generated y */
2502 y_i[yi] = y_elem[0];
2503 y_i[yi + 1] = y_elem[1];
2504 head_r_true[ri] = head_r_true_elem[0];
2505 head_r_true[ri + 1] = head_r_true_elem[1];
2506 tail_r_true[ri] = tail_r_true_elem[0];
2507 tail_r_true[ri + 1] = tail_r_true_elem[1];
2508 }
2509
2510 } else {
2511
2512 double *aa_vec;
2513
2514
2515 aa_vec = (double *) blas_malloc(n_i * sizeof(double) * 2);
2516 if (n_i > 0 && aa_vec == NULL) {
2517 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2518 }
2519
2520
2521 /* randomly select alpha, beta */
2522 if (alpha_flag == 0) {
2523 y_elem[0] = (float) xrand(seed);
2524 y_elem[1] = (float) xrand(seed);
2525 alpha_i[0] = y_elem[0];
2526 alpha_i[0 + 1] = y_elem[1];
2527 }
2528 if (beta_flag == 0) {
2529 y_elem[0] = (float) xrand(seed);
2530 y_elem[1] = (float) xrand(seed);
2531 beta_i[0] = y_elem[0];
2532 beta_i[0 + 1] = y_elem[1];
2533 }
2534
2535
2536 /*set a, x randomly */
2537
2538 if (order == blas_colmajor) {
2539 incai = 1;
2540 incaij = lda;
2541 } else {
2542 incai = lda;
2543 incaij = 1;
2544 }
2545
2546 incxi = incx;
2547 incxi *= 2;
2548
2549 if (incxi < 0) {
2550 x_starti = (-n + 1) * incxi;
2551 } else {
2552 x_starti = 0;
2553 }
2554
2555
2556
2557
2558 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
2559 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
2560 a_elem = (float) xrand(seed);
2561 a_i[aij] = a_elem;
2562 }
2563 }
2564
2565 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
2566 x_elem[0] = (float) xrand(seed);
2567 x_elem[1] = (float) xrand(seed);
2568 x_i[xi] = x_elem[0];
2569 x_i[xi + 1] = x_elem[1];
2570 }
2571
2572 /* now compute appropriate y vector */
2573
2574 /* get x */
2575 zcopy_vector(x_i, n_i, incx, x_vec, 1);
2576
2577
2578 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
2579 dsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
2580 {
2581 /* promote to complex */
2582 int r;
2583 for (r = 0; r < n_i; r++) {
2584 aa_vec[2 * r] = a_vec[r];
2585 aa_vec[2 * r + 1] = 0.0;
2586 }
2587 }
2588
2589 BLAS_zdot_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
2590 beta, 1,
2591 x_vec,
2592 aa_vec,
2593 seed, y_elem, head_r_true_elem, tail_r_true_elem);
2594
2595 y_i[yi] = y_elem[0];
2596 y_i[yi + 1] = y_elem[1];
2597 head_r_true[ri] = head_r_true_elem[0];
2598 head_r_true[ri + 1] = head_r_true_elem[1];
2599 tail_r_true[ri] = tail_r_true_elem[0];
2600 tail_r_true[ri + 1] = tail_r_true_elem[1];
2601 }
2602
2603 blas_free(aa_vec);
2604
2605 }
2606
2607 blas_free(a_vec);
2608 blas_free(x_vec);
2609 }
BLAS_zsymv_z_d_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,void * a,int lda,double * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)2610 void BLAS_zsymv_z_d_testgen(int norm, enum blas_order_type order,
2611 enum blas_uplo_type uplo,
2612 int n, int randomize,
2613 void *alpha, int alpha_flag, void *beta,
2614 int beta_flag, void *a, int lda, double *x,
2615 int incx, void *y, int incy, int *seed,
2616 double *head_r_true, double *tail_r_true)
2617
2618 /*
2619 * Purpose
2620 * =======
2621 *
2622 * Generates the test inputs to BLAS_zsymv_z_d{_x}
2623 *
2624 * Arguments
2625 * =========
2626 *
2627 * norm (input) int
2628 * = -1: the vectors are scaled with norms near underflow.
2629 * = 0: the vectors have norms of order 1.
2630 * = 1: the vectors are scaled with norms near overflow.
2631 *
2632 * order (input) enum blas_side_type
2633 * storage format of the matrices
2634 *
2635 * uplo (input) enum blas_uplo_type
2636 * which half of the symvetric matrix a is to be stored.
2637 *
2638 * n (input) int
2639 * sizes of symmetrical matrix a, size of vectors x, y:
2640 * matrix a is n-by-n.
2641 *
2642 * randomize (input) int
2643 * if 0, entries in matrices A, x will be chosen for
2644 * maximum cancellation, but with less randomness.
2645 * if 1, every entry in the matrix A, x will be
2646 * random.
2647 *
2648 * alpha (input/output) void*
2649 * if alpha_flag = 1, alpha is input.
2650 * if alpha_flag = 0, alpha is output.
2651 *
2652 * alpha_flag (input) int
2653 * = 0: alpha is free, and is output.
2654 * = 1: alpha is fixed on input.
2655 *
2656 * beta (input/output) void*
2657 * if beta_flag = 1, beta is input.
2658 * if beta_flag = 0, beta is output.
2659 *
2660 * beta_flag (input) int
2661 * = 0: beta is free, and is output.
2662 * = 1: beta is fixed on input.
2663 *
2664 * a (input/output) void*
2665 *
2666 * lda (input) lda
2667 * leading dimension of matrix A.
2668 *
2669 * x (input/output) double*
2670 *
2671 * incx (input) int
2672 * stride of vector x.
2673 *
2674 * y (input/output) void*
2675 * generated vector y that will be used as an input to SYMV.
2676 *
2677 * incy (input) int
2678 * leading dimension of vector y.
2679 *
2680 * seed (input/output) int *
2681 * seed for the random number generator.
2682 *
2683 * double (output) *head_r_true
2684 * the leading part of the truth in double-double.
2685 *
2686 * double (output) *tail_r_true
2687 * the trailing part of the truth in double-double
2688 *
2689 */
2690 {
2691
2692 int i, j;
2693 int yi;
2694 int xi;
2695 int aij, ai, ri;
2696 int incyi, incri;
2697 int incxi, incx_veci, x_starti, y_starti;
2698 int incaij, incai;
2699 int inca;
2700 int n_i;
2701
2702 double y_elem[2];
2703 double a_elem[2];
2704 double x_elem;
2705 double head_r_true_elem[2], tail_r_true_elem[2];
2706
2707 double *a_vec;
2708 double *x_vec;
2709
2710 double *y_i = (double *) y;
2711 double *alpha_i = (double *) alpha;
2712 double *beta_i = (double *) beta;
2713 double *a_i = (double *) a;
2714 double *x_i = x;
2715
2716 n_i = n;
2717
2718 /*x_vec, a_vec must have stride of 1 */
2719 inca = 1;
2720 inca *= 2;
2721
2722 a_vec = (double *) blas_malloc(n_i * sizeof(double) * 2);
2723 if (n_i > 0 && a_vec == NULL) {
2724 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2725 }
2726 for (i = 0; i < n_i; i += inca) {
2727 a_vec[i] = 0.0;
2728 a_vec[i + 1] = 0.0;
2729 }
2730
2731 incyi = incy;
2732 incyi *= 2;
2733 if (incyi < 0) {
2734 y_starti = (-n + 1) * incyi;
2735 } else {
2736 y_starti = 0;
2737 }
2738
2739
2740
2741 incri = 1;
2742 incri *= 2;
2743
2744 incxi = incx;
2745 incx_veci = 1;
2746
2747
2748
2749 if (incxi < 0) {
2750 x_starti = (-n + 1) * incxi;
2751 } else {
2752 x_starti = 0;
2753 }
2754
2755 x_vec = (double *) blas_malloc(n_i * sizeof(double));
2756 if (n_i > 0 && x_vec == NULL) {
2757 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2758 };
2759 for (i = 0; i < n_i; i += incx_veci) {
2760 x_vec[i] = 0.0;
2761 }
2762
2763 if (randomize == 0) {
2764 /* First fill in the first row of A and all of x */
2765
2766 BLAS_zdot_d_z_testgen(n_i, 0, 0, norm, blas_no_conj,
2767 alpha, alpha_flag, beta, beta_flag,
2768 x_vec, a_vec, seed, y_elem,
2769 head_r_true_elem, tail_r_true_elem);
2770
2771 yi = y_starti;
2772 ri = 0;
2773 y_i[yi] = y_elem[0];
2774 y_i[yi + 1] = y_elem[1];
2775 head_r_true[ri] = head_r_true_elem[0];
2776 head_r_true[ri + 1] = head_r_true_elem[1];
2777 tail_r_true[ri] = tail_r_true_elem[0];
2778 tail_r_true[ri + 1] = tail_r_true_elem[1];
2779
2780 /* Copy a_vec to first row of A */
2781 zsy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
2782
2783 /* commit x_vec to x */
2784 dcopy_vector(x_vec, n_i, 1, x_i, incx);
2785
2786 /* Fill in rest of matrix A */
2787 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
2788 yi += incyi) {
2789 zsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
2790 BLAS_zdot_d_z_testgen(n_i, i, n_i - i, norm,
2791 blas_no_conj, alpha, 1,
2792 beta, 1, x_vec, a_vec, seed,
2793 y_elem, head_r_true_elem, tail_r_true_elem);
2794
2795 zsy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
2796
2797 /*commits an element to the generated y */
2798 y_i[yi] = y_elem[0];
2799 y_i[yi + 1] = y_elem[1];
2800 head_r_true[ri] = head_r_true_elem[0];
2801 head_r_true[ri + 1] = head_r_true_elem[1];
2802 tail_r_true[ri] = tail_r_true_elem[0];
2803 tail_r_true[ri + 1] = tail_r_true_elem[1];
2804 }
2805
2806 } else {
2807
2808
2809 double *xx_vec;
2810
2811
2812 xx_vec = (double *) blas_malloc(n_i * sizeof(double) * 2);
2813 if (n_i > 0 && xx_vec == NULL) {
2814 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2815 }
2816
2817 /* randomly select alpha, beta */
2818 if (alpha_flag == 0) {
2819 y_elem[0] = xrand(seed);
2820 y_elem[1] = xrand(seed);
2821 alpha_i[0] = y_elem[0];
2822 alpha_i[0 + 1] = y_elem[1];
2823 }
2824 if (beta_flag == 0) {
2825 y_elem[0] = xrand(seed);
2826 y_elem[1] = xrand(seed);
2827 beta_i[0] = y_elem[0];
2828 beta_i[0 + 1] = y_elem[1];
2829 }
2830
2831
2832 /*set a, x randomly */
2833
2834 if (order == blas_colmajor) {
2835 incai = 1;
2836 incaij = lda;
2837 } else {
2838 incai = lda;
2839 incaij = 1;
2840 }
2841
2842 incxi = incx;
2843
2844
2845 if (incxi < 0) {
2846 x_starti = (-n + 1) * incxi;
2847 } else {
2848 x_starti = 0;
2849 }
2850
2851 incai *= 2;
2852 incaij *= 2;
2853
2854 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
2855 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
2856 a_elem[0] = xrand(seed);
2857 a_elem[1] = xrand(seed);
2858 a_i[aij] = a_elem[0];
2859 a_i[aij + 1] = a_elem[1];
2860 }
2861 }
2862
2863 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
2864 x_elem = xrand(seed);
2865 x_i[xi] = x_elem;
2866 }
2867
2868 /* now compute appropriate y vector */
2869
2870 /* get x */
2871 dcopy_vector(x_i, n_i, incx, x_vec, 1);
2872 {
2873 /* promote to complex */
2874 int r;
2875 for (r = 0; r < n_i; r++) {
2876 xx_vec[2 * r] = x_vec[r];
2877 xx_vec[2 * r + 1] = 0.0;
2878 }
2879 }
2880
2881 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
2882 zsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
2883
2884
2885 BLAS_zdot_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
2886 beta, 1,
2887 xx_vec,
2888 a_vec,
2889 seed, y_elem, head_r_true_elem, tail_r_true_elem);
2890
2891 y_i[yi] = y_elem[0];
2892 y_i[yi + 1] = y_elem[1];
2893 head_r_true[ri] = head_r_true_elem[0];
2894 head_r_true[ri + 1] = head_r_true_elem[1];
2895 tail_r_true[ri] = tail_r_true_elem[0];
2896 tail_r_true[ri + 1] = tail_r_true_elem[1];
2897 }
2898
2899
2900 blas_free(xx_vec);
2901 }
2902
2903 blas_free(a_vec);
2904 blas_free(x_vec);
2905 }
BLAS_dsymv_s_s_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,double * alpha,int alpha_flag,double * beta,int beta_flag,float * a,int lda,float * x,int incx,double * y,int incy,int * seed,double * head_r_true,double * tail_r_true)2906 void BLAS_dsymv_s_s_testgen(int norm, enum blas_order_type order,
2907 enum blas_uplo_type uplo,
2908 int n, int randomize,
2909 double *alpha, int alpha_flag, double *beta,
2910 int beta_flag, float *a, int lda, float *x,
2911 int incx, double *y, int incy, int *seed,
2912 double *head_r_true, double *tail_r_true)
2913
2914 /*
2915 * Purpose
2916 * =======
2917 *
2918 * Generates the test inputs to BLAS_dsymv_s_s{_x}
2919 *
2920 * Arguments
2921 * =========
2922 *
2923 * norm (input) int
2924 * = -1: the vectors are scaled with norms near underflow.
2925 * = 0: the vectors have norms of order 1.
2926 * = 1: the vectors are scaled with norms near overflow.
2927 *
2928 * order (input) enum blas_side_type
2929 * storage format of the matrices
2930 *
2931 * uplo (input) enum blas_uplo_type
2932 * which half of the symvetric matrix a is to be stored.
2933 *
2934 * n (input) int
2935 * sizes of symmetrical matrix a, size of vectors x, y:
2936 * matrix a is n-by-n.
2937 *
2938 * randomize (input) int
2939 * if 0, entries in matrices A, x will be chosen for
2940 * maximum cancellation, but with less randomness.
2941 * if 1, every entry in the matrix A, x will be
2942 * random.
2943 *
2944 * alpha (input/output) double*
2945 * if alpha_flag = 1, alpha is input.
2946 * if alpha_flag = 0, alpha is output.
2947 *
2948 * alpha_flag (input) int
2949 * = 0: alpha is free, and is output.
2950 * = 1: alpha is fixed on input.
2951 *
2952 * beta (input/output) double*
2953 * if beta_flag = 1, beta is input.
2954 * if beta_flag = 0, beta is output.
2955 *
2956 * beta_flag (input) int
2957 * = 0: beta is free, and is output.
2958 * = 1: beta is fixed on input.
2959 *
2960 * a (input/output) float*
2961 *
2962 * lda (input) lda
2963 * leading dimension of matrix A.
2964 *
2965 * x (input/output) float*
2966 *
2967 * incx (input) int
2968 * stride of vector x.
2969 *
2970 * y (input/output) double*
2971 * generated vector y that will be used as an input to SYMV.
2972 *
2973 * incy (input) int
2974 * leading dimension of vector y.
2975 *
2976 * seed (input/output) int *
2977 * seed for the random number generator.
2978 *
2979 * double (output) *head_r_true
2980 * the leading part of the truth in double-double.
2981 *
2982 * double (output) *tail_r_true
2983 * the trailing part of the truth in double-double
2984 *
2985 */
2986 {
2987
2988 int i, j;
2989 int yi;
2990 int xi;
2991 int aij, ai, ri;
2992 int incyi, incri;
2993 int incxi, incx_veci, x_starti, y_starti;
2994 int incaij, incai;
2995 int inca;
2996 int n_i;
2997
2998 double y_elem;
2999 float a_elem;
3000 float x_elem;
3001 double head_r_true_elem, tail_r_true_elem;
3002
3003 float *a_vec;
3004 float *x_vec;
3005
3006 double *y_i = y;
3007 double *alpha_i = alpha;
3008 double *beta_i = beta;
3009 float *a_i = a;
3010 float *x_i = x;
3011
3012 n_i = n;
3013
3014 /*x_vec, a_vec must have stride of 1 */
3015 inca = 1;
3016
3017
3018 a_vec = (float *) blas_malloc(n_i * sizeof(float));
3019 if (n_i > 0 && a_vec == NULL) {
3020 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3021 }
3022 for (i = 0; i < n_i; i += inca) {
3023 a_vec[i] = 0.0;
3024 }
3025
3026 incyi = incy;
3027
3028 if (incyi < 0) {
3029 y_starti = (-n + 1) * incyi;
3030 } else {
3031 y_starti = 0;
3032 }
3033
3034
3035
3036 incri = 1;
3037
3038
3039 incxi = incx;
3040 incx_veci = 1;
3041
3042
3043
3044 if (incxi < 0) {
3045 x_starti = (-n + 1) * incxi;
3046 } else {
3047 x_starti = 0;
3048 }
3049
3050 x_vec = (float *) blas_malloc(n_i * sizeof(float));
3051 if (n_i > 0 && x_vec == NULL) {
3052 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3053 };
3054 for (i = 0; i < n_i; i += incx_veci) {
3055 x_vec[i] = 0.0;
3056 }
3057
3058 if (randomize == 0) {
3059 /* First fill in the first row of A and all of x */
3060
3061 BLAS_ddot_s_s_testgen(n_i, 0, 0, norm, blas_no_conj,
3062 alpha, alpha_flag, beta, beta_flag,
3063 x_vec, a_vec, seed, &y_elem,
3064 &head_r_true_elem, &tail_r_true_elem);
3065
3066 yi = y_starti;
3067 ri = 0;
3068 y_i[yi] = y_elem;
3069 head_r_true[ri] = head_r_true_elem;
3070 tail_r_true[ri] = tail_r_true_elem;
3071
3072 /* Copy a_vec to first row of A */
3073 ssy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
3074
3075 /* commit x_vec to x */
3076 scopy_vector(x_vec, n_i, 1, x_i, incx);
3077
3078 /* Fill in rest of matrix A */
3079 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
3080 yi += incyi) {
3081 ssy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
3082 BLAS_ddot_s_s_testgen(n_i, i, n_i - i, norm,
3083 blas_no_conj, alpha, 1,
3084 beta, 1, x_vec, a_vec, seed,
3085 &y_elem, &head_r_true_elem, &tail_r_true_elem);
3086
3087 ssy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
3088
3089 /*commits an element to the generated y */
3090 y_i[yi] = y_elem;
3091 head_r_true[ri] = head_r_true_elem;
3092 tail_r_true[ri] = tail_r_true_elem;
3093 }
3094
3095 } else {
3096
3097
3098
3099
3100
3101
3102
3103 /* randomly select alpha, beta */
3104 if (alpha_flag == 0) {
3105 y_elem = (float) xrand(seed);
3106 alpha_i[0] = y_elem;
3107 }
3108 if (beta_flag == 0) {
3109 y_elem = (float) xrand(seed);
3110 beta_i[0] = y_elem;
3111 }
3112
3113
3114 /*set a, x randomly */
3115
3116 if (order == blas_colmajor) {
3117 incai = 1;
3118 incaij = lda;
3119 } else {
3120 incai = lda;
3121 incaij = 1;
3122 }
3123
3124 incxi = incx;
3125
3126
3127 if (incxi < 0) {
3128 x_starti = (-n + 1) * incxi;
3129 } else {
3130 x_starti = 0;
3131 }
3132
3133
3134
3135
3136 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
3137 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
3138 a_elem = (float) xrand(seed);
3139 a_i[aij] = a_elem;
3140 }
3141 }
3142
3143 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
3144 x_elem = (float) xrand(seed);
3145 x_i[xi] = x_elem;
3146 }
3147
3148 /* now compute appropriate y vector */
3149
3150 /* get x */
3151 scopy_vector(x_i, n_i, incx, x_vec, 1);
3152
3153
3154 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
3155 ssy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
3156
3157
3158 BLAS_ddot_s_s_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
3159 beta, 1, x_vec, a_vec, seed,
3160 &y_elem, &head_r_true_elem, &tail_r_true_elem);
3161
3162 y_i[yi] = y_elem;
3163 head_r_true[ri] = head_r_true_elem;
3164 tail_r_true[ri] = tail_r_true_elem;
3165 }
3166
3167
3168
3169 }
3170
3171 blas_free(a_vec);
3172 blas_free(x_vec);
3173 }
BLAS_dsymv_s_d_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,double * alpha,int alpha_flag,double * beta,int beta_flag,float * a,int lda,double * x,int incx,double * y,int incy,int * seed,double * head_r_true,double * tail_r_true)3174 void BLAS_dsymv_s_d_testgen(int norm, enum blas_order_type order,
3175 enum blas_uplo_type uplo,
3176 int n, int randomize,
3177 double *alpha, int alpha_flag, double *beta,
3178 int beta_flag, float *a, int lda, double *x,
3179 int incx, double *y, int incy, int *seed,
3180 double *head_r_true, double *tail_r_true)
3181
3182 /*
3183 * Purpose
3184 * =======
3185 *
3186 * Generates the test inputs to BLAS_dsymv_s_d{_x}
3187 *
3188 * Arguments
3189 * =========
3190 *
3191 * norm (input) int
3192 * = -1: the vectors are scaled with norms near underflow.
3193 * = 0: the vectors have norms of order 1.
3194 * = 1: the vectors are scaled with norms near overflow.
3195 *
3196 * order (input) enum blas_side_type
3197 * storage format of the matrices
3198 *
3199 * uplo (input) enum blas_uplo_type
3200 * which half of the symvetric matrix a is to be stored.
3201 *
3202 * n (input) int
3203 * sizes of symmetrical matrix a, size of vectors x, y:
3204 * matrix a is n-by-n.
3205 *
3206 * randomize (input) int
3207 * if 0, entries in matrices A, x will be chosen for
3208 * maximum cancellation, but with less randomness.
3209 * if 1, every entry in the matrix A, x will be
3210 * random.
3211 *
3212 * alpha (input/output) double*
3213 * if alpha_flag = 1, alpha is input.
3214 * if alpha_flag = 0, alpha is output.
3215 *
3216 * alpha_flag (input) int
3217 * = 0: alpha is free, and is output.
3218 * = 1: alpha is fixed on input.
3219 *
3220 * beta (input/output) double*
3221 * if beta_flag = 1, beta is input.
3222 * if beta_flag = 0, beta is output.
3223 *
3224 * beta_flag (input) int
3225 * = 0: beta is free, and is output.
3226 * = 1: beta is fixed on input.
3227 *
3228 * a (input/output) float*
3229 *
3230 * lda (input) lda
3231 * leading dimension of matrix A.
3232 *
3233 * x (input/output) double*
3234 *
3235 * incx (input) int
3236 * stride of vector x.
3237 *
3238 * y (input/output) double*
3239 * generated vector y that will be used as an input to SYMV.
3240 *
3241 * incy (input) int
3242 * leading dimension of vector y.
3243 *
3244 * seed (input/output) int *
3245 * seed for the random number generator.
3246 *
3247 * double (output) *head_r_true
3248 * the leading part of the truth in double-double.
3249 *
3250 * double (output) *tail_r_true
3251 * the trailing part of the truth in double-double
3252 *
3253 */
3254 {
3255
3256 int i, j;
3257 int yi;
3258 int xi;
3259 int aij, ai, ri;
3260 int incyi, incri;
3261 int incxi, incx_veci, x_starti, y_starti;
3262 int incaij, incai;
3263 int inca;
3264 int n_i;
3265
3266 double y_elem;
3267 float a_elem;
3268 double x_elem;
3269 double head_r_true_elem, tail_r_true_elem;
3270
3271 float *a_vec;
3272 double *x_vec;
3273
3274 double *y_i = y;
3275 double *alpha_i = alpha;
3276 double *beta_i = beta;
3277 float *a_i = a;
3278 double *x_i = x;
3279
3280 n_i = n;
3281
3282 /*x_vec, a_vec must have stride of 1 */
3283 inca = 1;
3284
3285
3286 a_vec = (float *) blas_malloc(n_i * sizeof(float));
3287 if (n_i > 0 && a_vec == NULL) {
3288 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3289 }
3290 for (i = 0; i < n_i; i += inca) {
3291 a_vec[i] = 0.0;
3292 }
3293
3294 incyi = incy;
3295
3296 if (incyi < 0) {
3297 y_starti = (-n + 1) * incyi;
3298 } else {
3299 y_starti = 0;
3300 }
3301
3302
3303
3304 incri = 1;
3305
3306
3307 incxi = incx;
3308 incx_veci = 1;
3309
3310
3311
3312 if (incxi < 0) {
3313 x_starti = (-n + 1) * incxi;
3314 } else {
3315 x_starti = 0;
3316 }
3317
3318 x_vec = (double *) blas_malloc(n_i * sizeof(double));
3319 if (n_i > 0 && x_vec == NULL) {
3320 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3321 };
3322 for (i = 0; i < n_i; i += incx_veci) {
3323 x_vec[i] = 0.0;
3324 }
3325
3326 if (randomize == 0) {
3327 /* First fill in the first row of A and all of x */
3328
3329 BLAS_ddot_d_s_testgen(n_i, 0, 0, norm, blas_no_conj,
3330 alpha, alpha_flag, beta, beta_flag,
3331 x_vec, a_vec, seed, &y_elem,
3332 &head_r_true_elem, &tail_r_true_elem);
3333
3334 yi = y_starti;
3335 ri = 0;
3336 y_i[yi] = y_elem;
3337 head_r_true[ri] = head_r_true_elem;
3338 tail_r_true[ri] = tail_r_true_elem;
3339
3340 /* Copy a_vec to first row of A */
3341 ssy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
3342
3343 /* commit x_vec to x */
3344 dcopy_vector(x_vec, n_i, 1, x_i, incx);
3345
3346 /* Fill in rest of matrix A */
3347 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
3348 yi += incyi) {
3349 ssy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
3350 BLAS_ddot_d_s_testgen(n_i, i, n_i - i, norm,
3351 blas_no_conj, alpha, 1,
3352 beta, 1, x_vec, a_vec, seed,
3353 &y_elem, &head_r_true_elem, &tail_r_true_elem);
3354
3355 ssy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
3356
3357 /*commits an element to the generated y */
3358 y_i[yi] = y_elem;
3359 head_r_true[ri] = head_r_true_elem;
3360 tail_r_true[ri] = tail_r_true_elem;
3361 }
3362
3363 } else {
3364
3365
3366
3367
3368
3369
3370
3371 /* randomly select alpha, beta */
3372 if (alpha_flag == 0) {
3373 y_elem = (float) xrand(seed);
3374 alpha_i[0] = y_elem;
3375 }
3376 if (beta_flag == 0) {
3377 y_elem = (float) xrand(seed);
3378 beta_i[0] = y_elem;
3379 }
3380
3381
3382 /*set a, x randomly */
3383
3384 if (order == blas_colmajor) {
3385 incai = 1;
3386 incaij = lda;
3387 } else {
3388 incai = lda;
3389 incaij = 1;
3390 }
3391
3392 incxi = incx;
3393
3394
3395 if (incxi < 0) {
3396 x_starti = (-n + 1) * incxi;
3397 } else {
3398 x_starti = 0;
3399 }
3400
3401
3402
3403
3404 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
3405 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
3406 a_elem = (float) xrand(seed);
3407 a_i[aij] = a_elem;
3408 }
3409 }
3410
3411 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
3412 x_elem = (float) xrand(seed);
3413 x_i[xi] = x_elem;
3414 }
3415
3416 /* now compute appropriate y vector */
3417
3418 /* get x */
3419 dcopy_vector(x_i, n_i, incx, x_vec, 1);
3420
3421
3422 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
3423 ssy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
3424
3425
3426 BLAS_ddot_d_s_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
3427 beta, 1, x_vec, a_vec, seed,
3428 &y_elem, &head_r_true_elem, &tail_r_true_elem);
3429
3430 y_i[yi] = y_elem;
3431 head_r_true[ri] = head_r_true_elem;
3432 tail_r_true[ri] = tail_r_true_elem;
3433 }
3434
3435
3436
3437 }
3438
3439 blas_free(a_vec);
3440 blas_free(x_vec);
3441 }
BLAS_dsymv_d_s_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,double * alpha,int alpha_flag,double * beta,int beta_flag,double * a,int lda,float * x,int incx,double * y,int incy,int * seed,double * head_r_true,double * tail_r_true)3442 void BLAS_dsymv_d_s_testgen(int norm, enum blas_order_type order,
3443 enum blas_uplo_type uplo,
3444 int n, int randomize,
3445 double *alpha, int alpha_flag, double *beta,
3446 int beta_flag, double *a, int lda, float *x,
3447 int incx, double *y, int incy, int *seed,
3448 double *head_r_true, double *tail_r_true)
3449
3450 /*
3451 * Purpose
3452 * =======
3453 *
3454 * Generates the test inputs to BLAS_dsymv_d_s{_x}
3455 *
3456 * Arguments
3457 * =========
3458 *
3459 * norm (input) int
3460 * = -1: the vectors are scaled with norms near underflow.
3461 * = 0: the vectors have norms of order 1.
3462 * = 1: the vectors are scaled with norms near overflow.
3463 *
3464 * order (input) enum blas_side_type
3465 * storage format of the matrices
3466 *
3467 * uplo (input) enum blas_uplo_type
3468 * which half of the symvetric matrix a is to be stored.
3469 *
3470 * n (input) int
3471 * sizes of symmetrical matrix a, size of vectors x, y:
3472 * matrix a is n-by-n.
3473 *
3474 * randomize (input) int
3475 * if 0, entries in matrices A, x will be chosen for
3476 * maximum cancellation, but with less randomness.
3477 * if 1, every entry in the matrix A, x will be
3478 * random.
3479 *
3480 * alpha (input/output) double*
3481 * if alpha_flag = 1, alpha is input.
3482 * if alpha_flag = 0, alpha is output.
3483 *
3484 * alpha_flag (input) int
3485 * = 0: alpha is free, and is output.
3486 * = 1: alpha is fixed on input.
3487 *
3488 * beta (input/output) double*
3489 * if beta_flag = 1, beta is input.
3490 * if beta_flag = 0, beta is output.
3491 *
3492 * beta_flag (input) int
3493 * = 0: beta is free, and is output.
3494 * = 1: beta is fixed on input.
3495 *
3496 * a (input/output) double*
3497 *
3498 * lda (input) lda
3499 * leading dimension of matrix A.
3500 *
3501 * x (input/output) float*
3502 *
3503 * incx (input) int
3504 * stride of vector x.
3505 *
3506 * y (input/output) double*
3507 * generated vector y that will be used as an input to SYMV.
3508 *
3509 * incy (input) int
3510 * leading dimension of vector y.
3511 *
3512 * seed (input/output) int *
3513 * seed for the random number generator.
3514 *
3515 * double (output) *head_r_true
3516 * the leading part of the truth in double-double.
3517 *
3518 * double (output) *tail_r_true
3519 * the trailing part of the truth in double-double
3520 *
3521 */
3522 {
3523
3524 int i, j;
3525 int yi;
3526 int xi;
3527 int aij, ai, ri;
3528 int incyi, incri;
3529 int incxi, incx_veci, x_starti, y_starti;
3530 int incaij, incai;
3531 int inca;
3532 int n_i;
3533
3534 double y_elem;
3535 double a_elem;
3536 float x_elem;
3537 double head_r_true_elem, tail_r_true_elem;
3538
3539 double *a_vec;
3540 float *x_vec;
3541
3542 double *y_i = y;
3543 double *alpha_i = alpha;
3544 double *beta_i = beta;
3545 double *a_i = a;
3546 float *x_i = x;
3547
3548 n_i = n;
3549
3550 /*x_vec, a_vec must have stride of 1 */
3551 inca = 1;
3552
3553
3554 a_vec = (double *) blas_malloc(n_i * sizeof(double));
3555 if (n_i > 0 && a_vec == NULL) {
3556 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3557 }
3558 for (i = 0; i < n_i; i += inca) {
3559 a_vec[i] = 0.0;
3560 }
3561
3562 incyi = incy;
3563
3564 if (incyi < 0) {
3565 y_starti = (-n + 1) * incyi;
3566 } else {
3567 y_starti = 0;
3568 }
3569
3570
3571
3572 incri = 1;
3573
3574
3575 incxi = incx;
3576 incx_veci = 1;
3577
3578
3579
3580 if (incxi < 0) {
3581 x_starti = (-n + 1) * incxi;
3582 } else {
3583 x_starti = 0;
3584 }
3585
3586 x_vec = (float *) blas_malloc(n_i * sizeof(float));
3587 if (n_i > 0 && x_vec == NULL) {
3588 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3589 };
3590 for (i = 0; i < n_i; i += incx_veci) {
3591 x_vec[i] = 0.0;
3592 }
3593
3594 if (randomize == 0) {
3595 /* First fill in the first row of A and all of x */
3596
3597 BLAS_ddot_s_d_testgen(n_i, 0, 0, norm, blas_no_conj,
3598 alpha, alpha_flag, beta, beta_flag,
3599 x_vec, a_vec, seed, &y_elem,
3600 &head_r_true_elem, &tail_r_true_elem);
3601
3602 yi = y_starti;
3603 ri = 0;
3604 y_i[yi] = y_elem;
3605 head_r_true[ri] = head_r_true_elem;
3606 tail_r_true[ri] = tail_r_true_elem;
3607
3608 /* Copy a_vec to first row of A */
3609 dsy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
3610
3611 /* commit x_vec to x */
3612 scopy_vector(x_vec, n_i, 1, x_i, incx);
3613
3614 /* Fill in rest of matrix A */
3615 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
3616 yi += incyi) {
3617 dsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
3618 BLAS_ddot_s_d_testgen(n_i, i, n_i - i, norm,
3619 blas_no_conj, alpha, 1,
3620 beta, 1, x_vec, a_vec, seed,
3621 &y_elem, &head_r_true_elem, &tail_r_true_elem);
3622
3623 dsy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
3624
3625 /*commits an element to the generated y */
3626 y_i[yi] = y_elem;
3627 head_r_true[ri] = head_r_true_elem;
3628 tail_r_true[ri] = tail_r_true_elem;
3629 }
3630
3631 } else {
3632
3633
3634
3635
3636
3637
3638
3639 /* randomly select alpha, beta */
3640 if (alpha_flag == 0) {
3641 y_elem = (float) xrand(seed);
3642 alpha_i[0] = y_elem;
3643 }
3644 if (beta_flag == 0) {
3645 y_elem = (float) xrand(seed);
3646 beta_i[0] = y_elem;
3647 }
3648
3649
3650 /*set a, x randomly */
3651
3652 if (order == blas_colmajor) {
3653 incai = 1;
3654 incaij = lda;
3655 } else {
3656 incai = lda;
3657 incaij = 1;
3658 }
3659
3660 incxi = incx;
3661
3662
3663 if (incxi < 0) {
3664 x_starti = (-n + 1) * incxi;
3665 } else {
3666 x_starti = 0;
3667 }
3668
3669
3670
3671
3672 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
3673 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
3674 a_elem = (float) xrand(seed);
3675 a_i[aij] = a_elem;
3676 }
3677 }
3678
3679 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
3680 x_elem = (float) xrand(seed);
3681 x_i[xi] = x_elem;
3682 }
3683
3684 /* now compute appropriate y vector */
3685
3686 /* get x */
3687 scopy_vector(x_i, n_i, incx, x_vec, 1);
3688
3689
3690 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
3691 dsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
3692
3693
3694 BLAS_ddot_s_d_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
3695 beta, 1, x_vec, a_vec, seed,
3696 &y_elem, &head_r_true_elem, &tail_r_true_elem);
3697
3698 y_i[yi] = y_elem;
3699 head_r_true[ri] = head_r_true_elem;
3700 tail_r_true[ri] = tail_r_true_elem;
3701 }
3702
3703
3704
3705 }
3706
3707 blas_free(a_vec);
3708 blas_free(x_vec);
3709 }
BLAS_zsymv_c_c_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,void * a,int lda,void * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)3710 void BLAS_zsymv_c_c_testgen(int norm, enum blas_order_type order,
3711 enum blas_uplo_type uplo,
3712 int n, int randomize,
3713 void *alpha, int alpha_flag, void *beta,
3714 int beta_flag, void *a, int lda, void *x,
3715 int incx, void *y, int incy, int *seed,
3716 double *head_r_true, double *tail_r_true)
3717
3718 /*
3719 * Purpose
3720 * =======
3721 *
3722 * Generates the test inputs to BLAS_zsymv_c_c{_x}
3723 *
3724 * Arguments
3725 * =========
3726 *
3727 * norm (input) int
3728 * = -1: the vectors are scaled with norms near underflow.
3729 * = 0: the vectors have norms of order 1.
3730 * = 1: the vectors are scaled with norms near overflow.
3731 *
3732 * order (input) enum blas_side_type
3733 * storage format of the matrices
3734 *
3735 * uplo (input) enum blas_uplo_type
3736 * which half of the symvetric matrix a is to be stored.
3737 *
3738 * n (input) int
3739 * sizes of symmetrical matrix a, size of vectors x, y:
3740 * matrix a is n-by-n.
3741 *
3742 * randomize (input) int
3743 * if 0, entries in matrices A, x will be chosen for
3744 * maximum cancellation, but with less randomness.
3745 * if 1, every entry in the matrix A, x will be
3746 * random.
3747 *
3748 * alpha (input/output) void*
3749 * if alpha_flag = 1, alpha is input.
3750 * if alpha_flag = 0, alpha is output.
3751 *
3752 * alpha_flag (input) int
3753 * = 0: alpha is free, and is output.
3754 * = 1: alpha is fixed on input.
3755 *
3756 * beta (input/output) void*
3757 * if beta_flag = 1, beta is input.
3758 * if beta_flag = 0, beta is output.
3759 *
3760 * beta_flag (input) int
3761 * = 0: beta is free, and is output.
3762 * = 1: beta is fixed on input.
3763 *
3764 * a (input/output) void*
3765 *
3766 * lda (input) lda
3767 * leading dimension of matrix A.
3768 *
3769 * x (input/output) void*
3770 *
3771 * incx (input) int
3772 * stride of vector x.
3773 *
3774 * y (input/output) void*
3775 * generated vector y that will be used as an input to SYMV.
3776 *
3777 * incy (input) int
3778 * leading dimension of vector y.
3779 *
3780 * seed (input/output) int *
3781 * seed for the random number generator.
3782 *
3783 * double (output) *head_r_true
3784 * the leading part of the truth in double-double.
3785 *
3786 * double (output) *tail_r_true
3787 * the trailing part of the truth in double-double
3788 *
3789 */
3790 {
3791
3792 int i, j;
3793 int yi;
3794 int xi;
3795 int aij, ai, ri;
3796 int incyi, incri;
3797 int incxi, incx_veci, x_starti, y_starti;
3798 int incaij, incai;
3799 int inca;
3800 int n_i;
3801
3802 double y_elem[2];
3803 float a_elem[2];
3804 float x_elem[2];
3805 double head_r_true_elem[2], tail_r_true_elem[2];
3806
3807 float *a_vec;
3808 float *x_vec;
3809
3810 double *y_i = (double *) y;
3811 double *alpha_i = (double *) alpha;
3812 double *beta_i = (double *) beta;
3813 float *a_i = (float *) a;
3814 float *x_i = (float *) x;
3815
3816 n_i = n;
3817
3818 /*x_vec, a_vec must have stride of 1 */
3819 inca = 1;
3820 inca *= 2;
3821
3822 a_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
3823 if (n_i > 0 && a_vec == NULL) {
3824 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3825 }
3826 for (i = 0; i < n_i; i += inca) {
3827 a_vec[i] = 0.0;
3828 a_vec[i + 1] = 0.0;
3829 }
3830
3831 incyi = incy;
3832 incyi *= 2;
3833 if (incyi < 0) {
3834 y_starti = (-n + 1) * incyi;
3835 } else {
3836 y_starti = 0;
3837 }
3838
3839
3840
3841 incri = 1;
3842 incri *= 2;
3843
3844 incxi = incx;
3845 incx_veci = 1;
3846 incx_veci *= 2;
3847 incxi *= 2;
3848
3849 if (incxi < 0) {
3850 x_starti = (-n + 1) * incxi;
3851 } else {
3852 x_starti = 0;
3853 }
3854
3855 x_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
3856 if (n_i > 0 && x_vec == NULL) {
3857 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3858 };
3859 for (i = 0; i < n_i; i += incx_veci) {
3860 x_vec[i] = 0.0;
3861 x_vec[i + 1] = 0.0;
3862 }
3863
3864 if (randomize == 0) {
3865 /* First fill in the first row of A and all of x */
3866
3867 BLAS_zdot_c_c_testgen(n_i, 0, 0, norm, blas_no_conj,
3868 alpha, alpha_flag, beta, beta_flag,
3869 x_vec, a_vec, seed, y_elem,
3870 head_r_true_elem, tail_r_true_elem);
3871
3872 yi = y_starti;
3873 ri = 0;
3874 y_i[yi] = y_elem[0];
3875 y_i[yi + 1] = y_elem[1];
3876 head_r_true[ri] = head_r_true_elem[0];
3877 head_r_true[ri + 1] = head_r_true_elem[1];
3878 tail_r_true[ri] = tail_r_true_elem[0];
3879 tail_r_true[ri + 1] = tail_r_true_elem[1];
3880
3881 /* Copy a_vec to first row of A */
3882 csy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
3883
3884 /* commit x_vec to x */
3885 ccopy_vector(x_vec, n_i, 1, x_i, incx);
3886
3887 /* Fill in rest of matrix A */
3888 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
3889 yi += incyi) {
3890 csy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
3891 BLAS_zdot_c_c_testgen(n_i, i, n_i - i, norm,
3892 blas_no_conj, alpha, 1,
3893 beta, 1, x_vec, a_vec, seed,
3894 y_elem, head_r_true_elem, tail_r_true_elem);
3895
3896 csy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
3897
3898 /*commits an element to the generated y */
3899 y_i[yi] = y_elem[0];
3900 y_i[yi + 1] = y_elem[1];
3901 head_r_true[ri] = head_r_true_elem[0];
3902 head_r_true[ri + 1] = head_r_true_elem[1];
3903 tail_r_true[ri] = tail_r_true_elem[0];
3904 tail_r_true[ri + 1] = tail_r_true_elem[1];
3905 }
3906
3907 } else {
3908
3909
3910
3911
3912
3913
3914
3915 /* randomly select alpha, beta */
3916 if (alpha_flag == 0) {
3917 y_elem[0] = (float) xrand(seed);
3918 y_elem[1] = (float) xrand(seed);
3919 alpha_i[0] = y_elem[0];
3920 alpha_i[0 + 1] = y_elem[1];
3921 }
3922 if (beta_flag == 0) {
3923 y_elem[0] = (float) xrand(seed);
3924 y_elem[1] = (float) xrand(seed);
3925 beta_i[0] = y_elem[0];
3926 beta_i[0 + 1] = y_elem[1];
3927 }
3928
3929
3930 /*set a, x randomly */
3931
3932 if (order == blas_colmajor) {
3933 incai = 1;
3934 incaij = lda;
3935 } else {
3936 incai = lda;
3937 incaij = 1;
3938 }
3939
3940 incxi = incx;
3941 incxi *= 2;
3942
3943 if (incxi < 0) {
3944 x_starti = (-n + 1) * incxi;
3945 } else {
3946 x_starti = 0;
3947 }
3948
3949 incai *= 2;
3950 incaij *= 2;
3951
3952 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
3953 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
3954 a_elem[0] = (float) xrand(seed);
3955 a_elem[1] = (float) xrand(seed);
3956 a_i[aij] = a_elem[0];
3957 a_i[aij + 1] = a_elem[1];
3958 }
3959 }
3960
3961 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
3962 x_elem[0] = (float) xrand(seed);
3963 x_elem[1] = (float) xrand(seed);
3964 x_i[xi] = x_elem[0];
3965 x_i[xi + 1] = x_elem[1];
3966 }
3967
3968 /* now compute appropriate y vector */
3969
3970 /* get x */
3971 ccopy_vector(x_i, n_i, incx, x_vec, 1);
3972
3973
3974 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
3975 csy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
3976
3977
3978 BLAS_zdot_c_c_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
3979 beta, 1, x_vec, a_vec, seed,
3980 y_elem, head_r_true_elem, tail_r_true_elem);
3981
3982 y_i[yi] = y_elem[0];
3983 y_i[yi + 1] = y_elem[1];
3984 head_r_true[ri] = head_r_true_elem[0];
3985 head_r_true[ri + 1] = head_r_true_elem[1];
3986 tail_r_true[ri] = tail_r_true_elem[0];
3987 tail_r_true[ri + 1] = tail_r_true_elem[1];
3988 }
3989
3990
3991
3992 }
3993
3994 blas_free(a_vec);
3995 blas_free(x_vec);
3996 }
BLAS_zsymv_c_z_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,void * a,int lda,void * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)3997 void BLAS_zsymv_c_z_testgen(int norm, enum blas_order_type order,
3998 enum blas_uplo_type uplo,
3999 int n, int randomize,
4000 void *alpha, int alpha_flag, void *beta,
4001 int beta_flag, void *a, int lda, void *x,
4002 int incx, void *y, int incy, int *seed,
4003 double *head_r_true, double *tail_r_true)
4004
4005 /*
4006 * Purpose
4007 * =======
4008 *
4009 * Generates the test inputs to BLAS_zsymv_c_z{_x}
4010 *
4011 * Arguments
4012 * =========
4013 *
4014 * norm (input) int
4015 * = -1: the vectors are scaled with norms near underflow.
4016 * = 0: the vectors have norms of order 1.
4017 * = 1: the vectors are scaled with norms near overflow.
4018 *
4019 * order (input) enum blas_side_type
4020 * storage format of the matrices
4021 *
4022 * uplo (input) enum blas_uplo_type
4023 * which half of the symvetric matrix a is to be stored.
4024 *
4025 * n (input) int
4026 * sizes of symmetrical matrix a, size of vectors x, y:
4027 * matrix a is n-by-n.
4028 *
4029 * randomize (input) int
4030 * if 0, entries in matrices A, x will be chosen for
4031 * maximum cancellation, but with less randomness.
4032 * if 1, every entry in the matrix A, x will be
4033 * random.
4034 *
4035 * alpha (input/output) void*
4036 * if alpha_flag = 1, alpha is input.
4037 * if alpha_flag = 0, alpha is output.
4038 *
4039 * alpha_flag (input) int
4040 * = 0: alpha is free, and is output.
4041 * = 1: alpha is fixed on input.
4042 *
4043 * beta (input/output) void*
4044 * if beta_flag = 1, beta is input.
4045 * if beta_flag = 0, beta is output.
4046 *
4047 * beta_flag (input) int
4048 * = 0: beta is free, and is output.
4049 * = 1: beta is fixed on input.
4050 *
4051 * a (input/output) void*
4052 *
4053 * lda (input) lda
4054 * leading dimension of matrix A.
4055 *
4056 * x (input/output) void*
4057 *
4058 * incx (input) int
4059 * stride of vector x.
4060 *
4061 * y (input/output) void*
4062 * generated vector y that will be used as an input to SYMV.
4063 *
4064 * incy (input) int
4065 * leading dimension of vector y.
4066 *
4067 * seed (input/output) int *
4068 * seed for the random number generator.
4069 *
4070 * double (output) *head_r_true
4071 * the leading part of the truth in double-double.
4072 *
4073 * double (output) *tail_r_true
4074 * the trailing part of the truth in double-double
4075 *
4076 */
4077 {
4078
4079 int i, j;
4080 int yi;
4081 int xi;
4082 int aij, ai, ri;
4083 int incyi, incri;
4084 int incxi, incx_veci, x_starti, y_starti;
4085 int incaij, incai;
4086 int inca;
4087 int n_i;
4088
4089 double y_elem[2];
4090 float a_elem[2];
4091 double x_elem[2];
4092 double head_r_true_elem[2], tail_r_true_elem[2];
4093
4094 float *a_vec;
4095 double *x_vec;
4096
4097 double *y_i = (double *) y;
4098 double *alpha_i = (double *) alpha;
4099 double *beta_i = (double *) beta;
4100 float *a_i = (float *) a;
4101 double *x_i = (double *) x;
4102
4103 n_i = n;
4104
4105 /*x_vec, a_vec must have stride of 1 */
4106 inca = 1;
4107 inca *= 2;
4108
4109 a_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
4110 if (n_i > 0 && a_vec == NULL) {
4111 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4112 }
4113 for (i = 0; i < n_i; i += inca) {
4114 a_vec[i] = 0.0;
4115 a_vec[i + 1] = 0.0;
4116 }
4117
4118 incyi = incy;
4119 incyi *= 2;
4120 if (incyi < 0) {
4121 y_starti = (-n + 1) * incyi;
4122 } else {
4123 y_starti = 0;
4124 }
4125
4126
4127
4128 incri = 1;
4129 incri *= 2;
4130
4131 incxi = incx;
4132 incx_veci = 1;
4133 incx_veci *= 2;
4134 incxi *= 2;
4135
4136 if (incxi < 0) {
4137 x_starti = (-n + 1) * incxi;
4138 } else {
4139 x_starti = 0;
4140 }
4141
4142 x_vec = (double *) blas_malloc(n_i * sizeof(double) * 2);
4143 if (n_i > 0 && x_vec == NULL) {
4144 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4145 };
4146 for (i = 0; i < n_i; i += incx_veci) {
4147 x_vec[i] = 0.0;
4148 x_vec[i + 1] = 0.0;
4149 }
4150
4151 if (randomize == 0) {
4152 /* First fill in the first row of A and all of x */
4153
4154 BLAS_zdot_z_c_testgen(n_i, 0, 0, norm, blas_no_conj,
4155 alpha, alpha_flag, beta, beta_flag,
4156 x_vec, a_vec, seed, y_elem,
4157 head_r_true_elem, tail_r_true_elem);
4158
4159 yi = y_starti;
4160 ri = 0;
4161 y_i[yi] = y_elem[0];
4162 y_i[yi + 1] = y_elem[1];
4163 head_r_true[ri] = head_r_true_elem[0];
4164 head_r_true[ri + 1] = head_r_true_elem[1];
4165 tail_r_true[ri] = tail_r_true_elem[0];
4166 tail_r_true[ri + 1] = tail_r_true_elem[1];
4167
4168 /* Copy a_vec to first row of A */
4169 csy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
4170
4171 /* commit x_vec to x */
4172 zcopy_vector(x_vec, n_i, 1, x_i, incx);
4173
4174 /* Fill in rest of matrix A */
4175 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
4176 yi += incyi) {
4177 csy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
4178 BLAS_zdot_z_c_testgen(n_i, i, n_i - i, norm,
4179 blas_no_conj, alpha, 1,
4180 beta, 1, x_vec, a_vec, seed,
4181 y_elem, head_r_true_elem, tail_r_true_elem);
4182
4183 csy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
4184
4185 /*commits an element to the generated y */
4186 y_i[yi] = y_elem[0];
4187 y_i[yi + 1] = y_elem[1];
4188 head_r_true[ri] = head_r_true_elem[0];
4189 head_r_true[ri + 1] = head_r_true_elem[1];
4190 tail_r_true[ri] = tail_r_true_elem[0];
4191 tail_r_true[ri + 1] = tail_r_true_elem[1];
4192 }
4193
4194 } else {
4195
4196
4197
4198
4199
4200
4201
4202 /* randomly select alpha, beta */
4203 if (alpha_flag == 0) {
4204 y_elem[0] = (float) xrand(seed);
4205 y_elem[1] = (float) xrand(seed);
4206 alpha_i[0] = y_elem[0];
4207 alpha_i[0 + 1] = y_elem[1];
4208 }
4209 if (beta_flag == 0) {
4210 y_elem[0] = (float) xrand(seed);
4211 y_elem[1] = (float) xrand(seed);
4212 beta_i[0] = y_elem[0];
4213 beta_i[0 + 1] = y_elem[1];
4214 }
4215
4216
4217 /*set a, x randomly */
4218
4219 if (order == blas_colmajor) {
4220 incai = 1;
4221 incaij = lda;
4222 } else {
4223 incai = lda;
4224 incaij = 1;
4225 }
4226
4227 incxi = incx;
4228 incxi *= 2;
4229
4230 if (incxi < 0) {
4231 x_starti = (-n + 1) * incxi;
4232 } else {
4233 x_starti = 0;
4234 }
4235
4236 incai *= 2;
4237 incaij *= 2;
4238
4239 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
4240 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
4241 a_elem[0] = (float) xrand(seed);
4242 a_elem[1] = (float) xrand(seed);
4243 a_i[aij] = a_elem[0];
4244 a_i[aij + 1] = a_elem[1];
4245 }
4246 }
4247
4248 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
4249 x_elem[0] = (float) xrand(seed);
4250 x_elem[1] = (float) xrand(seed);
4251 x_i[xi] = x_elem[0];
4252 x_i[xi + 1] = x_elem[1];
4253 }
4254
4255 /* now compute appropriate y vector */
4256
4257 /* get x */
4258 zcopy_vector(x_i, n_i, incx, x_vec, 1);
4259
4260
4261 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
4262 csy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
4263
4264
4265 BLAS_zdot_z_c_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
4266 beta, 1, x_vec, a_vec, seed,
4267 y_elem, head_r_true_elem, tail_r_true_elem);
4268
4269 y_i[yi] = y_elem[0];
4270 y_i[yi + 1] = y_elem[1];
4271 head_r_true[ri] = head_r_true_elem[0];
4272 head_r_true[ri + 1] = head_r_true_elem[1];
4273 tail_r_true[ri] = tail_r_true_elem[0];
4274 tail_r_true[ri + 1] = tail_r_true_elem[1];
4275 }
4276
4277
4278
4279 }
4280
4281 blas_free(a_vec);
4282 blas_free(x_vec);
4283 }
BLAS_zsymv_z_c_testgen(int norm,enum blas_order_type order,enum blas_uplo_type uplo,int n,int randomize,void * alpha,int alpha_flag,void * beta,int beta_flag,void * a,int lda,void * x,int incx,void * y,int incy,int * seed,double * head_r_true,double * tail_r_true)4284 void BLAS_zsymv_z_c_testgen(int norm, enum blas_order_type order,
4285 enum blas_uplo_type uplo,
4286 int n, int randomize,
4287 void *alpha, int alpha_flag, void *beta,
4288 int beta_flag, void *a, int lda, void *x,
4289 int incx, void *y, int incy, int *seed,
4290 double *head_r_true, double *tail_r_true)
4291
4292 /*
4293 * Purpose
4294 * =======
4295 *
4296 * Generates the test inputs to BLAS_zsymv_z_c{_x}
4297 *
4298 * Arguments
4299 * =========
4300 *
4301 * norm (input) int
4302 * = -1: the vectors are scaled with norms near underflow.
4303 * = 0: the vectors have norms of order 1.
4304 * = 1: the vectors are scaled with norms near overflow.
4305 *
4306 * order (input) enum blas_side_type
4307 * storage format of the matrices
4308 *
4309 * uplo (input) enum blas_uplo_type
4310 * which half of the symvetric matrix a is to be stored.
4311 *
4312 * n (input) int
4313 * sizes of symmetrical matrix a, size of vectors x, y:
4314 * matrix a is n-by-n.
4315 *
4316 * randomize (input) int
4317 * if 0, entries in matrices A, x will be chosen for
4318 * maximum cancellation, but with less randomness.
4319 * if 1, every entry in the matrix A, x will be
4320 * random.
4321 *
4322 * alpha (input/output) void*
4323 * if alpha_flag = 1, alpha is input.
4324 * if alpha_flag = 0, alpha is output.
4325 *
4326 * alpha_flag (input) int
4327 * = 0: alpha is free, and is output.
4328 * = 1: alpha is fixed on input.
4329 *
4330 * beta (input/output) void*
4331 * if beta_flag = 1, beta is input.
4332 * if beta_flag = 0, beta is output.
4333 *
4334 * beta_flag (input) int
4335 * = 0: beta is free, and is output.
4336 * = 1: beta is fixed on input.
4337 *
4338 * a (input/output) void*
4339 *
4340 * lda (input) lda
4341 * leading dimension of matrix A.
4342 *
4343 * x (input/output) void*
4344 *
4345 * incx (input) int
4346 * stride of vector x.
4347 *
4348 * y (input/output) void*
4349 * generated vector y that will be used as an input to SYMV.
4350 *
4351 * incy (input) int
4352 * leading dimension of vector y.
4353 *
4354 * seed (input/output) int *
4355 * seed for the random number generator.
4356 *
4357 * double (output) *head_r_true
4358 * the leading part of the truth in double-double.
4359 *
4360 * double (output) *tail_r_true
4361 * the trailing part of the truth in double-double
4362 *
4363 */
4364 {
4365
4366 int i, j;
4367 int yi;
4368 int xi;
4369 int aij, ai, ri;
4370 int incyi, incri;
4371 int incxi, incx_veci, x_starti, y_starti;
4372 int incaij, incai;
4373 int inca;
4374 int n_i;
4375
4376 double y_elem[2];
4377 double a_elem[2];
4378 float x_elem[2];
4379 double head_r_true_elem[2], tail_r_true_elem[2];
4380
4381 double *a_vec;
4382 float *x_vec;
4383
4384 double *y_i = (double *) y;
4385 double *alpha_i = (double *) alpha;
4386 double *beta_i = (double *) beta;
4387 double *a_i = (double *) a;
4388 float *x_i = (float *) x;
4389
4390 n_i = n;
4391
4392 /*x_vec, a_vec must have stride of 1 */
4393 inca = 1;
4394 inca *= 2;
4395
4396 a_vec = (double *) blas_malloc(n_i * sizeof(double) * 2);
4397 if (n_i > 0 && a_vec == NULL) {
4398 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4399 }
4400 for (i = 0; i < n_i; i += inca) {
4401 a_vec[i] = 0.0;
4402 a_vec[i + 1] = 0.0;
4403 }
4404
4405 incyi = incy;
4406 incyi *= 2;
4407 if (incyi < 0) {
4408 y_starti = (-n + 1) * incyi;
4409 } else {
4410 y_starti = 0;
4411 }
4412
4413
4414
4415 incri = 1;
4416 incri *= 2;
4417
4418 incxi = incx;
4419 incx_veci = 1;
4420 incx_veci *= 2;
4421 incxi *= 2;
4422
4423 if (incxi < 0) {
4424 x_starti = (-n + 1) * incxi;
4425 } else {
4426 x_starti = 0;
4427 }
4428
4429 x_vec = (float *) blas_malloc(n_i * sizeof(float) * 2);
4430 if (n_i > 0 && x_vec == NULL) {
4431 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4432 };
4433 for (i = 0; i < n_i; i += incx_veci) {
4434 x_vec[i] = 0.0;
4435 x_vec[i + 1] = 0.0;
4436 }
4437
4438 if (randomize == 0) {
4439 /* First fill in the first row of A and all of x */
4440
4441 BLAS_zdot_c_z_testgen(n_i, 0, 0, norm, blas_no_conj,
4442 alpha, alpha_flag, beta, beta_flag,
4443 x_vec, a_vec, seed, y_elem,
4444 head_r_true_elem, tail_r_true_elem);
4445
4446 yi = y_starti;
4447 ri = 0;
4448 y_i[yi] = y_elem[0];
4449 y_i[yi + 1] = y_elem[1];
4450 head_r_true[ri] = head_r_true_elem[0];
4451 head_r_true[ri + 1] = head_r_true_elem[1];
4452 tail_r_true[ri] = tail_r_true_elem[0];
4453 tail_r_true[ri + 1] = tail_r_true_elem[1];
4454
4455 /* Copy a_vec to first row of A */
4456 zsy_commit_row(order, uplo, n_i, a, lda, a_vec, 0);
4457
4458 /* commit x_vec to x */
4459 ccopy_vector(x_vec, n_i, 1, x_i, incx);
4460
4461 /* Fill in rest of matrix A */
4462 for (i = 1, yi += incyi, ri = incri; i < n_i; i++, ri += incri,
4463 yi += incyi) {
4464 zsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
4465 BLAS_zdot_c_z_testgen(n_i, i, n_i - i, norm,
4466 blas_no_conj, alpha, 1,
4467 beta, 1, x_vec, a_vec, seed,
4468 y_elem, head_r_true_elem, tail_r_true_elem);
4469
4470 zsy_commit_row(order, uplo, n_i, a, lda, a_vec, i);
4471
4472 /*commits an element to the generated y */
4473 y_i[yi] = y_elem[0];
4474 y_i[yi + 1] = y_elem[1];
4475 head_r_true[ri] = head_r_true_elem[0];
4476 head_r_true[ri + 1] = head_r_true_elem[1];
4477 tail_r_true[ri] = tail_r_true_elem[0];
4478 tail_r_true[ri + 1] = tail_r_true_elem[1];
4479 }
4480
4481 } else {
4482
4483
4484
4485
4486
4487
4488
4489 /* randomly select alpha, beta */
4490 if (alpha_flag == 0) {
4491 y_elem[0] = (float) xrand(seed);
4492 y_elem[1] = (float) xrand(seed);
4493 alpha_i[0] = y_elem[0];
4494 alpha_i[0 + 1] = y_elem[1];
4495 }
4496 if (beta_flag == 0) {
4497 y_elem[0] = (float) xrand(seed);
4498 y_elem[1] = (float) xrand(seed);
4499 beta_i[0] = y_elem[0];
4500 beta_i[0 + 1] = y_elem[1];
4501 }
4502
4503
4504 /*set a, x randomly */
4505
4506 if (order == blas_colmajor) {
4507 incai = 1;
4508 incaij = lda;
4509 } else {
4510 incai = lda;
4511 incaij = 1;
4512 }
4513
4514 incxi = incx;
4515 incxi *= 2;
4516
4517 if (incxi < 0) {
4518 x_starti = (-n + 1) * incxi;
4519 } else {
4520 x_starti = 0;
4521 }
4522
4523 incai *= 2;
4524 incaij *= 2;
4525
4526 for (i = 0, ai = 0; i < n_i; i++, ai += incai) {
4527 for (j = 0, aij = ai; j < n_i; j++, aij += incaij) {
4528 a_elem[0] = (float) xrand(seed);
4529 a_elem[1] = (float) xrand(seed);
4530 a_i[aij] = a_elem[0];
4531 a_i[aij + 1] = a_elem[1];
4532 }
4533 }
4534
4535 for (i = 0, xi = x_starti; i < n_i; i++, xi += incxi) {
4536 x_elem[0] = (float) xrand(seed);
4537 x_elem[1] = (float) xrand(seed);
4538 x_i[xi] = x_elem[0];
4539 x_i[xi + 1] = x_elem[1];
4540 }
4541
4542 /* now compute appropriate y vector */
4543
4544 /* get x */
4545 ccopy_vector(x_i, n_i, incx, x_vec, 1);
4546
4547
4548 for (i = 0, yi = y_starti, ri = 0; i < n_i; i++, yi += incyi, ri += incri) {
4549 zsy_copy_row(order, uplo, n_i, a, lda, a_vec, i);
4550
4551
4552 BLAS_zdot_c_z_testgen(n_i, n_i, 0, norm, blas_no_conj, alpha, 1,
4553 beta, 1, x_vec, a_vec, seed,
4554 y_elem, head_r_true_elem, tail_r_true_elem);
4555
4556 y_i[yi] = y_elem[0];
4557 y_i[yi + 1] = y_elem[1];
4558 head_r_true[ri] = head_r_true_elem[0];
4559 head_r_true[ri + 1] = head_r_true_elem[1];
4560 tail_r_true[ri] = tail_r_true_elem[0];
4561 tail_r_true[ri + 1] = tail_r_true_elem[1];
4562 }
4563
4564
4565
4566 }
4567
4568 blas_free(a_vec);
4569 blas_free(x_vec);
4570 }
4571