1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <math.h>
4 #include "blas_extended.h"
5 #include "blas_extended_private.h"
6 #include "blas_extended_test.h"
7
8 /* 0 -- 1 */
9 #define UPLO_START 0
10 #define UPLO_END 1
11
12 /* 0 -- 1 */
13 #define ORDER_START 0
14 #define ORDER_END 1
15
16 /* 0 -- 2 */
17 #define ALPHA_START 0
18 #define ALPHA_END 2
19
20 /* 0 -- 2 */
21 #define BETA_START 0
22 #define BETA_END 2
23
24 /* -1 -- 1 */
25 #define NORM_START -1
26 #define NORM_END 1
27
28 /* 0 -- 2 */
29 #define LDA_START 0
30 #define LDA_END 2
31
32 /* 0 -- 2 */
33 #define PREC_START 0
34 #define PREC_END 2
35
36 /* 0 -- 1 */
37 #define RANDOMIZE_START 0
38 #define RANDOMIZE_END 1
39
40 /* -2 -- 2 (Stride) */
41 #define INCX_START -2
42 #define INCX_END 2
43
44 /* -2 -- 2 (Stride) */
45 #define INCY_START -2
46 #define INCY_END 2
47
48 #define NUM_DATA 7
49
50
51
52
53
54
55
56
57
58
do_test_dsymv2_d_s(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)59 void do_test_dsymv2_d_s
60 (int n,
61 int ntests, int *seed, double thresh, int debug, float test_prob,
62 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
63
64 /* Function name */
65 const char fname[] = "do_test_dsymv2_d_s";
66 int i;
67 int yi;
68 int incyi, yi0;
69 int test_count;
70 int bad_ratio_count;
71 int ri;
72 int incri = 1;
73 int incx, incy;
74 double ratio;
75 double ratio_min, ratio_max;
76 double eps_int; /* internal machine epsilon */
77 double un_int; /* internal underflow threshold */
78
79 double rin;
80 double rout;
81 double head_r_true_elem, tail_r_true_elem;
82
83 enum blas_order_type order_type;
84 enum blas_uplo_type uplo_type;
85 enum blas_prec_type prec;
86
87 int order_val, uplo_val;
88 int lda_val, incx_val, incy_val;
89 int alpha_val, beta_val;
90
91
92
93 int lda;
94 int alpha_flag, beta_flag;
95 int saved_seed;
96 int norm;
97 int test_no;
98
99 double alpha;
100 double beta;
101 double *a;
102 float *head_x;
103 float *tail_x;
104 double *y;
105 double *a_vec;
106 double *y_gen;
107 float *head_x_gen;
108 float *tail_x_gen;
109 double *ratios;
110
111 /* true result calculated by testgen, in double-double */
112 double *head_r_true, *tail_r_true;
113
114 FPU_FIX_DECL;
115
116 if (n < 0)
117 BLAS_error(fname, -1, n, NULL);
118 if (ntests < 0)
119 BLAS_error(fname, -2, ntests, NULL);
120
121 /* initialization */
122 saved_seed = *seed;
123 ratio = 0.0;
124 ratio_min = 1e308;
125 ratio_max = 0.0;
126
127 *num_tests = 0;
128 *num_bad_ratio = 0;
129 *min_ratio = 0.0;
130 *max_ratio = 0.0;
131
132 if (n == 0)
133 return;
134
135
136 FPU_FIX_START;
137
138 y = (double *) blas_malloc(2 * n * sizeof(double));
139 if (2 * n > 0 && y == NULL) {
140 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
141 }
142 y_gen = (double *) blas_malloc(n * sizeof(double));
143 if (n > 0 && y_gen == NULL) {
144 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
145 }
146 head_x_gen = (float *) blas_malloc(n * sizeof(float));
147 if (n > 0 && head_x_gen == NULL) {
148 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
149 }
150 tail_x_gen = (float *) blas_malloc(n * sizeof(float));
151 if (n > 0 && tail_x_gen == NULL) {
152 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
153 }
154 a = (double *) blas_malloc(2 * n * n * sizeof(double));
155 if (2 * n * n > 0 && a == NULL) {
156 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
157 }
158 head_x = (float *) blas_malloc(2 * n * sizeof(float));
159 if (2 * n > 0 && head_x == NULL) {
160 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
161 }
162 tail_x = (float *) blas_malloc(2 * n * sizeof(float));
163 if (2 * n > 0 && tail_x == NULL) {
164 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
165 }
166 a_vec = (double *) blas_malloc(n * sizeof(double));
167 if (n > 0 && a_vec == NULL) {
168 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
169 }
170 head_r_true = (double *) blas_malloc(n * sizeof(double));
171 tail_r_true = (double *) blas_malloc(n * sizeof(double));
172 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
173 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
174 }
175 ratios = (double *) blas_malloc(n * sizeof(double));
176 if (n > 0 && ratios == NULL) {
177 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
178 }
179
180 test_count = 0;
181 bad_ratio_count = 0;
182
183 /* vary alpha */
184 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
185
186 alpha_flag = 0;
187 switch (alpha_val) {
188 case 0:
189 alpha = 0.0;
190 alpha_flag = 1;
191 break;
192 case 1:
193 alpha = 1.0;
194 alpha_flag = 1;
195 break;
196 }
197
198 /* vary beta */
199 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
200 beta_flag = 0;
201 switch (beta_val) {
202 case 0:
203 beta = 0.0;
204 beta_flag = 1;
205 break;
206 case 1:
207 beta = 1.0;
208 beta_flag = 1;
209 break;
210 }
211
212
213 eps_int = power(2, -BITS_D);
214 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
215 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
216 prec = blas_prec_double;
217
218 /* vary norm -- underflow, approx 1, overflow */
219 for (norm = NORM_START; norm <= NORM_END; norm++) {
220
221 /* number of tests */
222 for (test_no = 0; test_no < ntests; test_no++) {
223
224 /* vary storage format */
225 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
226
227 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
228
229 /* vary upper / lower variation */
230 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
231
232 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
233
234 /* vary lda = n, n+1, 2*n */
235 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
236
237 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
238
239 saved_seed = *seed;
240 /* For the sake of speed, we throw out this case at random */
241 if (xrand(seed) >= test_prob)
242 continue;
243
244 alpha_flag = 0;
245 switch (alpha_val) {
246 case 0:
247 alpha = 0.0;
248 alpha_flag = 1;
249 break;
250 case 1:
251 alpha = 1.0;
252 alpha_flag = 1;
253 break;
254 }
255 beta_flag = 0;
256 switch (beta_val) {
257 case 0:
258 beta = 0.0;
259 beta_flag = 1;
260 break;
261 case 1:
262 beta = 1.0;
263 beta_flag = 1;
264 break;
265 }
266
267 /* finally we are here to generate the test case */
268 BLAS_dsymv2_d_s_testgen(norm, order_type,
269 uplo_type, n, &alpha, alpha_flag, a,
270 lda, head_x_gen, tail_x_gen, &beta,
271 beta_flag, y_gen, seed, head_r_true,
272 tail_r_true);
273 test_count++;
274
275 /* vary incx = -2, -1, 1, 2 */
276 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
277
278 incx = incx_val;
279 if (0 == incx)
280 continue;
281
282 /* vary incy = -2, -1, 1, 2 */
283 for (incy_val = INCY_START; incy_val <= INCY_END;
284 incy_val++) {
285
286 incy = incy_val;
287 if (0 == incy)
288 continue;
289
290 /* copy generated vector with appropriate incs. */
291 dcopy_vector(y_gen, n, 1, y, incy);
292 scopy_vector(head_x_gen, n, 1, head_x, incx);
293 scopy_vector(tail_x_gen, n, 1, tail_x, incx);
294
295 /* call symv2 routines to be tested */
296 FPU_FIX_STOP;
297 BLAS_dsymv2_d_s(order_type,
298 uplo_type, n, alpha, a, lda, head_x,
299 tail_x, incx, beta, y, incy);
300 FPU_FIX_START;
301
302 /* now compute the ratio using test_BLAS_xdot */
303 /* copy a row from A, use x, run dot test */
304
305 incyi = incy;
306
307 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
308
309 for (i = 0, yi = yi0, ri = 0;
310 i < n; i++, yi += incyi, ri += incri) {
311 dsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
312 i);
313
314 /* just use the x vector - it was unchanged (in theory) */
315 rin = y_gen[i];
316 rout = y[yi];
317 head_r_true_elem = head_r_true[ri];
318 tail_r_true_elem = tail_r_true[ri];
319
320 test_BLAS_ddot2_d_s(n, blas_no_conj, alpha, beta,
321 rin, rout, head_r_true_elem,
322 tail_r_true_elem, a_vec, 1, head_x,
323 tail_x, incx, eps_int, un_int,
324 &ratios[i]);
325
326 /* take the max ratio */
327 if (i == 0) {
328 ratio = ratios[0];
329
330 /* The !<= below causes NaN errors to be included.
331 * Note that (NaN > 0) is false */
332 } else if (!(ratios[i] <= ratio)) {
333 ratio = ratios[i];
334 }
335
336 } /* end of dot-test loop */
337
338
339 /* The !<= below causes NaN errors to be included.
340 * Note that (NaN > 0) is false */
341 if (!(ratio <= thresh)) {
342
343 if (debug == 3) {
344 printf("\n\t\tTest # %d\n", test_count);
345 printf("y type : d, a type : d, x type : s\n");
346 printf("Seed = %d\t", saved_seed);
347 printf("n %d\n", n);
348 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
349
350 if (order_type == blas_rowmajor)
351 printf("row ");
352 else
353 printf("col ");
354
355 if (uplo_type == blas_upper)
356 printf("upper ");
357 else
358 printf("lower ");
359
360 printf("NORM %d, ALPHA %d, BETA %d\n",
361 norm, alpha_val, beta_val);
362
363 /* print out info */
364 printf("alpha = ");
365 printf("%24.16e", alpha);;
366 printf(" ");
367 printf("beta = ");
368 printf("%24.16e", beta);;
369 printf("\n");
370
371 printf("a\n");
372 dsy_print_matrix(a, n, lda, order_type, uplo_type);
373 sprint_vector(head_x, n, incx, "head_x");
374 sprint_vector(tail_x, n, incx, "tail_x");
375 dprint_vector(y_gen, n, incy, "y_gen");
376 dprint_vector(y, n, incy, "y");
377 dprint_vector(head_r_true, n, 1, "head_r_true");
378 dprint_vector(ratios, n, 1, "ratios");
379 printf("ratio = %g\n", ratio);
380 }
381 bad_ratio_count++;
382 if (bad_ratio_count >= MAX_BAD_TESTS) {
383 printf("\ntoo many failures, exiting....");
384 printf("\nTesting and compilation");
385 printf(" are incomplete\n\n");
386 goto end;
387 }
388 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
389 printf("\nFlagrant ratio error, exiting...");
390 printf("\nTesting and compilation");
391 printf(" are incomplete\n\n");
392 goto end;
393 }
394 }
395
396 if (!(ratio <= ratio_max))
397 ratio_max = ratio;
398
399 if (ratio != 0.0 && !(ratio >= ratio_min))
400 ratio_min = ratio;
401
402 } /* end of incy loop */
403
404 } /* end of incx loop */
405
406 } /* end of lda loop */
407
408 } /* end of uplo loop */
409
410 } /* end of order loop */
411
412 } /* end of nr test loop */
413
414 } /* end of norm loop */
415
416
417
418 } /* end of beta loop */
419
420 } /* end of alpha loop */
421
422 end:
423 FPU_FIX_STOP;
424
425 blas_free(y);
426 blas_free(a);
427 blas_free(y_gen);
428 blas_free(head_x);
429 blas_free(tail_x);
430 blas_free(head_x_gen);
431 blas_free(tail_x_gen);
432 blas_free(head_r_true);
433 blas_free(tail_r_true);
434 blas_free(ratios);
435 blas_free(a_vec);
436
437 *max_ratio = ratio_max;
438 *min_ratio = ratio_min;
439 *num_tests = test_count;
440 *num_bad_ratio = bad_ratio_count;
441
442 }
do_test_dsymv2_s_d(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)443 void do_test_dsymv2_s_d
444 (int n,
445 int ntests, int *seed, double thresh, int debug, float test_prob,
446 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
447
448 /* Function name */
449 const char fname[] = "do_test_dsymv2_s_d";
450 int i;
451 int yi;
452 int incyi, yi0;
453 int test_count;
454 int bad_ratio_count;
455 int ri;
456 int incri = 1;
457 int incx, incy;
458 double ratio;
459 double ratio_min, ratio_max;
460 double eps_int; /* internal machine epsilon */
461 double un_int; /* internal underflow threshold */
462
463 double rin;
464 double rout;
465 double head_r_true_elem, tail_r_true_elem;
466
467 enum blas_order_type order_type;
468 enum blas_uplo_type uplo_type;
469 enum blas_prec_type prec;
470
471 int order_val, uplo_val;
472 int lda_val, incx_val, incy_val;
473 int alpha_val, beta_val;
474
475
476
477 int lda;
478 int alpha_flag, beta_flag;
479 int saved_seed;
480 int norm;
481 int test_no;
482
483 double alpha;
484 double beta;
485 float *a;
486 double *head_x;
487 double *tail_x;
488 double *y;
489 float *a_vec;
490 double *y_gen;
491 double *head_x_gen;
492 double *tail_x_gen;
493 double *ratios;
494
495 /* true result calculated by testgen, in double-double */
496 double *head_r_true, *tail_r_true;
497
498 FPU_FIX_DECL;
499
500 if (n < 0)
501 BLAS_error(fname, -1, n, NULL);
502 if (ntests < 0)
503 BLAS_error(fname, -2, ntests, NULL);
504
505 /* initialization */
506 saved_seed = *seed;
507 ratio = 0.0;
508 ratio_min = 1e308;
509 ratio_max = 0.0;
510
511 *num_tests = 0;
512 *num_bad_ratio = 0;
513 *min_ratio = 0.0;
514 *max_ratio = 0.0;
515
516 if (n == 0)
517 return;
518
519
520 FPU_FIX_START;
521
522 y = (double *) blas_malloc(2 * n * sizeof(double));
523 if (2 * n > 0 && y == NULL) {
524 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
525 }
526 y_gen = (double *) blas_malloc(n * sizeof(double));
527 if (n > 0 && y_gen == NULL) {
528 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
529 }
530 head_x_gen = (double *) blas_malloc(n * sizeof(double));
531 if (n > 0 && head_x_gen == NULL) {
532 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
533 }
534 tail_x_gen = (double *) blas_malloc(n * sizeof(double));
535 if (n > 0 && tail_x_gen == NULL) {
536 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
537 }
538 a = (float *) blas_malloc(2 * n * n * sizeof(float));
539 if (2 * n * n > 0 && a == NULL) {
540 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
541 }
542 head_x = (double *) blas_malloc(2 * n * sizeof(double));
543 if (2 * n > 0 && head_x == NULL) {
544 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
545 }
546 tail_x = (double *) blas_malloc(2 * n * sizeof(double));
547 if (2 * n > 0 && tail_x == NULL) {
548 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
549 }
550 a_vec = (float *) blas_malloc(n * sizeof(float));
551 if (n > 0 && a_vec == NULL) {
552 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
553 }
554 head_r_true = (double *) blas_malloc(n * sizeof(double));
555 tail_r_true = (double *) blas_malloc(n * sizeof(double));
556 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
557 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
558 }
559 ratios = (double *) blas_malloc(n * sizeof(double));
560 if (n > 0 && ratios == NULL) {
561 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
562 }
563
564 test_count = 0;
565 bad_ratio_count = 0;
566
567 /* vary alpha */
568 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
569
570 alpha_flag = 0;
571 switch (alpha_val) {
572 case 0:
573 alpha = 0.0;
574 alpha_flag = 1;
575 break;
576 case 1:
577 alpha = 1.0;
578 alpha_flag = 1;
579 break;
580 }
581
582 /* vary beta */
583 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
584 beta_flag = 0;
585 switch (beta_val) {
586 case 0:
587 beta = 0.0;
588 beta_flag = 1;
589 break;
590 case 1:
591 beta = 1.0;
592 beta_flag = 1;
593 break;
594 }
595
596
597 eps_int = power(2, -BITS_D);
598 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
599 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
600 prec = blas_prec_double;
601
602 /* vary norm -- underflow, approx 1, overflow */
603 for (norm = NORM_START; norm <= NORM_END; norm++) {
604
605 /* number of tests */
606 for (test_no = 0; test_no < ntests; test_no++) {
607
608 /* vary storage format */
609 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
610
611 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
612
613 /* vary upper / lower variation */
614 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
615
616 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
617
618 /* vary lda = n, n+1, 2*n */
619 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
620
621 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
622
623 saved_seed = *seed;
624 /* For the sake of speed, we throw out this case at random */
625 if (xrand(seed) >= test_prob)
626 continue;
627
628 alpha_flag = 0;
629 switch (alpha_val) {
630 case 0:
631 alpha = 0.0;
632 alpha_flag = 1;
633 break;
634 case 1:
635 alpha = 1.0;
636 alpha_flag = 1;
637 break;
638 }
639 beta_flag = 0;
640 switch (beta_val) {
641 case 0:
642 beta = 0.0;
643 beta_flag = 1;
644 break;
645 case 1:
646 beta = 1.0;
647 beta_flag = 1;
648 break;
649 }
650
651 /* finally we are here to generate the test case */
652 BLAS_dsymv2_s_d_testgen(norm, order_type,
653 uplo_type, n, &alpha, alpha_flag, a,
654 lda, head_x_gen, tail_x_gen, &beta,
655 beta_flag, y_gen, seed, head_r_true,
656 tail_r_true);
657 test_count++;
658
659 /* vary incx = -2, -1, 1, 2 */
660 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
661
662 incx = incx_val;
663 if (0 == incx)
664 continue;
665
666 /* vary incy = -2, -1, 1, 2 */
667 for (incy_val = INCY_START; incy_val <= INCY_END;
668 incy_val++) {
669
670 incy = incy_val;
671 if (0 == incy)
672 continue;
673
674 /* copy generated vector with appropriate incs. */
675 dcopy_vector(y_gen, n, 1, y, incy);
676 dcopy_vector(head_x_gen, n, 1, head_x, incx);
677 dcopy_vector(tail_x_gen, n, 1, tail_x, incx);
678
679 /* call symv2 routines to be tested */
680 FPU_FIX_STOP;
681 BLAS_dsymv2_s_d(order_type,
682 uplo_type, n, alpha, a, lda, head_x,
683 tail_x, incx, beta, y, incy);
684 FPU_FIX_START;
685
686 /* now compute the ratio using test_BLAS_xdot */
687 /* copy a row from A, use x, run dot test */
688
689 incyi = incy;
690
691 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
692
693 for (i = 0, yi = yi0, ri = 0;
694 i < n; i++, yi += incyi, ri += incri) {
695 ssy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
696 i);
697
698 /* just use the x vector - it was unchanged (in theory) */
699 rin = y_gen[i];
700 rout = y[yi];
701 head_r_true_elem = head_r_true[ri];
702 tail_r_true_elem = tail_r_true[ri];
703
704 test_BLAS_ddot2_s_d(n, blas_no_conj, alpha, beta,
705 rin, rout, head_r_true_elem,
706 tail_r_true_elem, a_vec, 1, head_x,
707 tail_x, incx, eps_int, un_int,
708 &ratios[i]);
709
710 /* take the max ratio */
711 if (i == 0) {
712 ratio = ratios[0];
713
714 /* The !<= below causes NaN errors to be included.
715 * Note that (NaN > 0) is false */
716 } else if (!(ratios[i] <= ratio)) {
717 ratio = ratios[i];
718 }
719
720 } /* end of dot-test loop */
721
722
723 /* The !<= below causes NaN errors to be included.
724 * Note that (NaN > 0) is false */
725 if (!(ratio <= thresh)) {
726
727 if (debug == 3) {
728 printf("\n\t\tTest # %d\n", test_count);
729 printf("y type : d, a type : s, x type : d\n");
730 printf("Seed = %d\t", saved_seed);
731 printf("n %d\n", n);
732 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
733
734 if (order_type == blas_rowmajor)
735 printf("row ");
736 else
737 printf("col ");
738
739 if (uplo_type == blas_upper)
740 printf("upper ");
741 else
742 printf("lower ");
743
744 printf("NORM %d, ALPHA %d, BETA %d\n",
745 norm, alpha_val, beta_val);
746
747 /* print out info */
748 printf("alpha = ");
749 printf("%24.16e", alpha);;
750 printf(" ");
751 printf("beta = ");
752 printf("%24.16e", beta);;
753 printf("\n");
754
755 printf("a\n");
756 ssy_print_matrix(a, n, lda, order_type, uplo_type);
757 dprint_vector(head_x, n, incx, "head_x");
758 dprint_vector(tail_x, n, incx, "tail_x");
759 dprint_vector(y_gen, n, incy, "y_gen");
760 dprint_vector(y, n, incy, "y");
761 dprint_vector(head_r_true, n, 1, "head_r_true");
762 dprint_vector(ratios, n, 1, "ratios");
763 printf("ratio = %g\n", ratio);
764 }
765 bad_ratio_count++;
766 if (bad_ratio_count >= MAX_BAD_TESTS) {
767 printf("\ntoo many failures, exiting....");
768 printf("\nTesting and compilation");
769 printf(" are incomplete\n\n");
770 goto end;
771 }
772 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
773 printf("\nFlagrant ratio error, exiting...");
774 printf("\nTesting and compilation");
775 printf(" are incomplete\n\n");
776 goto end;
777 }
778 }
779
780 if (!(ratio <= ratio_max))
781 ratio_max = ratio;
782
783 if (ratio != 0.0 && !(ratio >= ratio_min))
784 ratio_min = ratio;
785
786 } /* end of incy loop */
787
788 } /* end of incx loop */
789
790 } /* end of lda loop */
791
792 } /* end of uplo loop */
793
794 } /* end of order loop */
795
796 } /* end of nr test loop */
797
798 } /* end of norm loop */
799
800
801
802 } /* end of beta loop */
803
804 } /* end of alpha loop */
805
806 end:
807 FPU_FIX_STOP;
808
809 blas_free(y);
810 blas_free(a);
811 blas_free(y_gen);
812 blas_free(head_x);
813 blas_free(tail_x);
814 blas_free(head_x_gen);
815 blas_free(tail_x_gen);
816 blas_free(head_r_true);
817 blas_free(tail_r_true);
818 blas_free(ratios);
819 blas_free(a_vec);
820
821 *max_ratio = ratio_max;
822 *min_ratio = ratio_min;
823 *num_tests = test_count;
824 *num_bad_ratio = bad_ratio_count;
825
826 }
do_test_dsymv2_s_s(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)827 void do_test_dsymv2_s_s
828 (int n,
829 int ntests, int *seed, double thresh, int debug, float test_prob,
830 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
831
832 /* Function name */
833 const char fname[] = "do_test_dsymv2_s_s";
834 int i;
835 int yi;
836 int incyi, yi0;
837 int test_count;
838 int bad_ratio_count;
839 int ri;
840 int incri = 1;
841 int incx, incy;
842 double ratio;
843 double ratio_min, ratio_max;
844 double eps_int; /* internal machine epsilon */
845 double un_int; /* internal underflow threshold */
846
847 double rin;
848 double rout;
849 double head_r_true_elem, tail_r_true_elem;
850
851 enum blas_order_type order_type;
852 enum blas_uplo_type uplo_type;
853 enum blas_prec_type prec;
854
855 int order_val, uplo_val;
856 int lda_val, incx_val, incy_val;
857 int alpha_val, beta_val;
858
859
860
861 int lda;
862 int alpha_flag, beta_flag;
863 int saved_seed;
864 int norm;
865 int test_no;
866
867 double alpha;
868 double beta;
869 float *a;
870 float *head_x;
871 float *tail_x;
872 double *y;
873 float *a_vec;
874 double *y_gen;
875 float *head_x_gen;
876 float *tail_x_gen;
877 double *ratios;
878
879 /* true result calculated by testgen, in double-double */
880 double *head_r_true, *tail_r_true;
881
882 FPU_FIX_DECL;
883
884 if (n < 0)
885 BLAS_error(fname, -1, n, NULL);
886 if (ntests < 0)
887 BLAS_error(fname, -2, ntests, NULL);
888
889 /* initialization */
890 saved_seed = *seed;
891 ratio = 0.0;
892 ratio_min = 1e308;
893 ratio_max = 0.0;
894
895 *num_tests = 0;
896 *num_bad_ratio = 0;
897 *min_ratio = 0.0;
898 *max_ratio = 0.0;
899
900 if (n == 0)
901 return;
902
903
904 FPU_FIX_START;
905
906 y = (double *) blas_malloc(2 * n * sizeof(double));
907 if (2 * n > 0 && y == NULL) {
908 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
909 }
910 y_gen = (double *) blas_malloc(n * sizeof(double));
911 if (n > 0 && y_gen == NULL) {
912 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
913 }
914 head_x_gen = (float *) blas_malloc(n * sizeof(float));
915 if (n > 0 && head_x_gen == NULL) {
916 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
917 }
918 tail_x_gen = (float *) blas_malloc(n * sizeof(float));
919 if (n > 0 && tail_x_gen == NULL) {
920 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
921 }
922 a = (float *) blas_malloc(2 * n * n * sizeof(float));
923 if (2 * n * n > 0 && a == NULL) {
924 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
925 }
926 head_x = (float *) blas_malloc(2 * n * sizeof(float));
927 if (2 * n > 0 && head_x == NULL) {
928 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
929 }
930 tail_x = (float *) blas_malloc(2 * n * sizeof(float));
931 if (2 * n > 0 && tail_x == NULL) {
932 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
933 }
934 a_vec = (float *) blas_malloc(n * sizeof(float));
935 if (n > 0 && a_vec == NULL) {
936 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
937 }
938 head_r_true = (double *) blas_malloc(n * sizeof(double));
939 tail_r_true = (double *) blas_malloc(n * sizeof(double));
940 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
941 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
942 }
943 ratios = (double *) blas_malloc(n * sizeof(double));
944 if (n > 0 && ratios == NULL) {
945 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
946 }
947
948 test_count = 0;
949 bad_ratio_count = 0;
950
951 /* vary alpha */
952 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
953
954 alpha_flag = 0;
955 switch (alpha_val) {
956 case 0:
957 alpha = 0.0;
958 alpha_flag = 1;
959 break;
960 case 1:
961 alpha = 1.0;
962 alpha_flag = 1;
963 break;
964 }
965
966 /* vary beta */
967 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
968 beta_flag = 0;
969 switch (beta_val) {
970 case 0:
971 beta = 0.0;
972 beta_flag = 1;
973 break;
974 case 1:
975 beta = 1.0;
976 beta_flag = 1;
977 break;
978 }
979
980
981 eps_int = power(2, -BITS_D);
982 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
983 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
984 prec = blas_prec_double;
985
986 /* vary norm -- underflow, approx 1, overflow */
987 for (norm = NORM_START; norm <= NORM_END; norm++) {
988
989 /* number of tests */
990 for (test_no = 0; test_no < ntests; test_no++) {
991
992 /* vary storage format */
993 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
994
995 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
996
997 /* vary upper / lower variation */
998 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
999
1000 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
1001
1002 /* vary lda = n, n+1, 2*n */
1003 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
1004
1005 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
1006
1007 saved_seed = *seed;
1008 /* For the sake of speed, we throw out this case at random */
1009 if (xrand(seed) >= test_prob)
1010 continue;
1011
1012 alpha_flag = 0;
1013 switch (alpha_val) {
1014 case 0:
1015 alpha = 0.0;
1016 alpha_flag = 1;
1017 break;
1018 case 1:
1019 alpha = 1.0;
1020 alpha_flag = 1;
1021 break;
1022 }
1023 beta_flag = 0;
1024 switch (beta_val) {
1025 case 0:
1026 beta = 0.0;
1027 beta_flag = 1;
1028 break;
1029 case 1:
1030 beta = 1.0;
1031 beta_flag = 1;
1032 break;
1033 }
1034
1035 /* finally we are here to generate the test case */
1036 BLAS_dsymv2_s_s_testgen(norm, order_type,
1037 uplo_type, n, &alpha, alpha_flag, a,
1038 lda, head_x_gen, tail_x_gen, &beta,
1039 beta_flag, y_gen, seed, head_r_true,
1040 tail_r_true);
1041 test_count++;
1042
1043 /* vary incx = -2, -1, 1, 2 */
1044 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
1045
1046 incx = incx_val;
1047 if (0 == incx)
1048 continue;
1049
1050 /* vary incy = -2, -1, 1, 2 */
1051 for (incy_val = INCY_START; incy_val <= INCY_END;
1052 incy_val++) {
1053
1054 incy = incy_val;
1055 if (0 == incy)
1056 continue;
1057
1058 /* copy generated vector with appropriate incs. */
1059 dcopy_vector(y_gen, n, 1, y, incy);
1060 scopy_vector(head_x_gen, n, 1, head_x, incx);
1061 scopy_vector(tail_x_gen, n, 1, tail_x, incx);
1062
1063 /* call symv2 routines to be tested */
1064 FPU_FIX_STOP;
1065 BLAS_dsymv2_s_s(order_type,
1066 uplo_type, n, alpha, a, lda, head_x,
1067 tail_x, incx, beta, y, incy);
1068 FPU_FIX_START;
1069
1070 /* now compute the ratio using test_BLAS_xdot */
1071 /* copy a row from A, use x, run dot test */
1072
1073 incyi = incy;
1074
1075 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
1076
1077 for (i = 0, yi = yi0, ri = 0;
1078 i < n; i++, yi += incyi, ri += incri) {
1079 ssy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
1080 i);
1081
1082 /* just use the x vector - it was unchanged (in theory) */
1083 rin = y_gen[i];
1084 rout = y[yi];
1085 head_r_true_elem = head_r_true[ri];
1086 tail_r_true_elem = tail_r_true[ri];
1087
1088 test_BLAS_ddot2_s_s(n, blas_no_conj, alpha, beta,
1089 rin, rout, head_r_true_elem,
1090 tail_r_true_elem, a_vec, 1, head_x,
1091 tail_x, incx, eps_int, un_int,
1092 &ratios[i]);
1093
1094 /* take the max ratio */
1095 if (i == 0) {
1096 ratio = ratios[0];
1097
1098 /* The !<= below causes NaN errors to be included.
1099 * Note that (NaN > 0) is false */
1100 } else if (!(ratios[i] <= ratio)) {
1101 ratio = ratios[i];
1102 }
1103
1104 } /* end of dot-test loop */
1105
1106
1107 /* The !<= below causes NaN errors to be included.
1108 * Note that (NaN > 0) is false */
1109 if (!(ratio <= thresh)) {
1110
1111 if (debug == 3) {
1112 printf("\n\t\tTest # %d\n", test_count);
1113 printf("y type : d, a type : s, x type : s\n");
1114 printf("Seed = %d\t", saved_seed);
1115 printf("n %d\n", n);
1116 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
1117
1118 if (order_type == blas_rowmajor)
1119 printf("row ");
1120 else
1121 printf("col ");
1122
1123 if (uplo_type == blas_upper)
1124 printf("upper ");
1125 else
1126 printf("lower ");
1127
1128 printf("NORM %d, ALPHA %d, BETA %d\n",
1129 norm, alpha_val, beta_val);
1130
1131 /* print out info */
1132 printf("alpha = ");
1133 printf("%24.16e", alpha);;
1134 printf(" ");
1135 printf("beta = ");
1136 printf("%24.16e", beta);;
1137 printf("\n");
1138
1139 printf("a\n");
1140 ssy_print_matrix(a, n, lda, order_type, uplo_type);
1141 sprint_vector(head_x, n, incx, "head_x");
1142 sprint_vector(tail_x, n, incx, "tail_x");
1143 dprint_vector(y_gen, n, incy, "y_gen");
1144 dprint_vector(y, n, incy, "y");
1145 dprint_vector(head_r_true, n, 1, "head_r_true");
1146 dprint_vector(ratios, n, 1, "ratios");
1147 printf("ratio = %g\n", ratio);
1148 }
1149 bad_ratio_count++;
1150 if (bad_ratio_count >= MAX_BAD_TESTS) {
1151 printf("\ntoo many failures, exiting....");
1152 printf("\nTesting and compilation");
1153 printf(" are incomplete\n\n");
1154 goto end;
1155 }
1156 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
1157 printf("\nFlagrant ratio error, exiting...");
1158 printf("\nTesting and compilation");
1159 printf(" are incomplete\n\n");
1160 goto end;
1161 }
1162 }
1163
1164 if (!(ratio <= ratio_max))
1165 ratio_max = ratio;
1166
1167 if (ratio != 0.0 && !(ratio >= ratio_min))
1168 ratio_min = ratio;
1169
1170 } /* end of incy loop */
1171
1172 } /* end of incx loop */
1173
1174 } /* end of lda loop */
1175
1176 } /* end of uplo loop */
1177
1178 } /* end of order loop */
1179
1180 } /* end of nr test loop */
1181
1182 } /* end of norm loop */
1183
1184
1185
1186 } /* end of beta loop */
1187
1188 } /* end of alpha loop */
1189
1190 end:
1191 FPU_FIX_STOP;
1192
1193 blas_free(y);
1194 blas_free(a);
1195 blas_free(y_gen);
1196 blas_free(head_x);
1197 blas_free(tail_x);
1198 blas_free(head_x_gen);
1199 blas_free(tail_x_gen);
1200 blas_free(head_r_true);
1201 blas_free(tail_r_true);
1202 blas_free(ratios);
1203 blas_free(a_vec);
1204
1205 *max_ratio = ratio_max;
1206 *min_ratio = ratio_min;
1207 *num_tests = test_count;
1208 *num_bad_ratio = bad_ratio_count;
1209
1210 }
do_test_zsymv2_z_c(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)1211 void do_test_zsymv2_z_c
1212 (int n,
1213 int ntests, int *seed, double thresh, int debug, float test_prob,
1214 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
1215
1216 /* Function name */
1217 const char fname[] = "do_test_zsymv2_z_c";
1218 int i;
1219 int yi;
1220 int incyi, yi0;
1221 int test_count;
1222 int bad_ratio_count;
1223 int ri;
1224 int incri = 1;
1225 int incx, incy;
1226 double ratio;
1227 double ratio_min, ratio_max;
1228 double eps_int; /* internal machine epsilon */
1229 double un_int; /* internal underflow threshold */
1230
1231 double rin[2];
1232 double rout[2];
1233 double head_r_true_elem[2], tail_r_true_elem[2];
1234
1235 enum blas_order_type order_type;
1236 enum blas_uplo_type uplo_type;
1237 enum blas_prec_type prec;
1238
1239 int order_val, uplo_val;
1240 int lda_val, incx_val, incy_val;
1241 int alpha_val, beta_val;
1242
1243
1244
1245 int lda;
1246 int alpha_flag, beta_flag;
1247 int saved_seed;
1248 int norm;
1249 int test_no;
1250
1251 double alpha[2];
1252 double beta[2];
1253 double *a;
1254 float *head_x;
1255 float *tail_x;
1256 double *y;
1257 double *a_vec;
1258 double *y_gen;
1259 float *head_x_gen;
1260 float *tail_x_gen;
1261 double *ratios;
1262
1263 /* true result calculated by testgen, in double-double */
1264 double *head_r_true, *tail_r_true;
1265
1266
1267 FPU_FIX_DECL;
1268
1269 if (n < 0)
1270 BLAS_error(fname, -1, n, NULL);
1271 if (ntests < 0)
1272 BLAS_error(fname, -2, ntests, NULL);
1273
1274 /* initialization */
1275 saved_seed = *seed;
1276 ratio = 0.0;
1277 ratio_min = 1e308;
1278 ratio_max = 0.0;
1279
1280 *num_tests = 0;
1281 *num_bad_ratio = 0;
1282 *min_ratio = 0.0;
1283 *max_ratio = 0.0;
1284
1285 if (n == 0)
1286 return;
1287 incri *= 2;
1288
1289 FPU_FIX_START;
1290
1291 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
1292 if (2 * n > 0 && y == NULL) {
1293 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1294 }
1295 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
1296 if (n > 0 && y_gen == NULL) {
1297 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1298 }
1299 head_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
1300 if (n > 0 && head_x_gen == NULL) {
1301 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1302 }
1303 tail_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
1304 if (n > 0 && tail_x_gen == NULL) {
1305 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1306 }
1307 a = (double *) blas_malloc(2 * n * n * sizeof(double) * 2);
1308 if (2 * n * n > 0 && a == NULL) {
1309 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1310 }
1311 head_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
1312 if (2 * n > 0 && head_x == NULL) {
1313 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1314 }
1315 tail_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
1316 if (2 * n > 0 && tail_x == NULL) {
1317 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1318 }
1319 a_vec = (double *) blas_malloc(n * sizeof(double) * 2);
1320 if (n > 0 && a_vec == NULL) {
1321 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1322 }
1323 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
1324 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
1325 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
1326 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1327 }
1328 ratios = (double *) blas_malloc(n * sizeof(double));
1329 if (n > 0 && ratios == NULL) {
1330 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1331 }
1332
1333 test_count = 0;
1334 bad_ratio_count = 0;
1335
1336 /* vary alpha */
1337 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
1338
1339 alpha_flag = 0;
1340 switch (alpha_val) {
1341 case 0:
1342 alpha[0] = alpha[1] = 0.0;
1343 alpha_flag = 1;
1344 break;
1345 case 1:
1346 alpha[0] = 1.0;
1347 alpha[1] = 0.0;
1348 alpha_flag = 1;
1349 break;
1350 }
1351
1352 /* vary beta */
1353 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
1354 beta_flag = 0;
1355 switch (beta_val) {
1356 case 0:
1357 beta[0] = beta[1] = 0.0;
1358 beta_flag = 1;
1359 break;
1360 case 1:
1361 beta[0] = 1.0;
1362 beta[1] = 0.0;
1363 beta_flag = 1;
1364 break;
1365 }
1366
1367
1368 eps_int = power(2, -BITS_D);
1369 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
1370 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
1371 prec = blas_prec_double;
1372
1373 /* vary norm -- underflow, approx 1, overflow */
1374 for (norm = NORM_START; norm <= NORM_END; norm++) {
1375
1376 /* number of tests */
1377 for (test_no = 0; test_no < ntests; test_no++) {
1378
1379 /* vary storage format */
1380 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
1381
1382 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
1383
1384 /* vary upper / lower variation */
1385 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
1386
1387 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
1388
1389 /* vary lda = n, n+1, 2*n */
1390 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
1391
1392 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
1393
1394 saved_seed = *seed;
1395 /* For the sake of speed, we throw out this case at random */
1396 if (xrand(seed) >= test_prob)
1397 continue;
1398
1399 alpha_flag = 0;
1400 switch (alpha_val) {
1401 case 0:
1402 alpha[0] = alpha[1] = 0.0;
1403 alpha_flag = 1;
1404 break;
1405 case 1:
1406 alpha[0] = 1.0;
1407 alpha[1] = 0.0;
1408 alpha_flag = 1;
1409 break;
1410 }
1411 beta_flag = 0;
1412 switch (beta_val) {
1413 case 0:
1414 beta[0] = beta[1] = 0.0;
1415 beta_flag = 1;
1416 break;
1417 case 1:
1418 beta[0] = 1.0;
1419 beta[1] = 0.0;
1420 beta_flag = 1;
1421 break;
1422 }
1423
1424 /* finally we are here to generate the test case */
1425 BLAS_zsymv2_z_c_testgen(norm, order_type,
1426 uplo_type, n, &alpha, alpha_flag, a,
1427 lda, head_x_gen, tail_x_gen, &beta,
1428 beta_flag, y_gen, seed, head_r_true,
1429 tail_r_true);
1430 test_count++;
1431
1432 /* vary incx = -2, -1, 1, 2 */
1433 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
1434
1435 incx = incx_val;
1436 if (0 == incx)
1437 continue;
1438
1439 /* vary incy = -2, -1, 1, 2 */
1440 for (incy_val = INCY_START; incy_val <= INCY_END;
1441 incy_val++) {
1442
1443 incy = incy_val;
1444 if (0 == incy)
1445 continue;
1446
1447 /* copy generated vector with appropriate incs. */
1448 zcopy_vector(y_gen, n, 1, y, incy);
1449 ccopy_vector(head_x_gen, n, 1, head_x, incx);
1450 ccopy_vector(tail_x_gen, n, 1, tail_x, incx);
1451
1452 /* call symv2 routines to be tested */
1453 FPU_FIX_STOP;
1454 BLAS_zsymv2_z_c(order_type,
1455 uplo_type, n, alpha, a, lda, head_x,
1456 tail_x, incx, beta, y, incy);
1457 FPU_FIX_START;
1458
1459 /* now compute the ratio using test_BLAS_xdot */
1460 /* copy a row from A, use x, run dot test */
1461
1462 incyi = incy;
1463 incyi *= 2;
1464 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
1465
1466 for (i = 0, yi = yi0, ri = 0;
1467 i < n; i++, yi += incyi, ri += incri) {
1468 zsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
1469 i);
1470
1471 /* just use the x vector - it was unchanged (in theory) */
1472 rin[0] = y_gen[i];
1473 rin[1] = y_gen[i + 1];
1474 rout[0] = y[yi];
1475 rout[1] = y[yi + 1];
1476 head_r_true_elem[0] = head_r_true[ri];
1477 head_r_true_elem[1] = head_r_true[ri + 1];
1478 tail_r_true_elem[0] = tail_r_true[ri];
1479 tail_r_true_elem[1] = tail_r_true[ri + 1];
1480
1481 test_BLAS_zdot2_z_c(n, blas_no_conj, alpha, beta,
1482 rin, rout, head_r_true_elem,
1483 tail_r_true_elem, a_vec, 1, head_x,
1484 tail_x, incx, eps_int, un_int,
1485 &ratios[i]);
1486
1487 /* take the max ratio */
1488 if (i == 0) {
1489 ratio = ratios[0];
1490
1491 /* The !<= below causes NaN errors to be included.
1492 * Note that (NaN > 0) is false */
1493 } else if (!(ratios[i] <= ratio)) {
1494 ratio = ratios[i];
1495 }
1496
1497 } /* end of dot-test loop */
1498
1499
1500 /* The !<= below causes NaN errors to be included.
1501 * Note that (NaN > 0) is false */
1502 if (!(ratio <= thresh)) {
1503
1504 if (debug == 3) {
1505 printf("\n\t\tTest # %d\n", test_count);
1506 printf("y type : z, a type : z, x type : c\n");
1507 printf("Seed = %d\t", saved_seed);
1508 printf("n %d\n", n);
1509 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
1510
1511 if (order_type == blas_rowmajor)
1512 printf("row ");
1513 else
1514 printf("col ");
1515
1516 if (uplo_type == blas_upper)
1517 printf("upper ");
1518 else
1519 printf("lower ");
1520
1521 printf("NORM %d, ALPHA %d, BETA %d\n",
1522 norm, alpha_val, beta_val);
1523
1524 /* print out info */
1525 printf("alpha = ");
1526 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
1527 printf(" ");
1528 printf("beta = ");
1529 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
1530 printf("\n");
1531
1532 printf("a\n");
1533 zsy_print_matrix(a, n, lda, order_type, uplo_type);
1534 cprint_vector(head_x, n, incx, "head_x");
1535 cprint_vector(tail_x, n, incx, "tail_x");
1536 zprint_vector(y_gen, n, incy, "y_gen");
1537 zprint_vector(y, n, incy, "y");
1538 zprint_vector(head_r_true, n, 1, "head_r_true");
1539 dprint_vector(ratios, n, 1, "ratios");
1540 printf("ratio = %g\n", ratio);
1541 }
1542 bad_ratio_count++;
1543 if (bad_ratio_count >= MAX_BAD_TESTS) {
1544 printf("\ntoo many failures, exiting....");
1545 printf("\nTesting and compilation");
1546 printf(" are incomplete\n\n");
1547 goto end;
1548 }
1549 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
1550 printf("\nFlagrant ratio error, exiting...");
1551 printf("\nTesting and compilation");
1552 printf(" are incomplete\n\n");
1553 goto end;
1554 }
1555 }
1556
1557 if (!(ratio <= ratio_max))
1558 ratio_max = ratio;
1559
1560 if (ratio != 0.0 && !(ratio >= ratio_min))
1561 ratio_min = ratio;
1562
1563 } /* end of incy loop */
1564
1565 } /* end of incx loop */
1566
1567 } /* end of lda loop */
1568
1569 } /* end of uplo loop */
1570
1571 } /* end of order loop */
1572
1573 } /* end of nr test loop */
1574
1575 } /* end of norm loop */
1576
1577
1578
1579 } /* end of beta loop */
1580
1581 } /* end of alpha loop */
1582
1583 end:
1584 FPU_FIX_STOP;
1585
1586 blas_free(y);
1587 blas_free(a);
1588 blas_free(y_gen);
1589 blas_free(head_x);
1590 blas_free(tail_x);
1591 blas_free(head_x_gen);
1592 blas_free(tail_x_gen);
1593 blas_free(head_r_true);
1594 blas_free(tail_r_true);
1595 blas_free(ratios);
1596 blas_free(a_vec);
1597
1598 *max_ratio = ratio_max;
1599 *min_ratio = ratio_min;
1600 *num_tests = test_count;
1601 *num_bad_ratio = bad_ratio_count;
1602
1603 }
do_test_zsymv2_c_z(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)1604 void do_test_zsymv2_c_z
1605 (int n,
1606 int ntests, int *seed, double thresh, int debug, float test_prob,
1607 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
1608
1609 /* Function name */
1610 const char fname[] = "do_test_zsymv2_c_z";
1611 int i;
1612 int yi;
1613 int incyi, yi0;
1614 int test_count;
1615 int bad_ratio_count;
1616 int ri;
1617 int incri = 1;
1618 int incx, incy;
1619 double ratio;
1620 double ratio_min, ratio_max;
1621 double eps_int; /* internal machine epsilon */
1622 double un_int; /* internal underflow threshold */
1623
1624 double rin[2];
1625 double rout[2];
1626 double head_r_true_elem[2], tail_r_true_elem[2];
1627
1628 enum blas_order_type order_type;
1629 enum blas_uplo_type uplo_type;
1630 enum blas_prec_type prec;
1631
1632 int order_val, uplo_val;
1633 int lda_val, incx_val, incy_val;
1634 int alpha_val, beta_val;
1635
1636
1637
1638 int lda;
1639 int alpha_flag, beta_flag;
1640 int saved_seed;
1641 int norm;
1642 int test_no;
1643
1644 double alpha[2];
1645 double beta[2];
1646 float *a;
1647 double *head_x;
1648 double *tail_x;
1649 double *y;
1650 float *a_vec;
1651 double *y_gen;
1652 double *head_x_gen;
1653 double *tail_x_gen;
1654 double *ratios;
1655
1656 /* true result calculated by testgen, in double-double */
1657 double *head_r_true, *tail_r_true;
1658
1659
1660 FPU_FIX_DECL;
1661
1662 if (n < 0)
1663 BLAS_error(fname, -1, n, NULL);
1664 if (ntests < 0)
1665 BLAS_error(fname, -2, ntests, NULL);
1666
1667 /* initialization */
1668 saved_seed = *seed;
1669 ratio = 0.0;
1670 ratio_min = 1e308;
1671 ratio_max = 0.0;
1672
1673 *num_tests = 0;
1674 *num_bad_ratio = 0;
1675 *min_ratio = 0.0;
1676 *max_ratio = 0.0;
1677
1678 if (n == 0)
1679 return;
1680 incri *= 2;
1681
1682 FPU_FIX_START;
1683
1684 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
1685 if (2 * n > 0 && y == NULL) {
1686 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1687 }
1688 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
1689 if (n > 0 && y_gen == NULL) {
1690 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1691 }
1692 head_x_gen = (double *) blas_malloc(n * sizeof(double) * 2);
1693 if (n > 0 && head_x_gen == NULL) {
1694 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1695 }
1696 tail_x_gen = (double *) blas_malloc(n * sizeof(double) * 2);
1697 if (n > 0 && tail_x_gen == NULL) {
1698 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1699 }
1700 a = (float *) blas_malloc(2 * n * n * sizeof(float) * 2);
1701 if (2 * n * n > 0 && a == NULL) {
1702 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1703 }
1704 head_x = (double *) blas_malloc(2 * n * sizeof(double) * 2);
1705 if (2 * n > 0 && head_x == NULL) {
1706 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1707 }
1708 tail_x = (double *) blas_malloc(2 * n * sizeof(double) * 2);
1709 if (2 * n > 0 && tail_x == NULL) {
1710 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1711 }
1712 a_vec = (float *) blas_malloc(n * sizeof(float) * 2);
1713 if (n > 0 && a_vec == NULL) {
1714 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1715 }
1716 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
1717 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
1718 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
1719 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1720 }
1721 ratios = (double *) blas_malloc(n * sizeof(double));
1722 if (n > 0 && ratios == NULL) {
1723 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
1724 }
1725
1726 test_count = 0;
1727 bad_ratio_count = 0;
1728
1729 /* vary alpha */
1730 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
1731
1732 alpha_flag = 0;
1733 switch (alpha_val) {
1734 case 0:
1735 alpha[0] = alpha[1] = 0.0;
1736 alpha_flag = 1;
1737 break;
1738 case 1:
1739 alpha[0] = 1.0;
1740 alpha[1] = 0.0;
1741 alpha_flag = 1;
1742 break;
1743 }
1744
1745 /* vary beta */
1746 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
1747 beta_flag = 0;
1748 switch (beta_val) {
1749 case 0:
1750 beta[0] = beta[1] = 0.0;
1751 beta_flag = 1;
1752 break;
1753 case 1:
1754 beta[0] = 1.0;
1755 beta[1] = 0.0;
1756 beta_flag = 1;
1757 break;
1758 }
1759
1760
1761 eps_int = power(2, -BITS_D);
1762 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
1763 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
1764 prec = blas_prec_double;
1765
1766 /* vary norm -- underflow, approx 1, overflow */
1767 for (norm = NORM_START; norm <= NORM_END; norm++) {
1768
1769 /* number of tests */
1770 for (test_no = 0; test_no < ntests; test_no++) {
1771
1772 /* vary storage format */
1773 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
1774
1775 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
1776
1777 /* vary upper / lower variation */
1778 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
1779
1780 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
1781
1782 /* vary lda = n, n+1, 2*n */
1783 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
1784
1785 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
1786
1787 saved_seed = *seed;
1788 /* For the sake of speed, we throw out this case at random */
1789 if (xrand(seed) >= test_prob)
1790 continue;
1791
1792 alpha_flag = 0;
1793 switch (alpha_val) {
1794 case 0:
1795 alpha[0] = alpha[1] = 0.0;
1796 alpha_flag = 1;
1797 break;
1798 case 1:
1799 alpha[0] = 1.0;
1800 alpha[1] = 0.0;
1801 alpha_flag = 1;
1802 break;
1803 }
1804 beta_flag = 0;
1805 switch (beta_val) {
1806 case 0:
1807 beta[0] = beta[1] = 0.0;
1808 beta_flag = 1;
1809 break;
1810 case 1:
1811 beta[0] = 1.0;
1812 beta[1] = 0.0;
1813 beta_flag = 1;
1814 break;
1815 }
1816
1817 /* finally we are here to generate the test case */
1818 BLAS_zsymv2_c_z_testgen(norm, order_type,
1819 uplo_type, n, &alpha, alpha_flag, a,
1820 lda, head_x_gen, tail_x_gen, &beta,
1821 beta_flag, y_gen, seed, head_r_true,
1822 tail_r_true);
1823 test_count++;
1824
1825 /* vary incx = -2, -1, 1, 2 */
1826 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
1827
1828 incx = incx_val;
1829 if (0 == incx)
1830 continue;
1831
1832 /* vary incy = -2, -1, 1, 2 */
1833 for (incy_val = INCY_START; incy_val <= INCY_END;
1834 incy_val++) {
1835
1836 incy = incy_val;
1837 if (0 == incy)
1838 continue;
1839
1840 /* copy generated vector with appropriate incs. */
1841 zcopy_vector(y_gen, n, 1, y, incy);
1842 zcopy_vector(head_x_gen, n, 1, head_x, incx);
1843 zcopy_vector(tail_x_gen, n, 1, tail_x, incx);
1844
1845 /* call symv2 routines to be tested */
1846 FPU_FIX_STOP;
1847 BLAS_zsymv2_c_z(order_type,
1848 uplo_type, n, alpha, a, lda, head_x,
1849 tail_x, incx, beta, y, incy);
1850 FPU_FIX_START;
1851
1852 /* now compute the ratio using test_BLAS_xdot */
1853 /* copy a row from A, use x, run dot test */
1854
1855 incyi = incy;
1856 incyi *= 2;
1857 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
1858
1859 for (i = 0, yi = yi0, ri = 0;
1860 i < n; i++, yi += incyi, ri += incri) {
1861 csy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
1862 i);
1863
1864 /* just use the x vector - it was unchanged (in theory) */
1865 rin[0] = y_gen[i];
1866 rin[1] = y_gen[i + 1];
1867 rout[0] = y[yi];
1868 rout[1] = y[yi + 1];
1869 head_r_true_elem[0] = head_r_true[ri];
1870 head_r_true_elem[1] = head_r_true[ri + 1];
1871 tail_r_true_elem[0] = tail_r_true[ri];
1872 tail_r_true_elem[1] = tail_r_true[ri + 1];
1873
1874 test_BLAS_zdot2_c_z(n, blas_no_conj, alpha, beta,
1875 rin, rout, head_r_true_elem,
1876 tail_r_true_elem, a_vec, 1, head_x,
1877 tail_x, incx, eps_int, un_int,
1878 &ratios[i]);
1879
1880 /* take the max ratio */
1881 if (i == 0) {
1882 ratio = ratios[0];
1883
1884 /* The !<= below causes NaN errors to be included.
1885 * Note that (NaN > 0) is false */
1886 } else if (!(ratios[i] <= ratio)) {
1887 ratio = ratios[i];
1888 }
1889
1890 } /* end of dot-test loop */
1891
1892
1893 /* The !<= below causes NaN errors to be included.
1894 * Note that (NaN > 0) is false */
1895 if (!(ratio <= thresh)) {
1896
1897 if (debug == 3) {
1898 printf("\n\t\tTest # %d\n", test_count);
1899 printf("y type : z, a type : c, x type : z\n");
1900 printf("Seed = %d\t", saved_seed);
1901 printf("n %d\n", n);
1902 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
1903
1904 if (order_type == blas_rowmajor)
1905 printf("row ");
1906 else
1907 printf("col ");
1908
1909 if (uplo_type == blas_upper)
1910 printf("upper ");
1911 else
1912 printf("lower ");
1913
1914 printf("NORM %d, ALPHA %d, BETA %d\n",
1915 norm, alpha_val, beta_val);
1916
1917 /* print out info */
1918 printf("alpha = ");
1919 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
1920 printf(" ");
1921 printf("beta = ");
1922 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
1923 printf("\n");
1924
1925 printf("a\n");
1926 csy_print_matrix(a, n, lda, order_type, uplo_type);
1927 zprint_vector(head_x, n, incx, "head_x");
1928 zprint_vector(tail_x, n, incx, "tail_x");
1929 zprint_vector(y_gen, n, incy, "y_gen");
1930 zprint_vector(y, n, incy, "y");
1931 zprint_vector(head_r_true, n, 1, "head_r_true");
1932 dprint_vector(ratios, n, 1, "ratios");
1933 printf("ratio = %g\n", ratio);
1934 }
1935 bad_ratio_count++;
1936 if (bad_ratio_count >= MAX_BAD_TESTS) {
1937 printf("\ntoo many failures, exiting....");
1938 printf("\nTesting and compilation");
1939 printf(" are incomplete\n\n");
1940 goto end;
1941 }
1942 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
1943 printf("\nFlagrant ratio error, exiting...");
1944 printf("\nTesting and compilation");
1945 printf(" are incomplete\n\n");
1946 goto end;
1947 }
1948 }
1949
1950 if (!(ratio <= ratio_max))
1951 ratio_max = ratio;
1952
1953 if (ratio != 0.0 && !(ratio >= ratio_min))
1954 ratio_min = ratio;
1955
1956 } /* end of incy loop */
1957
1958 } /* end of incx loop */
1959
1960 } /* end of lda loop */
1961
1962 } /* end of uplo loop */
1963
1964 } /* end of order loop */
1965
1966 } /* end of nr test loop */
1967
1968 } /* end of norm loop */
1969
1970
1971
1972 } /* end of beta loop */
1973
1974 } /* end of alpha loop */
1975
1976 end:
1977 FPU_FIX_STOP;
1978
1979 blas_free(y);
1980 blas_free(a);
1981 blas_free(y_gen);
1982 blas_free(head_x);
1983 blas_free(tail_x);
1984 blas_free(head_x_gen);
1985 blas_free(tail_x_gen);
1986 blas_free(head_r_true);
1987 blas_free(tail_r_true);
1988 blas_free(ratios);
1989 blas_free(a_vec);
1990
1991 *max_ratio = ratio_max;
1992 *min_ratio = ratio_min;
1993 *num_tests = test_count;
1994 *num_bad_ratio = bad_ratio_count;
1995
1996 }
do_test_zsymv2_c_c(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)1997 void do_test_zsymv2_c_c
1998 (int n,
1999 int ntests, int *seed, double thresh, int debug, float test_prob,
2000 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
2001
2002 /* Function name */
2003 const char fname[] = "do_test_zsymv2_c_c";
2004 int i;
2005 int yi;
2006 int incyi, yi0;
2007 int test_count;
2008 int bad_ratio_count;
2009 int ri;
2010 int incri = 1;
2011 int incx, incy;
2012 double ratio;
2013 double ratio_min, ratio_max;
2014 double eps_int; /* internal machine epsilon */
2015 double un_int; /* internal underflow threshold */
2016
2017 double rin[2];
2018 double rout[2];
2019 double head_r_true_elem[2], tail_r_true_elem[2];
2020
2021 enum blas_order_type order_type;
2022 enum blas_uplo_type uplo_type;
2023 enum blas_prec_type prec;
2024
2025 int order_val, uplo_val;
2026 int lda_val, incx_val, incy_val;
2027 int alpha_val, beta_val;
2028
2029
2030
2031 int lda;
2032 int alpha_flag, beta_flag;
2033 int saved_seed;
2034 int norm;
2035 int test_no;
2036
2037 double alpha[2];
2038 double beta[2];
2039 float *a;
2040 float *head_x;
2041 float *tail_x;
2042 double *y;
2043 float *a_vec;
2044 double *y_gen;
2045 float *head_x_gen;
2046 float *tail_x_gen;
2047 double *ratios;
2048
2049 /* true result calculated by testgen, in double-double */
2050 double *head_r_true, *tail_r_true;
2051
2052
2053 FPU_FIX_DECL;
2054
2055 if (n < 0)
2056 BLAS_error(fname, -1, n, NULL);
2057 if (ntests < 0)
2058 BLAS_error(fname, -2, ntests, NULL);
2059
2060 /* initialization */
2061 saved_seed = *seed;
2062 ratio = 0.0;
2063 ratio_min = 1e308;
2064 ratio_max = 0.0;
2065
2066 *num_tests = 0;
2067 *num_bad_ratio = 0;
2068 *min_ratio = 0.0;
2069 *max_ratio = 0.0;
2070
2071 if (n == 0)
2072 return;
2073 incri *= 2;
2074
2075 FPU_FIX_START;
2076
2077 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
2078 if (2 * n > 0 && y == NULL) {
2079 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2080 }
2081 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
2082 if (n > 0 && y_gen == NULL) {
2083 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2084 }
2085 head_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
2086 if (n > 0 && head_x_gen == NULL) {
2087 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2088 }
2089 tail_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
2090 if (n > 0 && tail_x_gen == NULL) {
2091 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2092 }
2093 a = (float *) blas_malloc(2 * n * n * sizeof(float) * 2);
2094 if (2 * n * n > 0 && a == NULL) {
2095 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2096 }
2097 head_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
2098 if (2 * n > 0 && head_x == NULL) {
2099 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2100 }
2101 tail_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
2102 if (2 * n > 0 && tail_x == NULL) {
2103 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2104 }
2105 a_vec = (float *) blas_malloc(n * sizeof(float) * 2);
2106 if (n > 0 && a_vec == NULL) {
2107 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2108 }
2109 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
2110 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
2111 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
2112 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2113 }
2114 ratios = (double *) blas_malloc(n * sizeof(double));
2115 if (n > 0 && ratios == NULL) {
2116 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2117 }
2118
2119 test_count = 0;
2120 bad_ratio_count = 0;
2121
2122 /* vary alpha */
2123 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
2124
2125 alpha_flag = 0;
2126 switch (alpha_val) {
2127 case 0:
2128 alpha[0] = alpha[1] = 0.0;
2129 alpha_flag = 1;
2130 break;
2131 case 1:
2132 alpha[0] = 1.0;
2133 alpha[1] = 0.0;
2134 alpha_flag = 1;
2135 break;
2136 }
2137
2138 /* vary beta */
2139 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
2140 beta_flag = 0;
2141 switch (beta_val) {
2142 case 0:
2143 beta[0] = beta[1] = 0.0;
2144 beta_flag = 1;
2145 break;
2146 case 1:
2147 beta[0] = 1.0;
2148 beta[1] = 0.0;
2149 beta_flag = 1;
2150 break;
2151 }
2152
2153
2154 eps_int = power(2, -BITS_D);
2155 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
2156 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
2157 prec = blas_prec_double;
2158
2159 /* vary norm -- underflow, approx 1, overflow */
2160 for (norm = NORM_START; norm <= NORM_END; norm++) {
2161
2162 /* number of tests */
2163 for (test_no = 0; test_no < ntests; test_no++) {
2164
2165 /* vary storage format */
2166 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
2167
2168 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
2169
2170 /* vary upper / lower variation */
2171 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
2172
2173 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
2174
2175 /* vary lda = n, n+1, 2*n */
2176 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
2177
2178 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
2179
2180 saved_seed = *seed;
2181 /* For the sake of speed, we throw out this case at random */
2182 if (xrand(seed) >= test_prob)
2183 continue;
2184
2185 alpha_flag = 0;
2186 switch (alpha_val) {
2187 case 0:
2188 alpha[0] = alpha[1] = 0.0;
2189 alpha_flag = 1;
2190 break;
2191 case 1:
2192 alpha[0] = 1.0;
2193 alpha[1] = 0.0;
2194 alpha_flag = 1;
2195 break;
2196 }
2197 beta_flag = 0;
2198 switch (beta_val) {
2199 case 0:
2200 beta[0] = beta[1] = 0.0;
2201 beta_flag = 1;
2202 break;
2203 case 1:
2204 beta[0] = 1.0;
2205 beta[1] = 0.0;
2206 beta_flag = 1;
2207 break;
2208 }
2209
2210 /* finally we are here to generate the test case */
2211 BLAS_zsymv2_c_c_testgen(norm, order_type,
2212 uplo_type, n, &alpha, alpha_flag, a,
2213 lda, head_x_gen, tail_x_gen, &beta,
2214 beta_flag, y_gen, seed, head_r_true,
2215 tail_r_true);
2216 test_count++;
2217
2218 /* vary incx = -2, -1, 1, 2 */
2219 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
2220
2221 incx = incx_val;
2222 if (0 == incx)
2223 continue;
2224
2225 /* vary incy = -2, -1, 1, 2 */
2226 for (incy_val = INCY_START; incy_val <= INCY_END;
2227 incy_val++) {
2228
2229 incy = incy_val;
2230 if (0 == incy)
2231 continue;
2232
2233 /* copy generated vector with appropriate incs. */
2234 zcopy_vector(y_gen, n, 1, y, incy);
2235 ccopy_vector(head_x_gen, n, 1, head_x, incx);
2236 ccopy_vector(tail_x_gen, n, 1, tail_x, incx);
2237
2238 /* call symv2 routines to be tested */
2239 FPU_FIX_STOP;
2240 BLAS_zsymv2_c_c(order_type,
2241 uplo_type, n, alpha, a, lda, head_x,
2242 tail_x, incx, beta, y, incy);
2243 FPU_FIX_START;
2244
2245 /* now compute the ratio using test_BLAS_xdot */
2246 /* copy a row from A, use x, run dot test */
2247
2248 incyi = incy;
2249 incyi *= 2;
2250 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
2251
2252 for (i = 0, yi = yi0, ri = 0;
2253 i < n; i++, yi += incyi, ri += incri) {
2254 csy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
2255 i);
2256
2257 /* just use the x vector - it was unchanged (in theory) */
2258 rin[0] = y_gen[i];
2259 rin[1] = y_gen[i + 1];
2260 rout[0] = y[yi];
2261 rout[1] = y[yi + 1];
2262 head_r_true_elem[0] = head_r_true[ri];
2263 head_r_true_elem[1] = head_r_true[ri + 1];
2264 tail_r_true_elem[0] = tail_r_true[ri];
2265 tail_r_true_elem[1] = tail_r_true[ri + 1];
2266
2267 test_BLAS_zdot2_c_c(n, blas_no_conj, alpha, beta,
2268 rin, rout, head_r_true_elem,
2269 tail_r_true_elem, a_vec, 1, head_x,
2270 tail_x, incx, eps_int, un_int,
2271 &ratios[i]);
2272
2273 /* take the max ratio */
2274 if (i == 0) {
2275 ratio = ratios[0];
2276
2277 /* The !<= below causes NaN errors to be included.
2278 * Note that (NaN > 0) is false */
2279 } else if (!(ratios[i] <= ratio)) {
2280 ratio = ratios[i];
2281 }
2282
2283 } /* end of dot-test loop */
2284
2285
2286 /* The !<= below causes NaN errors to be included.
2287 * Note that (NaN > 0) is false */
2288 if (!(ratio <= thresh)) {
2289
2290 if (debug == 3) {
2291 printf("\n\t\tTest # %d\n", test_count);
2292 printf("y type : z, a type : c, x type : c\n");
2293 printf("Seed = %d\t", saved_seed);
2294 printf("n %d\n", n);
2295 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
2296
2297 if (order_type == blas_rowmajor)
2298 printf("row ");
2299 else
2300 printf("col ");
2301
2302 if (uplo_type == blas_upper)
2303 printf("upper ");
2304 else
2305 printf("lower ");
2306
2307 printf("NORM %d, ALPHA %d, BETA %d\n",
2308 norm, alpha_val, beta_val);
2309
2310 /* print out info */
2311 printf("alpha = ");
2312 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
2313 printf(" ");
2314 printf("beta = ");
2315 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
2316 printf("\n");
2317
2318 printf("a\n");
2319 csy_print_matrix(a, n, lda, order_type, uplo_type);
2320 cprint_vector(head_x, n, incx, "head_x");
2321 cprint_vector(tail_x, n, incx, "tail_x");
2322 zprint_vector(y_gen, n, incy, "y_gen");
2323 zprint_vector(y, n, incy, "y");
2324 zprint_vector(head_r_true, n, 1, "head_r_true");
2325 dprint_vector(ratios, n, 1, "ratios");
2326 printf("ratio = %g\n", ratio);
2327 }
2328 bad_ratio_count++;
2329 if (bad_ratio_count >= MAX_BAD_TESTS) {
2330 printf("\ntoo many failures, exiting....");
2331 printf("\nTesting and compilation");
2332 printf(" are incomplete\n\n");
2333 goto end;
2334 }
2335 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
2336 printf("\nFlagrant ratio error, exiting...");
2337 printf("\nTesting and compilation");
2338 printf(" are incomplete\n\n");
2339 goto end;
2340 }
2341 }
2342
2343 if (!(ratio <= ratio_max))
2344 ratio_max = ratio;
2345
2346 if (ratio != 0.0 && !(ratio >= ratio_min))
2347 ratio_min = ratio;
2348
2349 } /* end of incy loop */
2350
2351 } /* end of incx loop */
2352
2353 } /* end of lda loop */
2354
2355 } /* end of uplo loop */
2356
2357 } /* end of order loop */
2358
2359 } /* end of nr test loop */
2360
2361 } /* end of norm loop */
2362
2363
2364
2365 } /* end of beta loop */
2366
2367 } /* end of alpha loop */
2368
2369 end:
2370 FPU_FIX_STOP;
2371
2372 blas_free(y);
2373 blas_free(a);
2374 blas_free(y_gen);
2375 blas_free(head_x);
2376 blas_free(tail_x);
2377 blas_free(head_x_gen);
2378 blas_free(tail_x_gen);
2379 blas_free(head_r_true);
2380 blas_free(tail_r_true);
2381 blas_free(ratios);
2382 blas_free(a_vec);
2383
2384 *max_ratio = ratio_max;
2385 *min_ratio = ratio_min;
2386 *num_tests = test_count;
2387 *num_bad_ratio = bad_ratio_count;
2388
2389 }
do_test_csymv2_c_s(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)2390 void do_test_csymv2_c_s
2391 (int n,
2392 int ntests, int *seed, double thresh, int debug, float test_prob,
2393 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
2394
2395 /* Function name */
2396 const char fname[] = "do_test_csymv2_c_s";
2397 int i;
2398 int yi;
2399 int incyi, yi0;
2400 int test_count;
2401 int bad_ratio_count;
2402 int ri;
2403 int incri = 1;
2404 int incx, incy;
2405 double ratio;
2406 double ratio_min, ratio_max;
2407 double eps_int; /* internal machine epsilon */
2408 double un_int; /* internal underflow threshold */
2409
2410 float rin[2];
2411 float rout[2];
2412 double head_r_true_elem[2], tail_r_true_elem[2];
2413
2414 enum blas_order_type order_type;
2415 enum blas_uplo_type uplo_type;
2416 enum blas_prec_type prec;
2417
2418 int order_val, uplo_val;
2419 int lda_val, incx_val, incy_val;
2420 int alpha_val, beta_val;
2421
2422
2423
2424 int lda;
2425 int alpha_flag, beta_flag;
2426 int saved_seed;
2427 int norm;
2428 int test_no;
2429
2430 float alpha[2];
2431 float beta[2];
2432 float *a;
2433 float *head_x;
2434 float *tail_x;
2435 float *y;
2436 float *a_vec;
2437 float *y_gen;
2438 float *head_x_gen;
2439 float *tail_x_gen;
2440 double *ratios;
2441
2442 /* true result calculated by testgen, in double-double */
2443 double *head_r_true, *tail_r_true;
2444
2445
2446 FPU_FIX_DECL;
2447
2448 if (n < 0)
2449 BLAS_error(fname, -1, n, NULL);
2450 if (ntests < 0)
2451 BLAS_error(fname, -2, ntests, NULL);
2452
2453 /* initialization */
2454 saved_seed = *seed;
2455 ratio = 0.0;
2456 ratio_min = 1e308;
2457 ratio_max = 0.0;
2458
2459 *num_tests = 0;
2460 *num_bad_ratio = 0;
2461 *min_ratio = 0.0;
2462 *max_ratio = 0.0;
2463
2464 if (n == 0)
2465 return;
2466 incri *= 2;
2467
2468 FPU_FIX_START;
2469
2470 y = (float *) blas_malloc(2 * n * sizeof(float) * 2);
2471 if (2 * n > 0 && y == NULL) {
2472 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2473 }
2474 y_gen = (float *) blas_malloc(n * sizeof(float) * 2);
2475 if (n > 0 && y_gen == NULL) {
2476 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2477 }
2478 head_x_gen = (float *) blas_malloc(n * sizeof(float));
2479 if (n > 0 && head_x_gen == NULL) {
2480 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2481 }
2482 tail_x_gen = (float *) blas_malloc(n * sizeof(float));
2483 if (n > 0 && tail_x_gen == NULL) {
2484 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2485 }
2486 a = (float *) blas_malloc(2 * n * n * sizeof(float) * 2);
2487 if (2 * n * n > 0 && a == NULL) {
2488 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2489 }
2490 head_x = (float *) blas_malloc(2 * n * sizeof(float));
2491 if (2 * n > 0 && head_x == NULL) {
2492 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2493 }
2494 tail_x = (float *) blas_malloc(2 * n * sizeof(float));
2495 if (2 * n > 0 && tail_x == NULL) {
2496 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2497 }
2498 a_vec = (float *) blas_malloc(n * sizeof(float) * 2);
2499 if (n > 0 && a_vec == NULL) {
2500 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2501 }
2502 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
2503 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
2504 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
2505 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2506 }
2507 ratios = (double *) blas_malloc(n * sizeof(double));
2508 if (n > 0 && ratios == NULL) {
2509 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2510 }
2511
2512 test_count = 0;
2513 bad_ratio_count = 0;
2514
2515 /* vary alpha */
2516 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
2517
2518 alpha_flag = 0;
2519 switch (alpha_val) {
2520 case 0:
2521 alpha[0] = alpha[1] = 0.0;
2522 alpha_flag = 1;
2523 break;
2524 case 1:
2525 alpha[0] = 1.0;
2526 alpha[1] = 0.0;
2527 alpha_flag = 1;
2528 break;
2529 }
2530
2531 /* vary beta */
2532 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
2533 beta_flag = 0;
2534 switch (beta_val) {
2535 case 0:
2536 beta[0] = beta[1] = 0.0;
2537 beta_flag = 1;
2538 break;
2539 case 1:
2540 beta[0] = 1.0;
2541 beta[1] = 0.0;
2542 beta_flag = 1;
2543 break;
2544 }
2545
2546
2547 eps_int = power(2, -BITS_S);
2548 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_single),
2549 (double) BLAS_fpinfo_x(blas_emin, blas_prec_single));
2550 prec = blas_prec_single;
2551
2552 /* vary norm -- underflow, approx 1, overflow */
2553 for (norm = NORM_START; norm <= NORM_END; norm++) {
2554
2555 /* number of tests */
2556 for (test_no = 0; test_no < ntests; test_no++) {
2557
2558 /* vary storage format */
2559 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
2560
2561 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
2562
2563 /* vary upper / lower variation */
2564 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
2565
2566 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
2567
2568 /* vary lda = n, n+1, 2*n */
2569 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
2570
2571 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
2572
2573 saved_seed = *seed;
2574 /* For the sake of speed, we throw out this case at random */
2575 if (xrand(seed) >= test_prob)
2576 continue;
2577
2578 alpha_flag = 0;
2579 switch (alpha_val) {
2580 case 0:
2581 alpha[0] = alpha[1] = 0.0;
2582 alpha_flag = 1;
2583 break;
2584 case 1:
2585 alpha[0] = 1.0;
2586 alpha[1] = 0.0;
2587 alpha_flag = 1;
2588 break;
2589 }
2590 beta_flag = 0;
2591 switch (beta_val) {
2592 case 0:
2593 beta[0] = beta[1] = 0.0;
2594 beta_flag = 1;
2595 break;
2596 case 1:
2597 beta[0] = 1.0;
2598 beta[1] = 0.0;
2599 beta_flag = 1;
2600 break;
2601 }
2602
2603 /* finally we are here to generate the test case */
2604 BLAS_csymv2_c_s_testgen(norm, order_type,
2605 uplo_type, n, &alpha, alpha_flag, a,
2606 lda, head_x_gen, tail_x_gen, &beta,
2607 beta_flag, y_gen, seed, head_r_true,
2608 tail_r_true);
2609 test_count++;
2610
2611 /* vary incx = -2, -1, 1, 2 */
2612 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
2613
2614 incx = incx_val;
2615 if (0 == incx)
2616 continue;
2617
2618 /* vary incy = -2, -1, 1, 2 */
2619 for (incy_val = INCY_START; incy_val <= INCY_END;
2620 incy_val++) {
2621
2622 incy = incy_val;
2623 if (0 == incy)
2624 continue;
2625
2626 /* copy generated vector with appropriate incs. */
2627 ccopy_vector(y_gen, n, 1, y, incy);
2628 scopy_vector(head_x_gen, n, 1, head_x, incx);
2629 scopy_vector(tail_x_gen, n, 1, tail_x, incx);
2630
2631 /* call symv2 routines to be tested */
2632 FPU_FIX_STOP;
2633 BLAS_csymv2_c_s(order_type,
2634 uplo_type, n, alpha, a, lda, head_x,
2635 tail_x, incx, beta, y, incy);
2636 FPU_FIX_START;
2637
2638 /* now compute the ratio using test_BLAS_xdot */
2639 /* copy a row from A, use x, run dot test */
2640
2641 incyi = incy;
2642 incyi *= 2;
2643 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
2644
2645 for (i = 0, yi = yi0, ri = 0;
2646 i < n; i++, yi += incyi, ri += incri) {
2647 csy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
2648 i);
2649
2650 /* just use the x vector - it was unchanged (in theory) */
2651 rin[0] = y_gen[i];
2652 rin[1] = y_gen[i + 1];
2653 rout[0] = y[yi];
2654 rout[1] = y[yi + 1];
2655 head_r_true_elem[0] = head_r_true[ri];
2656 head_r_true_elem[1] = head_r_true[ri + 1];
2657 tail_r_true_elem[0] = tail_r_true[ri];
2658 tail_r_true_elem[1] = tail_r_true[ri + 1];
2659
2660 test_BLAS_cdot2_c_s(n, blas_no_conj, alpha, beta,
2661 rin, rout, head_r_true_elem,
2662 tail_r_true_elem, a_vec, 1, head_x,
2663 tail_x, incx, eps_int, un_int,
2664 &ratios[i]);
2665
2666 /* take the max ratio */
2667 if (i == 0) {
2668 ratio = ratios[0];
2669
2670 /* The !<= below causes NaN errors to be included.
2671 * Note that (NaN > 0) is false */
2672 } else if (!(ratios[i] <= ratio)) {
2673 ratio = ratios[i];
2674 }
2675
2676 } /* end of dot-test loop */
2677
2678
2679 /* The !<= below causes NaN errors to be included.
2680 * Note that (NaN > 0) is false */
2681 if (!(ratio <= thresh)) {
2682
2683 if (debug == 3) {
2684 printf("\n\t\tTest # %d\n", test_count);
2685 printf("y type : c, a type : c, x type : s\n");
2686 printf("Seed = %d\t", saved_seed);
2687 printf("n %d\n", n);
2688 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
2689
2690 if (order_type == blas_rowmajor)
2691 printf("row ");
2692 else
2693 printf("col ");
2694
2695 if (uplo_type == blas_upper)
2696 printf("upper ");
2697 else
2698 printf("lower ");
2699
2700 printf("NORM %d, ALPHA %d, BETA %d\n",
2701 norm, alpha_val, beta_val);
2702
2703 /* print out info */
2704 printf("alpha = ");
2705 printf("(%16.8e, %16.8e)", alpha[0], alpha[1]);;
2706 printf(" ");
2707 printf("beta = ");
2708 printf("(%16.8e, %16.8e)", beta[0], beta[1]);;
2709 printf("\n");
2710
2711 printf("a\n");
2712 csy_print_matrix(a, n, lda, order_type, uplo_type);
2713 sprint_vector(head_x, n, incx, "head_x");
2714 sprint_vector(tail_x, n, incx, "tail_x");
2715 cprint_vector(y_gen, n, incy, "y_gen");
2716 cprint_vector(y, n, incy, "y");
2717 zprint_vector(head_r_true, n, 1, "head_r_true");
2718 dprint_vector(ratios, n, 1, "ratios");
2719 printf("ratio = %g\n", ratio);
2720 }
2721 bad_ratio_count++;
2722 if (bad_ratio_count >= MAX_BAD_TESTS) {
2723 printf("\ntoo many failures, exiting....");
2724 printf("\nTesting and compilation");
2725 printf(" are incomplete\n\n");
2726 goto end;
2727 }
2728 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
2729 printf("\nFlagrant ratio error, exiting...");
2730 printf("\nTesting and compilation");
2731 printf(" are incomplete\n\n");
2732 goto end;
2733 }
2734 }
2735
2736 if (!(ratio <= ratio_max))
2737 ratio_max = ratio;
2738
2739 if (ratio != 0.0 && !(ratio >= ratio_min))
2740 ratio_min = ratio;
2741
2742 } /* end of incy loop */
2743
2744 } /* end of incx loop */
2745
2746 } /* end of lda loop */
2747
2748 } /* end of uplo loop */
2749
2750 } /* end of order loop */
2751
2752 } /* end of nr test loop */
2753
2754 } /* end of norm loop */
2755
2756
2757
2758 } /* end of beta loop */
2759
2760 } /* end of alpha loop */
2761
2762 end:
2763 FPU_FIX_STOP;
2764
2765 blas_free(y);
2766 blas_free(a);
2767 blas_free(y_gen);
2768 blas_free(head_x);
2769 blas_free(tail_x);
2770 blas_free(head_x_gen);
2771 blas_free(tail_x_gen);
2772 blas_free(head_r_true);
2773 blas_free(tail_r_true);
2774 blas_free(ratios);
2775 blas_free(a_vec);
2776
2777 *max_ratio = ratio_max;
2778 *min_ratio = ratio_min;
2779 *num_tests = test_count;
2780 *num_bad_ratio = bad_ratio_count;
2781
2782 }
do_test_csymv2_s_c(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)2783 void do_test_csymv2_s_c
2784 (int n,
2785 int ntests, int *seed, double thresh, int debug, float test_prob,
2786 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
2787
2788 /* Function name */
2789 const char fname[] = "do_test_csymv2_s_c";
2790 int i;
2791 int yi;
2792 int incyi, yi0;
2793 int test_count;
2794 int bad_ratio_count;
2795 int ri;
2796 int incri = 1;
2797 int incx, incy;
2798 double ratio;
2799 double ratio_min, ratio_max;
2800 double eps_int; /* internal machine epsilon */
2801 double un_int; /* internal underflow threshold */
2802
2803 float rin[2];
2804 float rout[2];
2805 double head_r_true_elem[2], tail_r_true_elem[2];
2806
2807 enum blas_order_type order_type;
2808 enum blas_uplo_type uplo_type;
2809 enum blas_prec_type prec;
2810
2811 int order_val, uplo_val;
2812 int lda_val, incx_val, incy_val;
2813 int alpha_val, beta_val;
2814
2815
2816
2817 int lda;
2818 int alpha_flag, beta_flag;
2819 int saved_seed;
2820 int norm;
2821 int test_no;
2822
2823 float alpha[2];
2824 float beta[2];
2825 float *a;
2826 float *head_x;
2827 float *tail_x;
2828 float *y;
2829 float *a_vec;
2830 float *y_gen;
2831 float *head_x_gen;
2832 float *tail_x_gen;
2833 double *ratios;
2834
2835 /* true result calculated by testgen, in double-double */
2836 double *head_r_true, *tail_r_true;
2837
2838
2839 FPU_FIX_DECL;
2840
2841 if (n < 0)
2842 BLAS_error(fname, -1, n, NULL);
2843 if (ntests < 0)
2844 BLAS_error(fname, -2, ntests, NULL);
2845
2846 /* initialization */
2847 saved_seed = *seed;
2848 ratio = 0.0;
2849 ratio_min = 1e308;
2850 ratio_max = 0.0;
2851
2852 *num_tests = 0;
2853 *num_bad_ratio = 0;
2854 *min_ratio = 0.0;
2855 *max_ratio = 0.0;
2856
2857 if (n == 0)
2858 return;
2859 incri *= 2;
2860
2861 FPU_FIX_START;
2862
2863 y = (float *) blas_malloc(2 * n * sizeof(float) * 2);
2864 if (2 * n > 0 && y == NULL) {
2865 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2866 }
2867 y_gen = (float *) blas_malloc(n * sizeof(float) * 2);
2868 if (n > 0 && y_gen == NULL) {
2869 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2870 }
2871 head_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
2872 if (n > 0 && head_x_gen == NULL) {
2873 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2874 }
2875 tail_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
2876 if (n > 0 && tail_x_gen == NULL) {
2877 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2878 }
2879 a = (float *) blas_malloc(2 * n * n * sizeof(float));
2880 if (2 * n * n > 0 && a == NULL) {
2881 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2882 }
2883 head_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
2884 if (2 * n > 0 && head_x == NULL) {
2885 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2886 }
2887 tail_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
2888 if (2 * n > 0 && tail_x == NULL) {
2889 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2890 }
2891 a_vec = (float *) blas_malloc(n * sizeof(float));
2892 if (n > 0 && a_vec == NULL) {
2893 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2894 }
2895 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
2896 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
2897 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
2898 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2899 }
2900 ratios = (double *) blas_malloc(n * sizeof(double));
2901 if (n > 0 && ratios == NULL) {
2902 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
2903 }
2904
2905 test_count = 0;
2906 bad_ratio_count = 0;
2907
2908 /* vary alpha */
2909 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
2910
2911 alpha_flag = 0;
2912 switch (alpha_val) {
2913 case 0:
2914 alpha[0] = alpha[1] = 0.0;
2915 alpha_flag = 1;
2916 break;
2917 case 1:
2918 alpha[0] = 1.0;
2919 alpha[1] = 0.0;
2920 alpha_flag = 1;
2921 break;
2922 }
2923
2924 /* vary beta */
2925 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
2926 beta_flag = 0;
2927 switch (beta_val) {
2928 case 0:
2929 beta[0] = beta[1] = 0.0;
2930 beta_flag = 1;
2931 break;
2932 case 1:
2933 beta[0] = 1.0;
2934 beta[1] = 0.0;
2935 beta_flag = 1;
2936 break;
2937 }
2938
2939
2940 eps_int = power(2, -BITS_S);
2941 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_single),
2942 (double) BLAS_fpinfo_x(blas_emin, blas_prec_single));
2943 prec = blas_prec_single;
2944
2945 /* vary norm -- underflow, approx 1, overflow */
2946 for (norm = NORM_START; norm <= NORM_END; norm++) {
2947
2948 /* number of tests */
2949 for (test_no = 0; test_no < ntests; test_no++) {
2950
2951 /* vary storage format */
2952 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
2953
2954 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
2955
2956 /* vary upper / lower variation */
2957 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
2958
2959 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
2960
2961 /* vary lda = n, n+1, 2*n */
2962 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
2963
2964 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
2965
2966 saved_seed = *seed;
2967 /* For the sake of speed, we throw out this case at random */
2968 if (xrand(seed) >= test_prob)
2969 continue;
2970
2971 alpha_flag = 0;
2972 switch (alpha_val) {
2973 case 0:
2974 alpha[0] = alpha[1] = 0.0;
2975 alpha_flag = 1;
2976 break;
2977 case 1:
2978 alpha[0] = 1.0;
2979 alpha[1] = 0.0;
2980 alpha_flag = 1;
2981 break;
2982 }
2983 beta_flag = 0;
2984 switch (beta_val) {
2985 case 0:
2986 beta[0] = beta[1] = 0.0;
2987 beta_flag = 1;
2988 break;
2989 case 1:
2990 beta[0] = 1.0;
2991 beta[1] = 0.0;
2992 beta_flag = 1;
2993 break;
2994 }
2995
2996 /* finally we are here to generate the test case */
2997 BLAS_csymv2_s_c_testgen(norm, order_type,
2998 uplo_type, n, &alpha, alpha_flag, a,
2999 lda, head_x_gen, tail_x_gen, &beta,
3000 beta_flag, y_gen, seed, head_r_true,
3001 tail_r_true);
3002 test_count++;
3003
3004 /* vary incx = -2, -1, 1, 2 */
3005 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
3006
3007 incx = incx_val;
3008 if (0 == incx)
3009 continue;
3010
3011 /* vary incy = -2, -1, 1, 2 */
3012 for (incy_val = INCY_START; incy_val <= INCY_END;
3013 incy_val++) {
3014
3015 incy = incy_val;
3016 if (0 == incy)
3017 continue;
3018
3019 /* copy generated vector with appropriate incs. */
3020 ccopy_vector(y_gen, n, 1, y, incy);
3021 ccopy_vector(head_x_gen, n, 1, head_x, incx);
3022 ccopy_vector(tail_x_gen, n, 1, tail_x, incx);
3023
3024 /* call symv2 routines to be tested */
3025 FPU_FIX_STOP;
3026 BLAS_csymv2_s_c(order_type,
3027 uplo_type, n, alpha, a, lda, head_x,
3028 tail_x, incx, beta, y, incy);
3029 FPU_FIX_START;
3030
3031 /* now compute the ratio using test_BLAS_xdot */
3032 /* copy a row from A, use x, run dot test */
3033
3034 incyi = incy;
3035 incyi *= 2;
3036 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
3037
3038 for (i = 0, yi = yi0, ri = 0;
3039 i < n; i++, yi += incyi, ri += incri) {
3040 ssy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
3041 i);
3042
3043 /* just use the x vector - it was unchanged (in theory) */
3044 rin[0] = y_gen[i];
3045 rin[1] = y_gen[i + 1];
3046 rout[0] = y[yi];
3047 rout[1] = y[yi + 1];
3048 head_r_true_elem[0] = head_r_true[ri];
3049 head_r_true_elem[1] = head_r_true[ri + 1];
3050 tail_r_true_elem[0] = tail_r_true[ri];
3051 tail_r_true_elem[1] = tail_r_true[ri + 1];
3052
3053 test_BLAS_cdot2_s_c(n, blas_no_conj, alpha, beta,
3054 rin, rout, head_r_true_elem,
3055 tail_r_true_elem, a_vec, 1, head_x,
3056 tail_x, incx, eps_int, un_int,
3057 &ratios[i]);
3058
3059 /* take the max ratio */
3060 if (i == 0) {
3061 ratio = ratios[0];
3062
3063 /* The !<= below causes NaN errors to be included.
3064 * Note that (NaN > 0) is false */
3065 } else if (!(ratios[i] <= ratio)) {
3066 ratio = ratios[i];
3067 }
3068
3069 } /* end of dot-test loop */
3070
3071
3072 /* The !<= below causes NaN errors to be included.
3073 * Note that (NaN > 0) is false */
3074 if (!(ratio <= thresh)) {
3075
3076 if (debug == 3) {
3077 printf("\n\t\tTest # %d\n", test_count);
3078 printf("y type : c, a type : s, x type : c\n");
3079 printf("Seed = %d\t", saved_seed);
3080 printf("n %d\n", n);
3081 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
3082
3083 if (order_type == blas_rowmajor)
3084 printf("row ");
3085 else
3086 printf("col ");
3087
3088 if (uplo_type == blas_upper)
3089 printf("upper ");
3090 else
3091 printf("lower ");
3092
3093 printf("NORM %d, ALPHA %d, BETA %d\n",
3094 norm, alpha_val, beta_val);
3095
3096 /* print out info */
3097 printf("alpha = ");
3098 printf("(%16.8e, %16.8e)", alpha[0], alpha[1]);;
3099 printf(" ");
3100 printf("beta = ");
3101 printf("(%16.8e, %16.8e)", beta[0], beta[1]);;
3102 printf("\n");
3103
3104 printf("a\n");
3105 ssy_print_matrix(a, n, lda, order_type, uplo_type);
3106 cprint_vector(head_x, n, incx, "head_x");
3107 cprint_vector(tail_x, n, incx, "tail_x");
3108 cprint_vector(y_gen, n, incy, "y_gen");
3109 cprint_vector(y, n, incy, "y");
3110 zprint_vector(head_r_true, n, 1, "head_r_true");
3111 dprint_vector(ratios, n, 1, "ratios");
3112 printf("ratio = %g\n", ratio);
3113 }
3114 bad_ratio_count++;
3115 if (bad_ratio_count >= MAX_BAD_TESTS) {
3116 printf("\ntoo many failures, exiting....");
3117 printf("\nTesting and compilation");
3118 printf(" are incomplete\n\n");
3119 goto end;
3120 }
3121 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
3122 printf("\nFlagrant ratio error, exiting...");
3123 printf("\nTesting and compilation");
3124 printf(" are incomplete\n\n");
3125 goto end;
3126 }
3127 }
3128
3129 if (!(ratio <= ratio_max))
3130 ratio_max = ratio;
3131
3132 if (ratio != 0.0 && !(ratio >= ratio_min))
3133 ratio_min = ratio;
3134
3135 } /* end of incy loop */
3136
3137 } /* end of incx loop */
3138
3139 } /* end of lda loop */
3140
3141 } /* end of uplo loop */
3142
3143 } /* end of order loop */
3144
3145 } /* end of nr test loop */
3146
3147 } /* end of norm loop */
3148
3149
3150
3151 } /* end of beta loop */
3152
3153 } /* end of alpha loop */
3154
3155 end:
3156 FPU_FIX_STOP;
3157
3158 blas_free(y);
3159 blas_free(a);
3160 blas_free(y_gen);
3161 blas_free(head_x);
3162 blas_free(tail_x);
3163 blas_free(head_x_gen);
3164 blas_free(tail_x_gen);
3165 blas_free(head_r_true);
3166 blas_free(tail_r_true);
3167 blas_free(ratios);
3168 blas_free(a_vec);
3169
3170 *max_ratio = ratio_max;
3171 *min_ratio = ratio_min;
3172 *num_tests = test_count;
3173 *num_bad_ratio = bad_ratio_count;
3174
3175 }
do_test_csymv2_s_s(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)3176 void do_test_csymv2_s_s
3177 (int n,
3178 int ntests, int *seed, double thresh, int debug, float test_prob,
3179 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
3180
3181 /* Function name */
3182 const char fname[] = "do_test_csymv2_s_s";
3183 int i;
3184 int yi;
3185 int incyi, yi0;
3186 int test_count;
3187 int bad_ratio_count;
3188 int ri;
3189 int incri = 1;
3190 int incx, incy;
3191 double ratio;
3192 double ratio_min, ratio_max;
3193 double eps_int; /* internal machine epsilon */
3194 double un_int; /* internal underflow threshold */
3195
3196 float rin[2];
3197 float rout[2];
3198 double head_r_true_elem[2], tail_r_true_elem[2];
3199
3200 enum blas_order_type order_type;
3201 enum blas_uplo_type uplo_type;
3202 enum blas_prec_type prec;
3203
3204 int order_val, uplo_val;
3205 int lda_val, incx_val, incy_val;
3206 int alpha_val, beta_val;
3207
3208
3209
3210 int lda;
3211 int alpha_flag, beta_flag;
3212 int saved_seed;
3213 int norm;
3214 int test_no;
3215
3216 float alpha[2];
3217 float beta[2];
3218 float *a;
3219 float *head_x;
3220 float *tail_x;
3221 float *y;
3222 float *a_vec;
3223 float *y_gen;
3224 float *head_x_gen;
3225 float *tail_x_gen;
3226 double *ratios;
3227
3228 /* true result calculated by testgen, in double-double */
3229 double *head_r_true, *tail_r_true;
3230
3231
3232 FPU_FIX_DECL;
3233
3234 if (n < 0)
3235 BLAS_error(fname, -1, n, NULL);
3236 if (ntests < 0)
3237 BLAS_error(fname, -2, ntests, NULL);
3238
3239 /* initialization */
3240 saved_seed = *seed;
3241 ratio = 0.0;
3242 ratio_min = 1e308;
3243 ratio_max = 0.0;
3244
3245 *num_tests = 0;
3246 *num_bad_ratio = 0;
3247 *min_ratio = 0.0;
3248 *max_ratio = 0.0;
3249
3250 if (n == 0)
3251 return;
3252 incri *= 2;
3253
3254 FPU_FIX_START;
3255
3256 y = (float *) blas_malloc(2 * n * sizeof(float) * 2);
3257 if (2 * n > 0 && y == NULL) {
3258 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3259 }
3260 y_gen = (float *) blas_malloc(n * sizeof(float) * 2);
3261 if (n > 0 && y_gen == NULL) {
3262 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3263 }
3264 head_x_gen = (float *) blas_malloc(n * sizeof(float));
3265 if (n > 0 && head_x_gen == NULL) {
3266 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3267 }
3268 tail_x_gen = (float *) blas_malloc(n * sizeof(float));
3269 if (n > 0 && tail_x_gen == NULL) {
3270 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3271 }
3272 a = (float *) blas_malloc(2 * n * n * sizeof(float));
3273 if (2 * n * n > 0 && a == NULL) {
3274 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3275 }
3276 head_x = (float *) blas_malloc(2 * n * sizeof(float));
3277 if (2 * n > 0 && head_x == NULL) {
3278 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3279 }
3280 tail_x = (float *) blas_malloc(2 * n * sizeof(float));
3281 if (2 * n > 0 && tail_x == NULL) {
3282 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3283 }
3284 a_vec = (float *) blas_malloc(n * sizeof(float));
3285 if (n > 0 && a_vec == NULL) {
3286 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3287 }
3288 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
3289 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
3290 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
3291 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3292 }
3293 ratios = (double *) blas_malloc(n * sizeof(double));
3294 if (n > 0 && ratios == NULL) {
3295 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3296 }
3297
3298 test_count = 0;
3299 bad_ratio_count = 0;
3300
3301 /* vary alpha */
3302 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
3303
3304 alpha_flag = 0;
3305 switch (alpha_val) {
3306 case 0:
3307 alpha[0] = alpha[1] = 0.0;
3308 alpha_flag = 1;
3309 break;
3310 case 1:
3311 alpha[0] = 1.0;
3312 alpha[1] = 0.0;
3313 alpha_flag = 1;
3314 break;
3315 }
3316
3317 /* vary beta */
3318 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
3319 beta_flag = 0;
3320 switch (beta_val) {
3321 case 0:
3322 beta[0] = beta[1] = 0.0;
3323 beta_flag = 1;
3324 break;
3325 case 1:
3326 beta[0] = 1.0;
3327 beta[1] = 0.0;
3328 beta_flag = 1;
3329 break;
3330 }
3331
3332
3333 eps_int = power(2, -BITS_S);
3334 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_single),
3335 (double) BLAS_fpinfo_x(blas_emin, blas_prec_single));
3336 prec = blas_prec_single;
3337
3338 /* vary norm -- underflow, approx 1, overflow */
3339 for (norm = NORM_START; norm <= NORM_END; norm++) {
3340
3341 /* number of tests */
3342 for (test_no = 0; test_no < ntests; test_no++) {
3343
3344 /* vary storage format */
3345 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
3346
3347 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
3348
3349 /* vary upper / lower variation */
3350 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
3351
3352 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
3353
3354 /* vary lda = n, n+1, 2*n */
3355 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
3356
3357 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
3358
3359 saved_seed = *seed;
3360 /* For the sake of speed, we throw out this case at random */
3361 if (xrand(seed) >= test_prob)
3362 continue;
3363
3364 alpha_flag = 0;
3365 switch (alpha_val) {
3366 case 0:
3367 alpha[0] = alpha[1] = 0.0;
3368 alpha_flag = 1;
3369 break;
3370 case 1:
3371 alpha[0] = 1.0;
3372 alpha[1] = 0.0;
3373 alpha_flag = 1;
3374 break;
3375 }
3376 beta_flag = 0;
3377 switch (beta_val) {
3378 case 0:
3379 beta[0] = beta[1] = 0.0;
3380 beta_flag = 1;
3381 break;
3382 case 1:
3383 beta[0] = 1.0;
3384 beta[1] = 0.0;
3385 beta_flag = 1;
3386 break;
3387 }
3388
3389 /* finally we are here to generate the test case */
3390 BLAS_csymv2_s_s_testgen(norm, order_type,
3391 uplo_type, n, &alpha, alpha_flag, a,
3392 lda, head_x_gen, tail_x_gen, &beta,
3393 beta_flag, y_gen, seed, head_r_true,
3394 tail_r_true);
3395 test_count++;
3396
3397 /* vary incx = -2, -1, 1, 2 */
3398 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
3399
3400 incx = incx_val;
3401 if (0 == incx)
3402 continue;
3403
3404 /* vary incy = -2, -1, 1, 2 */
3405 for (incy_val = INCY_START; incy_val <= INCY_END;
3406 incy_val++) {
3407
3408 incy = incy_val;
3409 if (0 == incy)
3410 continue;
3411
3412 /* copy generated vector with appropriate incs. */
3413 ccopy_vector(y_gen, n, 1, y, incy);
3414 scopy_vector(head_x_gen, n, 1, head_x, incx);
3415 scopy_vector(tail_x_gen, n, 1, tail_x, incx);
3416
3417 /* call symv2 routines to be tested */
3418 FPU_FIX_STOP;
3419 BLAS_csymv2_s_s(order_type,
3420 uplo_type, n, alpha, a, lda, head_x,
3421 tail_x, incx, beta, y, incy);
3422 FPU_FIX_START;
3423
3424 /* now compute the ratio using test_BLAS_xdot */
3425 /* copy a row from A, use x, run dot test */
3426
3427 incyi = incy;
3428 incyi *= 2;
3429 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
3430
3431 for (i = 0, yi = yi0, ri = 0;
3432 i < n; i++, yi += incyi, ri += incri) {
3433 ssy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
3434 i);
3435
3436 /* just use the x vector - it was unchanged (in theory) */
3437 rin[0] = y_gen[i];
3438 rin[1] = y_gen[i + 1];
3439 rout[0] = y[yi];
3440 rout[1] = y[yi + 1];
3441 head_r_true_elem[0] = head_r_true[ri];
3442 head_r_true_elem[1] = head_r_true[ri + 1];
3443 tail_r_true_elem[0] = tail_r_true[ri];
3444 tail_r_true_elem[1] = tail_r_true[ri + 1];
3445
3446 test_BLAS_cdot2_s_s(n, blas_no_conj, alpha, beta,
3447 rin, rout, head_r_true_elem,
3448 tail_r_true_elem, a_vec, 1, head_x,
3449 tail_x, incx, eps_int, un_int,
3450 &ratios[i]);
3451
3452 /* take the max ratio */
3453 if (i == 0) {
3454 ratio = ratios[0];
3455
3456 /* The !<= below causes NaN errors to be included.
3457 * Note that (NaN > 0) is false */
3458 } else if (!(ratios[i] <= ratio)) {
3459 ratio = ratios[i];
3460 }
3461
3462 } /* end of dot-test loop */
3463
3464
3465 /* The !<= below causes NaN errors to be included.
3466 * Note that (NaN > 0) is false */
3467 if (!(ratio <= thresh)) {
3468
3469 if (debug == 3) {
3470 printf("\n\t\tTest # %d\n", test_count);
3471 printf("y type : c, a type : s, x type : s\n");
3472 printf("Seed = %d\t", saved_seed);
3473 printf("n %d\n", n);
3474 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
3475
3476 if (order_type == blas_rowmajor)
3477 printf("row ");
3478 else
3479 printf("col ");
3480
3481 if (uplo_type == blas_upper)
3482 printf("upper ");
3483 else
3484 printf("lower ");
3485
3486 printf("NORM %d, ALPHA %d, BETA %d\n",
3487 norm, alpha_val, beta_val);
3488
3489 /* print out info */
3490 printf("alpha = ");
3491 printf("(%16.8e, %16.8e)", alpha[0], alpha[1]);;
3492 printf(" ");
3493 printf("beta = ");
3494 printf("(%16.8e, %16.8e)", beta[0], beta[1]);;
3495 printf("\n");
3496
3497 printf("a\n");
3498 ssy_print_matrix(a, n, lda, order_type, uplo_type);
3499 sprint_vector(head_x, n, incx, "head_x");
3500 sprint_vector(tail_x, n, incx, "tail_x");
3501 cprint_vector(y_gen, n, incy, "y_gen");
3502 cprint_vector(y, n, incy, "y");
3503 zprint_vector(head_r_true, n, 1, "head_r_true");
3504 dprint_vector(ratios, n, 1, "ratios");
3505 printf("ratio = %g\n", ratio);
3506 }
3507 bad_ratio_count++;
3508 if (bad_ratio_count >= MAX_BAD_TESTS) {
3509 printf("\ntoo many failures, exiting....");
3510 printf("\nTesting and compilation");
3511 printf(" are incomplete\n\n");
3512 goto end;
3513 }
3514 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
3515 printf("\nFlagrant ratio error, exiting...");
3516 printf("\nTesting and compilation");
3517 printf(" are incomplete\n\n");
3518 goto end;
3519 }
3520 }
3521
3522 if (!(ratio <= ratio_max))
3523 ratio_max = ratio;
3524
3525 if (ratio != 0.0 && !(ratio >= ratio_min))
3526 ratio_min = ratio;
3527
3528 } /* end of incy loop */
3529
3530 } /* end of incx loop */
3531
3532 } /* end of lda loop */
3533
3534 } /* end of uplo loop */
3535
3536 } /* end of order loop */
3537
3538 } /* end of nr test loop */
3539
3540 } /* end of norm loop */
3541
3542
3543
3544 } /* end of beta loop */
3545
3546 } /* end of alpha loop */
3547
3548 end:
3549 FPU_FIX_STOP;
3550
3551 blas_free(y);
3552 blas_free(a);
3553 blas_free(y_gen);
3554 blas_free(head_x);
3555 blas_free(tail_x);
3556 blas_free(head_x_gen);
3557 blas_free(tail_x_gen);
3558 blas_free(head_r_true);
3559 blas_free(tail_r_true);
3560 blas_free(ratios);
3561 blas_free(a_vec);
3562
3563 *max_ratio = ratio_max;
3564 *min_ratio = ratio_min;
3565 *num_tests = test_count;
3566 *num_bad_ratio = bad_ratio_count;
3567
3568 }
do_test_zsymv2_z_d(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)3569 void do_test_zsymv2_z_d
3570 (int n,
3571 int ntests, int *seed, double thresh, int debug, float test_prob,
3572 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
3573
3574 /* Function name */
3575 const char fname[] = "do_test_zsymv2_z_d";
3576 int i;
3577 int yi;
3578 int incyi, yi0;
3579 int test_count;
3580 int bad_ratio_count;
3581 int ri;
3582 int incri = 1;
3583 int incx, incy;
3584 double ratio;
3585 double ratio_min, ratio_max;
3586 double eps_int; /* internal machine epsilon */
3587 double un_int; /* internal underflow threshold */
3588
3589 double rin[2];
3590 double rout[2];
3591 double head_r_true_elem[2], tail_r_true_elem[2];
3592
3593 enum blas_order_type order_type;
3594 enum blas_uplo_type uplo_type;
3595 enum blas_prec_type prec;
3596
3597 int order_val, uplo_val;
3598 int lda_val, incx_val, incy_val;
3599 int alpha_val, beta_val;
3600
3601
3602
3603 int lda;
3604 int alpha_flag, beta_flag;
3605 int saved_seed;
3606 int norm;
3607 int test_no;
3608
3609 double alpha[2];
3610 double beta[2];
3611 double *a;
3612 double *head_x;
3613 double *tail_x;
3614 double *y;
3615 double *a_vec;
3616 double *y_gen;
3617 double *head_x_gen;
3618 double *tail_x_gen;
3619 double *ratios;
3620
3621 /* true result calculated by testgen, in double-double */
3622 double *head_r_true, *tail_r_true;
3623
3624
3625 FPU_FIX_DECL;
3626
3627 if (n < 0)
3628 BLAS_error(fname, -1, n, NULL);
3629 if (ntests < 0)
3630 BLAS_error(fname, -2, ntests, NULL);
3631
3632 /* initialization */
3633 saved_seed = *seed;
3634 ratio = 0.0;
3635 ratio_min = 1e308;
3636 ratio_max = 0.0;
3637
3638 *num_tests = 0;
3639 *num_bad_ratio = 0;
3640 *min_ratio = 0.0;
3641 *max_ratio = 0.0;
3642
3643 if (n == 0)
3644 return;
3645 incri *= 2;
3646
3647 FPU_FIX_START;
3648
3649 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
3650 if (2 * n > 0 && y == NULL) {
3651 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3652 }
3653 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
3654 if (n > 0 && y_gen == NULL) {
3655 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3656 }
3657 head_x_gen = (double *) blas_malloc(n * sizeof(double));
3658 if (n > 0 && head_x_gen == NULL) {
3659 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3660 }
3661 tail_x_gen = (double *) blas_malloc(n * sizeof(double));
3662 if (n > 0 && tail_x_gen == NULL) {
3663 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3664 }
3665 a = (double *) blas_malloc(2 * n * n * sizeof(double) * 2);
3666 if (2 * n * n > 0 && a == NULL) {
3667 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3668 }
3669 head_x = (double *) blas_malloc(2 * n * sizeof(double));
3670 if (2 * n > 0 && head_x == NULL) {
3671 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3672 }
3673 tail_x = (double *) blas_malloc(2 * n * sizeof(double));
3674 if (2 * n > 0 && tail_x == NULL) {
3675 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3676 }
3677 a_vec = (double *) blas_malloc(n * sizeof(double) * 2);
3678 if (n > 0 && a_vec == NULL) {
3679 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3680 }
3681 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
3682 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
3683 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
3684 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3685 }
3686 ratios = (double *) blas_malloc(n * sizeof(double));
3687 if (n > 0 && ratios == NULL) {
3688 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
3689 }
3690
3691 test_count = 0;
3692 bad_ratio_count = 0;
3693
3694 /* vary alpha */
3695 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
3696
3697 alpha_flag = 0;
3698 switch (alpha_val) {
3699 case 0:
3700 alpha[0] = alpha[1] = 0.0;
3701 alpha_flag = 1;
3702 break;
3703 case 1:
3704 alpha[0] = 1.0;
3705 alpha[1] = 0.0;
3706 alpha_flag = 1;
3707 break;
3708 }
3709
3710 /* vary beta */
3711 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
3712 beta_flag = 0;
3713 switch (beta_val) {
3714 case 0:
3715 beta[0] = beta[1] = 0.0;
3716 beta_flag = 1;
3717 break;
3718 case 1:
3719 beta[0] = 1.0;
3720 beta[1] = 0.0;
3721 beta_flag = 1;
3722 break;
3723 }
3724
3725
3726 eps_int = power(2, -BITS_D);
3727 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
3728 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
3729 prec = blas_prec_double;
3730
3731 /* vary norm -- underflow, approx 1, overflow */
3732 for (norm = NORM_START; norm <= NORM_END; norm++) {
3733
3734 /* number of tests */
3735 for (test_no = 0; test_no < ntests; test_no++) {
3736
3737 /* vary storage format */
3738 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
3739
3740 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
3741
3742 /* vary upper / lower variation */
3743 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
3744
3745 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
3746
3747 /* vary lda = n, n+1, 2*n */
3748 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
3749
3750 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
3751
3752 saved_seed = *seed;
3753 /* For the sake of speed, we throw out this case at random */
3754 if (xrand(seed) >= test_prob)
3755 continue;
3756
3757 alpha_flag = 0;
3758 switch (alpha_val) {
3759 case 0:
3760 alpha[0] = alpha[1] = 0.0;
3761 alpha_flag = 1;
3762 break;
3763 case 1:
3764 alpha[0] = 1.0;
3765 alpha[1] = 0.0;
3766 alpha_flag = 1;
3767 break;
3768 }
3769 beta_flag = 0;
3770 switch (beta_val) {
3771 case 0:
3772 beta[0] = beta[1] = 0.0;
3773 beta_flag = 1;
3774 break;
3775 case 1:
3776 beta[0] = 1.0;
3777 beta[1] = 0.0;
3778 beta_flag = 1;
3779 break;
3780 }
3781
3782 /* finally we are here to generate the test case */
3783 BLAS_zsymv2_z_d_testgen(norm, order_type,
3784 uplo_type, n, &alpha, alpha_flag, a,
3785 lda, head_x_gen, tail_x_gen, &beta,
3786 beta_flag, y_gen, seed, head_r_true,
3787 tail_r_true);
3788 test_count++;
3789
3790 /* vary incx = -2, -1, 1, 2 */
3791 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
3792
3793 incx = incx_val;
3794 if (0 == incx)
3795 continue;
3796
3797 /* vary incy = -2, -1, 1, 2 */
3798 for (incy_val = INCY_START; incy_val <= INCY_END;
3799 incy_val++) {
3800
3801 incy = incy_val;
3802 if (0 == incy)
3803 continue;
3804
3805 /* copy generated vector with appropriate incs. */
3806 zcopy_vector(y_gen, n, 1, y, incy);
3807 dcopy_vector(head_x_gen, n, 1, head_x, incx);
3808 dcopy_vector(tail_x_gen, n, 1, tail_x, incx);
3809
3810 /* call symv2 routines to be tested */
3811 FPU_FIX_STOP;
3812 BLAS_zsymv2_z_d(order_type,
3813 uplo_type, n, alpha, a, lda, head_x,
3814 tail_x, incx, beta, y, incy);
3815 FPU_FIX_START;
3816
3817 /* now compute the ratio using test_BLAS_xdot */
3818 /* copy a row from A, use x, run dot test */
3819
3820 incyi = incy;
3821 incyi *= 2;
3822 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
3823
3824 for (i = 0, yi = yi0, ri = 0;
3825 i < n; i++, yi += incyi, ri += incri) {
3826 zsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
3827 i);
3828
3829 /* just use the x vector - it was unchanged (in theory) */
3830 rin[0] = y_gen[i];
3831 rin[1] = y_gen[i + 1];
3832 rout[0] = y[yi];
3833 rout[1] = y[yi + 1];
3834 head_r_true_elem[0] = head_r_true[ri];
3835 head_r_true_elem[1] = head_r_true[ri + 1];
3836 tail_r_true_elem[0] = tail_r_true[ri];
3837 tail_r_true_elem[1] = tail_r_true[ri + 1];
3838
3839 test_BLAS_zdot2_z_d(n, blas_no_conj, alpha, beta,
3840 rin, rout, head_r_true_elem,
3841 tail_r_true_elem, a_vec, 1, head_x,
3842 tail_x, incx, eps_int, un_int,
3843 &ratios[i]);
3844
3845 /* take the max ratio */
3846 if (i == 0) {
3847 ratio = ratios[0];
3848
3849 /* The !<= below causes NaN errors to be included.
3850 * Note that (NaN > 0) is false */
3851 } else if (!(ratios[i] <= ratio)) {
3852 ratio = ratios[i];
3853 }
3854
3855 } /* end of dot-test loop */
3856
3857
3858 /* The !<= below causes NaN errors to be included.
3859 * Note that (NaN > 0) is false */
3860 if (!(ratio <= thresh)) {
3861
3862 if (debug == 3) {
3863 printf("\n\t\tTest # %d\n", test_count);
3864 printf("y type : z, a type : z, x type : d\n");
3865 printf("Seed = %d\t", saved_seed);
3866 printf("n %d\n", n);
3867 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
3868
3869 if (order_type == blas_rowmajor)
3870 printf("row ");
3871 else
3872 printf("col ");
3873
3874 if (uplo_type == blas_upper)
3875 printf("upper ");
3876 else
3877 printf("lower ");
3878
3879 printf("NORM %d, ALPHA %d, BETA %d\n",
3880 norm, alpha_val, beta_val);
3881
3882 /* print out info */
3883 printf("alpha = ");
3884 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
3885 printf(" ");
3886 printf("beta = ");
3887 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
3888 printf("\n");
3889
3890 printf("a\n");
3891 zsy_print_matrix(a, n, lda, order_type, uplo_type);
3892 dprint_vector(head_x, n, incx, "head_x");
3893 dprint_vector(tail_x, n, incx, "tail_x");
3894 zprint_vector(y_gen, n, incy, "y_gen");
3895 zprint_vector(y, n, incy, "y");
3896 zprint_vector(head_r_true, n, 1, "head_r_true");
3897 dprint_vector(ratios, n, 1, "ratios");
3898 printf("ratio = %g\n", ratio);
3899 }
3900 bad_ratio_count++;
3901 if (bad_ratio_count >= MAX_BAD_TESTS) {
3902 printf("\ntoo many failures, exiting....");
3903 printf("\nTesting and compilation");
3904 printf(" are incomplete\n\n");
3905 goto end;
3906 }
3907 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
3908 printf("\nFlagrant ratio error, exiting...");
3909 printf("\nTesting and compilation");
3910 printf(" are incomplete\n\n");
3911 goto end;
3912 }
3913 }
3914
3915 if (!(ratio <= ratio_max))
3916 ratio_max = ratio;
3917
3918 if (ratio != 0.0 && !(ratio >= ratio_min))
3919 ratio_min = ratio;
3920
3921 } /* end of incy loop */
3922
3923 } /* end of incx loop */
3924
3925 } /* end of lda loop */
3926
3927 } /* end of uplo loop */
3928
3929 } /* end of order loop */
3930
3931 } /* end of nr test loop */
3932
3933 } /* end of norm loop */
3934
3935
3936
3937 } /* end of beta loop */
3938
3939 } /* end of alpha loop */
3940
3941 end:
3942 FPU_FIX_STOP;
3943
3944 blas_free(y);
3945 blas_free(a);
3946 blas_free(y_gen);
3947 blas_free(head_x);
3948 blas_free(tail_x);
3949 blas_free(head_x_gen);
3950 blas_free(tail_x_gen);
3951 blas_free(head_r_true);
3952 blas_free(tail_r_true);
3953 blas_free(ratios);
3954 blas_free(a_vec);
3955
3956 *max_ratio = ratio_max;
3957 *min_ratio = ratio_min;
3958 *num_tests = test_count;
3959 *num_bad_ratio = bad_ratio_count;
3960
3961 }
do_test_zsymv2_d_z(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)3962 void do_test_zsymv2_d_z
3963 (int n,
3964 int ntests, int *seed, double thresh, int debug, float test_prob,
3965 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
3966
3967 /* Function name */
3968 const char fname[] = "do_test_zsymv2_d_z";
3969 int i;
3970 int yi;
3971 int incyi, yi0;
3972 int test_count;
3973 int bad_ratio_count;
3974 int ri;
3975 int incri = 1;
3976 int incx, incy;
3977 double ratio;
3978 double ratio_min, ratio_max;
3979 double eps_int; /* internal machine epsilon */
3980 double un_int; /* internal underflow threshold */
3981
3982 double rin[2];
3983 double rout[2];
3984 double head_r_true_elem[2], tail_r_true_elem[2];
3985
3986 enum blas_order_type order_type;
3987 enum blas_uplo_type uplo_type;
3988 enum blas_prec_type prec;
3989
3990 int order_val, uplo_val;
3991 int lda_val, incx_val, incy_val;
3992 int alpha_val, beta_val;
3993
3994
3995
3996 int lda;
3997 int alpha_flag, beta_flag;
3998 int saved_seed;
3999 int norm;
4000 int test_no;
4001
4002 double alpha[2];
4003 double beta[2];
4004 double *a;
4005 double *head_x;
4006 double *tail_x;
4007 double *y;
4008 double *a_vec;
4009 double *y_gen;
4010 double *head_x_gen;
4011 double *tail_x_gen;
4012 double *ratios;
4013
4014 /* true result calculated by testgen, in double-double */
4015 double *head_r_true, *tail_r_true;
4016
4017
4018 FPU_FIX_DECL;
4019
4020 if (n < 0)
4021 BLAS_error(fname, -1, n, NULL);
4022 if (ntests < 0)
4023 BLAS_error(fname, -2, ntests, NULL);
4024
4025 /* initialization */
4026 saved_seed = *seed;
4027 ratio = 0.0;
4028 ratio_min = 1e308;
4029 ratio_max = 0.0;
4030
4031 *num_tests = 0;
4032 *num_bad_ratio = 0;
4033 *min_ratio = 0.0;
4034 *max_ratio = 0.0;
4035
4036 if (n == 0)
4037 return;
4038 incri *= 2;
4039
4040 FPU_FIX_START;
4041
4042 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
4043 if (2 * n > 0 && y == NULL) {
4044 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4045 }
4046 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
4047 if (n > 0 && y_gen == NULL) {
4048 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4049 }
4050 head_x_gen = (double *) blas_malloc(n * sizeof(double) * 2);
4051 if (n > 0 && head_x_gen == NULL) {
4052 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4053 }
4054 tail_x_gen = (double *) blas_malloc(n * sizeof(double) * 2);
4055 if (n > 0 && tail_x_gen == NULL) {
4056 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4057 }
4058 a = (double *) blas_malloc(2 * n * n * sizeof(double));
4059 if (2 * n * n > 0 && a == NULL) {
4060 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4061 }
4062 head_x = (double *) blas_malloc(2 * n * sizeof(double) * 2);
4063 if (2 * n > 0 && head_x == NULL) {
4064 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4065 }
4066 tail_x = (double *) blas_malloc(2 * n * sizeof(double) * 2);
4067 if (2 * n > 0 && tail_x == NULL) {
4068 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4069 }
4070 a_vec = (double *) blas_malloc(n * sizeof(double));
4071 if (n > 0 && a_vec == NULL) {
4072 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4073 }
4074 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
4075 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
4076 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
4077 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4078 }
4079 ratios = (double *) blas_malloc(n * sizeof(double));
4080 if (n > 0 && ratios == NULL) {
4081 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4082 }
4083
4084 test_count = 0;
4085 bad_ratio_count = 0;
4086
4087 /* vary alpha */
4088 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
4089
4090 alpha_flag = 0;
4091 switch (alpha_val) {
4092 case 0:
4093 alpha[0] = alpha[1] = 0.0;
4094 alpha_flag = 1;
4095 break;
4096 case 1:
4097 alpha[0] = 1.0;
4098 alpha[1] = 0.0;
4099 alpha_flag = 1;
4100 break;
4101 }
4102
4103 /* vary beta */
4104 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
4105 beta_flag = 0;
4106 switch (beta_val) {
4107 case 0:
4108 beta[0] = beta[1] = 0.0;
4109 beta_flag = 1;
4110 break;
4111 case 1:
4112 beta[0] = 1.0;
4113 beta[1] = 0.0;
4114 beta_flag = 1;
4115 break;
4116 }
4117
4118
4119 eps_int = power(2, -BITS_D);
4120 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
4121 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
4122 prec = blas_prec_double;
4123
4124 /* vary norm -- underflow, approx 1, overflow */
4125 for (norm = NORM_START; norm <= NORM_END; norm++) {
4126
4127 /* number of tests */
4128 for (test_no = 0; test_no < ntests; test_no++) {
4129
4130 /* vary storage format */
4131 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
4132
4133 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
4134
4135 /* vary upper / lower variation */
4136 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
4137
4138 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
4139
4140 /* vary lda = n, n+1, 2*n */
4141 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
4142
4143 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
4144
4145 saved_seed = *seed;
4146 /* For the sake of speed, we throw out this case at random */
4147 if (xrand(seed) >= test_prob)
4148 continue;
4149
4150 alpha_flag = 0;
4151 switch (alpha_val) {
4152 case 0:
4153 alpha[0] = alpha[1] = 0.0;
4154 alpha_flag = 1;
4155 break;
4156 case 1:
4157 alpha[0] = 1.0;
4158 alpha[1] = 0.0;
4159 alpha_flag = 1;
4160 break;
4161 }
4162 beta_flag = 0;
4163 switch (beta_val) {
4164 case 0:
4165 beta[0] = beta[1] = 0.0;
4166 beta_flag = 1;
4167 break;
4168 case 1:
4169 beta[0] = 1.0;
4170 beta[1] = 0.0;
4171 beta_flag = 1;
4172 break;
4173 }
4174
4175 /* finally we are here to generate the test case */
4176 BLAS_zsymv2_d_z_testgen(norm, order_type,
4177 uplo_type, n, &alpha, alpha_flag, a,
4178 lda, head_x_gen, tail_x_gen, &beta,
4179 beta_flag, y_gen, seed, head_r_true,
4180 tail_r_true);
4181 test_count++;
4182
4183 /* vary incx = -2, -1, 1, 2 */
4184 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
4185
4186 incx = incx_val;
4187 if (0 == incx)
4188 continue;
4189
4190 /* vary incy = -2, -1, 1, 2 */
4191 for (incy_val = INCY_START; incy_val <= INCY_END;
4192 incy_val++) {
4193
4194 incy = incy_val;
4195 if (0 == incy)
4196 continue;
4197
4198 /* copy generated vector with appropriate incs. */
4199 zcopy_vector(y_gen, n, 1, y, incy);
4200 zcopy_vector(head_x_gen, n, 1, head_x, incx);
4201 zcopy_vector(tail_x_gen, n, 1, tail_x, incx);
4202
4203 /* call symv2 routines to be tested */
4204 FPU_FIX_STOP;
4205 BLAS_zsymv2_d_z(order_type,
4206 uplo_type, n, alpha, a, lda, head_x,
4207 tail_x, incx, beta, y, incy);
4208 FPU_FIX_START;
4209
4210 /* now compute the ratio using test_BLAS_xdot */
4211 /* copy a row from A, use x, run dot test */
4212
4213 incyi = incy;
4214 incyi *= 2;
4215 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
4216
4217 for (i = 0, yi = yi0, ri = 0;
4218 i < n; i++, yi += incyi, ri += incri) {
4219 dsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
4220 i);
4221
4222 /* just use the x vector - it was unchanged (in theory) */
4223 rin[0] = y_gen[i];
4224 rin[1] = y_gen[i + 1];
4225 rout[0] = y[yi];
4226 rout[1] = y[yi + 1];
4227 head_r_true_elem[0] = head_r_true[ri];
4228 head_r_true_elem[1] = head_r_true[ri + 1];
4229 tail_r_true_elem[0] = tail_r_true[ri];
4230 tail_r_true_elem[1] = tail_r_true[ri + 1];
4231
4232 test_BLAS_zdot2_d_z(n, blas_no_conj, alpha, beta,
4233 rin, rout, head_r_true_elem,
4234 tail_r_true_elem, a_vec, 1, head_x,
4235 tail_x, incx, eps_int, un_int,
4236 &ratios[i]);
4237
4238 /* take the max ratio */
4239 if (i == 0) {
4240 ratio = ratios[0];
4241
4242 /* The !<= below causes NaN errors to be included.
4243 * Note that (NaN > 0) is false */
4244 } else if (!(ratios[i] <= ratio)) {
4245 ratio = ratios[i];
4246 }
4247
4248 } /* end of dot-test loop */
4249
4250
4251 /* The !<= below causes NaN errors to be included.
4252 * Note that (NaN > 0) is false */
4253 if (!(ratio <= thresh)) {
4254
4255 if (debug == 3) {
4256 printf("\n\t\tTest # %d\n", test_count);
4257 printf("y type : z, a type : d, x type : z\n");
4258 printf("Seed = %d\t", saved_seed);
4259 printf("n %d\n", n);
4260 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
4261
4262 if (order_type == blas_rowmajor)
4263 printf("row ");
4264 else
4265 printf("col ");
4266
4267 if (uplo_type == blas_upper)
4268 printf("upper ");
4269 else
4270 printf("lower ");
4271
4272 printf("NORM %d, ALPHA %d, BETA %d\n",
4273 norm, alpha_val, beta_val);
4274
4275 /* print out info */
4276 printf("alpha = ");
4277 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
4278 printf(" ");
4279 printf("beta = ");
4280 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
4281 printf("\n");
4282
4283 printf("a\n");
4284 dsy_print_matrix(a, n, lda, order_type, uplo_type);
4285 zprint_vector(head_x, n, incx, "head_x");
4286 zprint_vector(tail_x, n, incx, "tail_x");
4287 zprint_vector(y_gen, n, incy, "y_gen");
4288 zprint_vector(y, n, incy, "y");
4289 zprint_vector(head_r_true, n, 1, "head_r_true");
4290 dprint_vector(ratios, n, 1, "ratios");
4291 printf("ratio = %g\n", ratio);
4292 }
4293 bad_ratio_count++;
4294 if (bad_ratio_count >= MAX_BAD_TESTS) {
4295 printf("\ntoo many failures, exiting....");
4296 printf("\nTesting and compilation");
4297 printf(" are incomplete\n\n");
4298 goto end;
4299 }
4300 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
4301 printf("\nFlagrant ratio error, exiting...");
4302 printf("\nTesting and compilation");
4303 printf(" are incomplete\n\n");
4304 goto end;
4305 }
4306 }
4307
4308 if (!(ratio <= ratio_max))
4309 ratio_max = ratio;
4310
4311 if (ratio != 0.0 && !(ratio >= ratio_min))
4312 ratio_min = ratio;
4313
4314 } /* end of incy loop */
4315
4316 } /* end of incx loop */
4317
4318 } /* end of lda loop */
4319
4320 } /* end of uplo loop */
4321
4322 } /* end of order loop */
4323
4324 } /* end of nr test loop */
4325
4326 } /* end of norm loop */
4327
4328
4329
4330 } /* end of beta loop */
4331
4332 } /* end of alpha loop */
4333
4334 end:
4335 FPU_FIX_STOP;
4336
4337 blas_free(y);
4338 blas_free(a);
4339 blas_free(y_gen);
4340 blas_free(head_x);
4341 blas_free(tail_x);
4342 blas_free(head_x_gen);
4343 blas_free(tail_x_gen);
4344 blas_free(head_r_true);
4345 blas_free(tail_r_true);
4346 blas_free(ratios);
4347 blas_free(a_vec);
4348
4349 *max_ratio = ratio_max;
4350 *min_ratio = ratio_min;
4351 *num_tests = test_count;
4352 *num_bad_ratio = bad_ratio_count;
4353
4354 }
do_test_zsymv2_d_d(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)4355 void do_test_zsymv2_d_d
4356 (int n,
4357 int ntests, int *seed, double thresh, int debug, float test_prob,
4358 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
4359
4360 /* Function name */
4361 const char fname[] = "do_test_zsymv2_d_d";
4362 int i;
4363 int yi;
4364 int incyi, yi0;
4365 int test_count;
4366 int bad_ratio_count;
4367 int ri;
4368 int incri = 1;
4369 int incx, incy;
4370 double ratio;
4371 double ratio_min, ratio_max;
4372 double eps_int; /* internal machine epsilon */
4373 double un_int; /* internal underflow threshold */
4374
4375 double rin[2];
4376 double rout[2];
4377 double head_r_true_elem[2], tail_r_true_elem[2];
4378
4379 enum blas_order_type order_type;
4380 enum blas_uplo_type uplo_type;
4381 enum blas_prec_type prec;
4382
4383 int order_val, uplo_val;
4384 int lda_val, incx_val, incy_val;
4385 int alpha_val, beta_val;
4386
4387
4388
4389 int lda;
4390 int alpha_flag, beta_flag;
4391 int saved_seed;
4392 int norm;
4393 int test_no;
4394
4395 double alpha[2];
4396 double beta[2];
4397 double *a;
4398 double *head_x;
4399 double *tail_x;
4400 double *y;
4401 double *a_vec;
4402 double *y_gen;
4403 double *head_x_gen;
4404 double *tail_x_gen;
4405 double *ratios;
4406
4407 /* true result calculated by testgen, in double-double */
4408 double *head_r_true, *tail_r_true;
4409
4410
4411 FPU_FIX_DECL;
4412
4413 if (n < 0)
4414 BLAS_error(fname, -1, n, NULL);
4415 if (ntests < 0)
4416 BLAS_error(fname, -2, ntests, NULL);
4417
4418 /* initialization */
4419 saved_seed = *seed;
4420 ratio = 0.0;
4421 ratio_min = 1e308;
4422 ratio_max = 0.0;
4423
4424 *num_tests = 0;
4425 *num_bad_ratio = 0;
4426 *min_ratio = 0.0;
4427 *max_ratio = 0.0;
4428
4429 if (n == 0)
4430 return;
4431 incri *= 2;
4432
4433 FPU_FIX_START;
4434
4435 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
4436 if (2 * n > 0 && y == NULL) {
4437 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4438 }
4439 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
4440 if (n > 0 && y_gen == NULL) {
4441 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4442 }
4443 head_x_gen = (double *) blas_malloc(n * sizeof(double));
4444 if (n > 0 && head_x_gen == NULL) {
4445 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4446 }
4447 tail_x_gen = (double *) blas_malloc(n * sizeof(double));
4448 if (n > 0 && tail_x_gen == NULL) {
4449 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4450 }
4451 a = (double *) blas_malloc(2 * n * n * sizeof(double));
4452 if (2 * n * n > 0 && a == NULL) {
4453 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4454 }
4455 head_x = (double *) blas_malloc(2 * n * sizeof(double));
4456 if (2 * n > 0 && head_x == NULL) {
4457 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4458 }
4459 tail_x = (double *) blas_malloc(2 * n * sizeof(double));
4460 if (2 * n > 0 && tail_x == NULL) {
4461 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4462 }
4463 a_vec = (double *) blas_malloc(n * sizeof(double));
4464 if (n > 0 && a_vec == NULL) {
4465 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4466 }
4467 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
4468 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
4469 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
4470 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4471 }
4472 ratios = (double *) blas_malloc(n * sizeof(double));
4473 if (n > 0 && ratios == NULL) {
4474 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4475 }
4476
4477 test_count = 0;
4478 bad_ratio_count = 0;
4479
4480 /* vary alpha */
4481 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
4482
4483 alpha_flag = 0;
4484 switch (alpha_val) {
4485 case 0:
4486 alpha[0] = alpha[1] = 0.0;
4487 alpha_flag = 1;
4488 break;
4489 case 1:
4490 alpha[0] = 1.0;
4491 alpha[1] = 0.0;
4492 alpha_flag = 1;
4493 break;
4494 }
4495
4496 /* vary beta */
4497 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
4498 beta_flag = 0;
4499 switch (beta_val) {
4500 case 0:
4501 beta[0] = beta[1] = 0.0;
4502 beta_flag = 1;
4503 break;
4504 case 1:
4505 beta[0] = 1.0;
4506 beta[1] = 0.0;
4507 beta_flag = 1;
4508 break;
4509 }
4510
4511
4512 eps_int = power(2, -BITS_D);
4513 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
4514 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
4515 prec = blas_prec_double;
4516
4517 /* vary norm -- underflow, approx 1, overflow */
4518 for (norm = NORM_START; norm <= NORM_END; norm++) {
4519
4520 /* number of tests */
4521 for (test_no = 0; test_no < ntests; test_no++) {
4522
4523 /* vary storage format */
4524 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
4525
4526 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
4527
4528 /* vary upper / lower variation */
4529 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
4530
4531 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
4532
4533 /* vary lda = n, n+1, 2*n */
4534 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
4535
4536 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
4537
4538 saved_seed = *seed;
4539 /* For the sake of speed, we throw out this case at random */
4540 if (xrand(seed) >= test_prob)
4541 continue;
4542
4543 alpha_flag = 0;
4544 switch (alpha_val) {
4545 case 0:
4546 alpha[0] = alpha[1] = 0.0;
4547 alpha_flag = 1;
4548 break;
4549 case 1:
4550 alpha[0] = 1.0;
4551 alpha[1] = 0.0;
4552 alpha_flag = 1;
4553 break;
4554 }
4555 beta_flag = 0;
4556 switch (beta_val) {
4557 case 0:
4558 beta[0] = beta[1] = 0.0;
4559 beta_flag = 1;
4560 break;
4561 case 1:
4562 beta[0] = 1.0;
4563 beta[1] = 0.0;
4564 beta_flag = 1;
4565 break;
4566 }
4567
4568 /* finally we are here to generate the test case */
4569 BLAS_zsymv2_d_d_testgen(norm, order_type,
4570 uplo_type, n, &alpha, alpha_flag, a,
4571 lda, head_x_gen, tail_x_gen, &beta,
4572 beta_flag, y_gen, seed, head_r_true,
4573 tail_r_true);
4574 test_count++;
4575
4576 /* vary incx = -2, -1, 1, 2 */
4577 for (incx_val = INCX_START; incx_val <= INCX_END; incx_val++) {
4578
4579 incx = incx_val;
4580 if (0 == incx)
4581 continue;
4582
4583 /* vary incy = -2, -1, 1, 2 */
4584 for (incy_val = INCY_START; incy_val <= INCY_END;
4585 incy_val++) {
4586
4587 incy = incy_val;
4588 if (0 == incy)
4589 continue;
4590
4591 /* copy generated vector with appropriate incs. */
4592 zcopy_vector(y_gen, n, 1, y, incy);
4593 dcopy_vector(head_x_gen, n, 1, head_x, incx);
4594 dcopy_vector(tail_x_gen, n, 1, tail_x, incx);
4595
4596 /* call symv2 routines to be tested */
4597 FPU_FIX_STOP;
4598 BLAS_zsymv2_d_d(order_type,
4599 uplo_type, n, alpha, a, lda, head_x,
4600 tail_x, incx, beta, y, incy);
4601 FPU_FIX_START;
4602
4603 /* now compute the ratio using test_BLAS_xdot */
4604 /* copy a row from A, use x, run dot test */
4605
4606 incyi = incy;
4607 incyi *= 2;
4608 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
4609
4610 for (i = 0, yi = yi0, ri = 0;
4611 i < n; i++, yi += incyi, ri += incri) {
4612 dsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
4613 i);
4614
4615 /* just use the x vector - it was unchanged (in theory) */
4616 rin[0] = y_gen[i];
4617 rin[1] = y_gen[i + 1];
4618 rout[0] = y[yi];
4619 rout[1] = y[yi + 1];
4620 head_r_true_elem[0] = head_r_true[ri];
4621 head_r_true_elem[1] = head_r_true[ri + 1];
4622 tail_r_true_elem[0] = tail_r_true[ri];
4623 tail_r_true_elem[1] = tail_r_true[ri + 1];
4624
4625 test_BLAS_zdot2_d_d(n, blas_no_conj, alpha, beta,
4626 rin, rout, head_r_true_elem,
4627 tail_r_true_elem, a_vec, 1, head_x,
4628 tail_x, incx, eps_int, un_int,
4629 &ratios[i]);
4630
4631 /* take the max ratio */
4632 if (i == 0) {
4633 ratio = ratios[0];
4634
4635 /* The !<= below causes NaN errors to be included.
4636 * Note that (NaN > 0) is false */
4637 } else if (!(ratios[i] <= ratio)) {
4638 ratio = ratios[i];
4639 }
4640
4641 } /* end of dot-test loop */
4642
4643
4644 /* The !<= below causes NaN errors to be included.
4645 * Note that (NaN > 0) is false */
4646 if (!(ratio <= thresh)) {
4647
4648 if (debug == 3) {
4649 printf("\n\t\tTest # %d\n", test_count);
4650 printf("y type : z, a type : d, x type : d\n");
4651 printf("Seed = %d\t", saved_seed);
4652 printf("n %d\n", n);
4653 printf("LDA %d INCX %d INCY %d\n", lda, incx, incx);
4654
4655 if (order_type == blas_rowmajor)
4656 printf("row ");
4657 else
4658 printf("col ");
4659
4660 if (uplo_type == blas_upper)
4661 printf("upper ");
4662 else
4663 printf("lower ");
4664
4665 printf("NORM %d, ALPHA %d, BETA %d\n",
4666 norm, alpha_val, beta_val);
4667
4668 /* print out info */
4669 printf("alpha = ");
4670 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
4671 printf(" ");
4672 printf("beta = ");
4673 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
4674 printf("\n");
4675
4676 printf("a\n");
4677 dsy_print_matrix(a, n, lda, order_type, uplo_type);
4678 dprint_vector(head_x, n, incx, "head_x");
4679 dprint_vector(tail_x, n, incx, "tail_x");
4680 zprint_vector(y_gen, n, incy, "y_gen");
4681 zprint_vector(y, n, incy, "y");
4682 zprint_vector(head_r_true, n, 1, "head_r_true");
4683 dprint_vector(ratios, n, 1, "ratios");
4684 printf("ratio = %g\n", ratio);
4685 }
4686 bad_ratio_count++;
4687 if (bad_ratio_count >= MAX_BAD_TESTS) {
4688 printf("\ntoo many failures, exiting....");
4689 printf("\nTesting and compilation");
4690 printf(" are incomplete\n\n");
4691 goto end;
4692 }
4693 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
4694 printf("\nFlagrant ratio error, exiting...");
4695 printf("\nTesting and compilation");
4696 printf(" are incomplete\n\n");
4697 goto end;
4698 }
4699 }
4700
4701 if (!(ratio <= ratio_max))
4702 ratio_max = ratio;
4703
4704 if (ratio != 0.0 && !(ratio >= ratio_min))
4705 ratio_min = ratio;
4706
4707 } /* end of incy loop */
4708
4709 } /* end of incx loop */
4710
4711 } /* end of lda loop */
4712
4713 } /* end of uplo loop */
4714
4715 } /* end of order loop */
4716
4717 } /* end of nr test loop */
4718
4719 } /* end of norm loop */
4720
4721
4722
4723 } /* end of beta loop */
4724
4725 } /* end of alpha loop */
4726
4727 end:
4728 FPU_FIX_STOP;
4729
4730 blas_free(y);
4731 blas_free(a);
4732 blas_free(y_gen);
4733 blas_free(head_x);
4734 blas_free(tail_x);
4735 blas_free(head_x_gen);
4736 blas_free(tail_x_gen);
4737 blas_free(head_r_true);
4738 blas_free(tail_r_true);
4739 blas_free(ratios);
4740 blas_free(a_vec);
4741
4742 *max_ratio = ratio_max;
4743 *min_ratio = ratio_min;
4744 *num_tests = test_count;
4745 *num_bad_ratio = bad_ratio_count;
4746
4747 }
do_test_ssymv2_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)4748 void do_test_ssymv2_x
4749 (int n,
4750 int ntests, int *seed, double thresh, int debug, float test_prob,
4751 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
4752
4753 /* Function name */
4754 const char fname[] = "do_test_ssymv2_x";
4755 int i;
4756 int yi;
4757 int incyi, yi0;
4758 int test_count;
4759 int bad_ratio_count;
4760 int ri;
4761 int incri = 1;
4762 int incx, incy;
4763 double ratio;
4764 double ratio_min, ratio_max;
4765 double eps_int; /* internal machine epsilon */
4766 double un_int; /* internal underflow threshold */
4767
4768 float rin;
4769 float rout;
4770 double head_r_true_elem, tail_r_true_elem;
4771
4772 enum blas_order_type order_type;
4773 enum blas_uplo_type uplo_type;
4774 enum blas_prec_type prec;
4775
4776 int order_val, uplo_val;
4777 int lda_val, incx_val, incy_val;
4778 int alpha_val, beta_val;
4779
4780 int prec_val;
4781
4782 int lda;
4783 int alpha_flag, beta_flag;
4784 int saved_seed;
4785 int norm;
4786 int test_no;
4787
4788 float alpha;
4789 float beta;
4790 float *a;
4791 float *head_x;
4792 float *tail_x;
4793 float *y;
4794 float *a_vec;
4795 float *y_gen;
4796 float *head_x_gen;
4797 float *tail_x_gen;
4798 double *ratios;
4799
4800 /* true result calculated by testgen, in double-double */
4801 double *head_r_true, *tail_r_true;
4802
4803 FPU_FIX_DECL;
4804
4805 if (n < 0)
4806 BLAS_error(fname, -1, n, NULL);
4807 if (ntests < 0)
4808 BLAS_error(fname, -2, ntests, NULL);
4809
4810 /* initialization */
4811 saved_seed = *seed;
4812 ratio = 0.0;
4813 ratio_min = 1e308;
4814 ratio_max = 0.0;
4815
4816 *num_tests = 0;
4817 *num_bad_ratio = 0;
4818 *min_ratio = 0.0;
4819 *max_ratio = 0.0;
4820
4821 if (n == 0)
4822 return;
4823
4824
4825 FPU_FIX_START;
4826
4827 y = (float *) blas_malloc(2 * n * sizeof(float));
4828 if (2 * n > 0 && y == NULL) {
4829 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4830 }
4831 y_gen = (float *) blas_malloc(n * sizeof(float));
4832 if (n > 0 && y_gen == NULL) {
4833 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4834 }
4835 head_x_gen = (float *) blas_malloc(n * sizeof(float));
4836 if (n > 0 && head_x_gen == NULL) {
4837 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4838 }
4839 tail_x_gen = (float *) blas_malloc(n * sizeof(float));
4840 if (n > 0 && tail_x_gen == NULL) {
4841 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4842 }
4843 a = (float *) blas_malloc(2 * n * n * sizeof(float));
4844 if (2 * n * n > 0 && a == NULL) {
4845 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4846 }
4847 head_x = (float *) blas_malloc(2 * n * sizeof(float));
4848 if (2 * n > 0 && head_x == NULL) {
4849 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4850 }
4851 tail_x = (float *) blas_malloc(2 * n * sizeof(float));
4852 if (2 * n > 0 && tail_x == NULL) {
4853 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4854 }
4855 a_vec = (float *) blas_malloc(n * sizeof(float));
4856 if (n > 0 && a_vec == NULL) {
4857 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4858 }
4859 head_r_true = (double *) blas_malloc(n * sizeof(double));
4860 tail_r_true = (double *) blas_malloc(n * sizeof(double));
4861 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
4862 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4863 }
4864 ratios = (double *) blas_malloc(n * sizeof(double));
4865 if (n > 0 && ratios == NULL) {
4866 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
4867 }
4868
4869 test_count = 0;
4870 bad_ratio_count = 0;
4871
4872 /* vary alpha */
4873 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
4874
4875 alpha_flag = 0;
4876 switch (alpha_val) {
4877 case 0:
4878 alpha = 0.0;
4879 alpha_flag = 1;
4880 break;
4881 case 1:
4882 alpha = 1.0;
4883 alpha_flag = 1;
4884 break;
4885 }
4886
4887 /* vary beta */
4888 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
4889 beta_flag = 0;
4890 switch (beta_val) {
4891 case 0:
4892 beta = 0.0;
4893 beta_flag = 1;
4894 break;
4895 case 1:
4896 beta = 1.0;
4897 beta_flag = 1;
4898 break;
4899 }
4900
4901
4902 /* varying extra precs */
4903 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
4904 switch (prec_val) {
4905 case 0:
4906 eps_int = power(2, -BITS_S);
4907 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_single),
4908 (double) BLAS_fpinfo_x(blas_emin, blas_prec_single));
4909 prec = blas_prec_single;
4910 break;
4911 case 1:
4912 eps_int = power(2, -BITS_D);
4913 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
4914 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
4915 prec = blas_prec_double;
4916 break;
4917 case 2:
4918 default:
4919 eps_int = power(2, -BITS_E);
4920 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
4921 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
4922 prec = blas_prec_extra;
4923 break;
4924 }
4925
4926 /* vary norm -- underflow, approx 1, overflow */
4927 for (norm = NORM_START; norm <= NORM_END; norm++) {
4928
4929 /* number of tests */
4930 for (test_no = 0; test_no < ntests; test_no++) {
4931
4932 /* vary storage format */
4933 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
4934
4935 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
4936
4937 /* vary upper / lower variation */
4938 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
4939
4940 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
4941
4942 /* vary lda = n, n+1, 2*n */
4943 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
4944
4945 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
4946
4947 saved_seed = *seed;
4948 /* For the sake of speed, we throw out this case at random */
4949 if (xrand(seed) >= test_prob)
4950 continue;
4951
4952 alpha_flag = 0;
4953 switch (alpha_val) {
4954 case 0:
4955 alpha = 0.0;
4956 alpha_flag = 1;
4957 break;
4958 case 1:
4959 alpha = 1.0;
4960 alpha_flag = 1;
4961 break;
4962 }
4963 beta_flag = 0;
4964 switch (beta_val) {
4965 case 0:
4966 beta = 0.0;
4967 beta_flag = 1;
4968 break;
4969 case 1:
4970 beta = 1.0;
4971 beta_flag = 1;
4972 break;
4973 }
4974
4975 /* finally we are here to generate the test case */
4976 BLAS_ssymv2_testgen(norm, order_type,
4977 uplo_type, n, &alpha, alpha_flag, a,
4978 lda, head_x_gen, tail_x_gen, &beta,
4979 beta_flag, y_gen, seed, head_r_true,
4980 tail_r_true);
4981 test_count++;
4982
4983 /* vary incx = -2, -1, 1, 2 */
4984 for (incx_val = INCX_START; incx_val <= INCX_END;
4985 incx_val++) {
4986
4987 incx = incx_val;
4988 if (0 == incx)
4989 continue;
4990
4991 /* vary incy = -2, -1, 1, 2 */
4992 for (incy_val = INCY_START; incy_val <= INCY_END;
4993 incy_val++) {
4994
4995 incy = incy_val;
4996 if (0 == incy)
4997 continue;
4998
4999 /* copy generated vector with appropriate incs. */
5000 scopy_vector(y_gen, n, 1, y, incy);
5001 scopy_vector(head_x_gen, n, 1, head_x, incx);
5002 scopy_vector(tail_x_gen, n, 1, tail_x, incx);
5003
5004 /* call symv2 routines to be tested */
5005 FPU_FIX_STOP;
5006 BLAS_ssymv2_x(order_type,
5007 uplo_type, n, alpha, a, lda, head_x,
5008 tail_x, incx, beta, y, incy, prec);
5009 FPU_FIX_START;
5010
5011 /* now compute the ratio using test_BLAS_xdot */
5012 /* copy a row from A, use x, run dot test */
5013
5014 incyi = incy;
5015
5016 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
5017
5018 for (i = 0, yi = yi0, ri = 0;
5019 i < n; i++, yi += incyi, ri += incri) {
5020 ssy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
5021 i);
5022
5023 /* just use the x vector - it was unchanged (in theory) */
5024 rin = y_gen[i];
5025 rout = y[yi];
5026 head_r_true_elem = head_r_true[ri];
5027 tail_r_true_elem = tail_r_true[ri];
5028
5029 test_BLAS_sdot2(n, blas_no_conj, alpha, beta,
5030 rin, rout, head_r_true_elem,
5031 tail_r_true_elem, a_vec, 1, head_x,
5032 tail_x, incx, eps_int, un_int,
5033 &ratios[i]);
5034
5035 /* take the max ratio */
5036 if (i == 0) {
5037 ratio = ratios[0];
5038
5039 /* The !<= below causes NaN errors to be included.
5040 * Note that (NaN > 0) is false */
5041 } else if (!(ratios[i] <= ratio)) {
5042 ratio = ratios[i];
5043 }
5044
5045 } /* end of dot-test loop */
5046
5047
5048 /* The !<= below causes NaN errors to be included.
5049 * Note that (NaN > 0) is false */
5050 if (!(ratio <= thresh)) {
5051
5052 if (debug == 3) {
5053 printf("\n\t\tTest # %d\n", test_count);
5054 printf("y type : s, a type : s, x type : s\n");
5055 printf("Seed = %d\t", saved_seed);
5056 printf("n %d\n", n);
5057 printf("LDA %d INCX %d INCY %d\n", lda, incx,
5058 incx);
5059
5060 if (order_type == blas_rowmajor)
5061 printf("row ");
5062 else
5063 printf("col ");
5064
5065 if (uplo_type == blas_upper)
5066 printf("upper ");
5067 else
5068 printf("lower ");
5069
5070 printf("NORM %d, ALPHA %d, BETA %d\n",
5071 norm, alpha_val, beta_val);
5072
5073 /* print out info */
5074 printf("alpha = ");
5075 printf("%16.8e", alpha);;
5076 printf(" ");
5077 printf("beta = ");
5078 printf("%16.8e", beta);;
5079 printf("\n");
5080
5081 printf("a\n");
5082 ssy_print_matrix(a, n, lda, order_type, uplo_type);
5083 sprint_vector(head_x, n, incx, "head_x");
5084 sprint_vector(tail_x, n, incx, "tail_x");
5085 sprint_vector(y_gen, n, incy, "y_gen");
5086 sprint_vector(y, n, incy, "y");
5087 dprint_vector(head_r_true, n, 1, "head_r_true");
5088 dprint_vector(ratios, n, 1, "ratios");
5089 printf("ratio = %g\n", ratio);
5090 }
5091 bad_ratio_count++;
5092 if (bad_ratio_count >= MAX_BAD_TESTS) {
5093 printf("\ntoo many failures, exiting....");
5094 printf("\nTesting and compilation");
5095 printf(" are incomplete\n\n");
5096 goto end;
5097 }
5098 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
5099 printf("\nFlagrant ratio error, exiting...");
5100 printf("\nTesting and compilation");
5101 printf(" are incomplete\n\n");
5102 goto end;
5103 }
5104 }
5105
5106 if (!(ratio <= ratio_max))
5107 ratio_max = ratio;
5108
5109 if (ratio != 0.0 && !(ratio >= ratio_min))
5110 ratio_min = ratio;
5111
5112 } /* end of incy loop */
5113
5114 } /* end of incx loop */
5115
5116 } /* end of lda loop */
5117
5118 } /* end of uplo loop */
5119
5120 } /* end of order loop */
5121
5122 } /* end of nr test loop */
5123
5124 } /* end of norm loop */
5125
5126
5127 } /* end of prec loop */
5128
5129 } /* end of beta loop */
5130
5131 } /* end of alpha loop */
5132
5133 end:
5134 FPU_FIX_STOP;
5135
5136 blas_free(y);
5137 blas_free(a);
5138 blas_free(y_gen);
5139 blas_free(head_x);
5140 blas_free(tail_x);
5141 blas_free(head_x_gen);
5142 blas_free(tail_x_gen);
5143 blas_free(head_r_true);
5144 blas_free(tail_r_true);
5145 blas_free(ratios);
5146 blas_free(a_vec);
5147
5148 *max_ratio = ratio_max;
5149 *min_ratio = ratio_min;
5150 *num_tests = test_count;
5151 *num_bad_ratio = bad_ratio_count;
5152
5153 }
do_test_dsymv2_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)5154 void do_test_dsymv2_x
5155 (int n,
5156 int ntests, int *seed, double thresh, int debug, float test_prob,
5157 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
5158
5159 /* Function name */
5160 const char fname[] = "do_test_dsymv2_x";
5161 int i;
5162 int yi;
5163 int incyi, yi0;
5164 int test_count;
5165 int bad_ratio_count;
5166 int ri;
5167 int incri = 1;
5168 int incx, incy;
5169 double ratio;
5170 double ratio_min, ratio_max;
5171 double eps_int; /* internal machine epsilon */
5172 double un_int; /* internal underflow threshold */
5173
5174 double rin;
5175 double rout;
5176 double head_r_true_elem, tail_r_true_elem;
5177
5178 enum blas_order_type order_type;
5179 enum blas_uplo_type uplo_type;
5180 enum blas_prec_type prec;
5181
5182 int order_val, uplo_val;
5183 int lda_val, incx_val, incy_val;
5184 int alpha_val, beta_val;
5185
5186 int prec_val;
5187
5188 int lda;
5189 int alpha_flag, beta_flag;
5190 int saved_seed;
5191 int norm;
5192 int test_no;
5193
5194 double alpha;
5195 double beta;
5196 double *a;
5197 double *head_x;
5198 double *tail_x;
5199 double *y;
5200 double *a_vec;
5201 double *y_gen;
5202 double *head_x_gen;
5203 double *tail_x_gen;
5204 double *ratios;
5205
5206 /* true result calculated by testgen, in double-double */
5207 double *head_r_true, *tail_r_true;
5208
5209 FPU_FIX_DECL;
5210
5211 if (n < 0)
5212 BLAS_error(fname, -1, n, NULL);
5213 if (ntests < 0)
5214 BLAS_error(fname, -2, ntests, NULL);
5215
5216 /* initialization */
5217 saved_seed = *seed;
5218 ratio = 0.0;
5219 ratio_min = 1e308;
5220 ratio_max = 0.0;
5221
5222 *num_tests = 0;
5223 *num_bad_ratio = 0;
5224 *min_ratio = 0.0;
5225 *max_ratio = 0.0;
5226
5227 if (n == 0)
5228 return;
5229
5230
5231 FPU_FIX_START;
5232
5233 y = (double *) blas_malloc(2 * n * sizeof(double));
5234 if (2 * n > 0 && y == NULL) {
5235 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5236 }
5237 y_gen = (double *) blas_malloc(n * sizeof(double));
5238 if (n > 0 && y_gen == NULL) {
5239 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5240 }
5241 head_x_gen = (double *) blas_malloc(n * sizeof(double));
5242 if (n > 0 && head_x_gen == NULL) {
5243 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5244 }
5245 tail_x_gen = (double *) blas_malloc(n * sizeof(double));
5246 if (n > 0 && tail_x_gen == NULL) {
5247 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5248 }
5249 a = (double *) blas_malloc(2 * n * n * sizeof(double));
5250 if (2 * n * n > 0 && a == NULL) {
5251 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5252 }
5253 head_x = (double *) blas_malloc(2 * n * sizeof(double));
5254 if (2 * n > 0 && head_x == NULL) {
5255 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5256 }
5257 tail_x = (double *) blas_malloc(2 * n * sizeof(double));
5258 if (2 * n > 0 && tail_x == NULL) {
5259 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5260 }
5261 a_vec = (double *) blas_malloc(n * sizeof(double));
5262 if (n > 0 && a_vec == NULL) {
5263 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5264 }
5265 head_r_true = (double *) blas_malloc(n * sizeof(double));
5266 tail_r_true = (double *) blas_malloc(n * sizeof(double));
5267 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
5268 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5269 }
5270 ratios = (double *) blas_malloc(n * sizeof(double));
5271 if (n > 0 && ratios == NULL) {
5272 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5273 }
5274
5275 test_count = 0;
5276 bad_ratio_count = 0;
5277
5278 /* vary alpha */
5279 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
5280
5281 alpha_flag = 0;
5282 switch (alpha_val) {
5283 case 0:
5284 alpha = 0.0;
5285 alpha_flag = 1;
5286 break;
5287 case 1:
5288 alpha = 1.0;
5289 alpha_flag = 1;
5290 break;
5291 }
5292
5293 /* vary beta */
5294 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
5295 beta_flag = 0;
5296 switch (beta_val) {
5297 case 0:
5298 beta = 0.0;
5299 beta_flag = 1;
5300 break;
5301 case 1:
5302 beta = 1.0;
5303 beta_flag = 1;
5304 break;
5305 }
5306
5307
5308 /* varying extra precs */
5309 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
5310 switch (prec_val) {
5311 case 0:
5312 eps_int = power(2, -BITS_D);
5313 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
5314 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
5315 prec = blas_prec_double;
5316 break;
5317 case 1:
5318 eps_int = power(2, -BITS_D);
5319 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
5320 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
5321 prec = blas_prec_double;
5322 break;
5323 case 2:
5324 default:
5325 eps_int = power(2, -BITS_E);
5326 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
5327 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
5328 prec = blas_prec_extra;
5329 break;
5330 }
5331
5332 /* vary norm -- underflow, approx 1, overflow */
5333 for (norm = NORM_START; norm <= NORM_END; norm++) {
5334
5335 /* number of tests */
5336 for (test_no = 0; test_no < ntests; test_no++) {
5337
5338 /* vary storage format */
5339 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
5340
5341 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
5342
5343 /* vary upper / lower variation */
5344 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
5345
5346 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
5347
5348 /* vary lda = n, n+1, 2*n */
5349 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
5350
5351 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
5352
5353 saved_seed = *seed;
5354 /* For the sake of speed, we throw out this case at random */
5355 if (xrand(seed) >= test_prob)
5356 continue;
5357
5358 alpha_flag = 0;
5359 switch (alpha_val) {
5360 case 0:
5361 alpha = 0.0;
5362 alpha_flag = 1;
5363 break;
5364 case 1:
5365 alpha = 1.0;
5366 alpha_flag = 1;
5367 break;
5368 }
5369 beta_flag = 0;
5370 switch (beta_val) {
5371 case 0:
5372 beta = 0.0;
5373 beta_flag = 1;
5374 break;
5375 case 1:
5376 beta = 1.0;
5377 beta_flag = 1;
5378 break;
5379 }
5380
5381 /* finally we are here to generate the test case */
5382 BLAS_dsymv2_testgen(norm, order_type,
5383 uplo_type, n, &alpha, alpha_flag, a,
5384 lda, head_x_gen, tail_x_gen, &beta,
5385 beta_flag, y_gen, seed, head_r_true,
5386 tail_r_true);
5387 test_count++;
5388
5389 /* vary incx = -2, -1, 1, 2 */
5390 for (incx_val = INCX_START; incx_val <= INCX_END;
5391 incx_val++) {
5392
5393 incx = incx_val;
5394 if (0 == incx)
5395 continue;
5396
5397 /* vary incy = -2, -1, 1, 2 */
5398 for (incy_val = INCY_START; incy_val <= INCY_END;
5399 incy_val++) {
5400
5401 incy = incy_val;
5402 if (0 == incy)
5403 continue;
5404
5405 /* copy generated vector with appropriate incs. */
5406 dcopy_vector(y_gen, n, 1, y, incy);
5407 dcopy_vector(head_x_gen, n, 1, head_x, incx);
5408 dcopy_vector(tail_x_gen, n, 1, tail_x, incx);
5409
5410 /* call symv2 routines to be tested */
5411 FPU_FIX_STOP;
5412 BLAS_dsymv2_x(order_type,
5413 uplo_type, n, alpha, a, lda, head_x,
5414 tail_x, incx, beta, y, incy, prec);
5415 FPU_FIX_START;
5416
5417 /* now compute the ratio using test_BLAS_xdot */
5418 /* copy a row from A, use x, run dot test */
5419
5420 incyi = incy;
5421
5422 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
5423
5424 for (i = 0, yi = yi0, ri = 0;
5425 i < n; i++, yi += incyi, ri += incri) {
5426 dsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
5427 i);
5428
5429 /* just use the x vector - it was unchanged (in theory) */
5430 rin = y_gen[i];
5431 rout = y[yi];
5432 head_r_true_elem = head_r_true[ri];
5433 tail_r_true_elem = tail_r_true[ri];
5434
5435 test_BLAS_ddot2(n, blas_no_conj, alpha, beta,
5436 rin, rout, head_r_true_elem,
5437 tail_r_true_elem, a_vec, 1, head_x,
5438 tail_x, incx, eps_int, un_int,
5439 &ratios[i]);
5440
5441 /* take the max ratio */
5442 if (i == 0) {
5443 ratio = ratios[0];
5444
5445 /* The !<= below causes NaN errors to be included.
5446 * Note that (NaN > 0) is false */
5447 } else if (!(ratios[i] <= ratio)) {
5448 ratio = ratios[i];
5449 }
5450
5451 } /* end of dot-test loop */
5452
5453
5454 /* The !<= below causes NaN errors to be included.
5455 * Note that (NaN > 0) is false */
5456 if (!(ratio <= thresh)) {
5457
5458 if (debug == 3) {
5459 printf("\n\t\tTest # %d\n", test_count);
5460 printf("y type : d, a type : d, x type : d\n");
5461 printf("Seed = %d\t", saved_seed);
5462 printf("n %d\n", n);
5463 printf("LDA %d INCX %d INCY %d\n", lda, incx,
5464 incx);
5465
5466 if (order_type == blas_rowmajor)
5467 printf("row ");
5468 else
5469 printf("col ");
5470
5471 if (uplo_type == blas_upper)
5472 printf("upper ");
5473 else
5474 printf("lower ");
5475
5476 printf("NORM %d, ALPHA %d, BETA %d\n",
5477 norm, alpha_val, beta_val);
5478
5479 /* print out info */
5480 printf("alpha = ");
5481 printf("%24.16e", alpha);;
5482 printf(" ");
5483 printf("beta = ");
5484 printf("%24.16e", beta);;
5485 printf("\n");
5486
5487 printf("a\n");
5488 dsy_print_matrix(a, n, lda, order_type, uplo_type);
5489 dprint_vector(head_x, n, incx, "head_x");
5490 dprint_vector(tail_x, n, incx, "tail_x");
5491 dprint_vector(y_gen, n, incy, "y_gen");
5492 dprint_vector(y, n, incy, "y");
5493 dprint_vector(head_r_true, n, 1, "head_r_true");
5494 dprint_vector(ratios, n, 1, "ratios");
5495 printf("ratio = %g\n", ratio);
5496 }
5497 bad_ratio_count++;
5498 if (bad_ratio_count >= MAX_BAD_TESTS) {
5499 printf("\ntoo many failures, exiting....");
5500 printf("\nTesting and compilation");
5501 printf(" are incomplete\n\n");
5502 goto end;
5503 }
5504 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
5505 printf("\nFlagrant ratio error, exiting...");
5506 printf("\nTesting and compilation");
5507 printf(" are incomplete\n\n");
5508 goto end;
5509 }
5510 }
5511
5512 if (!(ratio <= ratio_max))
5513 ratio_max = ratio;
5514
5515 if (ratio != 0.0 && !(ratio >= ratio_min))
5516 ratio_min = ratio;
5517
5518 } /* end of incy loop */
5519
5520 } /* end of incx loop */
5521
5522 } /* end of lda loop */
5523
5524 } /* end of uplo loop */
5525
5526 } /* end of order loop */
5527
5528 } /* end of nr test loop */
5529
5530 } /* end of norm loop */
5531
5532
5533 } /* end of prec loop */
5534
5535 } /* end of beta loop */
5536
5537 } /* end of alpha loop */
5538
5539 end:
5540 FPU_FIX_STOP;
5541
5542 blas_free(y);
5543 blas_free(a);
5544 blas_free(y_gen);
5545 blas_free(head_x);
5546 blas_free(tail_x);
5547 blas_free(head_x_gen);
5548 blas_free(tail_x_gen);
5549 blas_free(head_r_true);
5550 blas_free(tail_r_true);
5551 blas_free(ratios);
5552 blas_free(a_vec);
5553
5554 *max_ratio = ratio_max;
5555 *min_ratio = ratio_min;
5556 *num_tests = test_count;
5557 *num_bad_ratio = bad_ratio_count;
5558
5559 }
do_test_csymv2_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)5560 void do_test_csymv2_x
5561 (int n,
5562 int ntests, int *seed, double thresh, int debug, float test_prob,
5563 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
5564
5565 /* Function name */
5566 const char fname[] = "do_test_csymv2_x";
5567 int i;
5568 int yi;
5569 int incyi, yi0;
5570 int test_count;
5571 int bad_ratio_count;
5572 int ri;
5573 int incri = 1;
5574 int incx, incy;
5575 double ratio;
5576 double ratio_min, ratio_max;
5577 double eps_int; /* internal machine epsilon */
5578 double un_int; /* internal underflow threshold */
5579
5580 float rin[2];
5581 float rout[2];
5582 double head_r_true_elem[2], tail_r_true_elem[2];
5583
5584 enum blas_order_type order_type;
5585 enum blas_uplo_type uplo_type;
5586 enum blas_prec_type prec;
5587
5588 int order_val, uplo_val;
5589 int lda_val, incx_val, incy_val;
5590 int alpha_val, beta_val;
5591
5592 int prec_val;
5593
5594 int lda;
5595 int alpha_flag, beta_flag;
5596 int saved_seed;
5597 int norm;
5598 int test_no;
5599
5600 float alpha[2];
5601 float beta[2];
5602 float *a;
5603 float *head_x;
5604 float *tail_x;
5605 float *y;
5606 float *a_vec;
5607 float *y_gen;
5608 float *head_x_gen;
5609 float *tail_x_gen;
5610 double *ratios;
5611
5612 /* true result calculated by testgen, in double-double */
5613 double *head_r_true, *tail_r_true;
5614
5615
5616 FPU_FIX_DECL;
5617
5618 if (n < 0)
5619 BLAS_error(fname, -1, n, NULL);
5620 if (ntests < 0)
5621 BLAS_error(fname, -2, ntests, NULL);
5622
5623 /* initialization */
5624 saved_seed = *seed;
5625 ratio = 0.0;
5626 ratio_min = 1e308;
5627 ratio_max = 0.0;
5628
5629 *num_tests = 0;
5630 *num_bad_ratio = 0;
5631 *min_ratio = 0.0;
5632 *max_ratio = 0.0;
5633
5634 if (n == 0)
5635 return;
5636 incri *= 2;
5637
5638 FPU_FIX_START;
5639
5640 y = (float *) blas_malloc(2 * n * sizeof(float) * 2);
5641 if (2 * n > 0 && y == NULL) {
5642 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5643 }
5644 y_gen = (float *) blas_malloc(n * sizeof(float) * 2);
5645 if (n > 0 && y_gen == NULL) {
5646 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5647 }
5648 head_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
5649 if (n > 0 && head_x_gen == NULL) {
5650 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5651 }
5652 tail_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
5653 if (n > 0 && tail_x_gen == NULL) {
5654 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5655 }
5656 a = (float *) blas_malloc(2 * n * n * sizeof(float) * 2);
5657 if (2 * n * n > 0 && a == NULL) {
5658 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5659 }
5660 head_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
5661 if (2 * n > 0 && head_x == NULL) {
5662 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5663 }
5664 tail_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
5665 if (2 * n > 0 && tail_x == NULL) {
5666 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5667 }
5668 a_vec = (float *) blas_malloc(n * sizeof(float) * 2);
5669 if (n > 0 && a_vec == NULL) {
5670 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5671 }
5672 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
5673 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
5674 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
5675 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5676 }
5677 ratios = (double *) blas_malloc(n * sizeof(double));
5678 if (n > 0 && ratios == NULL) {
5679 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
5680 }
5681
5682 test_count = 0;
5683 bad_ratio_count = 0;
5684
5685 /* vary alpha */
5686 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
5687
5688 alpha_flag = 0;
5689 switch (alpha_val) {
5690 case 0:
5691 alpha[0] = alpha[1] = 0.0;
5692 alpha_flag = 1;
5693 break;
5694 case 1:
5695 alpha[0] = 1.0;
5696 alpha[1] = 0.0;
5697 alpha_flag = 1;
5698 break;
5699 }
5700
5701 /* vary beta */
5702 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
5703 beta_flag = 0;
5704 switch (beta_val) {
5705 case 0:
5706 beta[0] = beta[1] = 0.0;
5707 beta_flag = 1;
5708 break;
5709 case 1:
5710 beta[0] = 1.0;
5711 beta[1] = 0.0;
5712 beta_flag = 1;
5713 break;
5714 }
5715
5716
5717 /* varying extra precs */
5718 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
5719 switch (prec_val) {
5720 case 0:
5721 eps_int = power(2, -BITS_S);
5722 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_single),
5723 (double) BLAS_fpinfo_x(blas_emin, blas_prec_single));
5724 prec = blas_prec_single;
5725 break;
5726 case 1:
5727 eps_int = power(2, -BITS_D);
5728 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
5729 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
5730 prec = blas_prec_double;
5731 break;
5732 case 2:
5733 default:
5734 eps_int = power(2, -BITS_E);
5735 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
5736 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
5737 prec = blas_prec_extra;
5738 break;
5739 }
5740
5741 /* vary norm -- underflow, approx 1, overflow */
5742 for (norm = NORM_START; norm <= NORM_END; norm++) {
5743
5744 /* number of tests */
5745 for (test_no = 0; test_no < ntests; test_no++) {
5746
5747 /* vary storage format */
5748 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
5749
5750 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
5751
5752 /* vary upper / lower variation */
5753 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
5754
5755 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
5756
5757 /* vary lda = n, n+1, 2*n */
5758 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
5759
5760 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
5761
5762 saved_seed = *seed;
5763 /* For the sake of speed, we throw out this case at random */
5764 if (xrand(seed) >= test_prob)
5765 continue;
5766
5767 alpha_flag = 0;
5768 switch (alpha_val) {
5769 case 0:
5770 alpha[0] = alpha[1] = 0.0;
5771 alpha_flag = 1;
5772 break;
5773 case 1:
5774 alpha[0] = 1.0;
5775 alpha[1] = 0.0;
5776 alpha_flag = 1;
5777 break;
5778 }
5779 beta_flag = 0;
5780 switch (beta_val) {
5781 case 0:
5782 beta[0] = beta[1] = 0.0;
5783 beta_flag = 1;
5784 break;
5785 case 1:
5786 beta[0] = 1.0;
5787 beta[1] = 0.0;
5788 beta_flag = 1;
5789 break;
5790 }
5791
5792 /* finally we are here to generate the test case */
5793 BLAS_csymv2_testgen(norm, order_type,
5794 uplo_type, n, &alpha, alpha_flag, a,
5795 lda, head_x_gen, tail_x_gen, &beta,
5796 beta_flag, y_gen, seed, head_r_true,
5797 tail_r_true);
5798 test_count++;
5799
5800 /* vary incx = -2, -1, 1, 2 */
5801 for (incx_val = INCX_START; incx_val <= INCX_END;
5802 incx_val++) {
5803
5804 incx = incx_val;
5805 if (0 == incx)
5806 continue;
5807
5808 /* vary incy = -2, -1, 1, 2 */
5809 for (incy_val = INCY_START; incy_val <= INCY_END;
5810 incy_val++) {
5811
5812 incy = incy_val;
5813 if (0 == incy)
5814 continue;
5815
5816 /* copy generated vector with appropriate incs. */
5817 ccopy_vector(y_gen, n, 1, y, incy);
5818 ccopy_vector(head_x_gen, n, 1, head_x, incx);
5819 ccopy_vector(tail_x_gen, n, 1, tail_x, incx);
5820
5821 /* call symv2 routines to be tested */
5822 FPU_FIX_STOP;
5823 BLAS_csymv2_x(order_type,
5824 uplo_type, n, alpha, a, lda, head_x,
5825 tail_x, incx, beta, y, incy, prec);
5826 FPU_FIX_START;
5827
5828 /* now compute the ratio using test_BLAS_xdot */
5829 /* copy a row from A, use x, run dot test */
5830
5831 incyi = incy;
5832 incyi *= 2;
5833 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
5834
5835 for (i = 0, yi = yi0, ri = 0;
5836 i < n; i++, yi += incyi, ri += incri) {
5837 csy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
5838 i);
5839
5840 /* just use the x vector - it was unchanged (in theory) */
5841 rin[0] = y_gen[i];
5842 rin[1] = y_gen[i + 1];
5843 rout[0] = y[yi];
5844 rout[1] = y[yi + 1];
5845 head_r_true_elem[0] = head_r_true[ri];
5846 head_r_true_elem[1] = head_r_true[ri + 1];
5847 tail_r_true_elem[0] = tail_r_true[ri];
5848 tail_r_true_elem[1] = tail_r_true[ri + 1];
5849
5850 test_BLAS_cdot2(n, blas_no_conj, alpha, beta,
5851 rin, rout, head_r_true_elem,
5852 tail_r_true_elem, a_vec, 1, head_x,
5853 tail_x, incx, eps_int, un_int,
5854 &ratios[i]);
5855
5856 /* take the max ratio */
5857 if (i == 0) {
5858 ratio = ratios[0];
5859
5860 /* The !<= below causes NaN errors to be included.
5861 * Note that (NaN > 0) is false */
5862 } else if (!(ratios[i] <= ratio)) {
5863 ratio = ratios[i];
5864 }
5865
5866 } /* end of dot-test loop */
5867
5868
5869 /* The !<= below causes NaN errors to be included.
5870 * Note that (NaN > 0) is false */
5871 if (!(ratio <= thresh)) {
5872
5873 if (debug == 3) {
5874 printf("\n\t\tTest # %d\n", test_count);
5875 printf("y type : c, a type : c, x type : c\n");
5876 printf("Seed = %d\t", saved_seed);
5877 printf("n %d\n", n);
5878 printf("LDA %d INCX %d INCY %d\n", lda, incx,
5879 incx);
5880
5881 if (order_type == blas_rowmajor)
5882 printf("row ");
5883 else
5884 printf("col ");
5885
5886 if (uplo_type == blas_upper)
5887 printf("upper ");
5888 else
5889 printf("lower ");
5890
5891 printf("NORM %d, ALPHA %d, BETA %d\n",
5892 norm, alpha_val, beta_val);
5893
5894 /* print out info */
5895 printf("alpha = ");
5896 printf("(%16.8e, %16.8e)", alpha[0], alpha[1]);;
5897 printf(" ");
5898 printf("beta = ");
5899 printf("(%16.8e, %16.8e)", beta[0], beta[1]);;
5900 printf("\n");
5901
5902 printf("a\n");
5903 csy_print_matrix(a, n, lda, order_type, uplo_type);
5904 cprint_vector(head_x, n, incx, "head_x");
5905 cprint_vector(tail_x, n, incx, "tail_x");
5906 cprint_vector(y_gen, n, incy, "y_gen");
5907 cprint_vector(y, n, incy, "y");
5908 zprint_vector(head_r_true, n, 1, "head_r_true");
5909 dprint_vector(ratios, n, 1, "ratios");
5910 printf("ratio = %g\n", ratio);
5911 }
5912 bad_ratio_count++;
5913 if (bad_ratio_count >= MAX_BAD_TESTS) {
5914 printf("\ntoo many failures, exiting....");
5915 printf("\nTesting and compilation");
5916 printf(" are incomplete\n\n");
5917 goto end;
5918 }
5919 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
5920 printf("\nFlagrant ratio error, exiting...");
5921 printf("\nTesting and compilation");
5922 printf(" are incomplete\n\n");
5923 goto end;
5924 }
5925 }
5926
5927 if (!(ratio <= ratio_max))
5928 ratio_max = ratio;
5929
5930 if (ratio != 0.0 && !(ratio >= ratio_min))
5931 ratio_min = ratio;
5932
5933 } /* end of incy loop */
5934
5935 } /* end of incx loop */
5936
5937 } /* end of lda loop */
5938
5939 } /* end of uplo loop */
5940
5941 } /* end of order loop */
5942
5943 } /* end of nr test loop */
5944
5945 } /* end of norm loop */
5946
5947
5948 } /* end of prec loop */
5949
5950 } /* end of beta loop */
5951
5952 } /* end of alpha loop */
5953
5954 end:
5955 FPU_FIX_STOP;
5956
5957 blas_free(y);
5958 blas_free(a);
5959 blas_free(y_gen);
5960 blas_free(head_x);
5961 blas_free(tail_x);
5962 blas_free(head_x_gen);
5963 blas_free(tail_x_gen);
5964 blas_free(head_r_true);
5965 blas_free(tail_r_true);
5966 blas_free(ratios);
5967 blas_free(a_vec);
5968
5969 *max_ratio = ratio_max;
5970 *min_ratio = ratio_min;
5971 *num_tests = test_count;
5972 *num_bad_ratio = bad_ratio_count;
5973
5974 }
do_test_zsymv2_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)5975 void do_test_zsymv2_x
5976 (int n,
5977 int ntests, int *seed, double thresh, int debug, float test_prob,
5978 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
5979
5980 /* Function name */
5981 const char fname[] = "do_test_zsymv2_x";
5982 int i;
5983 int yi;
5984 int incyi, yi0;
5985 int test_count;
5986 int bad_ratio_count;
5987 int ri;
5988 int incri = 1;
5989 int incx, incy;
5990 double ratio;
5991 double ratio_min, ratio_max;
5992 double eps_int; /* internal machine epsilon */
5993 double un_int; /* internal underflow threshold */
5994
5995 double rin[2];
5996 double rout[2];
5997 double head_r_true_elem[2], tail_r_true_elem[2];
5998
5999 enum blas_order_type order_type;
6000 enum blas_uplo_type uplo_type;
6001 enum blas_prec_type prec;
6002
6003 int order_val, uplo_val;
6004 int lda_val, incx_val, incy_val;
6005 int alpha_val, beta_val;
6006
6007 int prec_val;
6008
6009 int lda;
6010 int alpha_flag, beta_flag;
6011 int saved_seed;
6012 int norm;
6013 int test_no;
6014
6015 double alpha[2];
6016 double beta[2];
6017 double *a;
6018 double *head_x;
6019 double *tail_x;
6020 double *y;
6021 double *a_vec;
6022 double *y_gen;
6023 double *head_x_gen;
6024 double *tail_x_gen;
6025 double *ratios;
6026
6027 /* true result calculated by testgen, in double-double */
6028 double *head_r_true, *tail_r_true;
6029
6030
6031 FPU_FIX_DECL;
6032
6033 if (n < 0)
6034 BLAS_error(fname, -1, n, NULL);
6035 if (ntests < 0)
6036 BLAS_error(fname, -2, ntests, NULL);
6037
6038 /* initialization */
6039 saved_seed = *seed;
6040 ratio = 0.0;
6041 ratio_min = 1e308;
6042 ratio_max = 0.0;
6043
6044 *num_tests = 0;
6045 *num_bad_ratio = 0;
6046 *min_ratio = 0.0;
6047 *max_ratio = 0.0;
6048
6049 if (n == 0)
6050 return;
6051 incri *= 2;
6052
6053 FPU_FIX_START;
6054
6055 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
6056 if (2 * n > 0 && y == NULL) {
6057 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6058 }
6059 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
6060 if (n > 0 && y_gen == NULL) {
6061 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6062 }
6063 head_x_gen = (double *) blas_malloc(n * sizeof(double) * 2);
6064 if (n > 0 && head_x_gen == NULL) {
6065 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6066 }
6067 tail_x_gen = (double *) blas_malloc(n * sizeof(double) * 2);
6068 if (n > 0 && tail_x_gen == NULL) {
6069 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6070 }
6071 a = (double *) blas_malloc(2 * n * n * sizeof(double) * 2);
6072 if (2 * n * n > 0 && a == NULL) {
6073 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6074 }
6075 head_x = (double *) blas_malloc(2 * n * sizeof(double) * 2);
6076 if (2 * n > 0 && head_x == NULL) {
6077 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6078 }
6079 tail_x = (double *) blas_malloc(2 * n * sizeof(double) * 2);
6080 if (2 * n > 0 && tail_x == NULL) {
6081 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6082 }
6083 a_vec = (double *) blas_malloc(n * sizeof(double) * 2);
6084 if (n > 0 && a_vec == NULL) {
6085 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6086 }
6087 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
6088 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
6089 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
6090 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6091 }
6092 ratios = (double *) blas_malloc(n * sizeof(double));
6093 if (n > 0 && ratios == NULL) {
6094 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6095 }
6096
6097 test_count = 0;
6098 bad_ratio_count = 0;
6099
6100 /* vary alpha */
6101 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
6102
6103 alpha_flag = 0;
6104 switch (alpha_val) {
6105 case 0:
6106 alpha[0] = alpha[1] = 0.0;
6107 alpha_flag = 1;
6108 break;
6109 case 1:
6110 alpha[0] = 1.0;
6111 alpha[1] = 0.0;
6112 alpha_flag = 1;
6113 break;
6114 }
6115
6116 /* vary beta */
6117 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
6118 beta_flag = 0;
6119 switch (beta_val) {
6120 case 0:
6121 beta[0] = beta[1] = 0.0;
6122 beta_flag = 1;
6123 break;
6124 case 1:
6125 beta[0] = 1.0;
6126 beta[1] = 0.0;
6127 beta_flag = 1;
6128 break;
6129 }
6130
6131
6132 /* varying extra precs */
6133 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
6134 switch (prec_val) {
6135 case 0:
6136 eps_int = power(2, -BITS_D);
6137 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
6138 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
6139 prec = blas_prec_double;
6140 break;
6141 case 1:
6142 eps_int = power(2, -BITS_D);
6143 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
6144 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
6145 prec = blas_prec_double;
6146 break;
6147 case 2:
6148 default:
6149 eps_int = power(2, -BITS_E);
6150 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
6151 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
6152 prec = blas_prec_extra;
6153 break;
6154 }
6155
6156 /* vary norm -- underflow, approx 1, overflow */
6157 for (norm = NORM_START; norm <= NORM_END; norm++) {
6158
6159 /* number of tests */
6160 for (test_no = 0; test_no < ntests; test_no++) {
6161
6162 /* vary storage format */
6163 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
6164
6165 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
6166
6167 /* vary upper / lower variation */
6168 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
6169
6170 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
6171
6172 /* vary lda = n, n+1, 2*n */
6173 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
6174
6175 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
6176
6177 saved_seed = *seed;
6178 /* For the sake of speed, we throw out this case at random */
6179 if (xrand(seed) >= test_prob)
6180 continue;
6181
6182 alpha_flag = 0;
6183 switch (alpha_val) {
6184 case 0:
6185 alpha[0] = alpha[1] = 0.0;
6186 alpha_flag = 1;
6187 break;
6188 case 1:
6189 alpha[0] = 1.0;
6190 alpha[1] = 0.0;
6191 alpha_flag = 1;
6192 break;
6193 }
6194 beta_flag = 0;
6195 switch (beta_val) {
6196 case 0:
6197 beta[0] = beta[1] = 0.0;
6198 beta_flag = 1;
6199 break;
6200 case 1:
6201 beta[0] = 1.0;
6202 beta[1] = 0.0;
6203 beta_flag = 1;
6204 break;
6205 }
6206
6207 /* finally we are here to generate the test case */
6208 BLAS_zsymv2_testgen(norm, order_type,
6209 uplo_type, n, &alpha, alpha_flag, a,
6210 lda, head_x_gen, tail_x_gen, &beta,
6211 beta_flag, y_gen, seed, head_r_true,
6212 tail_r_true);
6213 test_count++;
6214
6215 /* vary incx = -2, -1, 1, 2 */
6216 for (incx_val = INCX_START; incx_val <= INCX_END;
6217 incx_val++) {
6218
6219 incx = incx_val;
6220 if (0 == incx)
6221 continue;
6222
6223 /* vary incy = -2, -1, 1, 2 */
6224 for (incy_val = INCY_START; incy_val <= INCY_END;
6225 incy_val++) {
6226
6227 incy = incy_val;
6228 if (0 == incy)
6229 continue;
6230
6231 /* copy generated vector with appropriate incs. */
6232 zcopy_vector(y_gen, n, 1, y, incy);
6233 zcopy_vector(head_x_gen, n, 1, head_x, incx);
6234 zcopy_vector(tail_x_gen, n, 1, tail_x, incx);
6235
6236 /* call symv2 routines to be tested */
6237 FPU_FIX_STOP;
6238 BLAS_zsymv2_x(order_type,
6239 uplo_type, n, alpha, a, lda, head_x,
6240 tail_x, incx, beta, y, incy, prec);
6241 FPU_FIX_START;
6242
6243 /* now compute the ratio using test_BLAS_xdot */
6244 /* copy a row from A, use x, run dot test */
6245
6246 incyi = incy;
6247 incyi *= 2;
6248 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
6249
6250 for (i = 0, yi = yi0, ri = 0;
6251 i < n; i++, yi += incyi, ri += incri) {
6252 zsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
6253 i);
6254
6255 /* just use the x vector - it was unchanged (in theory) */
6256 rin[0] = y_gen[i];
6257 rin[1] = y_gen[i + 1];
6258 rout[0] = y[yi];
6259 rout[1] = y[yi + 1];
6260 head_r_true_elem[0] = head_r_true[ri];
6261 head_r_true_elem[1] = head_r_true[ri + 1];
6262 tail_r_true_elem[0] = tail_r_true[ri];
6263 tail_r_true_elem[1] = tail_r_true[ri + 1];
6264
6265 test_BLAS_zdot2(n, blas_no_conj, alpha, beta,
6266 rin, rout, head_r_true_elem,
6267 tail_r_true_elem, a_vec, 1, head_x,
6268 tail_x, incx, eps_int, un_int,
6269 &ratios[i]);
6270
6271 /* take the max ratio */
6272 if (i == 0) {
6273 ratio = ratios[0];
6274
6275 /* The !<= below causes NaN errors to be included.
6276 * Note that (NaN > 0) is false */
6277 } else if (!(ratios[i] <= ratio)) {
6278 ratio = ratios[i];
6279 }
6280
6281 } /* end of dot-test loop */
6282
6283
6284 /* The !<= below causes NaN errors to be included.
6285 * Note that (NaN > 0) is false */
6286 if (!(ratio <= thresh)) {
6287
6288 if (debug == 3) {
6289 printf("\n\t\tTest # %d\n", test_count);
6290 printf("y type : z, a type : z, x type : z\n");
6291 printf("Seed = %d\t", saved_seed);
6292 printf("n %d\n", n);
6293 printf("LDA %d INCX %d INCY %d\n", lda, incx,
6294 incx);
6295
6296 if (order_type == blas_rowmajor)
6297 printf("row ");
6298 else
6299 printf("col ");
6300
6301 if (uplo_type == blas_upper)
6302 printf("upper ");
6303 else
6304 printf("lower ");
6305
6306 printf("NORM %d, ALPHA %d, BETA %d\n",
6307 norm, alpha_val, beta_val);
6308
6309 /* print out info */
6310 printf("alpha = ");
6311 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
6312 printf(" ");
6313 printf("beta = ");
6314 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
6315 printf("\n");
6316
6317 printf("a\n");
6318 zsy_print_matrix(a, n, lda, order_type, uplo_type);
6319 zprint_vector(head_x, n, incx, "head_x");
6320 zprint_vector(tail_x, n, incx, "tail_x");
6321 zprint_vector(y_gen, n, incy, "y_gen");
6322 zprint_vector(y, n, incy, "y");
6323 zprint_vector(head_r_true, n, 1, "head_r_true");
6324 dprint_vector(ratios, n, 1, "ratios");
6325 printf("ratio = %g\n", ratio);
6326 }
6327 bad_ratio_count++;
6328 if (bad_ratio_count >= MAX_BAD_TESTS) {
6329 printf("\ntoo many failures, exiting....");
6330 printf("\nTesting and compilation");
6331 printf(" are incomplete\n\n");
6332 goto end;
6333 }
6334 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
6335 printf("\nFlagrant ratio error, exiting...");
6336 printf("\nTesting and compilation");
6337 printf(" are incomplete\n\n");
6338 goto end;
6339 }
6340 }
6341
6342 if (!(ratio <= ratio_max))
6343 ratio_max = ratio;
6344
6345 if (ratio != 0.0 && !(ratio >= ratio_min))
6346 ratio_min = ratio;
6347
6348 } /* end of incy loop */
6349
6350 } /* end of incx loop */
6351
6352 } /* end of lda loop */
6353
6354 } /* end of uplo loop */
6355
6356 } /* end of order loop */
6357
6358 } /* end of nr test loop */
6359
6360 } /* end of norm loop */
6361
6362
6363 } /* end of prec loop */
6364
6365 } /* end of beta loop */
6366
6367 } /* end of alpha loop */
6368
6369 end:
6370 FPU_FIX_STOP;
6371
6372 blas_free(y);
6373 blas_free(a);
6374 blas_free(y_gen);
6375 blas_free(head_x);
6376 blas_free(tail_x);
6377 blas_free(head_x_gen);
6378 blas_free(tail_x_gen);
6379 blas_free(head_r_true);
6380 blas_free(tail_r_true);
6381 blas_free(ratios);
6382 blas_free(a_vec);
6383
6384 *max_ratio = ratio_max;
6385 *min_ratio = ratio_min;
6386 *num_tests = test_count;
6387 *num_bad_ratio = bad_ratio_count;
6388
6389 }
do_test_dsymv2_d_s_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)6390 void do_test_dsymv2_d_s_x
6391 (int n,
6392 int ntests, int *seed, double thresh, int debug, float test_prob,
6393 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
6394
6395 /* Function name */
6396 const char fname[] = "do_test_dsymv2_d_s_x";
6397 int i;
6398 int yi;
6399 int incyi, yi0;
6400 int test_count;
6401 int bad_ratio_count;
6402 int ri;
6403 int incri = 1;
6404 int incx, incy;
6405 double ratio;
6406 double ratio_min, ratio_max;
6407 double eps_int; /* internal machine epsilon */
6408 double un_int; /* internal underflow threshold */
6409
6410 double rin;
6411 double rout;
6412 double head_r_true_elem, tail_r_true_elem;
6413
6414 enum blas_order_type order_type;
6415 enum blas_uplo_type uplo_type;
6416 enum blas_prec_type prec;
6417
6418 int order_val, uplo_val;
6419 int lda_val, incx_val, incy_val;
6420 int alpha_val, beta_val;
6421
6422 int prec_val;
6423
6424 int lda;
6425 int alpha_flag, beta_flag;
6426 int saved_seed;
6427 int norm;
6428 int test_no;
6429
6430 double alpha;
6431 double beta;
6432 double *a;
6433 float *head_x;
6434 float *tail_x;
6435 double *y;
6436 double *a_vec;
6437 double *y_gen;
6438 float *head_x_gen;
6439 float *tail_x_gen;
6440 double *ratios;
6441
6442 /* true result calculated by testgen, in double-double */
6443 double *head_r_true, *tail_r_true;
6444
6445 FPU_FIX_DECL;
6446
6447 if (n < 0)
6448 BLAS_error(fname, -1, n, NULL);
6449 if (ntests < 0)
6450 BLAS_error(fname, -2, ntests, NULL);
6451
6452 /* initialization */
6453 saved_seed = *seed;
6454 ratio = 0.0;
6455 ratio_min = 1e308;
6456 ratio_max = 0.0;
6457
6458 *num_tests = 0;
6459 *num_bad_ratio = 0;
6460 *min_ratio = 0.0;
6461 *max_ratio = 0.0;
6462
6463 if (n == 0)
6464 return;
6465
6466
6467 FPU_FIX_START;
6468
6469 y = (double *) blas_malloc(2 * n * sizeof(double));
6470 if (2 * n > 0 && y == NULL) {
6471 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6472 }
6473 y_gen = (double *) blas_malloc(n * sizeof(double));
6474 if (n > 0 && y_gen == NULL) {
6475 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6476 }
6477 head_x_gen = (float *) blas_malloc(n * sizeof(float));
6478 if (n > 0 && head_x_gen == NULL) {
6479 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6480 }
6481 tail_x_gen = (float *) blas_malloc(n * sizeof(float));
6482 if (n > 0 && tail_x_gen == NULL) {
6483 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6484 }
6485 a = (double *) blas_malloc(2 * n * n * sizeof(double));
6486 if (2 * n * n > 0 && a == NULL) {
6487 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6488 }
6489 head_x = (float *) blas_malloc(2 * n * sizeof(float));
6490 if (2 * n > 0 && head_x == NULL) {
6491 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6492 }
6493 tail_x = (float *) blas_malloc(2 * n * sizeof(float));
6494 if (2 * n > 0 && tail_x == NULL) {
6495 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6496 }
6497 a_vec = (double *) blas_malloc(n * sizeof(double));
6498 if (n > 0 && a_vec == NULL) {
6499 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6500 }
6501 head_r_true = (double *) blas_malloc(n * sizeof(double));
6502 tail_r_true = (double *) blas_malloc(n * sizeof(double));
6503 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
6504 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6505 }
6506 ratios = (double *) blas_malloc(n * sizeof(double));
6507 if (n > 0 && ratios == NULL) {
6508 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6509 }
6510
6511 test_count = 0;
6512 bad_ratio_count = 0;
6513
6514 /* vary alpha */
6515 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
6516
6517 alpha_flag = 0;
6518 switch (alpha_val) {
6519 case 0:
6520 alpha = 0.0;
6521 alpha_flag = 1;
6522 break;
6523 case 1:
6524 alpha = 1.0;
6525 alpha_flag = 1;
6526 break;
6527 }
6528
6529 /* vary beta */
6530 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
6531 beta_flag = 0;
6532 switch (beta_val) {
6533 case 0:
6534 beta = 0.0;
6535 beta_flag = 1;
6536 break;
6537 case 1:
6538 beta = 1.0;
6539 beta_flag = 1;
6540 break;
6541 }
6542
6543
6544 /* varying extra precs */
6545 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
6546 switch (prec_val) {
6547 case 0:
6548 eps_int = power(2, -BITS_D);
6549 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
6550 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
6551 prec = blas_prec_double;
6552 break;
6553 case 1:
6554 eps_int = power(2, -BITS_D);
6555 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
6556 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
6557 prec = blas_prec_double;
6558 break;
6559 case 2:
6560 default:
6561 eps_int = power(2, -BITS_E);
6562 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
6563 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
6564 prec = blas_prec_extra;
6565 break;
6566 }
6567
6568 /* vary norm -- underflow, approx 1, overflow */
6569 for (norm = NORM_START; norm <= NORM_END; norm++) {
6570
6571 /* number of tests */
6572 for (test_no = 0; test_no < ntests; test_no++) {
6573
6574 /* vary storage format */
6575 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
6576
6577 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
6578
6579 /* vary upper / lower variation */
6580 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
6581
6582 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
6583
6584 /* vary lda = n, n+1, 2*n */
6585 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
6586
6587 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
6588
6589 saved_seed = *seed;
6590 /* For the sake of speed, we throw out this case at random */
6591 if (xrand(seed) >= test_prob)
6592 continue;
6593
6594 alpha_flag = 0;
6595 switch (alpha_val) {
6596 case 0:
6597 alpha = 0.0;
6598 alpha_flag = 1;
6599 break;
6600 case 1:
6601 alpha = 1.0;
6602 alpha_flag = 1;
6603 break;
6604 }
6605 beta_flag = 0;
6606 switch (beta_val) {
6607 case 0:
6608 beta = 0.0;
6609 beta_flag = 1;
6610 break;
6611 case 1:
6612 beta = 1.0;
6613 beta_flag = 1;
6614 break;
6615 }
6616
6617 /* finally we are here to generate the test case */
6618 BLAS_dsymv2_d_s_testgen(norm, order_type,
6619 uplo_type, n, &alpha, alpha_flag, a,
6620 lda, head_x_gen, tail_x_gen, &beta,
6621 beta_flag, y_gen, seed, head_r_true,
6622 tail_r_true);
6623 test_count++;
6624
6625 /* vary incx = -2, -1, 1, 2 */
6626 for (incx_val = INCX_START; incx_val <= INCX_END;
6627 incx_val++) {
6628
6629 incx = incx_val;
6630 if (0 == incx)
6631 continue;
6632
6633 /* vary incy = -2, -1, 1, 2 */
6634 for (incy_val = INCY_START; incy_val <= INCY_END;
6635 incy_val++) {
6636
6637 incy = incy_val;
6638 if (0 == incy)
6639 continue;
6640
6641 /* copy generated vector with appropriate incs. */
6642 dcopy_vector(y_gen, n, 1, y, incy);
6643 scopy_vector(head_x_gen, n, 1, head_x, incx);
6644 scopy_vector(tail_x_gen, n, 1, tail_x, incx);
6645
6646 /* call symv2 routines to be tested */
6647 FPU_FIX_STOP;
6648 BLAS_dsymv2_d_s_x(order_type,
6649 uplo_type, n, alpha, a, lda, head_x,
6650 tail_x, incx, beta, y, incy, prec);
6651 FPU_FIX_START;
6652
6653 /* now compute the ratio using test_BLAS_xdot */
6654 /* copy a row from A, use x, run dot test */
6655
6656 incyi = incy;
6657
6658 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
6659
6660 for (i = 0, yi = yi0, ri = 0;
6661 i < n; i++, yi += incyi, ri += incri) {
6662 dsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
6663 i);
6664
6665 /* just use the x vector - it was unchanged (in theory) */
6666 rin = y_gen[i];
6667 rout = y[yi];
6668 head_r_true_elem = head_r_true[ri];
6669 tail_r_true_elem = tail_r_true[ri];
6670
6671 test_BLAS_ddot2_d_s(n, blas_no_conj, alpha, beta,
6672 rin, rout, head_r_true_elem,
6673 tail_r_true_elem, a_vec, 1,
6674 head_x, tail_x, incx, eps_int,
6675 un_int, &ratios[i]);
6676
6677 /* take the max ratio */
6678 if (i == 0) {
6679 ratio = ratios[0];
6680
6681 /* The !<= below causes NaN errors to be included.
6682 * Note that (NaN > 0) is false */
6683 } else if (!(ratios[i] <= ratio)) {
6684 ratio = ratios[i];
6685 }
6686
6687 } /* end of dot-test loop */
6688
6689
6690 /* The !<= below causes NaN errors to be included.
6691 * Note that (NaN > 0) is false */
6692 if (!(ratio <= thresh)) {
6693
6694 if (debug == 3) {
6695 printf("\n\t\tTest # %d\n", test_count);
6696 printf("y type : d, a type : d, x type : s\n");
6697 printf("Seed = %d\t", saved_seed);
6698 printf("n %d\n", n);
6699 printf("LDA %d INCX %d INCY %d\n", lda, incx,
6700 incx);
6701
6702 if (order_type == blas_rowmajor)
6703 printf("row ");
6704 else
6705 printf("col ");
6706
6707 if (uplo_type == blas_upper)
6708 printf("upper ");
6709 else
6710 printf("lower ");
6711
6712 printf("NORM %d, ALPHA %d, BETA %d\n",
6713 norm, alpha_val, beta_val);
6714
6715 /* print out info */
6716 printf("alpha = ");
6717 printf("%24.16e", alpha);;
6718 printf(" ");
6719 printf("beta = ");
6720 printf("%24.16e", beta);;
6721 printf("\n");
6722
6723 printf("a\n");
6724 dsy_print_matrix(a, n, lda, order_type, uplo_type);
6725 sprint_vector(head_x, n, incx, "head_x");
6726 sprint_vector(tail_x, n, incx, "tail_x");
6727 dprint_vector(y_gen, n, incy, "y_gen");
6728 dprint_vector(y, n, incy, "y");
6729 dprint_vector(head_r_true, n, 1, "head_r_true");
6730 dprint_vector(ratios, n, 1, "ratios");
6731 printf("ratio = %g\n", ratio);
6732 }
6733 bad_ratio_count++;
6734 if (bad_ratio_count >= MAX_BAD_TESTS) {
6735 printf("\ntoo many failures, exiting....");
6736 printf("\nTesting and compilation");
6737 printf(" are incomplete\n\n");
6738 goto end;
6739 }
6740 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
6741 printf("\nFlagrant ratio error, exiting...");
6742 printf("\nTesting and compilation");
6743 printf(" are incomplete\n\n");
6744 goto end;
6745 }
6746 }
6747
6748 if (!(ratio <= ratio_max))
6749 ratio_max = ratio;
6750
6751 if (ratio != 0.0 && !(ratio >= ratio_min))
6752 ratio_min = ratio;
6753
6754 } /* end of incy loop */
6755
6756 } /* end of incx loop */
6757
6758 } /* end of lda loop */
6759
6760 } /* end of uplo loop */
6761
6762 } /* end of order loop */
6763
6764 } /* end of nr test loop */
6765
6766 } /* end of norm loop */
6767
6768
6769 } /* end of prec loop */
6770
6771 } /* end of beta loop */
6772
6773 } /* end of alpha loop */
6774
6775 end:
6776 FPU_FIX_STOP;
6777
6778 blas_free(y);
6779 blas_free(a);
6780 blas_free(y_gen);
6781 blas_free(head_x);
6782 blas_free(tail_x);
6783 blas_free(head_x_gen);
6784 blas_free(tail_x_gen);
6785 blas_free(head_r_true);
6786 blas_free(tail_r_true);
6787 blas_free(ratios);
6788 blas_free(a_vec);
6789
6790 *max_ratio = ratio_max;
6791 *min_ratio = ratio_min;
6792 *num_tests = test_count;
6793 *num_bad_ratio = bad_ratio_count;
6794
6795 }
do_test_dsymv2_s_d_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)6796 void do_test_dsymv2_s_d_x
6797 (int n,
6798 int ntests, int *seed, double thresh, int debug, float test_prob,
6799 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
6800
6801 /* Function name */
6802 const char fname[] = "do_test_dsymv2_s_d_x";
6803 int i;
6804 int yi;
6805 int incyi, yi0;
6806 int test_count;
6807 int bad_ratio_count;
6808 int ri;
6809 int incri = 1;
6810 int incx, incy;
6811 double ratio;
6812 double ratio_min, ratio_max;
6813 double eps_int; /* internal machine epsilon */
6814 double un_int; /* internal underflow threshold */
6815
6816 double rin;
6817 double rout;
6818 double head_r_true_elem, tail_r_true_elem;
6819
6820 enum blas_order_type order_type;
6821 enum blas_uplo_type uplo_type;
6822 enum blas_prec_type prec;
6823
6824 int order_val, uplo_val;
6825 int lda_val, incx_val, incy_val;
6826 int alpha_val, beta_val;
6827
6828 int prec_val;
6829
6830 int lda;
6831 int alpha_flag, beta_flag;
6832 int saved_seed;
6833 int norm;
6834 int test_no;
6835
6836 double alpha;
6837 double beta;
6838 float *a;
6839 double *head_x;
6840 double *tail_x;
6841 double *y;
6842 float *a_vec;
6843 double *y_gen;
6844 double *head_x_gen;
6845 double *tail_x_gen;
6846 double *ratios;
6847
6848 /* true result calculated by testgen, in double-double */
6849 double *head_r_true, *tail_r_true;
6850
6851 FPU_FIX_DECL;
6852
6853 if (n < 0)
6854 BLAS_error(fname, -1, n, NULL);
6855 if (ntests < 0)
6856 BLAS_error(fname, -2, ntests, NULL);
6857
6858 /* initialization */
6859 saved_seed = *seed;
6860 ratio = 0.0;
6861 ratio_min = 1e308;
6862 ratio_max = 0.0;
6863
6864 *num_tests = 0;
6865 *num_bad_ratio = 0;
6866 *min_ratio = 0.0;
6867 *max_ratio = 0.0;
6868
6869 if (n == 0)
6870 return;
6871
6872
6873 FPU_FIX_START;
6874
6875 y = (double *) blas_malloc(2 * n * sizeof(double));
6876 if (2 * n > 0 && y == NULL) {
6877 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6878 }
6879 y_gen = (double *) blas_malloc(n * sizeof(double));
6880 if (n > 0 && y_gen == NULL) {
6881 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6882 }
6883 head_x_gen = (double *) blas_malloc(n * sizeof(double));
6884 if (n > 0 && head_x_gen == NULL) {
6885 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6886 }
6887 tail_x_gen = (double *) blas_malloc(n * sizeof(double));
6888 if (n > 0 && tail_x_gen == NULL) {
6889 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6890 }
6891 a = (float *) blas_malloc(2 * n * n * sizeof(float));
6892 if (2 * n * n > 0 && a == NULL) {
6893 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6894 }
6895 head_x = (double *) blas_malloc(2 * n * sizeof(double));
6896 if (2 * n > 0 && head_x == NULL) {
6897 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6898 }
6899 tail_x = (double *) blas_malloc(2 * n * sizeof(double));
6900 if (2 * n > 0 && tail_x == NULL) {
6901 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6902 }
6903 a_vec = (float *) blas_malloc(n * sizeof(float));
6904 if (n > 0 && a_vec == NULL) {
6905 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6906 }
6907 head_r_true = (double *) blas_malloc(n * sizeof(double));
6908 tail_r_true = (double *) blas_malloc(n * sizeof(double));
6909 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
6910 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6911 }
6912 ratios = (double *) blas_malloc(n * sizeof(double));
6913 if (n > 0 && ratios == NULL) {
6914 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
6915 }
6916
6917 test_count = 0;
6918 bad_ratio_count = 0;
6919
6920 /* vary alpha */
6921 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
6922
6923 alpha_flag = 0;
6924 switch (alpha_val) {
6925 case 0:
6926 alpha = 0.0;
6927 alpha_flag = 1;
6928 break;
6929 case 1:
6930 alpha = 1.0;
6931 alpha_flag = 1;
6932 break;
6933 }
6934
6935 /* vary beta */
6936 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
6937 beta_flag = 0;
6938 switch (beta_val) {
6939 case 0:
6940 beta = 0.0;
6941 beta_flag = 1;
6942 break;
6943 case 1:
6944 beta = 1.0;
6945 beta_flag = 1;
6946 break;
6947 }
6948
6949
6950 /* varying extra precs */
6951 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
6952 switch (prec_val) {
6953 case 0:
6954 eps_int = power(2, -BITS_D);
6955 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
6956 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
6957 prec = blas_prec_double;
6958 break;
6959 case 1:
6960 eps_int = power(2, -BITS_D);
6961 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
6962 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
6963 prec = blas_prec_double;
6964 break;
6965 case 2:
6966 default:
6967 eps_int = power(2, -BITS_E);
6968 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
6969 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
6970 prec = blas_prec_extra;
6971 break;
6972 }
6973
6974 /* vary norm -- underflow, approx 1, overflow */
6975 for (norm = NORM_START; norm <= NORM_END; norm++) {
6976
6977 /* number of tests */
6978 for (test_no = 0; test_no < ntests; test_no++) {
6979
6980 /* vary storage format */
6981 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
6982
6983 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
6984
6985 /* vary upper / lower variation */
6986 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
6987
6988 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
6989
6990 /* vary lda = n, n+1, 2*n */
6991 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
6992
6993 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
6994
6995 saved_seed = *seed;
6996 /* For the sake of speed, we throw out this case at random */
6997 if (xrand(seed) >= test_prob)
6998 continue;
6999
7000 alpha_flag = 0;
7001 switch (alpha_val) {
7002 case 0:
7003 alpha = 0.0;
7004 alpha_flag = 1;
7005 break;
7006 case 1:
7007 alpha = 1.0;
7008 alpha_flag = 1;
7009 break;
7010 }
7011 beta_flag = 0;
7012 switch (beta_val) {
7013 case 0:
7014 beta = 0.0;
7015 beta_flag = 1;
7016 break;
7017 case 1:
7018 beta = 1.0;
7019 beta_flag = 1;
7020 break;
7021 }
7022
7023 /* finally we are here to generate the test case */
7024 BLAS_dsymv2_s_d_testgen(norm, order_type,
7025 uplo_type, n, &alpha, alpha_flag, a,
7026 lda, head_x_gen, tail_x_gen, &beta,
7027 beta_flag, y_gen, seed, head_r_true,
7028 tail_r_true);
7029 test_count++;
7030
7031 /* vary incx = -2, -1, 1, 2 */
7032 for (incx_val = INCX_START; incx_val <= INCX_END;
7033 incx_val++) {
7034
7035 incx = incx_val;
7036 if (0 == incx)
7037 continue;
7038
7039 /* vary incy = -2, -1, 1, 2 */
7040 for (incy_val = INCY_START; incy_val <= INCY_END;
7041 incy_val++) {
7042
7043 incy = incy_val;
7044 if (0 == incy)
7045 continue;
7046
7047 /* copy generated vector with appropriate incs. */
7048 dcopy_vector(y_gen, n, 1, y, incy);
7049 dcopy_vector(head_x_gen, n, 1, head_x, incx);
7050 dcopy_vector(tail_x_gen, n, 1, tail_x, incx);
7051
7052 /* call symv2 routines to be tested */
7053 FPU_FIX_STOP;
7054 BLAS_dsymv2_s_d_x(order_type,
7055 uplo_type, n, alpha, a, lda, head_x,
7056 tail_x, incx, beta, y, incy, prec);
7057 FPU_FIX_START;
7058
7059 /* now compute the ratio using test_BLAS_xdot */
7060 /* copy a row from A, use x, run dot test */
7061
7062 incyi = incy;
7063
7064 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
7065
7066 for (i = 0, yi = yi0, ri = 0;
7067 i < n; i++, yi += incyi, ri += incri) {
7068 ssy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
7069 i);
7070
7071 /* just use the x vector - it was unchanged (in theory) */
7072 rin = y_gen[i];
7073 rout = y[yi];
7074 head_r_true_elem = head_r_true[ri];
7075 tail_r_true_elem = tail_r_true[ri];
7076
7077 test_BLAS_ddot2_s_d(n, blas_no_conj, alpha, beta,
7078 rin, rout, head_r_true_elem,
7079 tail_r_true_elem, a_vec, 1,
7080 head_x, tail_x, incx, eps_int,
7081 un_int, &ratios[i]);
7082
7083 /* take the max ratio */
7084 if (i == 0) {
7085 ratio = ratios[0];
7086
7087 /* The !<= below causes NaN errors to be included.
7088 * Note that (NaN > 0) is false */
7089 } else if (!(ratios[i] <= ratio)) {
7090 ratio = ratios[i];
7091 }
7092
7093 } /* end of dot-test loop */
7094
7095
7096 /* The !<= below causes NaN errors to be included.
7097 * Note that (NaN > 0) is false */
7098 if (!(ratio <= thresh)) {
7099
7100 if (debug == 3) {
7101 printf("\n\t\tTest # %d\n", test_count);
7102 printf("y type : d, a type : s, x type : d\n");
7103 printf("Seed = %d\t", saved_seed);
7104 printf("n %d\n", n);
7105 printf("LDA %d INCX %d INCY %d\n", lda, incx,
7106 incx);
7107
7108 if (order_type == blas_rowmajor)
7109 printf("row ");
7110 else
7111 printf("col ");
7112
7113 if (uplo_type == blas_upper)
7114 printf("upper ");
7115 else
7116 printf("lower ");
7117
7118 printf("NORM %d, ALPHA %d, BETA %d\n",
7119 norm, alpha_val, beta_val);
7120
7121 /* print out info */
7122 printf("alpha = ");
7123 printf("%24.16e", alpha);;
7124 printf(" ");
7125 printf("beta = ");
7126 printf("%24.16e", beta);;
7127 printf("\n");
7128
7129 printf("a\n");
7130 ssy_print_matrix(a, n, lda, order_type, uplo_type);
7131 dprint_vector(head_x, n, incx, "head_x");
7132 dprint_vector(tail_x, n, incx, "tail_x");
7133 dprint_vector(y_gen, n, incy, "y_gen");
7134 dprint_vector(y, n, incy, "y");
7135 dprint_vector(head_r_true, n, 1, "head_r_true");
7136 dprint_vector(ratios, n, 1, "ratios");
7137 printf("ratio = %g\n", ratio);
7138 }
7139 bad_ratio_count++;
7140 if (bad_ratio_count >= MAX_BAD_TESTS) {
7141 printf("\ntoo many failures, exiting....");
7142 printf("\nTesting and compilation");
7143 printf(" are incomplete\n\n");
7144 goto end;
7145 }
7146 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
7147 printf("\nFlagrant ratio error, exiting...");
7148 printf("\nTesting and compilation");
7149 printf(" are incomplete\n\n");
7150 goto end;
7151 }
7152 }
7153
7154 if (!(ratio <= ratio_max))
7155 ratio_max = ratio;
7156
7157 if (ratio != 0.0 && !(ratio >= ratio_min))
7158 ratio_min = ratio;
7159
7160 } /* end of incy loop */
7161
7162 } /* end of incx loop */
7163
7164 } /* end of lda loop */
7165
7166 } /* end of uplo loop */
7167
7168 } /* end of order loop */
7169
7170 } /* end of nr test loop */
7171
7172 } /* end of norm loop */
7173
7174
7175 } /* end of prec loop */
7176
7177 } /* end of beta loop */
7178
7179 } /* end of alpha loop */
7180
7181 end:
7182 FPU_FIX_STOP;
7183
7184 blas_free(y);
7185 blas_free(a);
7186 blas_free(y_gen);
7187 blas_free(head_x);
7188 blas_free(tail_x);
7189 blas_free(head_x_gen);
7190 blas_free(tail_x_gen);
7191 blas_free(head_r_true);
7192 blas_free(tail_r_true);
7193 blas_free(ratios);
7194 blas_free(a_vec);
7195
7196 *max_ratio = ratio_max;
7197 *min_ratio = ratio_min;
7198 *num_tests = test_count;
7199 *num_bad_ratio = bad_ratio_count;
7200
7201 }
do_test_dsymv2_s_s_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)7202 void do_test_dsymv2_s_s_x
7203 (int n,
7204 int ntests, int *seed, double thresh, int debug, float test_prob,
7205 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
7206
7207 /* Function name */
7208 const char fname[] = "do_test_dsymv2_s_s_x";
7209 int i;
7210 int yi;
7211 int incyi, yi0;
7212 int test_count;
7213 int bad_ratio_count;
7214 int ri;
7215 int incri = 1;
7216 int incx, incy;
7217 double ratio;
7218 double ratio_min, ratio_max;
7219 double eps_int; /* internal machine epsilon */
7220 double un_int; /* internal underflow threshold */
7221
7222 double rin;
7223 double rout;
7224 double head_r_true_elem, tail_r_true_elem;
7225
7226 enum blas_order_type order_type;
7227 enum blas_uplo_type uplo_type;
7228 enum blas_prec_type prec;
7229
7230 int order_val, uplo_val;
7231 int lda_val, incx_val, incy_val;
7232 int alpha_val, beta_val;
7233
7234 int prec_val;
7235
7236 int lda;
7237 int alpha_flag, beta_flag;
7238 int saved_seed;
7239 int norm;
7240 int test_no;
7241
7242 double alpha;
7243 double beta;
7244 float *a;
7245 float *head_x;
7246 float *tail_x;
7247 double *y;
7248 float *a_vec;
7249 double *y_gen;
7250 float *head_x_gen;
7251 float *tail_x_gen;
7252 double *ratios;
7253
7254 /* true result calculated by testgen, in double-double */
7255 double *head_r_true, *tail_r_true;
7256
7257 FPU_FIX_DECL;
7258
7259 if (n < 0)
7260 BLAS_error(fname, -1, n, NULL);
7261 if (ntests < 0)
7262 BLAS_error(fname, -2, ntests, NULL);
7263
7264 /* initialization */
7265 saved_seed = *seed;
7266 ratio = 0.0;
7267 ratio_min = 1e308;
7268 ratio_max = 0.0;
7269
7270 *num_tests = 0;
7271 *num_bad_ratio = 0;
7272 *min_ratio = 0.0;
7273 *max_ratio = 0.0;
7274
7275 if (n == 0)
7276 return;
7277
7278
7279 FPU_FIX_START;
7280
7281 y = (double *) blas_malloc(2 * n * sizeof(double));
7282 if (2 * n > 0 && y == NULL) {
7283 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7284 }
7285 y_gen = (double *) blas_malloc(n * sizeof(double));
7286 if (n > 0 && y_gen == NULL) {
7287 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7288 }
7289 head_x_gen = (float *) blas_malloc(n * sizeof(float));
7290 if (n > 0 && head_x_gen == NULL) {
7291 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7292 }
7293 tail_x_gen = (float *) blas_malloc(n * sizeof(float));
7294 if (n > 0 && tail_x_gen == NULL) {
7295 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7296 }
7297 a = (float *) blas_malloc(2 * n * n * sizeof(float));
7298 if (2 * n * n > 0 && a == NULL) {
7299 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7300 }
7301 head_x = (float *) blas_malloc(2 * n * sizeof(float));
7302 if (2 * n > 0 && head_x == NULL) {
7303 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7304 }
7305 tail_x = (float *) blas_malloc(2 * n * sizeof(float));
7306 if (2 * n > 0 && tail_x == NULL) {
7307 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7308 }
7309 a_vec = (float *) blas_malloc(n * sizeof(float));
7310 if (n > 0 && a_vec == NULL) {
7311 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7312 }
7313 head_r_true = (double *) blas_malloc(n * sizeof(double));
7314 tail_r_true = (double *) blas_malloc(n * sizeof(double));
7315 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
7316 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7317 }
7318 ratios = (double *) blas_malloc(n * sizeof(double));
7319 if (n > 0 && ratios == NULL) {
7320 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7321 }
7322
7323 test_count = 0;
7324 bad_ratio_count = 0;
7325
7326 /* vary alpha */
7327 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
7328
7329 alpha_flag = 0;
7330 switch (alpha_val) {
7331 case 0:
7332 alpha = 0.0;
7333 alpha_flag = 1;
7334 break;
7335 case 1:
7336 alpha = 1.0;
7337 alpha_flag = 1;
7338 break;
7339 }
7340
7341 /* vary beta */
7342 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
7343 beta_flag = 0;
7344 switch (beta_val) {
7345 case 0:
7346 beta = 0.0;
7347 beta_flag = 1;
7348 break;
7349 case 1:
7350 beta = 1.0;
7351 beta_flag = 1;
7352 break;
7353 }
7354
7355
7356 /* varying extra precs */
7357 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
7358 switch (prec_val) {
7359 case 0:
7360 eps_int = power(2, -BITS_D);
7361 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
7362 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
7363 prec = blas_prec_double;
7364 break;
7365 case 1:
7366 eps_int = power(2, -BITS_D);
7367 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
7368 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
7369 prec = blas_prec_double;
7370 break;
7371 case 2:
7372 default:
7373 eps_int = power(2, -BITS_E);
7374 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
7375 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
7376 prec = blas_prec_extra;
7377 break;
7378 }
7379
7380 /* vary norm -- underflow, approx 1, overflow */
7381 for (norm = NORM_START; norm <= NORM_END; norm++) {
7382
7383 /* number of tests */
7384 for (test_no = 0; test_no < ntests; test_no++) {
7385
7386 /* vary storage format */
7387 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
7388
7389 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
7390
7391 /* vary upper / lower variation */
7392 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
7393
7394 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
7395
7396 /* vary lda = n, n+1, 2*n */
7397 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
7398
7399 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
7400
7401 saved_seed = *seed;
7402 /* For the sake of speed, we throw out this case at random */
7403 if (xrand(seed) >= test_prob)
7404 continue;
7405
7406 alpha_flag = 0;
7407 switch (alpha_val) {
7408 case 0:
7409 alpha = 0.0;
7410 alpha_flag = 1;
7411 break;
7412 case 1:
7413 alpha = 1.0;
7414 alpha_flag = 1;
7415 break;
7416 }
7417 beta_flag = 0;
7418 switch (beta_val) {
7419 case 0:
7420 beta = 0.0;
7421 beta_flag = 1;
7422 break;
7423 case 1:
7424 beta = 1.0;
7425 beta_flag = 1;
7426 break;
7427 }
7428
7429 /* finally we are here to generate the test case */
7430 BLAS_dsymv2_s_s_testgen(norm, order_type,
7431 uplo_type, n, &alpha, alpha_flag, a,
7432 lda, head_x_gen, tail_x_gen, &beta,
7433 beta_flag, y_gen, seed, head_r_true,
7434 tail_r_true);
7435 test_count++;
7436
7437 /* vary incx = -2, -1, 1, 2 */
7438 for (incx_val = INCX_START; incx_val <= INCX_END;
7439 incx_val++) {
7440
7441 incx = incx_val;
7442 if (0 == incx)
7443 continue;
7444
7445 /* vary incy = -2, -1, 1, 2 */
7446 for (incy_val = INCY_START; incy_val <= INCY_END;
7447 incy_val++) {
7448
7449 incy = incy_val;
7450 if (0 == incy)
7451 continue;
7452
7453 /* copy generated vector with appropriate incs. */
7454 dcopy_vector(y_gen, n, 1, y, incy);
7455 scopy_vector(head_x_gen, n, 1, head_x, incx);
7456 scopy_vector(tail_x_gen, n, 1, tail_x, incx);
7457
7458 /* call symv2 routines to be tested */
7459 FPU_FIX_STOP;
7460 BLAS_dsymv2_s_s_x(order_type,
7461 uplo_type, n, alpha, a, lda, head_x,
7462 tail_x, incx, beta, y, incy, prec);
7463 FPU_FIX_START;
7464
7465 /* now compute the ratio using test_BLAS_xdot */
7466 /* copy a row from A, use x, run dot test */
7467
7468 incyi = incy;
7469
7470 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
7471
7472 for (i = 0, yi = yi0, ri = 0;
7473 i < n; i++, yi += incyi, ri += incri) {
7474 ssy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
7475 i);
7476
7477 /* just use the x vector - it was unchanged (in theory) */
7478 rin = y_gen[i];
7479 rout = y[yi];
7480 head_r_true_elem = head_r_true[ri];
7481 tail_r_true_elem = tail_r_true[ri];
7482
7483 test_BLAS_ddot2_s_s(n, blas_no_conj, alpha, beta,
7484 rin, rout, head_r_true_elem,
7485 tail_r_true_elem, a_vec, 1,
7486 head_x, tail_x, incx, eps_int,
7487 un_int, &ratios[i]);
7488
7489 /* take the max ratio */
7490 if (i == 0) {
7491 ratio = ratios[0];
7492
7493 /* The !<= below causes NaN errors to be included.
7494 * Note that (NaN > 0) is false */
7495 } else if (!(ratios[i] <= ratio)) {
7496 ratio = ratios[i];
7497 }
7498
7499 } /* end of dot-test loop */
7500
7501
7502 /* The !<= below causes NaN errors to be included.
7503 * Note that (NaN > 0) is false */
7504 if (!(ratio <= thresh)) {
7505
7506 if (debug == 3) {
7507 printf("\n\t\tTest # %d\n", test_count);
7508 printf("y type : d, a type : s, x type : s\n");
7509 printf("Seed = %d\t", saved_seed);
7510 printf("n %d\n", n);
7511 printf("LDA %d INCX %d INCY %d\n", lda, incx,
7512 incx);
7513
7514 if (order_type == blas_rowmajor)
7515 printf("row ");
7516 else
7517 printf("col ");
7518
7519 if (uplo_type == blas_upper)
7520 printf("upper ");
7521 else
7522 printf("lower ");
7523
7524 printf("NORM %d, ALPHA %d, BETA %d\n",
7525 norm, alpha_val, beta_val);
7526
7527 /* print out info */
7528 printf("alpha = ");
7529 printf("%24.16e", alpha);;
7530 printf(" ");
7531 printf("beta = ");
7532 printf("%24.16e", beta);;
7533 printf("\n");
7534
7535 printf("a\n");
7536 ssy_print_matrix(a, n, lda, order_type, uplo_type);
7537 sprint_vector(head_x, n, incx, "head_x");
7538 sprint_vector(tail_x, n, incx, "tail_x");
7539 dprint_vector(y_gen, n, incy, "y_gen");
7540 dprint_vector(y, n, incy, "y");
7541 dprint_vector(head_r_true, n, 1, "head_r_true");
7542 dprint_vector(ratios, n, 1, "ratios");
7543 printf("ratio = %g\n", ratio);
7544 }
7545 bad_ratio_count++;
7546 if (bad_ratio_count >= MAX_BAD_TESTS) {
7547 printf("\ntoo many failures, exiting....");
7548 printf("\nTesting and compilation");
7549 printf(" are incomplete\n\n");
7550 goto end;
7551 }
7552 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
7553 printf("\nFlagrant ratio error, exiting...");
7554 printf("\nTesting and compilation");
7555 printf(" are incomplete\n\n");
7556 goto end;
7557 }
7558 }
7559
7560 if (!(ratio <= ratio_max))
7561 ratio_max = ratio;
7562
7563 if (ratio != 0.0 && !(ratio >= ratio_min))
7564 ratio_min = ratio;
7565
7566 } /* end of incy loop */
7567
7568 } /* end of incx loop */
7569
7570 } /* end of lda loop */
7571
7572 } /* end of uplo loop */
7573
7574 } /* end of order loop */
7575
7576 } /* end of nr test loop */
7577
7578 } /* end of norm loop */
7579
7580
7581 } /* end of prec loop */
7582
7583 } /* end of beta loop */
7584
7585 } /* end of alpha loop */
7586
7587 end:
7588 FPU_FIX_STOP;
7589
7590 blas_free(y);
7591 blas_free(a);
7592 blas_free(y_gen);
7593 blas_free(head_x);
7594 blas_free(tail_x);
7595 blas_free(head_x_gen);
7596 blas_free(tail_x_gen);
7597 blas_free(head_r_true);
7598 blas_free(tail_r_true);
7599 blas_free(ratios);
7600 blas_free(a_vec);
7601
7602 *max_ratio = ratio_max;
7603 *min_ratio = ratio_min;
7604 *num_tests = test_count;
7605 *num_bad_ratio = bad_ratio_count;
7606
7607 }
do_test_zsymv2_z_c_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)7608 void do_test_zsymv2_z_c_x
7609 (int n,
7610 int ntests, int *seed, double thresh, int debug, float test_prob,
7611 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
7612
7613 /* Function name */
7614 const char fname[] = "do_test_zsymv2_z_c_x";
7615 int i;
7616 int yi;
7617 int incyi, yi0;
7618 int test_count;
7619 int bad_ratio_count;
7620 int ri;
7621 int incri = 1;
7622 int incx, incy;
7623 double ratio;
7624 double ratio_min, ratio_max;
7625 double eps_int; /* internal machine epsilon */
7626 double un_int; /* internal underflow threshold */
7627
7628 double rin[2];
7629 double rout[2];
7630 double head_r_true_elem[2], tail_r_true_elem[2];
7631
7632 enum blas_order_type order_type;
7633 enum blas_uplo_type uplo_type;
7634 enum blas_prec_type prec;
7635
7636 int order_val, uplo_val;
7637 int lda_val, incx_val, incy_val;
7638 int alpha_val, beta_val;
7639
7640 int prec_val;
7641
7642 int lda;
7643 int alpha_flag, beta_flag;
7644 int saved_seed;
7645 int norm;
7646 int test_no;
7647
7648 double alpha[2];
7649 double beta[2];
7650 double *a;
7651 float *head_x;
7652 float *tail_x;
7653 double *y;
7654 double *a_vec;
7655 double *y_gen;
7656 float *head_x_gen;
7657 float *tail_x_gen;
7658 double *ratios;
7659
7660 /* true result calculated by testgen, in double-double */
7661 double *head_r_true, *tail_r_true;
7662
7663
7664 FPU_FIX_DECL;
7665
7666 if (n < 0)
7667 BLAS_error(fname, -1, n, NULL);
7668 if (ntests < 0)
7669 BLAS_error(fname, -2, ntests, NULL);
7670
7671 /* initialization */
7672 saved_seed = *seed;
7673 ratio = 0.0;
7674 ratio_min = 1e308;
7675 ratio_max = 0.0;
7676
7677 *num_tests = 0;
7678 *num_bad_ratio = 0;
7679 *min_ratio = 0.0;
7680 *max_ratio = 0.0;
7681
7682 if (n == 0)
7683 return;
7684 incri *= 2;
7685
7686 FPU_FIX_START;
7687
7688 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
7689 if (2 * n > 0 && y == NULL) {
7690 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7691 }
7692 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
7693 if (n > 0 && y_gen == NULL) {
7694 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7695 }
7696 head_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
7697 if (n > 0 && head_x_gen == NULL) {
7698 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7699 }
7700 tail_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
7701 if (n > 0 && tail_x_gen == NULL) {
7702 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7703 }
7704 a = (double *) blas_malloc(2 * n * n * sizeof(double) * 2);
7705 if (2 * n * n > 0 && a == NULL) {
7706 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7707 }
7708 head_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
7709 if (2 * n > 0 && head_x == NULL) {
7710 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7711 }
7712 tail_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
7713 if (2 * n > 0 && tail_x == NULL) {
7714 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7715 }
7716 a_vec = (double *) blas_malloc(n * sizeof(double) * 2);
7717 if (n > 0 && a_vec == NULL) {
7718 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7719 }
7720 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
7721 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
7722 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
7723 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7724 }
7725 ratios = (double *) blas_malloc(n * sizeof(double));
7726 if (n > 0 && ratios == NULL) {
7727 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
7728 }
7729
7730 test_count = 0;
7731 bad_ratio_count = 0;
7732
7733 /* vary alpha */
7734 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
7735
7736 alpha_flag = 0;
7737 switch (alpha_val) {
7738 case 0:
7739 alpha[0] = alpha[1] = 0.0;
7740 alpha_flag = 1;
7741 break;
7742 case 1:
7743 alpha[0] = 1.0;
7744 alpha[1] = 0.0;
7745 alpha_flag = 1;
7746 break;
7747 }
7748
7749 /* vary beta */
7750 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
7751 beta_flag = 0;
7752 switch (beta_val) {
7753 case 0:
7754 beta[0] = beta[1] = 0.0;
7755 beta_flag = 1;
7756 break;
7757 case 1:
7758 beta[0] = 1.0;
7759 beta[1] = 0.0;
7760 beta_flag = 1;
7761 break;
7762 }
7763
7764
7765 /* varying extra precs */
7766 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
7767 switch (prec_val) {
7768 case 0:
7769 eps_int = power(2, -BITS_D);
7770 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
7771 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
7772 prec = blas_prec_double;
7773 break;
7774 case 1:
7775 eps_int = power(2, -BITS_D);
7776 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
7777 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
7778 prec = blas_prec_double;
7779 break;
7780 case 2:
7781 default:
7782 eps_int = power(2, -BITS_E);
7783 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
7784 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
7785 prec = blas_prec_extra;
7786 break;
7787 }
7788
7789 /* vary norm -- underflow, approx 1, overflow */
7790 for (norm = NORM_START; norm <= NORM_END; norm++) {
7791
7792 /* number of tests */
7793 for (test_no = 0; test_no < ntests; test_no++) {
7794
7795 /* vary storage format */
7796 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
7797
7798 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
7799
7800 /* vary upper / lower variation */
7801 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
7802
7803 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
7804
7805 /* vary lda = n, n+1, 2*n */
7806 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
7807
7808 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
7809
7810 saved_seed = *seed;
7811 /* For the sake of speed, we throw out this case at random */
7812 if (xrand(seed) >= test_prob)
7813 continue;
7814
7815 alpha_flag = 0;
7816 switch (alpha_val) {
7817 case 0:
7818 alpha[0] = alpha[1] = 0.0;
7819 alpha_flag = 1;
7820 break;
7821 case 1:
7822 alpha[0] = 1.0;
7823 alpha[1] = 0.0;
7824 alpha_flag = 1;
7825 break;
7826 }
7827 beta_flag = 0;
7828 switch (beta_val) {
7829 case 0:
7830 beta[0] = beta[1] = 0.0;
7831 beta_flag = 1;
7832 break;
7833 case 1:
7834 beta[0] = 1.0;
7835 beta[1] = 0.0;
7836 beta_flag = 1;
7837 break;
7838 }
7839
7840 /* finally we are here to generate the test case */
7841 BLAS_zsymv2_z_c_testgen(norm, order_type,
7842 uplo_type, n, &alpha, alpha_flag, a,
7843 lda, head_x_gen, tail_x_gen, &beta,
7844 beta_flag, y_gen, seed, head_r_true,
7845 tail_r_true);
7846 test_count++;
7847
7848 /* vary incx = -2, -1, 1, 2 */
7849 for (incx_val = INCX_START; incx_val <= INCX_END;
7850 incx_val++) {
7851
7852 incx = incx_val;
7853 if (0 == incx)
7854 continue;
7855
7856 /* vary incy = -2, -1, 1, 2 */
7857 for (incy_val = INCY_START; incy_val <= INCY_END;
7858 incy_val++) {
7859
7860 incy = incy_val;
7861 if (0 == incy)
7862 continue;
7863
7864 /* copy generated vector with appropriate incs. */
7865 zcopy_vector(y_gen, n, 1, y, incy);
7866 ccopy_vector(head_x_gen, n, 1, head_x, incx);
7867 ccopy_vector(tail_x_gen, n, 1, tail_x, incx);
7868
7869 /* call symv2 routines to be tested */
7870 FPU_FIX_STOP;
7871 BLAS_zsymv2_z_c_x(order_type,
7872 uplo_type, n, alpha, a, lda, head_x,
7873 tail_x, incx, beta, y, incy, prec);
7874 FPU_FIX_START;
7875
7876 /* now compute the ratio using test_BLAS_xdot */
7877 /* copy a row from A, use x, run dot test */
7878
7879 incyi = incy;
7880 incyi *= 2;
7881 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
7882
7883 for (i = 0, yi = yi0, ri = 0;
7884 i < n; i++, yi += incyi, ri += incri) {
7885 zsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
7886 i);
7887
7888 /* just use the x vector - it was unchanged (in theory) */
7889 rin[0] = y_gen[i];
7890 rin[1] = y_gen[i + 1];
7891 rout[0] = y[yi];
7892 rout[1] = y[yi + 1];
7893 head_r_true_elem[0] = head_r_true[ri];
7894 head_r_true_elem[1] = head_r_true[ri + 1];
7895 tail_r_true_elem[0] = tail_r_true[ri];
7896 tail_r_true_elem[1] = tail_r_true[ri + 1];
7897
7898 test_BLAS_zdot2_z_c(n, blas_no_conj, alpha, beta,
7899 rin, rout, head_r_true_elem,
7900 tail_r_true_elem, a_vec, 1,
7901 head_x, tail_x, incx, eps_int,
7902 un_int, &ratios[i]);
7903
7904 /* take the max ratio */
7905 if (i == 0) {
7906 ratio = ratios[0];
7907
7908 /* The !<= below causes NaN errors to be included.
7909 * Note that (NaN > 0) is false */
7910 } else if (!(ratios[i] <= ratio)) {
7911 ratio = ratios[i];
7912 }
7913
7914 } /* end of dot-test loop */
7915
7916
7917 /* The !<= below causes NaN errors to be included.
7918 * Note that (NaN > 0) is false */
7919 if (!(ratio <= thresh)) {
7920
7921 if (debug == 3) {
7922 printf("\n\t\tTest # %d\n", test_count);
7923 printf("y type : z, a type : z, x type : c\n");
7924 printf("Seed = %d\t", saved_seed);
7925 printf("n %d\n", n);
7926 printf("LDA %d INCX %d INCY %d\n", lda, incx,
7927 incx);
7928
7929 if (order_type == blas_rowmajor)
7930 printf("row ");
7931 else
7932 printf("col ");
7933
7934 if (uplo_type == blas_upper)
7935 printf("upper ");
7936 else
7937 printf("lower ");
7938
7939 printf("NORM %d, ALPHA %d, BETA %d\n",
7940 norm, alpha_val, beta_val);
7941
7942 /* print out info */
7943 printf("alpha = ");
7944 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
7945 printf(" ");
7946 printf("beta = ");
7947 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
7948 printf("\n");
7949
7950 printf("a\n");
7951 zsy_print_matrix(a, n, lda, order_type, uplo_type);
7952 cprint_vector(head_x, n, incx, "head_x");
7953 cprint_vector(tail_x, n, incx, "tail_x");
7954 zprint_vector(y_gen, n, incy, "y_gen");
7955 zprint_vector(y, n, incy, "y");
7956 zprint_vector(head_r_true, n, 1, "head_r_true");
7957 dprint_vector(ratios, n, 1, "ratios");
7958 printf("ratio = %g\n", ratio);
7959 }
7960 bad_ratio_count++;
7961 if (bad_ratio_count >= MAX_BAD_TESTS) {
7962 printf("\ntoo many failures, exiting....");
7963 printf("\nTesting and compilation");
7964 printf(" are incomplete\n\n");
7965 goto end;
7966 }
7967 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
7968 printf("\nFlagrant ratio error, exiting...");
7969 printf("\nTesting and compilation");
7970 printf(" are incomplete\n\n");
7971 goto end;
7972 }
7973 }
7974
7975 if (!(ratio <= ratio_max))
7976 ratio_max = ratio;
7977
7978 if (ratio != 0.0 && !(ratio >= ratio_min))
7979 ratio_min = ratio;
7980
7981 } /* end of incy loop */
7982
7983 } /* end of incx loop */
7984
7985 } /* end of lda loop */
7986
7987 } /* end of uplo loop */
7988
7989 } /* end of order loop */
7990
7991 } /* end of nr test loop */
7992
7993 } /* end of norm loop */
7994
7995
7996 } /* end of prec loop */
7997
7998 } /* end of beta loop */
7999
8000 } /* end of alpha loop */
8001
8002 end:
8003 FPU_FIX_STOP;
8004
8005 blas_free(y);
8006 blas_free(a);
8007 blas_free(y_gen);
8008 blas_free(head_x);
8009 blas_free(tail_x);
8010 blas_free(head_x_gen);
8011 blas_free(tail_x_gen);
8012 blas_free(head_r_true);
8013 blas_free(tail_r_true);
8014 blas_free(ratios);
8015 blas_free(a_vec);
8016
8017 *max_ratio = ratio_max;
8018 *min_ratio = ratio_min;
8019 *num_tests = test_count;
8020 *num_bad_ratio = bad_ratio_count;
8021
8022 }
do_test_zsymv2_c_z_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)8023 void do_test_zsymv2_c_z_x
8024 (int n,
8025 int ntests, int *seed, double thresh, int debug, float test_prob,
8026 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
8027
8028 /* Function name */
8029 const char fname[] = "do_test_zsymv2_c_z_x";
8030 int i;
8031 int yi;
8032 int incyi, yi0;
8033 int test_count;
8034 int bad_ratio_count;
8035 int ri;
8036 int incri = 1;
8037 int incx, incy;
8038 double ratio;
8039 double ratio_min, ratio_max;
8040 double eps_int; /* internal machine epsilon */
8041 double un_int; /* internal underflow threshold */
8042
8043 double rin[2];
8044 double rout[2];
8045 double head_r_true_elem[2], tail_r_true_elem[2];
8046
8047 enum blas_order_type order_type;
8048 enum blas_uplo_type uplo_type;
8049 enum blas_prec_type prec;
8050
8051 int order_val, uplo_val;
8052 int lda_val, incx_val, incy_val;
8053 int alpha_val, beta_val;
8054
8055 int prec_val;
8056
8057 int lda;
8058 int alpha_flag, beta_flag;
8059 int saved_seed;
8060 int norm;
8061 int test_no;
8062
8063 double alpha[2];
8064 double beta[2];
8065 float *a;
8066 double *head_x;
8067 double *tail_x;
8068 double *y;
8069 float *a_vec;
8070 double *y_gen;
8071 double *head_x_gen;
8072 double *tail_x_gen;
8073 double *ratios;
8074
8075 /* true result calculated by testgen, in double-double */
8076 double *head_r_true, *tail_r_true;
8077
8078
8079 FPU_FIX_DECL;
8080
8081 if (n < 0)
8082 BLAS_error(fname, -1, n, NULL);
8083 if (ntests < 0)
8084 BLAS_error(fname, -2, ntests, NULL);
8085
8086 /* initialization */
8087 saved_seed = *seed;
8088 ratio = 0.0;
8089 ratio_min = 1e308;
8090 ratio_max = 0.0;
8091
8092 *num_tests = 0;
8093 *num_bad_ratio = 0;
8094 *min_ratio = 0.0;
8095 *max_ratio = 0.0;
8096
8097 if (n == 0)
8098 return;
8099 incri *= 2;
8100
8101 FPU_FIX_START;
8102
8103 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
8104 if (2 * n > 0 && y == NULL) {
8105 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8106 }
8107 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
8108 if (n > 0 && y_gen == NULL) {
8109 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8110 }
8111 head_x_gen = (double *) blas_malloc(n * sizeof(double) * 2);
8112 if (n > 0 && head_x_gen == NULL) {
8113 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8114 }
8115 tail_x_gen = (double *) blas_malloc(n * sizeof(double) * 2);
8116 if (n > 0 && tail_x_gen == NULL) {
8117 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8118 }
8119 a = (float *) blas_malloc(2 * n * n * sizeof(float) * 2);
8120 if (2 * n * n > 0 && a == NULL) {
8121 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8122 }
8123 head_x = (double *) blas_malloc(2 * n * sizeof(double) * 2);
8124 if (2 * n > 0 && head_x == NULL) {
8125 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8126 }
8127 tail_x = (double *) blas_malloc(2 * n * sizeof(double) * 2);
8128 if (2 * n > 0 && tail_x == NULL) {
8129 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8130 }
8131 a_vec = (float *) blas_malloc(n * sizeof(float) * 2);
8132 if (n > 0 && a_vec == NULL) {
8133 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8134 }
8135 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
8136 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
8137 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
8138 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8139 }
8140 ratios = (double *) blas_malloc(n * sizeof(double));
8141 if (n > 0 && ratios == NULL) {
8142 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8143 }
8144
8145 test_count = 0;
8146 bad_ratio_count = 0;
8147
8148 /* vary alpha */
8149 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
8150
8151 alpha_flag = 0;
8152 switch (alpha_val) {
8153 case 0:
8154 alpha[0] = alpha[1] = 0.0;
8155 alpha_flag = 1;
8156 break;
8157 case 1:
8158 alpha[0] = 1.0;
8159 alpha[1] = 0.0;
8160 alpha_flag = 1;
8161 break;
8162 }
8163
8164 /* vary beta */
8165 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
8166 beta_flag = 0;
8167 switch (beta_val) {
8168 case 0:
8169 beta[0] = beta[1] = 0.0;
8170 beta_flag = 1;
8171 break;
8172 case 1:
8173 beta[0] = 1.0;
8174 beta[1] = 0.0;
8175 beta_flag = 1;
8176 break;
8177 }
8178
8179
8180 /* varying extra precs */
8181 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
8182 switch (prec_val) {
8183 case 0:
8184 eps_int = power(2, -BITS_D);
8185 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
8186 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
8187 prec = blas_prec_double;
8188 break;
8189 case 1:
8190 eps_int = power(2, -BITS_D);
8191 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
8192 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
8193 prec = blas_prec_double;
8194 break;
8195 case 2:
8196 default:
8197 eps_int = power(2, -BITS_E);
8198 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
8199 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
8200 prec = blas_prec_extra;
8201 break;
8202 }
8203
8204 /* vary norm -- underflow, approx 1, overflow */
8205 for (norm = NORM_START; norm <= NORM_END; norm++) {
8206
8207 /* number of tests */
8208 for (test_no = 0; test_no < ntests; test_no++) {
8209
8210 /* vary storage format */
8211 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
8212
8213 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
8214
8215 /* vary upper / lower variation */
8216 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
8217
8218 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
8219
8220 /* vary lda = n, n+1, 2*n */
8221 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
8222
8223 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
8224
8225 saved_seed = *seed;
8226 /* For the sake of speed, we throw out this case at random */
8227 if (xrand(seed) >= test_prob)
8228 continue;
8229
8230 alpha_flag = 0;
8231 switch (alpha_val) {
8232 case 0:
8233 alpha[0] = alpha[1] = 0.0;
8234 alpha_flag = 1;
8235 break;
8236 case 1:
8237 alpha[0] = 1.0;
8238 alpha[1] = 0.0;
8239 alpha_flag = 1;
8240 break;
8241 }
8242 beta_flag = 0;
8243 switch (beta_val) {
8244 case 0:
8245 beta[0] = beta[1] = 0.0;
8246 beta_flag = 1;
8247 break;
8248 case 1:
8249 beta[0] = 1.0;
8250 beta[1] = 0.0;
8251 beta_flag = 1;
8252 break;
8253 }
8254
8255 /* finally we are here to generate the test case */
8256 BLAS_zsymv2_c_z_testgen(norm, order_type,
8257 uplo_type, n, &alpha, alpha_flag, a,
8258 lda, head_x_gen, tail_x_gen, &beta,
8259 beta_flag, y_gen, seed, head_r_true,
8260 tail_r_true);
8261 test_count++;
8262
8263 /* vary incx = -2, -1, 1, 2 */
8264 for (incx_val = INCX_START; incx_val <= INCX_END;
8265 incx_val++) {
8266
8267 incx = incx_val;
8268 if (0 == incx)
8269 continue;
8270
8271 /* vary incy = -2, -1, 1, 2 */
8272 for (incy_val = INCY_START; incy_val <= INCY_END;
8273 incy_val++) {
8274
8275 incy = incy_val;
8276 if (0 == incy)
8277 continue;
8278
8279 /* copy generated vector with appropriate incs. */
8280 zcopy_vector(y_gen, n, 1, y, incy);
8281 zcopy_vector(head_x_gen, n, 1, head_x, incx);
8282 zcopy_vector(tail_x_gen, n, 1, tail_x, incx);
8283
8284 /* call symv2 routines to be tested */
8285 FPU_FIX_STOP;
8286 BLAS_zsymv2_c_z_x(order_type,
8287 uplo_type, n, alpha, a, lda, head_x,
8288 tail_x, incx, beta, y, incy, prec);
8289 FPU_FIX_START;
8290
8291 /* now compute the ratio using test_BLAS_xdot */
8292 /* copy a row from A, use x, run dot test */
8293
8294 incyi = incy;
8295 incyi *= 2;
8296 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
8297
8298 for (i = 0, yi = yi0, ri = 0;
8299 i < n; i++, yi += incyi, ri += incri) {
8300 csy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
8301 i);
8302
8303 /* just use the x vector - it was unchanged (in theory) */
8304 rin[0] = y_gen[i];
8305 rin[1] = y_gen[i + 1];
8306 rout[0] = y[yi];
8307 rout[1] = y[yi + 1];
8308 head_r_true_elem[0] = head_r_true[ri];
8309 head_r_true_elem[1] = head_r_true[ri + 1];
8310 tail_r_true_elem[0] = tail_r_true[ri];
8311 tail_r_true_elem[1] = tail_r_true[ri + 1];
8312
8313 test_BLAS_zdot2_c_z(n, blas_no_conj, alpha, beta,
8314 rin, rout, head_r_true_elem,
8315 tail_r_true_elem, a_vec, 1,
8316 head_x, tail_x, incx, eps_int,
8317 un_int, &ratios[i]);
8318
8319 /* take the max ratio */
8320 if (i == 0) {
8321 ratio = ratios[0];
8322
8323 /* The !<= below causes NaN errors to be included.
8324 * Note that (NaN > 0) is false */
8325 } else if (!(ratios[i] <= ratio)) {
8326 ratio = ratios[i];
8327 }
8328
8329 } /* end of dot-test loop */
8330
8331
8332 /* The !<= below causes NaN errors to be included.
8333 * Note that (NaN > 0) is false */
8334 if (!(ratio <= thresh)) {
8335
8336 if (debug == 3) {
8337 printf("\n\t\tTest # %d\n", test_count);
8338 printf("y type : z, a type : c, x type : z\n");
8339 printf("Seed = %d\t", saved_seed);
8340 printf("n %d\n", n);
8341 printf("LDA %d INCX %d INCY %d\n", lda, incx,
8342 incx);
8343
8344 if (order_type == blas_rowmajor)
8345 printf("row ");
8346 else
8347 printf("col ");
8348
8349 if (uplo_type == blas_upper)
8350 printf("upper ");
8351 else
8352 printf("lower ");
8353
8354 printf("NORM %d, ALPHA %d, BETA %d\n",
8355 norm, alpha_val, beta_val);
8356
8357 /* print out info */
8358 printf("alpha = ");
8359 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
8360 printf(" ");
8361 printf("beta = ");
8362 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
8363 printf("\n");
8364
8365 printf("a\n");
8366 csy_print_matrix(a, n, lda, order_type, uplo_type);
8367 zprint_vector(head_x, n, incx, "head_x");
8368 zprint_vector(tail_x, n, incx, "tail_x");
8369 zprint_vector(y_gen, n, incy, "y_gen");
8370 zprint_vector(y, n, incy, "y");
8371 zprint_vector(head_r_true, n, 1, "head_r_true");
8372 dprint_vector(ratios, n, 1, "ratios");
8373 printf("ratio = %g\n", ratio);
8374 }
8375 bad_ratio_count++;
8376 if (bad_ratio_count >= MAX_BAD_TESTS) {
8377 printf("\ntoo many failures, exiting....");
8378 printf("\nTesting and compilation");
8379 printf(" are incomplete\n\n");
8380 goto end;
8381 }
8382 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
8383 printf("\nFlagrant ratio error, exiting...");
8384 printf("\nTesting and compilation");
8385 printf(" are incomplete\n\n");
8386 goto end;
8387 }
8388 }
8389
8390 if (!(ratio <= ratio_max))
8391 ratio_max = ratio;
8392
8393 if (ratio != 0.0 && !(ratio >= ratio_min))
8394 ratio_min = ratio;
8395
8396 } /* end of incy loop */
8397
8398 } /* end of incx loop */
8399
8400 } /* end of lda loop */
8401
8402 } /* end of uplo loop */
8403
8404 } /* end of order loop */
8405
8406 } /* end of nr test loop */
8407
8408 } /* end of norm loop */
8409
8410
8411 } /* end of prec loop */
8412
8413 } /* end of beta loop */
8414
8415 } /* end of alpha loop */
8416
8417 end:
8418 FPU_FIX_STOP;
8419
8420 blas_free(y);
8421 blas_free(a);
8422 blas_free(y_gen);
8423 blas_free(head_x);
8424 blas_free(tail_x);
8425 blas_free(head_x_gen);
8426 blas_free(tail_x_gen);
8427 blas_free(head_r_true);
8428 blas_free(tail_r_true);
8429 blas_free(ratios);
8430 blas_free(a_vec);
8431
8432 *max_ratio = ratio_max;
8433 *min_ratio = ratio_min;
8434 *num_tests = test_count;
8435 *num_bad_ratio = bad_ratio_count;
8436
8437 }
do_test_zsymv2_c_c_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)8438 void do_test_zsymv2_c_c_x
8439 (int n,
8440 int ntests, int *seed, double thresh, int debug, float test_prob,
8441 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
8442
8443 /* Function name */
8444 const char fname[] = "do_test_zsymv2_c_c_x";
8445 int i;
8446 int yi;
8447 int incyi, yi0;
8448 int test_count;
8449 int bad_ratio_count;
8450 int ri;
8451 int incri = 1;
8452 int incx, incy;
8453 double ratio;
8454 double ratio_min, ratio_max;
8455 double eps_int; /* internal machine epsilon */
8456 double un_int; /* internal underflow threshold */
8457
8458 double rin[2];
8459 double rout[2];
8460 double head_r_true_elem[2], tail_r_true_elem[2];
8461
8462 enum blas_order_type order_type;
8463 enum blas_uplo_type uplo_type;
8464 enum blas_prec_type prec;
8465
8466 int order_val, uplo_val;
8467 int lda_val, incx_val, incy_val;
8468 int alpha_val, beta_val;
8469
8470 int prec_val;
8471
8472 int lda;
8473 int alpha_flag, beta_flag;
8474 int saved_seed;
8475 int norm;
8476 int test_no;
8477
8478 double alpha[2];
8479 double beta[2];
8480 float *a;
8481 float *head_x;
8482 float *tail_x;
8483 double *y;
8484 float *a_vec;
8485 double *y_gen;
8486 float *head_x_gen;
8487 float *tail_x_gen;
8488 double *ratios;
8489
8490 /* true result calculated by testgen, in double-double */
8491 double *head_r_true, *tail_r_true;
8492
8493
8494 FPU_FIX_DECL;
8495
8496 if (n < 0)
8497 BLAS_error(fname, -1, n, NULL);
8498 if (ntests < 0)
8499 BLAS_error(fname, -2, ntests, NULL);
8500
8501 /* initialization */
8502 saved_seed = *seed;
8503 ratio = 0.0;
8504 ratio_min = 1e308;
8505 ratio_max = 0.0;
8506
8507 *num_tests = 0;
8508 *num_bad_ratio = 0;
8509 *min_ratio = 0.0;
8510 *max_ratio = 0.0;
8511
8512 if (n == 0)
8513 return;
8514 incri *= 2;
8515
8516 FPU_FIX_START;
8517
8518 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
8519 if (2 * n > 0 && y == NULL) {
8520 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8521 }
8522 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
8523 if (n > 0 && y_gen == NULL) {
8524 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8525 }
8526 head_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
8527 if (n > 0 && head_x_gen == NULL) {
8528 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8529 }
8530 tail_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
8531 if (n > 0 && tail_x_gen == NULL) {
8532 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8533 }
8534 a = (float *) blas_malloc(2 * n * n * sizeof(float) * 2);
8535 if (2 * n * n > 0 && a == NULL) {
8536 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8537 }
8538 head_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
8539 if (2 * n > 0 && head_x == NULL) {
8540 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8541 }
8542 tail_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
8543 if (2 * n > 0 && tail_x == NULL) {
8544 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8545 }
8546 a_vec = (float *) blas_malloc(n * sizeof(float) * 2);
8547 if (n > 0 && a_vec == NULL) {
8548 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8549 }
8550 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
8551 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
8552 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
8553 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8554 }
8555 ratios = (double *) blas_malloc(n * sizeof(double));
8556 if (n > 0 && ratios == NULL) {
8557 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8558 }
8559
8560 test_count = 0;
8561 bad_ratio_count = 0;
8562
8563 /* vary alpha */
8564 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
8565
8566 alpha_flag = 0;
8567 switch (alpha_val) {
8568 case 0:
8569 alpha[0] = alpha[1] = 0.0;
8570 alpha_flag = 1;
8571 break;
8572 case 1:
8573 alpha[0] = 1.0;
8574 alpha[1] = 0.0;
8575 alpha_flag = 1;
8576 break;
8577 }
8578
8579 /* vary beta */
8580 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
8581 beta_flag = 0;
8582 switch (beta_val) {
8583 case 0:
8584 beta[0] = beta[1] = 0.0;
8585 beta_flag = 1;
8586 break;
8587 case 1:
8588 beta[0] = 1.0;
8589 beta[1] = 0.0;
8590 beta_flag = 1;
8591 break;
8592 }
8593
8594
8595 /* varying extra precs */
8596 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
8597 switch (prec_val) {
8598 case 0:
8599 eps_int = power(2, -BITS_D);
8600 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
8601 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
8602 prec = blas_prec_double;
8603 break;
8604 case 1:
8605 eps_int = power(2, -BITS_D);
8606 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
8607 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
8608 prec = blas_prec_double;
8609 break;
8610 case 2:
8611 default:
8612 eps_int = power(2, -BITS_E);
8613 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
8614 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
8615 prec = blas_prec_extra;
8616 break;
8617 }
8618
8619 /* vary norm -- underflow, approx 1, overflow */
8620 for (norm = NORM_START; norm <= NORM_END; norm++) {
8621
8622 /* number of tests */
8623 for (test_no = 0; test_no < ntests; test_no++) {
8624
8625 /* vary storage format */
8626 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
8627
8628 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
8629
8630 /* vary upper / lower variation */
8631 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
8632
8633 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
8634
8635 /* vary lda = n, n+1, 2*n */
8636 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
8637
8638 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
8639
8640 saved_seed = *seed;
8641 /* For the sake of speed, we throw out this case at random */
8642 if (xrand(seed) >= test_prob)
8643 continue;
8644
8645 alpha_flag = 0;
8646 switch (alpha_val) {
8647 case 0:
8648 alpha[0] = alpha[1] = 0.0;
8649 alpha_flag = 1;
8650 break;
8651 case 1:
8652 alpha[0] = 1.0;
8653 alpha[1] = 0.0;
8654 alpha_flag = 1;
8655 break;
8656 }
8657 beta_flag = 0;
8658 switch (beta_val) {
8659 case 0:
8660 beta[0] = beta[1] = 0.0;
8661 beta_flag = 1;
8662 break;
8663 case 1:
8664 beta[0] = 1.0;
8665 beta[1] = 0.0;
8666 beta_flag = 1;
8667 break;
8668 }
8669
8670 /* finally we are here to generate the test case */
8671 BLAS_zsymv2_c_c_testgen(norm, order_type,
8672 uplo_type, n, &alpha, alpha_flag, a,
8673 lda, head_x_gen, tail_x_gen, &beta,
8674 beta_flag, y_gen, seed, head_r_true,
8675 tail_r_true);
8676 test_count++;
8677
8678 /* vary incx = -2, -1, 1, 2 */
8679 for (incx_val = INCX_START; incx_val <= INCX_END;
8680 incx_val++) {
8681
8682 incx = incx_val;
8683 if (0 == incx)
8684 continue;
8685
8686 /* vary incy = -2, -1, 1, 2 */
8687 for (incy_val = INCY_START; incy_val <= INCY_END;
8688 incy_val++) {
8689
8690 incy = incy_val;
8691 if (0 == incy)
8692 continue;
8693
8694 /* copy generated vector with appropriate incs. */
8695 zcopy_vector(y_gen, n, 1, y, incy);
8696 ccopy_vector(head_x_gen, n, 1, head_x, incx);
8697 ccopy_vector(tail_x_gen, n, 1, tail_x, incx);
8698
8699 /* call symv2 routines to be tested */
8700 FPU_FIX_STOP;
8701 BLAS_zsymv2_c_c_x(order_type,
8702 uplo_type, n, alpha, a, lda, head_x,
8703 tail_x, incx, beta, y, incy, prec);
8704 FPU_FIX_START;
8705
8706 /* now compute the ratio using test_BLAS_xdot */
8707 /* copy a row from A, use x, run dot test */
8708
8709 incyi = incy;
8710 incyi *= 2;
8711 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
8712
8713 for (i = 0, yi = yi0, ri = 0;
8714 i < n; i++, yi += incyi, ri += incri) {
8715 csy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
8716 i);
8717
8718 /* just use the x vector - it was unchanged (in theory) */
8719 rin[0] = y_gen[i];
8720 rin[1] = y_gen[i + 1];
8721 rout[0] = y[yi];
8722 rout[1] = y[yi + 1];
8723 head_r_true_elem[0] = head_r_true[ri];
8724 head_r_true_elem[1] = head_r_true[ri + 1];
8725 tail_r_true_elem[0] = tail_r_true[ri];
8726 tail_r_true_elem[1] = tail_r_true[ri + 1];
8727
8728 test_BLAS_zdot2_c_c(n, blas_no_conj, alpha, beta,
8729 rin, rout, head_r_true_elem,
8730 tail_r_true_elem, a_vec, 1,
8731 head_x, tail_x, incx, eps_int,
8732 un_int, &ratios[i]);
8733
8734 /* take the max ratio */
8735 if (i == 0) {
8736 ratio = ratios[0];
8737
8738 /* The !<= below causes NaN errors to be included.
8739 * Note that (NaN > 0) is false */
8740 } else if (!(ratios[i] <= ratio)) {
8741 ratio = ratios[i];
8742 }
8743
8744 } /* end of dot-test loop */
8745
8746
8747 /* The !<= below causes NaN errors to be included.
8748 * Note that (NaN > 0) is false */
8749 if (!(ratio <= thresh)) {
8750
8751 if (debug == 3) {
8752 printf("\n\t\tTest # %d\n", test_count);
8753 printf("y type : z, a type : c, x type : c\n");
8754 printf("Seed = %d\t", saved_seed);
8755 printf("n %d\n", n);
8756 printf("LDA %d INCX %d INCY %d\n", lda, incx,
8757 incx);
8758
8759 if (order_type == blas_rowmajor)
8760 printf("row ");
8761 else
8762 printf("col ");
8763
8764 if (uplo_type == blas_upper)
8765 printf("upper ");
8766 else
8767 printf("lower ");
8768
8769 printf("NORM %d, ALPHA %d, BETA %d\n",
8770 norm, alpha_val, beta_val);
8771
8772 /* print out info */
8773 printf("alpha = ");
8774 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
8775 printf(" ");
8776 printf("beta = ");
8777 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
8778 printf("\n");
8779
8780 printf("a\n");
8781 csy_print_matrix(a, n, lda, order_type, uplo_type);
8782 cprint_vector(head_x, n, incx, "head_x");
8783 cprint_vector(tail_x, n, incx, "tail_x");
8784 zprint_vector(y_gen, n, incy, "y_gen");
8785 zprint_vector(y, n, incy, "y");
8786 zprint_vector(head_r_true, n, 1, "head_r_true");
8787 dprint_vector(ratios, n, 1, "ratios");
8788 printf("ratio = %g\n", ratio);
8789 }
8790 bad_ratio_count++;
8791 if (bad_ratio_count >= MAX_BAD_TESTS) {
8792 printf("\ntoo many failures, exiting....");
8793 printf("\nTesting and compilation");
8794 printf(" are incomplete\n\n");
8795 goto end;
8796 }
8797 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
8798 printf("\nFlagrant ratio error, exiting...");
8799 printf("\nTesting and compilation");
8800 printf(" are incomplete\n\n");
8801 goto end;
8802 }
8803 }
8804
8805 if (!(ratio <= ratio_max))
8806 ratio_max = ratio;
8807
8808 if (ratio != 0.0 && !(ratio >= ratio_min))
8809 ratio_min = ratio;
8810
8811 } /* end of incy loop */
8812
8813 } /* end of incx loop */
8814
8815 } /* end of lda loop */
8816
8817 } /* end of uplo loop */
8818
8819 } /* end of order loop */
8820
8821 } /* end of nr test loop */
8822
8823 } /* end of norm loop */
8824
8825
8826 } /* end of prec loop */
8827
8828 } /* end of beta loop */
8829
8830 } /* end of alpha loop */
8831
8832 end:
8833 FPU_FIX_STOP;
8834
8835 blas_free(y);
8836 blas_free(a);
8837 blas_free(y_gen);
8838 blas_free(head_x);
8839 blas_free(tail_x);
8840 blas_free(head_x_gen);
8841 blas_free(tail_x_gen);
8842 blas_free(head_r_true);
8843 blas_free(tail_r_true);
8844 blas_free(ratios);
8845 blas_free(a_vec);
8846
8847 *max_ratio = ratio_max;
8848 *min_ratio = ratio_min;
8849 *num_tests = test_count;
8850 *num_bad_ratio = bad_ratio_count;
8851
8852 }
do_test_csymv2_c_s_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)8853 void do_test_csymv2_c_s_x
8854 (int n,
8855 int ntests, int *seed, double thresh, int debug, float test_prob,
8856 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
8857
8858 /* Function name */
8859 const char fname[] = "do_test_csymv2_c_s_x";
8860 int i;
8861 int yi;
8862 int incyi, yi0;
8863 int test_count;
8864 int bad_ratio_count;
8865 int ri;
8866 int incri = 1;
8867 int incx, incy;
8868 double ratio;
8869 double ratio_min, ratio_max;
8870 double eps_int; /* internal machine epsilon */
8871 double un_int; /* internal underflow threshold */
8872
8873 float rin[2];
8874 float rout[2];
8875 double head_r_true_elem[2], tail_r_true_elem[2];
8876
8877 enum blas_order_type order_type;
8878 enum blas_uplo_type uplo_type;
8879 enum blas_prec_type prec;
8880
8881 int order_val, uplo_val;
8882 int lda_val, incx_val, incy_val;
8883 int alpha_val, beta_val;
8884
8885 int prec_val;
8886
8887 int lda;
8888 int alpha_flag, beta_flag;
8889 int saved_seed;
8890 int norm;
8891 int test_no;
8892
8893 float alpha[2];
8894 float beta[2];
8895 float *a;
8896 float *head_x;
8897 float *tail_x;
8898 float *y;
8899 float *a_vec;
8900 float *y_gen;
8901 float *head_x_gen;
8902 float *tail_x_gen;
8903 double *ratios;
8904
8905 /* true result calculated by testgen, in double-double */
8906 double *head_r_true, *tail_r_true;
8907
8908
8909 FPU_FIX_DECL;
8910
8911 if (n < 0)
8912 BLAS_error(fname, -1, n, NULL);
8913 if (ntests < 0)
8914 BLAS_error(fname, -2, ntests, NULL);
8915
8916 /* initialization */
8917 saved_seed = *seed;
8918 ratio = 0.0;
8919 ratio_min = 1e308;
8920 ratio_max = 0.0;
8921
8922 *num_tests = 0;
8923 *num_bad_ratio = 0;
8924 *min_ratio = 0.0;
8925 *max_ratio = 0.0;
8926
8927 if (n == 0)
8928 return;
8929 incri *= 2;
8930
8931 FPU_FIX_START;
8932
8933 y = (float *) blas_malloc(2 * n * sizeof(float) * 2);
8934 if (2 * n > 0 && y == NULL) {
8935 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8936 }
8937 y_gen = (float *) blas_malloc(n * sizeof(float) * 2);
8938 if (n > 0 && y_gen == NULL) {
8939 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8940 }
8941 head_x_gen = (float *) blas_malloc(n * sizeof(float));
8942 if (n > 0 && head_x_gen == NULL) {
8943 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8944 }
8945 tail_x_gen = (float *) blas_malloc(n * sizeof(float));
8946 if (n > 0 && tail_x_gen == NULL) {
8947 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8948 }
8949 a = (float *) blas_malloc(2 * n * n * sizeof(float) * 2);
8950 if (2 * n * n > 0 && a == NULL) {
8951 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8952 }
8953 head_x = (float *) blas_malloc(2 * n * sizeof(float));
8954 if (2 * n > 0 && head_x == NULL) {
8955 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8956 }
8957 tail_x = (float *) blas_malloc(2 * n * sizeof(float));
8958 if (2 * n > 0 && tail_x == NULL) {
8959 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8960 }
8961 a_vec = (float *) blas_malloc(n * sizeof(float) * 2);
8962 if (n > 0 && a_vec == NULL) {
8963 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8964 }
8965 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
8966 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
8967 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
8968 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8969 }
8970 ratios = (double *) blas_malloc(n * sizeof(double));
8971 if (n > 0 && ratios == NULL) {
8972 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
8973 }
8974
8975 test_count = 0;
8976 bad_ratio_count = 0;
8977
8978 /* vary alpha */
8979 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
8980
8981 alpha_flag = 0;
8982 switch (alpha_val) {
8983 case 0:
8984 alpha[0] = alpha[1] = 0.0;
8985 alpha_flag = 1;
8986 break;
8987 case 1:
8988 alpha[0] = 1.0;
8989 alpha[1] = 0.0;
8990 alpha_flag = 1;
8991 break;
8992 }
8993
8994 /* vary beta */
8995 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
8996 beta_flag = 0;
8997 switch (beta_val) {
8998 case 0:
8999 beta[0] = beta[1] = 0.0;
9000 beta_flag = 1;
9001 break;
9002 case 1:
9003 beta[0] = 1.0;
9004 beta[1] = 0.0;
9005 beta_flag = 1;
9006 break;
9007 }
9008
9009
9010 /* varying extra precs */
9011 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
9012 switch (prec_val) {
9013 case 0:
9014 eps_int = power(2, -BITS_S);
9015 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_single),
9016 (double) BLAS_fpinfo_x(blas_emin, blas_prec_single));
9017 prec = blas_prec_single;
9018 break;
9019 case 1:
9020 eps_int = power(2, -BITS_D);
9021 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
9022 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
9023 prec = blas_prec_double;
9024 break;
9025 case 2:
9026 default:
9027 eps_int = power(2, -BITS_E);
9028 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
9029 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
9030 prec = blas_prec_extra;
9031 break;
9032 }
9033
9034 /* vary norm -- underflow, approx 1, overflow */
9035 for (norm = NORM_START; norm <= NORM_END; norm++) {
9036
9037 /* number of tests */
9038 for (test_no = 0; test_no < ntests; test_no++) {
9039
9040 /* vary storage format */
9041 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
9042
9043 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
9044
9045 /* vary upper / lower variation */
9046 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
9047
9048 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
9049
9050 /* vary lda = n, n+1, 2*n */
9051 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
9052
9053 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
9054
9055 saved_seed = *seed;
9056 /* For the sake of speed, we throw out this case at random */
9057 if (xrand(seed) >= test_prob)
9058 continue;
9059
9060 alpha_flag = 0;
9061 switch (alpha_val) {
9062 case 0:
9063 alpha[0] = alpha[1] = 0.0;
9064 alpha_flag = 1;
9065 break;
9066 case 1:
9067 alpha[0] = 1.0;
9068 alpha[1] = 0.0;
9069 alpha_flag = 1;
9070 break;
9071 }
9072 beta_flag = 0;
9073 switch (beta_val) {
9074 case 0:
9075 beta[0] = beta[1] = 0.0;
9076 beta_flag = 1;
9077 break;
9078 case 1:
9079 beta[0] = 1.0;
9080 beta[1] = 0.0;
9081 beta_flag = 1;
9082 break;
9083 }
9084
9085 /* finally we are here to generate the test case */
9086 BLAS_csymv2_c_s_testgen(norm, order_type,
9087 uplo_type, n, &alpha, alpha_flag, a,
9088 lda, head_x_gen, tail_x_gen, &beta,
9089 beta_flag, y_gen, seed, head_r_true,
9090 tail_r_true);
9091 test_count++;
9092
9093 /* vary incx = -2, -1, 1, 2 */
9094 for (incx_val = INCX_START; incx_val <= INCX_END;
9095 incx_val++) {
9096
9097 incx = incx_val;
9098 if (0 == incx)
9099 continue;
9100
9101 /* vary incy = -2, -1, 1, 2 */
9102 for (incy_val = INCY_START; incy_val <= INCY_END;
9103 incy_val++) {
9104
9105 incy = incy_val;
9106 if (0 == incy)
9107 continue;
9108
9109 /* copy generated vector with appropriate incs. */
9110 ccopy_vector(y_gen, n, 1, y, incy);
9111 scopy_vector(head_x_gen, n, 1, head_x, incx);
9112 scopy_vector(tail_x_gen, n, 1, tail_x, incx);
9113
9114 /* call symv2 routines to be tested */
9115 FPU_FIX_STOP;
9116 BLAS_csymv2_c_s_x(order_type,
9117 uplo_type, n, alpha, a, lda, head_x,
9118 tail_x, incx, beta, y, incy, prec);
9119 FPU_FIX_START;
9120
9121 /* now compute the ratio using test_BLAS_xdot */
9122 /* copy a row from A, use x, run dot test */
9123
9124 incyi = incy;
9125 incyi *= 2;
9126 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
9127
9128 for (i = 0, yi = yi0, ri = 0;
9129 i < n; i++, yi += incyi, ri += incri) {
9130 csy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
9131 i);
9132
9133 /* just use the x vector - it was unchanged (in theory) */
9134 rin[0] = y_gen[i];
9135 rin[1] = y_gen[i + 1];
9136 rout[0] = y[yi];
9137 rout[1] = y[yi + 1];
9138 head_r_true_elem[0] = head_r_true[ri];
9139 head_r_true_elem[1] = head_r_true[ri + 1];
9140 tail_r_true_elem[0] = tail_r_true[ri];
9141 tail_r_true_elem[1] = tail_r_true[ri + 1];
9142
9143 test_BLAS_cdot2_c_s(n, blas_no_conj, alpha, beta,
9144 rin, rout, head_r_true_elem,
9145 tail_r_true_elem, a_vec, 1,
9146 head_x, tail_x, incx, eps_int,
9147 un_int, &ratios[i]);
9148
9149 /* take the max ratio */
9150 if (i == 0) {
9151 ratio = ratios[0];
9152
9153 /* The !<= below causes NaN errors to be included.
9154 * Note that (NaN > 0) is false */
9155 } else if (!(ratios[i] <= ratio)) {
9156 ratio = ratios[i];
9157 }
9158
9159 } /* end of dot-test loop */
9160
9161
9162 /* The !<= below causes NaN errors to be included.
9163 * Note that (NaN > 0) is false */
9164 if (!(ratio <= thresh)) {
9165
9166 if (debug == 3) {
9167 printf("\n\t\tTest # %d\n", test_count);
9168 printf("y type : c, a type : c, x type : s\n");
9169 printf("Seed = %d\t", saved_seed);
9170 printf("n %d\n", n);
9171 printf("LDA %d INCX %d INCY %d\n", lda, incx,
9172 incx);
9173
9174 if (order_type == blas_rowmajor)
9175 printf("row ");
9176 else
9177 printf("col ");
9178
9179 if (uplo_type == blas_upper)
9180 printf("upper ");
9181 else
9182 printf("lower ");
9183
9184 printf("NORM %d, ALPHA %d, BETA %d\n",
9185 norm, alpha_val, beta_val);
9186
9187 /* print out info */
9188 printf("alpha = ");
9189 printf("(%16.8e, %16.8e)", alpha[0], alpha[1]);;
9190 printf(" ");
9191 printf("beta = ");
9192 printf("(%16.8e, %16.8e)", beta[0], beta[1]);;
9193 printf("\n");
9194
9195 printf("a\n");
9196 csy_print_matrix(a, n, lda, order_type, uplo_type);
9197 sprint_vector(head_x, n, incx, "head_x");
9198 sprint_vector(tail_x, n, incx, "tail_x");
9199 cprint_vector(y_gen, n, incy, "y_gen");
9200 cprint_vector(y, n, incy, "y");
9201 zprint_vector(head_r_true, n, 1, "head_r_true");
9202 dprint_vector(ratios, n, 1, "ratios");
9203 printf("ratio = %g\n", ratio);
9204 }
9205 bad_ratio_count++;
9206 if (bad_ratio_count >= MAX_BAD_TESTS) {
9207 printf("\ntoo many failures, exiting....");
9208 printf("\nTesting and compilation");
9209 printf(" are incomplete\n\n");
9210 goto end;
9211 }
9212 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
9213 printf("\nFlagrant ratio error, exiting...");
9214 printf("\nTesting and compilation");
9215 printf(" are incomplete\n\n");
9216 goto end;
9217 }
9218 }
9219
9220 if (!(ratio <= ratio_max))
9221 ratio_max = ratio;
9222
9223 if (ratio != 0.0 && !(ratio >= ratio_min))
9224 ratio_min = ratio;
9225
9226 } /* end of incy loop */
9227
9228 } /* end of incx loop */
9229
9230 } /* end of lda loop */
9231
9232 } /* end of uplo loop */
9233
9234 } /* end of order loop */
9235
9236 } /* end of nr test loop */
9237
9238 } /* end of norm loop */
9239
9240
9241 } /* end of prec loop */
9242
9243 } /* end of beta loop */
9244
9245 } /* end of alpha loop */
9246
9247 end:
9248 FPU_FIX_STOP;
9249
9250 blas_free(y);
9251 blas_free(a);
9252 blas_free(y_gen);
9253 blas_free(head_x);
9254 blas_free(tail_x);
9255 blas_free(head_x_gen);
9256 blas_free(tail_x_gen);
9257 blas_free(head_r_true);
9258 blas_free(tail_r_true);
9259 blas_free(ratios);
9260 blas_free(a_vec);
9261
9262 *max_ratio = ratio_max;
9263 *min_ratio = ratio_min;
9264 *num_tests = test_count;
9265 *num_bad_ratio = bad_ratio_count;
9266
9267 }
do_test_csymv2_s_c_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)9268 void do_test_csymv2_s_c_x
9269 (int n,
9270 int ntests, int *seed, double thresh, int debug, float test_prob,
9271 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
9272
9273 /* Function name */
9274 const char fname[] = "do_test_csymv2_s_c_x";
9275 int i;
9276 int yi;
9277 int incyi, yi0;
9278 int test_count;
9279 int bad_ratio_count;
9280 int ri;
9281 int incri = 1;
9282 int incx, incy;
9283 double ratio;
9284 double ratio_min, ratio_max;
9285 double eps_int; /* internal machine epsilon */
9286 double un_int; /* internal underflow threshold */
9287
9288 float rin[2];
9289 float rout[2];
9290 double head_r_true_elem[2], tail_r_true_elem[2];
9291
9292 enum blas_order_type order_type;
9293 enum blas_uplo_type uplo_type;
9294 enum blas_prec_type prec;
9295
9296 int order_val, uplo_val;
9297 int lda_val, incx_val, incy_val;
9298 int alpha_val, beta_val;
9299
9300 int prec_val;
9301
9302 int lda;
9303 int alpha_flag, beta_flag;
9304 int saved_seed;
9305 int norm;
9306 int test_no;
9307
9308 float alpha[2];
9309 float beta[2];
9310 float *a;
9311 float *head_x;
9312 float *tail_x;
9313 float *y;
9314 float *a_vec;
9315 float *y_gen;
9316 float *head_x_gen;
9317 float *tail_x_gen;
9318 double *ratios;
9319
9320 /* true result calculated by testgen, in double-double */
9321 double *head_r_true, *tail_r_true;
9322
9323
9324 FPU_FIX_DECL;
9325
9326 if (n < 0)
9327 BLAS_error(fname, -1, n, NULL);
9328 if (ntests < 0)
9329 BLAS_error(fname, -2, ntests, NULL);
9330
9331 /* initialization */
9332 saved_seed = *seed;
9333 ratio = 0.0;
9334 ratio_min = 1e308;
9335 ratio_max = 0.0;
9336
9337 *num_tests = 0;
9338 *num_bad_ratio = 0;
9339 *min_ratio = 0.0;
9340 *max_ratio = 0.0;
9341
9342 if (n == 0)
9343 return;
9344 incri *= 2;
9345
9346 FPU_FIX_START;
9347
9348 y = (float *) blas_malloc(2 * n * sizeof(float) * 2);
9349 if (2 * n > 0 && y == NULL) {
9350 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9351 }
9352 y_gen = (float *) blas_malloc(n * sizeof(float) * 2);
9353 if (n > 0 && y_gen == NULL) {
9354 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9355 }
9356 head_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
9357 if (n > 0 && head_x_gen == NULL) {
9358 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9359 }
9360 tail_x_gen = (float *) blas_malloc(n * sizeof(float) * 2);
9361 if (n > 0 && tail_x_gen == NULL) {
9362 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9363 }
9364 a = (float *) blas_malloc(2 * n * n * sizeof(float));
9365 if (2 * n * n > 0 && a == NULL) {
9366 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9367 }
9368 head_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
9369 if (2 * n > 0 && head_x == NULL) {
9370 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9371 }
9372 tail_x = (float *) blas_malloc(2 * n * sizeof(float) * 2);
9373 if (2 * n > 0 && tail_x == NULL) {
9374 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9375 }
9376 a_vec = (float *) blas_malloc(n * sizeof(float));
9377 if (n > 0 && a_vec == NULL) {
9378 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9379 }
9380 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
9381 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
9382 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
9383 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9384 }
9385 ratios = (double *) blas_malloc(n * sizeof(double));
9386 if (n > 0 && ratios == NULL) {
9387 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9388 }
9389
9390 test_count = 0;
9391 bad_ratio_count = 0;
9392
9393 /* vary alpha */
9394 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
9395
9396 alpha_flag = 0;
9397 switch (alpha_val) {
9398 case 0:
9399 alpha[0] = alpha[1] = 0.0;
9400 alpha_flag = 1;
9401 break;
9402 case 1:
9403 alpha[0] = 1.0;
9404 alpha[1] = 0.0;
9405 alpha_flag = 1;
9406 break;
9407 }
9408
9409 /* vary beta */
9410 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
9411 beta_flag = 0;
9412 switch (beta_val) {
9413 case 0:
9414 beta[0] = beta[1] = 0.0;
9415 beta_flag = 1;
9416 break;
9417 case 1:
9418 beta[0] = 1.0;
9419 beta[1] = 0.0;
9420 beta_flag = 1;
9421 break;
9422 }
9423
9424
9425 /* varying extra precs */
9426 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
9427 switch (prec_val) {
9428 case 0:
9429 eps_int = power(2, -BITS_S);
9430 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_single),
9431 (double) BLAS_fpinfo_x(blas_emin, blas_prec_single));
9432 prec = blas_prec_single;
9433 break;
9434 case 1:
9435 eps_int = power(2, -BITS_D);
9436 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
9437 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
9438 prec = blas_prec_double;
9439 break;
9440 case 2:
9441 default:
9442 eps_int = power(2, -BITS_E);
9443 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
9444 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
9445 prec = blas_prec_extra;
9446 break;
9447 }
9448
9449 /* vary norm -- underflow, approx 1, overflow */
9450 for (norm = NORM_START; norm <= NORM_END; norm++) {
9451
9452 /* number of tests */
9453 for (test_no = 0; test_no < ntests; test_no++) {
9454
9455 /* vary storage format */
9456 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
9457
9458 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
9459
9460 /* vary upper / lower variation */
9461 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
9462
9463 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
9464
9465 /* vary lda = n, n+1, 2*n */
9466 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
9467
9468 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
9469
9470 saved_seed = *seed;
9471 /* For the sake of speed, we throw out this case at random */
9472 if (xrand(seed) >= test_prob)
9473 continue;
9474
9475 alpha_flag = 0;
9476 switch (alpha_val) {
9477 case 0:
9478 alpha[0] = alpha[1] = 0.0;
9479 alpha_flag = 1;
9480 break;
9481 case 1:
9482 alpha[0] = 1.0;
9483 alpha[1] = 0.0;
9484 alpha_flag = 1;
9485 break;
9486 }
9487 beta_flag = 0;
9488 switch (beta_val) {
9489 case 0:
9490 beta[0] = beta[1] = 0.0;
9491 beta_flag = 1;
9492 break;
9493 case 1:
9494 beta[0] = 1.0;
9495 beta[1] = 0.0;
9496 beta_flag = 1;
9497 break;
9498 }
9499
9500 /* finally we are here to generate the test case */
9501 BLAS_csymv2_s_c_testgen(norm, order_type,
9502 uplo_type, n, &alpha, alpha_flag, a,
9503 lda, head_x_gen, tail_x_gen, &beta,
9504 beta_flag, y_gen, seed, head_r_true,
9505 tail_r_true);
9506 test_count++;
9507
9508 /* vary incx = -2, -1, 1, 2 */
9509 for (incx_val = INCX_START; incx_val <= INCX_END;
9510 incx_val++) {
9511
9512 incx = incx_val;
9513 if (0 == incx)
9514 continue;
9515
9516 /* vary incy = -2, -1, 1, 2 */
9517 for (incy_val = INCY_START; incy_val <= INCY_END;
9518 incy_val++) {
9519
9520 incy = incy_val;
9521 if (0 == incy)
9522 continue;
9523
9524 /* copy generated vector with appropriate incs. */
9525 ccopy_vector(y_gen, n, 1, y, incy);
9526 ccopy_vector(head_x_gen, n, 1, head_x, incx);
9527 ccopy_vector(tail_x_gen, n, 1, tail_x, incx);
9528
9529 /* call symv2 routines to be tested */
9530 FPU_FIX_STOP;
9531 BLAS_csymv2_s_c_x(order_type,
9532 uplo_type, n, alpha, a, lda, head_x,
9533 tail_x, incx, beta, y, incy, prec);
9534 FPU_FIX_START;
9535
9536 /* now compute the ratio using test_BLAS_xdot */
9537 /* copy a row from A, use x, run dot test */
9538
9539 incyi = incy;
9540 incyi *= 2;
9541 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
9542
9543 for (i = 0, yi = yi0, ri = 0;
9544 i < n; i++, yi += incyi, ri += incri) {
9545 ssy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
9546 i);
9547
9548 /* just use the x vector - it was unchanged (in theory) */
9549 rin[0] = y_gen[i];
9550 rin[1] = y_gen[i + 1];
9551 rout[0] = y[yi];
9552 rout[1] = y[yi + 1];
9553 head_r_true_elem[0] = head_r_true[ri];
9554 head_r_true_elem[1] = head_r_true[ri + 1];
9555 tail_r_true_elem[0] = tail_r_true[ri];
9556 tail_r_true_elem[1] = tail_r_true[ri + 1];
9557
9558 test_BLAS_cdot2_s_c(n, blas_no_conj, alpha, beta,
9559 rin, rout, head_r_true_elem,
9560 tail_r_true_elem, a_vec, 1,
9561 head_x, tail_x, incx, eps_int,
9562 un_int, &ratios[i]);
9563
9564 /* take the max ratio */
9565 if (i == 0) {
9566 ratio = ratios[0];
9567
9568 /* The !<= below causes NaN errors to be included.
9569 * Note that (NaN > 0) is false */
9570 } else if (!(ratios[i] <= ratio)) {
9571 ratio = ratios[i];
9572 }
9573
9574 } /* end of dot-test loop */
9575
9576
9577 /* The !<= below causes NaN errors to be included.
9578 * Note that (NaN > 0) is false */
9579 if (!(ratio <= thresh)) {
9580
9581 if (debug == 3) {
9582 printf("\n\t\tTest # %d\n", test_count);
9583 printf("y type : c, a type : s, x type : c\n");
9584 printf("Seed = %d\t", saved_seed);
9585 printf("n %d\n", n);
9586 printf("LDA %d INCX %d INCY %d\n", lda, incx,
9587 incx);
9588
9589 if (order_type == blas_rowmajor)
9590 printf("row ");
9591 else
9592 printf("col ");
9593
9594 if (uplo_type == blas_upper)
9595 printf("upper ");
9596 else
9597 printf("lower ");
9598
9599 printf("NORM %d, ALPHA %d, BETA %d\n",
9600 norm, alpha_val, beta_val);
9601
9602 /* print out info */
9603 printf("alpha = ");
9604 printf("(%16.8e, %16.8e)", alpha[0], alpha[1]);;
9605 printf(" ");
9606 printf("beta = ");
9607 printf("(%16.8e, %16.8e)", beta[0], beta[1]);;
9608 printf("\n");
9609
9610 printf("a\n");
9611 ssy_print_matrix(a, n, lda, order_type, uplo_type);
9612 cprint_vector(head_x, n, incx, "head_x");
9613 cprint_vector(tail_x, n, incx, "tail_x");
9614 cprint_vector(y_gen, n, incy, "y_gen");
9615 cprint_vector(y, n, incy, "y");
9616 zprint_vector(head_r_true, n, 1, "head_r_true");
9617 dprint_vector(ratios, n, 1, "ratios");
9618 printf("ratio = %g\n", ratio);
9619 }
9620 bad_ratio_count++;
9621 if (bad_ratio_count >= MAX_BAD_TESTS) {
9622 printf("\ntoo many failures, exiting....");
9623 printf("\nTesting and compilation");
9624 printf(" are incomplete\n\n");
9625 goto end;
9626 }
9627 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
9628 printf("\nFlagrant ratio error, exiting...");
9629 printf("\nTesting and compilation");
9630 printf(" are incomplete\n\n");
9631 goto end;
9632 }
9633 }
9634
9635 if (!(ratio <= ratio_max))
9636 ratio_max = ratio;
9637
9638 if (ratio != 0.0 && !(ratio >= ratio_min))
9639 ratio_min = ratio;
9640
9641 } /* end of incy loop */
9642
9643 } /* end of incx loop */
9644
9645 } /* end of lda loop */
9646
9647 } /* end of uplo loop */
9648
9649 } /* end of order loop */
9650
9651 } /* end of nr test loop */
9652
9653 } /* end of norm loop */
9654
9655
9656 } /* end of prec loop */
9657
9658 } /* end of beta loop */
9659
9660 } /* end of alpha loop */
9661
9662 end:
9663 FPU_FIX_STOP;
9664
9665 blas_free(y);
9666 blas_free(a);
9667 blas_free(y_gen);
9668 blas_free(head_x);
9669 blas_free(tail_x);
9670 blas_free(head_x_gen);
9671 blas_free(tail_x_gen);
9672 blas_free(head_r_true);
9673 blas_free(tail_r_true);
9674 blas_free(ratios);
9675 blas_free(a_vec);
9676
9677 *max_ratio = ratio_max;
9678 *min_ratio = ratio_min;
9679 *num_tests = test_count;
9680 *num_bad_ratio = bad_ratio_count;
9681
9682 }
do_test_csymv2_s_s_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)9683 void do_test_csymv2_s_s_x
9684 (int n,
9685 int ntests, int *seed, double thresh, int debug, float test_prob,
9686 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
9687
9688 /* Function name */
9689 const char fname[] = "do_test_csymv2_s_s_x";
9690 int i;
9691 int yi;
9692 int incyi, yi0;
9693 int test_count;
9694 int bad_ratio_count;
9695 int ri;
9696 int incri = 1;
9697 int incx, incy;
9698 double ratio;
9699 double ratio_min, ratio_max;
9700 double eps_int; /* internal machine epsilon */
9701 double un_int; /* internal underflow threshold */
9702
9703 float rin[2];
9704 float rout[2];
9705 double head_r_true_elem[2], tail_r_true_elem[2];
9706
9707 enum blas_order_type order_type;
9708 enum blas_uplo_type uplo_type;
9709 enum blas_prec_type prec;
9710
9711 int order_val, uplo_val;
9712 int lda_val, incx_val, incy_val;
9713 int alpha_val, beta_val;
9714
9715 int prec_val;
9716
9717 int lda;
9718 int alpha_flag, beta_flag;
9719 int saved_seed;
9720 int norm;
9721 int test_no;
9722
9723 float alpha[2];
9724 float beta[2];
9725 float *a;
9726 float *head_x;
9727 float *tail_x;
9728 float *y;
9729 float *a_vec;
9730 float *y_gen;
9731 float *head_x_gen;
9732 float *tail_x_gen;
9733 double *ratios;
9734
9735 /* true result calculated by testgen, in double-double */
9736 double *head_r_true, *tail_r_true;
9737
9738
9739 FPU_FIX_DECL;
9740
9741 if (n < 0)
9742 BLAS_error(fname, -1, n, NULL);
9743 if (ntests < 0)
9744 BLAS_error(fname, -2, ntests, NULL);
9745
9746 /* initialization */
9747 saved_seed = *seed;
9748 ratio = 0.0;
9749 ratio_min = 1e308;
9750 ratio_max = 0.0;
9751
9752 *num_tests = 0;
9753 *num_bad_ratio = 0;
9754 *min_ratio = 0.0;
9755 *max_ratio = 0.0;
9756
9757 if (n == 0)
9758 return;
9759 incri *= 2;
9760
9761 FPU_FIX_START;
9762
9763 y = (float *) blas_malloc(2 * n * sizeof(float) * 2);
9764 if (2 * n > 0 && y == NULL) {
9765 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9766 }
9767 y_gen = (float *) blas_malloc(n * sizeof(float) * 2);
9768 if (n > 0 && y_gen == NULL) {
9769 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9770 }
9771 head_x_gen = (float *) blas_malloc(n * sizeof(float));
9772 if (n > 0 && head_x_gen == NULL) {
9773 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9774 }
9775 tail_x_gen = (float *) blas_malloc(n * sizeof(float));
9776 if (n > 0 && tail_x_gen == NULL) {
9777 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9778 }
9779 a = (float *) blas_malloc(2 * n * n * sizeof(float));
9780 if (2 * n * n > 0 && a == NULL) {
9781 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9782 }
9783 head_x = (float *) blas_malloc(2 * n * sizeof(float));
9784 if (2 * n > 0 && head_x == NULL) {
9785 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9786 }
9787 tail_x = (float *) blas_malloc(2 * n * sizeof(float));
9788 if (2 * n > 0 && tail_x == NULL) {
9789 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9790 }
9791 a_vec = (float *) blas_malloc(n * sizeof(float));
9792 if (n > 0 && a_vec == NULL) {
9793 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9794 }
9795 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
9796 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
9797 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
9798 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9799 }
9800 ratios = (double *) blas_malloc(n * sizeof(double));
9801 if (n > 0 && ratios == NULL) {
9802 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
9803 }
9804
9805 test_count = 0;
9806 bad_ratio_count = 0;
9807
9808 /* vary alpha */
9809 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
9810
9811 alpha_flag = 0;
9812 switch (alpha_val) {
9813 case 0:
9814 alpha[0] = alpha[1] = 0.0;
9815 alpha_flag = 1;
9816 break;
9817 case 1:
9818 alpha[0] = 1.0;
9819 alpha[1] = 0.0;
9820 alpha_flag = 1;
9821 break;
9822 }
9823
9824 /* vary beta */
9825 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
9826 beta_flag = 0;
9827 switch (beta_val) {
9828 case 0:
9829 beta[0] = beta[1] = 0.0;
9830 beta_flag = 1;
9831 break;
9832 case 1:
9833 beta[0] = 1.0;
9834 beta[1] = 0.0;
9835 beta_flag = 1;
9836 break;
9837 }
9838
9839
9840 /* varying extra precs */
9841 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
9842 switch (prec_val) {
9843 case 0:
9844 eps_int = power(2, -BITS_S);
9845 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_single),
9846 (double) BLAS_fpinfo_x(blas_emin, blas_prec_single));
9847 prec = blas_prec_single;
9848 break;
9849 case 1:
9850 eps_int = power(2, -BITS_D);
9851 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
9852 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
9853 prec = blas_prec_double;
9854 break;
9855 case 2:
9856 default:
9857 eps_int = power(2, -BITS_E);
9858 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
9859 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
9860 prec = blas_prec_extra;
9861 break;
9862 }
9863
9864 /* vary norm -- underflow, approx 1, overflow */
9865 for (norm = NORM_START; norm <= NORM_END; norm++) {
9866
9867 /* number of tests */
9868 for (test_no = 0; test_no < ntests; test_no++) {
9869
9870 /* vary storage format */
9871 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
9872
9873 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
9874
9875 /* vary upper / lower variation */
9876 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
9877
9878 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
9879
9880 /* vary lda = n, n+1, 2*n */
9881 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
9882
9883 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
9884
9885 saved_seed = *seed;
9886 /* For the sake of speed, we throw out this case at random */
9887 if (xrand(seed) >= test_prob)
9888 continue;
9889
9890 alpha_flag = 0;
9891 switch (alpha_val) {
9892 case 0:
9893 alpha[0] = alpha[1] = 0.0;
9894 alpha_flag = 1;
9895 break;
9896 case 1:
9897 alpha[0] = 1.0;
9898 alpha[1] = 0.0;
9899 alpha_flag = 1;
9900 break;
9901 }
9902 beta_flag = 0;
9903 switch (beta_val) {
9904 case 0:
9905 beta[0] = beta[1] = 0.0;
9906 beta_flag = 1;
9907 break;
9908 case 1:
9909 beta[0] = 1.0;
9910 beta[1] = 0.0;
9911 beta_flag = 1;
9912 break;
9913 }
9914
9915 /* finally we are here to generate the test case */
9916 BLAS_csymv2_s_s_testgen(norm, order_type,
9917 uplo_type, n, &alpha, alpha_flag, a,
9918 lda, head_x_gen, tail_x_gen, &beta,
9919 beta_flag, y_gen, seed, head_r_true,
9920 tail_r_true);
9921 test_count++;
9922
9923 /* vary incx = -2, -1, 1, 2 */
9924 for (incx_val = INCX_START; incx_val <= INCX_END;
9925 incx_val++) {
9926
9927 incx = incx_val;
9928 if (0 == incx)
9929 continue;
9930
9931 /* vary incy = -2, -1, 1, 2 */
9932 for (incy_val = INCY_START; incy_val <= INCY_END;
9933 incy_val++) {
9934
9935 incy = incy_val;
9936 if (0 == incy)
9937 continue;
9938
9939 /* copy generated vector with appropriate incs. */
9940 ccopy_vector(y_gen, n, 1, y, incy);
9941 scopy_vector(head_x_gen, n, 1, head_x, incx);
9942 scopy_vector(tail_x_gen, n, 1, tail_x, incx);
9943
9944 /* call symv2 routines to be tested */
9945 FPU_FIX_STOP;
9946 BLAS_csymv2_s_s_x(order_type,
9947 uplo_type, n, alpha, a, lda, head_x,
9948 tail_x, incx, beta, y, incy, prec);
9949 FPU_FIX_START;
9950
9951 /* now compute the ratio using test_BLAS_xdot */
9952 /* copy a row from A, use x, run dot test */
9953
9954 incyi = incy;
9955 incyi *= 2;
9956 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
9957
9958 for (i = 0, yi = yi0, ri = 0;
9959 i < n; i++, yi += incyi, ri += incri) {
9960 ssy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
9961 i);
9962
9963 /* just use the x vector - it was unchanged (in theory) */
9964 rin[0] = y_gen[i];
9965 rin[1] = y_gen[i + 1];
9966 rout[0] = y[yi];
9967 rout[1] = y[yi + 1];
9968 head_r_true_elem[0] = head_r_true[ri];
9969 head_r_true_elem[1] = head_r_true[ri + 1];
9970 tail_r_true_elem[0] = tail_r_true[ri];
9971 tail_r_true_elem[1] = tail_r_true[ri + 1];
9972
9973 test_BLAS_cdot2_s_s(n, blas_no_conj, alpha, beta,
9974 rin, rout, head_r_true_elem,
9975 tail_r_true_elem, a_vec, 1,
9976 head_x, tail_x, incx, eps_int,
9977 un_int, &ratios[i]);
9978
9979 /* take the max ratio */
9980 if (i == 0) {
9981 ratio = ratios[0];
9982
9983 /* The !<= below causes NaN errors to be included.
9984 * Note that (NaN > 0) is false */
9985 } else if (!(ratios[i] <= ratio)) {
9986 ratio = ratios[i];
9987 }
9988
9989 } /* end of dot-test loop */
9990
9991
9992 /* The !<= below causes NaN errors to be included.
9993 * Note that (NaN > 0) is false */
9994 if (!(ratio <= thresh)) {
9995
9996 if (debug == 3) {
9997 printf("\n\t\tTest # %d\n", test_count);
9998 printf("y type : c, a type : s, x type : s\n");
9999 printf("Seed = %d\t", saved_seed);
10000 printf("n %d\n", n);
10001 printf("LDA %d INCX %d INCY %d\n", lda, incx,
10002 incx);
10003
10004 if (order_type == blas_rowmajor)
10005 printf("row ");
10006 else
10007 printf("col ");
10008
10009 if (uplo_type == blas_upper)
10010 printf("upper ");
10011 else
10012 printf("lower ");
10013
10014 printf("NORM %d, ALPHA %d, BETA %d\n",
10015 norm, alpha_val, beta_val);
10016
10017 /* print out info */
10018 printf("alpha = ");
10019 printf("(%16.8e, %16.8e)", alpha[0], alpha[1]);;
10020 printf(" ");
10021 printf("beta = ");
10022 printf("(%16.8e, %16.8e)", beta[0], beta[1]);;
10023 printf("\n");
10024
10025 printf("a\n");
10026 ssy_print_matrix(a, n, lda, order_type, uplo_type);
10027 sprint_vector(head_x, n, incx, "head_x");
10028 sprint_vector(tail_x, n, incx, "tail_x");
10029 cprint_vector(y_gen, n, incy, "y_gen");
10030 cprint_vector(y, n, incy, "y");
10031 zprint_vector(head_r_true, n, 1, "head_r_true");
10032 dprint_vector(ratios, n, 1, "ratios");
10033 printf("ratio = %g\n", ratio);
10034 }
10035 bad_ratio_count++;
10036 if (bad_ratio_count >= MAX_BAD_TESTS) {
10037 printf("\ntoo many failures, exiting....");
10038 printf("\nTesting and compilation");
10039 printf(" are incomplete\n\n");
10040 goto end;
10041 }
10042 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
10043 printf("\nFlagrant ratio error, exiting...");
10044 printf("\nTesting and compilation");
10045 printf(" are incomplete\n\n");
10046 goto end;
10047 }
10048 }
10049
10050 if (!(ratio <= ratio_max))
10051 ratio_max = ratio;
10052
10053 if (ratio != 0.0 && !(ratio >= ratio_min))
10054 ratio_min = ratio;
10055
10056 } /* end of incy loop */
10057
10058 } /* end of incx loop */
10059
10060 } /* end of lda loop */
10061
10062 } /* end of uplo loop */
10063
10064 } /* end of order loop */
10065
10066 } /* end of nr test loop */
10067
10068 } /* end of norm loop */
10069
10070
10071 } /* end of prec loop */
10072
10073 } /* end of beta loop */
10074
10075 } /* end of alpha loop */
10076
10077 end:
10078 FPU_FIX_STOP;
10079
10080 blas_free(y);
10081 blas_free(a);
10082 blas_free(y_gen);
10083 blas_free(head_x);
10084 blas_free(tail_x);
10085 blas_free(head_x_gen);
10086 blas_free(tail_x_gen);
10087 blas_free(head_r_true);
10088 blas_free(tail_r_true);
10089 blas_free(ratios);
10090 blas_free(a_vec);
10091
10092 *max_ratio = ratio_max;
10093 *min_ratio = ratio_min;
10094 *num_tests = test_count;
10095 *num_bad_ratio = bad_ratio_count;
10096
10097 }
do_test_zsymv2_z_d_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)10098 void do_test_zsymv2_z_d_x
10099 (int n,
10100 int ntests, int *seed, double thresh, int debug, float test_prob,
10101 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
10102
10103 /* Function name */
10104 const char fname[] = "do_test_zsymv2_z_d_x";
10105 int i;
10106 int yi;
10107 int incyi, yi0;
10108 int test_count;
10109 int bad_ratio_count;
10110 int ri;
10111 int incri = 1;
10112 int incx, incy;
10113 double ratio;
10114 double ratio_min, ratio_max;
10115 double eps_int; /* internal machine epsilon */
10116 double un_int; /* internal underflow threshold */
10117
10118 double rin[2];
10119 double rout[2];
10120 double head_r_true_elem[2], tail_r_true_elem[2];
10121
10122 enum blas_order_type order_type;
10123 enum blas_uplo_type uplo_type;
10124 enum blas_prec_type prec;
10125
10126 int order_val, uplo_val;
10127 int lda_val, incx_val, incy_val;
10128 int alpha_val, beta_val;
10129
10130 int prec_val;
10131
10132 int lda;
10133 int alpha_flag, beta_flag;
10134 int saved_seed;
10135 int norm;
10136 int test_no;
10137
10138 double alpha[2];
10139 double beta[2];
10140 double *a;
10141 double *head_x;
10142 double *tail_x;
10143 double *y;
10144 double *a_vec;
10145 double *y_gen;
10146 double *head_x_gen;
10147 double *tail_x_gen;
10148 double *ratios;
10149
10150 /* true result calculated by testgen, in double-double */
10151 double *head_r_true, *tail_r_true;
10152
10153
10154 FPU_FIX_DECL;
10155
10156 if (n < 0)
10157 BLAS_error(fname, -1, n, NULL);
10158 if (ntests < 0)
10159 BLAS_error(fname, -2, ntests, NULL);
10160
10161 /* initialization */
10162 saved_seed = *seed;
10163 ratio = 0.0;
10164 ratio_min = 1e308;
10165 ratio_max = 0.0;
10166
10167 *num_tests = 0;
10168 *num_bad_ratio = 0;
10169 *min_ratio = 0.0;
10170 *max_ratio = 0.0;
10171
10172 if (n == 0)
10173 return;
10174 incri *= 2;
10175
10176 FPU_FIX_START;
10177
10178 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
10179 if (2 * n > 0 && y == NULL) {
10180 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10181 }
10182 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
10183 if (n > 0 && y_gen == NULL) {
10184 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10185 }
10186 head_x_gen = (double *) blas_malloc(n * sizeof(double));
10187 if (n > 0 && head_x_gen == NULL) {
10188 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10189 }
10190 tail_x_gen = (double *) blas_malloc(n * sizeof(double));
10191 if (n > 0 && tail_x_gen == NULL) {
10192 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10193 }
10194 a = (double *) blas_malloc(2 * n * n * sizeof(double) * 2);
10195 if (2 * n * n > 0 && a == NULL) {
10196 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10197 }
10198 head_x = (double *) blas_malloc(2 * n * sizeof(double));
10199 if (2 * n > 0 && head_x == NULL) {
10200 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10201 }
10202 tail_x = (double *) blas_malloc(2 * n * sizeof(double));
10203 if (2 * n > 0 && tail_x == NULL) {
10204 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10205 }
10206 a_vec = (double *) blas_malloc(n * sizeof(double) * 2);
10207 if (n > 0 && a_vec == NULL) {
10208 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10209 }
10210 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
10211 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
10212 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
10213 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10214 }
10215 ratios = (double *) blas_malloc(n * sizeof(double));
10216 if (n > 0 && ratios == NULL) {
10217 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10218 }
10219
10220 test_count = 0;
10221 bad_ratio_count = 0;
10222
10223 /* vary alpha */
10224 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
10225
10226 alpha_flag = 0;
10227 switch (alpha_val) {
10228 case 0:
10229 alpha[0] = alpha[1] = 0.0;
10230 alpha_flag = 1;
10231 break;
10232 case 1:
10233 alpha[0] = 1.0;
10234 alpha[1] = 0.0;
10235 alpha_flag = 1;
10236 break;
10237 }
10238
10239 /* vary beta */
10240 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
10241 beta_flag = 0;
10242 switch (beta_val) {
10243 case 0:
10244 beta[0] = beta[1] = 0.0;
10245 beta_flag = 1;
10246 break;
10247 case 1:
10248 beta[0] = 1.0;
10249 beta[1] = 0.0;
10250 beta_flag = 1;
10251 break;
10252 }
10253
10254
10255 /* varying extra precs */
10256 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
10257 switch (prec_val) {
10258 case 0:
10259 eps_int = power(2, -BITS_D);
10260 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
10261 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
10262 prec = blas_prec_double;
10263 break;
10264 case 1:
10265 eps_int = power(2, -BITS_D);
10266 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
10267 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
10268 prec = blas_prec_double;
10269 break;
10270 case 2:
10271 default:
10272 eps_int = power(2, -BITS_E);
10273 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
10274 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
10275 prec = blas_prec_extra;
10276 break;
10277 }
10278
10279 /* vary norm -- underflow, approx 1, overflow */
10280 for (norm = NORM_START; norm <= NORM_END; norm++) {
10281
10282 /* number of tests */
10283 for (test_no = 0; test_no < ntests; test_no++) {
10284
10285 /* vary storage format */
10286 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
10287
10288 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
10289
10290 /* vary upper / lower variation */
10291 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
10292
10293 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
10294
10295 /* vary lda = n, n+1, 2*n */
10296 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
10297
10298 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
10299
10300 saved_seed = *seed;
10301 /* For the sake of speed, we throw out this case at random */
10302 if (xrand(seed) >= test_prob)
10303 continue;
10304
10305 alpha_flag = 0;
10306 switch (alpha_val) {
10307 case 0:
10308 alpha[0] = alpha[1] = 0.0;
10309 alpha_flag = 1;
10310 break;
10311 case 1:
10312 alpha[0] = 1.0;
10313 alpha[1] = 0.0;
10314 alpha_flag = 1;
10315 break;
10316 }
10317 beta_flag = 0;
10318 switch (beta_val) {
10319 case 0:
10320 beta[0] = beta[1] = 0.0;
10321 beta_flag = 1;
10322 break;
10323 case 1:
10324 beta[0] = 1.0;
10325 beta[1] = 0.0;
10326 beta_flag = 1;
10327 break;
10328 }
10329
10330 /* finally we are here to generate the test case */
10331 BLAS_zsymv2_z_d_testgen(norm, order_type,
10332 uplo_type, n, &alpha, alpha_flag, a,
10333 lda, head_x_gen, tail_x_gen, &beta,
10334 beta_flag, y_gen, seed, head_r_true,
10335 tail_r_true);
10336 test_count++;
10337
10338 /* vary incx = -2, -1, 1, 2 */
10339 for (incx_val = INCX_START; incx_val <= INCX_END;
10340 incx_val++) {
10341
10342 incx = incx_val;
10343 if (0 == incx)
10344 continue;
10345
10346 /* vary incy = -2, -1, 1, 2 */
10347 for (incy_val = INCY_START; incy_val <= INCY_END;
10348 incy_val++) {
10349
10350 incy = incy_val;
10351 if (0 == incy)
10352 continue;
10353
10354 /* copy generated vector with appropriate incs. */
10355 zcopy_vector(y_gen, n, 1, y, incy);
10356 dcopy_vector(head_x_gen, n, 1, head_x, incx);
10357 dcopy_vector(tail_x_gen, n, 1, tail_x, incx);
10358
10359 /* call symv2 routines to be tested */
10360 FPU_FIX_STOP;
10361 BLAS_zsymv2_z_d_x(order_type,
10362 uplo_type, n, alpha, a, lda, head_x,
10363 tail_x, incx, beta, y, incy, prec);
10364 FPU_FIX_START;
10365
10366 /* now compute the ratio using test_BLAS_xdot */
10367 /* copy a row from A, use x, run dot test */
10368
10369 incyi = incy;
10370 incyi *= 2;
10371 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
10372
10373 for (i = 0, yi = yi0, ri = 0;
10374 i < n; i++, yi += incyi, ri += incri) {
10375 zsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
10376 i);
10377
10378 /* just use the x vector - it was unchanged (in theory) */
10379 rin[0] = y_gen[i];
10380 rin[1] = y_gen[i + 1];
10381 rout[0] = y[yi];
10382 rout[1] = y[yi + 1];
10383 head_r_true_elem[0] = head_r_true[ri];
10384 head_r_true_elem[1] = head_r_true[ri + 1];
10385 tail_r_true_elem[0] = tail_r_true[ri];
10386 tail_r_true_elem[1] = tail_r_true[ri + 1];
10387
10388 test_BLAS_zdot2_z_d(n, blas_no_conj, alpha, beta,
10389 rin, rout, head_r_true_elem,
10390 tail_r_true_elem, a_vec, 1,
10391 head_x, tail_x, incx, eps_int,
10392 un_int, &ratios[i]);
10393
10394 /* take the max ratio */
10395 if (i == 0) {
10396 ratio = ratios[0];
10397
10398 /* The !<= below causes NaN errors to be included.
10399 * Note that (NaN > 0) is false */
10400 } else if (!(ratios[i] <= ratio)) {
10401 ratio = ratios[i];
10402 }
10403
10404 } /* end of dot-test loop */
10405
10406
10407 /* The !<= below causes NaN errors to be included.
10408 * Note that (NaN > 0) is false */
10409 if (!(ratio <= thresh)) {
10410
10411 if (debug == 3) {
10412 printf("\n\t\tTest # %d\n", test_count);
10413 printf("y type : z, a type : z, x type : d\n");
10414 printf("Seed = %d\t", saved_seed);
10415 printf("n %d\n", n);
10416 printf("LDA %d INCX %d INCY %d\n", lda, incx,
10417 incx);
10418
10419 if (order_type == blas_rowmajor)
10420 printf("row ");
10421 else
10422 printf("col ");
10423
10424 if (uplo_type == blas_upper)
10425 printf("upper ");
10426 else
10427 printf("lower ");
10428
10429 printf("NORM %d, ALPHA %d, BETA %d\n",
10430 norm, alpha_val, beta_val);
10431
10432 /* print out info */
10433 printf("alpha = ");
10434 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
10435 printf(" ");
10436 printf("beta = ");
10437 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
10438 printf("\n");
10439
10440 printf("a\n");
10441 zsy_print_matrix(a, n, lda, order_type, uplo_type);
10442 dprint_vector(head_x, n, incx, "head_x");
10443 dprint_vector(tail_x, n, incx, "tail_x");
10444 zprint_vector(y_gen, n, incy, "y_gen");
10445 zprint_vector(y, n, incy, "y");
10446 zprint_vector(head_r_true, n, 1, "head_r_true");
10447 dprint_vector(ratios, n, 1, "ratios");
10448 printf("ratio = %g\n", ratio);
10449 }
10450 bad_ratio_count++;
10451 if (bad_ratio_count >= MAX_BAD_TESTS) {
10452 printf("\ntoo many failures, exiting....");
10453 printf("\nTesting and compilation");
10454 printf(" are incomplete\n\n");
10455 goto end;
10456 }
10457 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
10458 printf("\nFlagrant ratio error, exiting...");
10459 printf("\nTesting and compilation");
10460 printf(" are incomplete\n\n");
10461 goto end;
10462 }
10463 }
10464
10465 if (!(ratio <= ratio_max))
10466 ratio_max = ratio;
10467
10468 if (ratio != 0.0 && !(ratio >= ratio_min))
10469 ratio_min = ratio;
10470
10471 } /* end of incy loop */
10472
10473 } /* end of incx loop */
10474
10475 } /* end of lda loop */
10476
10477 } /* end of uplo loop */
10478
10479 } /* end of order loop */
10480
10481 } /* end of nr test loop */
10482
10483 } /* end of norm loop */
10484
10485
10486 } /* end of prec loop */
10487
10488 } /* end of beta loop */
10489
10490 } /* end of alpha loop */
10491
10492 end:
10493 FPU_FIX_STOP;
10494
10495 blas_free(y);
10496 blas_free(a);
10497 blas_free(y_gen);
10498 blas_free(head_x);
10499 blas_free(tail_x);
10500 blas_free(head_x_gen);
10501 blas_free(tail_x_gen);
10502 blas_free(head_r_true);
10503 blas_free(tail_r_true);
10504 blas_free(ratios);
10505 blas_free(a_vec);
10506
10507 *max_ratio = ratio_max;
10508 *min_ratio = ratio_min;
10509 *num_tests = test_count;
10510 *num_bad_ratio = bad_ratio_count;
10511
10512 }
do_test_zsymv2_d_z_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)10513 void do_test_zsymv2_d_z_x
10514 (int n,
10515 int ntests, int *seed, double thresh, int debug, float test_prob,
10516 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
10517
10518 /* Function name */
10519 const char fname[] = "do_test_zsymv2_d_z_x";
10520 int i;
10521 int yi;
10522 int incyi, yi0;
10523 int test_count;
10524 int bad_ratio_count;
10525 int ri;
10526 int incri = 1;
10527 int incx, incy;
10528 double ratio;
10529 double ratio_min, ratio_max;
10530 double eps_int; /* internal machine epsilon */
10531 double un_int; /* internal underflow threshold */
10532
10533 double rin[2];
10534 double rout[2];
10535 double head_r_true_elem[2], tail_r_true_elem[2];
10536
10537 enum blas_order_type order_type;
10538 enum blas_uplo_type uplo_type;
10539 enum blas_prec_type prec;
10540
10541 int order_val, uplo_val;
10542 int lda_val, incx_val, incy_val;
10543 int alpha_val, beta_val;
10544
10545 int prec_val;
10546
10547 int lda;
10548 int alpha_flag, beta_flag;
10549 int saved_seed;
10550 int norm;
10551 int test_no;
10552
10553 double alpha[2];
10554 double beta[2];
10555 double *a;
10556 double *head_x;
10557 double *tail_x;
10558 double *y;
10559 double *a_vec;
10560 double *y_gen;
10561 double *head_x_gen;
10562 double *tail_x_gen;
10563 double *ratios;
10564
10565 /* true result calculated by testgen, in double-double */
10566 double *head_r_true, *tail_r_true;
10567
10568
10569 FPU_FIX_DECL;
10570
10571 if (n < 0)
10572 BLAS_error(fname, -1, n, NULL);
10573 if (ntests < 0)
10574 BLAS_error(fname, -2, ntests, NULL);
10575
10576 /* initialization */
10577 saved_seed = *seed;
10578 ratio = 0.0;
10579 ratio_min = 1e308;
10580 ratio_max = 0.0;
10581
10582 *num_tests = 0;
10583 *num_bad_ratio = 0;
10584 *min_ratio = 0.0;
10585 *max_ratio = 0.0;
10586
10587 if (n == 0)
10588 return;
10589 incri *= 2;
10590
10591 FPU_FIX_START;
10592
10593 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
10594 if (2 * n > 0 && y == NULL) {
10595 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10596 }
10597 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
10598 if (n > 0 && y_gen == NULL) {
10599 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10600 }
10601 head_x_gen = (double *) blas_malloc(n * sizeof(double) * 2);
10602 if (n > 0 && head_x_gen == NULL) {
10603 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10604 }
10605 tail_x_gen = (double *) blas_malloc(n * sizeof(double) * 2);
10606 if (n > 0 && tail_x_gen == NULL) {
10607 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10608 }
10609 a = (double *) blas_malloc(2 * n * n * sizeof(double));
10610 if (2 * n * n > 0 && a == NULL) {
10611 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10612 }
10613 head_x = (double *) blas_malloc(2 * n * sizeof(double) * 2);
10614 if (2 * n > 0 && head_x == NULL) {
10615 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10616 }
10617 tail_x = (double *) blas_malloc(2 * n * sizeof(double) * 2);
10618 if (2 * n > 0 && tail_x == NULL) {
10619 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10620 }
10621 a_vec = (double *) blas_malloc(n * sizeof(double));
10622 if (n > 0 && a_vec == NULL) {
10623 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10624 }
10625 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
10626 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
10627 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
10628 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10629 }
10630 ratios = (double *) blas_malloc(n * sizeof(double));
10631 if (n > 0 && ratios == NULL) {
10632 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
10633 }
10634
10635 test_count = 0;
10636 bad_ratio_count = 0;
10637
10638 /* vary alpha */
10639 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
10640
10641 alpha_flag = 0;
10642 switch (alpha_val) {
10643 case 0:
10644 alpha[0] = alpha[1] = 0.0;
10645 alpha_flag = 1;
10646 break;
10647 case 1:
10648 alpha[0] = 1.0;
10649 alpha[1] = 0.0;
10650 alpha_flag = 1;
10651 break;
10652 }
10653
10654 /* vary beta */
10655 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
10656 beta_flag = 0;
10657 switch (beta_val) {
10658 case 0:
10659 beta[0] = beta[1] = 0.0;
10660 beta_flag = 1;
10661 break;
10662 case 1:
10663 beta[0] = 1.0;
10664 beta[1] = 0.0;
10665 beta_flag = 1;
10666 break;
10667 }
10668
10669
10670 /* varying extra precs */
10671 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
10672 switch (prec_val) {
10673 case 0:
10674 eps_int = power(2, -BITS_D);
10675 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
10676 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
10677 prec = blas_prec_double;
10678 break;
10679 case 1:
10680 eps_int = power(2, -BITS_D);
10681 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
10682 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
10683 prec = blas_prec_double;
10684 break;
10685 case 2:
10686 default:
10687 eps_int = power(2, -BITS_E);
10688 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
10689 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
10690 prec = blas_prec_extra;
10691 break;
10692 }
10693
10694 /* vary norm -- underflow, approx 1, overflow */
10695 for (norm = NORM_START; norm <= NORM_END; norm++) {
10696
10697 /* number of tests */
10698 for (test_no = 0; test_no < ntests; test_no++) {
10699
10700 /* vary storage format */
10701 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
10702
10703 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
10704
10705 /* vary upper / lower variation */
10706 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
10707
10708 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
10709
10710 /* vary lda = n, n+1, 2*n */
10711 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
10712
10713 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
10714
10715 saved_seed = *seed;
10716 /* For the sake of speed, we throw out this case at random */
10717 if (xrand(seed) >= test_prob)
10718 continue;
10719
10720 alpha_flag = 0;
10721 switch (alpha_val) {
10722 case 0:
10723 alpha[0] = alpha[1] = 0.0;
10724 alpha_flag = 1;
10725 break;
10726 case 1:
10727 alpha[0] = 1.0;
10728 alpha[1] = 0.0;
10729 alpha_flag = 1;
10730 break;
10731 }
10732 beta_flag = 0;
10733 switch (beta_val) {
10734 case 0:
10735 beta[0] = beta[1] = 0.0;
10736 beta_flag = 1;
10737 break;
10738 case 1:
10739 beta[0] = 1.0;
10740 beta[1] = 0.0;
10741 beta_flag = 1;
10742 break;
10743 }
10744
10745 /* finally we are here to generate the test case */
10746 BLAS_zsymv2_d_z_testgen(norm, order_type,
10747 uplo_type, n, &alpha, alpha_flag, a,
10748 lda, head_x_gen, tail_x_gen, &beta,
10749 beta_flag, y_gen, seed, head_r_true,
10750 tail_r_true);
10751 test_count++;
10752
10753 /* vary incx = -2, -1, 1, 2 */
10754 for (incx_val = INCX_START; incx_val <= INCX_END;
10755 incx_val++) {
10756
10757 incx = incx_val;
10758 if (0 == incx)
10759 continue;
10760
10761 /* vary incy = -2, -1, 1, 2 */
10762 for (incy_val = INCY_START; incy_val <= INCY_END;
10763 incy_val++) {
10764
10765 incy = incy_val;
10766 if (0 == incy)
10767 continue;
10768
10769 /* copy generated vector with appropriate incs. */
10770 zcopy_vector(y_gen, n, 1, y, incy);
10771 zcopy_vector(head_x_gen, n, 1, head_x, incx);
10772 zcopy_vector(tail_x_gen, n, 1, tail_x, incx);
10773
10774 /* call symv2 routines to be tested */
10775 FPU_FIX_STOP;
10776 BLAS_zsymv2_d_z_x(order_type,
10777 uplo_type, n, alpha, a, lda, head_x,
10778 tail_x, incx, beta, y, incy, prec);
10779 FPU_FIX_START;
10780
10781 /* now compute the ratio using test_BLAS_xdot */
10782 /* copy a row from A, use x, run dot test */
10783
10784 incyi = incy;
10785 incyi *= 2;
10786 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
10787
10788 for (i = 0, yi = yi0, ri = 0;
10789 i < n; i++, yi += incyi, ri += incri) {
10790 dsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
10791 i);
10792
10793 /* just use the x vector - it was unchanged (in theory) */
10794 rin[0] = y_gen[i];
10795 rin[1] = y_gen[i + 1];
10796 rout[0] = y[yi];
10797 rout[1] = y[yi + 1];
10798 head_r_true_elem[0] = head_r_true[ri];
10799 head_r_true_elem[1] = head_r_true[ri + 1];
10800 tail_r_true_elem[0] = tail_r_true[ri];
10801 tail_r_true_elem[1] = tail_r_true[ri + 1];
10802
10803 test_BLAS_zdot2_d_z(n, blas_no_conj, alpha, beta,
10804 rin, rout, head_r_true_elem,
10805 tail_r_true_elem, a_vec, 1,
10806 head_x, tail_x, incx, eps_int,
10807 un_int, &ratios[i]);
10808
10809 /* take the max ratio */
10810 if (i == 0) {
10811 ratio = ratios[0];
10812
10813 /* The !<= below causes NaN errors to be included.
10814 * Note that (NaN > 0) is false */
10815 } else if (!(ratios[i] <= ratio)) {
10816 ratio = ratios[i];
10817 }
10818
10819 } /* end of dot-test loop */
10820
10821
10822 /* The !<= below causes NaN errors to be included.
10823 * Note that (NaN > 0) is false */
10824 if (!(ratio <= thresh)) {
10825
10826 if (debug == 3) {
10827 printf("\n\t\tTest # %d\n", test_count);
10828 printf("y type : z, a type : d, x type : z\n");
10829 printf("Seed = %d\t", saved_seed);
10830 printf("n %d\n", n);
10831 printf("LDA %d INCX %d INCY %d\n", lda, incx,
10832 incx);
10833
10834 if (order_type == blas_rowmajor)
10835 printf("row ");
10836 else
10837 printf("col ");
10838
10839 if (uplo_type == blas_upper)
10840 printf("upper ");
10841 else
10842 printf("lower ");
10843
10844 printf("NORM %d, ALPHA %d, BETA %d\n",
10845 norm, alpha_val, beta_val);
10846
10847 /* print out info */
10848 printf("alpha = ");
10849 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
10850 printf(" ");
10851 printf("beta = ");
10852 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
10853 printf("\n");
10854
10855 printf("a\n");
10856 dsy_print_matrix(a, n, lda, order_type, uplo_type);
10857 zprint_vector(head_x, n, incx, "head_x");
10858 zprint_vector(tail_x, n, incx, "tail_x");
10859 zprint_vector(y_gen, n, incy, "y_gen");
10860 zprint_vector(y, n, incy, "y");
10861 zprint_vector(head_r_true, n, 1, "head_r_true");
10862 dprint_vector(ratios, n, 1, "ratios");
10863 printf("ratio = %g\n", ratio);
10864 }
10865 bad_ratio_count++;
10866 if (bad_ratio_count >= MAX_BAD_TESTS) {
10867 printf("\ntoo many failures, exiting....");
10868 printf("\nTesting and compilation");
10869 printf(" are incomplete\n\n");
10870 goto end;
10871 }
10872 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
10873 printf("\nFlagrant ratio error, exiting...");
10874 printf("\nTesting and compilation");
10875 printf(" are incomplete\n\n");
10876 goto end;
10877 }
10878 }
10879
10880 if (!(ratio <= ratio_max))
10881 ratio_max = ratio;
10882
10883 if (ratio != 0.0 && !(ratio >= ratio_min))
10884 ratio_min = ratio;
10885
10886 } /* end of incy loop */
10887
10888 } /* end of incx loop */
10889
10890 } /* end of lda loop */
10891
10892 } /* end of uplo loop */
10893
10894 } /* end of order loop */
10895
10896 } /* end of nr test loop */
10897
10898 } /* end of norm loop */
10899
10900
10901 } /* end of prec loop */
10902
10903 } /* end of beta loop */
10904
10905 } /* end of alpha loop */
10906
10907 end:
10908 FPU_FIX_STOP;
10909
10910 blas_free(y);
10911 blas_free(a);
10912 blas_free(y_gen);
10913 blas_free(head_x);
10914 blas_free(tail_x);
10915 blas_free(head_x_gen);
10916 blas_free(tail_x_gen);
10917 blas_free(head_r_true);
10918 blas_free(tail_r_true);
10919 blas_free(ratios);
10920 blas_free(a_vec);
10921
10922 *max_ratio = ratio_max;
10923 *min_ratio = ratio_min;
10924 *num_tests = test_count;
10925 *num_bad_ratio = bad_ratio_count;
10926
10927 }
do_test_zsymv2_d_d_x(int n,int ntests,int * seed,double thresh,int debug,float test_prob,double * min_ratio,double * max_ratio,int * num_bad_ratio,int * num_tests)10928 void do_test_zsymv2_d_d_x
10929 (int n,
10930 int ntests, int *seed, double thresh, int debug, float test_prob,
10931 double *min_ratio, double *max_ratio, int *num_bad_ratio, int *num_tests) {
10932
10933 /* Function name */
10934 const char fname[] = "do_test_zsymv2_d_d_x";
10935 int i;
10936 int yi;
10937 int incyi, yi0;
10938 int test_count;
10939 int bad_ratio_count;
10940 int ri;
10941 int incri = 1;
10942 int incx, incy;
10943 double ratio;
10944 double ratio_min, ratio_max;
10945 double eps_int; /* internal machine epsilon */
10946 double un_int; /* internal underflow threshold */
10947
10948 double rin[2];
10949 double rout[2];
10950 double head_r_true_elem[2], tail_r_true_elem[2];
10951
10952 enum blas_order_type order_type;
10953 enum blas_uplo_type uplo_type;
10954 enum blas_prec_type prec;
10955
10956 int order_val, uplo_val;
10957 int lda_val, incx_val, incy_val;
10958 int alpha_val, beta_val;
10959
10960 int prec_val;
10961
10962 int lda;
10963 int alpha_flag, beta_flag;
10964 int saved_seed;
10965 int norm;
10966 int test_no;
10967
10968 double alpha[2];
10969 double beta[2];
10970 double *a;
10971 double *head_x;
10972 double *tail_x;
10973 double *y;
10974 double *a_vec;
10975 double *y_gen;
10976 double *head_x_gen;
10977 double *tail_x_gen;
10978 double *ratios;
10979
10980 /* true result calculated by testgen, in double-double */
10981 double *head_r_true, *tail_r_true;
10982
10983
10984 FPU_FIX_DECL;
10985
10986 if (n < 0)
10987 BLAS_error(fname, -1, n, NULL);
10988 if (ntests < 0)
10989 BLAS_error(fname, -2, ntests, NULL);
10990
10991 /* initialization */
10992 saved_seed = *seed;
10993 ratio = 0.0;
10994 ratio_min = 1e308;
10995 ratio_max = 0.0;
10996
10997 *num_tests = 0;
10998 *num_bad_ratio = 0;
10999 *min_ratio = 0.0;
11000 *max_ratio = 0.0;
11001
11002 if (n == 0)
11003 return;
11004 incri *= 2;
11005
11006 FPU_FIX_START;
11007
11008 y = (double *) blas_malloc(2 * n * sizeof(double) * 2);
11009 if (2 * n > 0 && y == NULL) {
11010 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
11011 }
11012 y_gen = (double *) blas_malloc(n * sizeof(double) * 2);
11013 if (n > 0 && y_gen == NULL) {
11014 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
11015 }
11016 head_x_gen = (double *) blas_malloc(n * sizeof(double));
11017 if (n > 0 && head_x_gen == NULL) {
11018 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
11019 }
11020 tail_x_gen = (double *) blas_malloc(n * sizeof(double));
11021 if (n > 0 && tail_x_gen == NULL) {
11022 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
11023 }
11024 a = (double *) blas_malloc(2 * n * n * sizeof(double));
11025 if (2 * n * n > 0 && a == NULL) {
11026 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
11027 }
11028 head_x = (double *) blas_malloc(2 * n * sizeof(double));
11029 if (2 * n > 0 && head_x == NULL) {
11030 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
11031 }
11032 tail_x = (double *) blas_malloc(2 * n * sizeof(double));
11033 if (2 * n > 0 && tail_x == NULL) {
11034 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
11035 }
11036 a_vec = (double *) blas_malloc(n * sizeof(double));
11037 if (n > 0 && a_vec == NULL) {
11038 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
11039 }
11040 head_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
11041 tail_r_true = (double *) blas_malloc(n * sizeof(double) * 2);
11042 if (n > 0 && (head_r_true == NULL || tail_r_true == NULL)) {
11043 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
11044 }
11045 ratios = (double *) blas_malloc(n * sizeof(double));
11046 if (n > 0 && ratios == NULL) {
11047 BLAS_error("blas_malloc", 0, 0, "malloc failed.\n");
11048 }
11049
11050 test_count = 0;
11051 bad_ratio_count = 0;
11052
11053 /* vary alpha */
11054 for (alpha_val = ALPHA_START; alpha_val <= ALPHA_END; alpha_val++) {
11055
11056 alpha_flag = 0;
11057 switch (alpha_val) {
11058 case 0:
11059 alpha[0] = alpha[1] = 0.0;
11060 alpha_flag = 1;
11061 break;
11062 case 1:
11063 alpha[0] = 1.0;
11064 alpha[1] = 0.0;
11065 alpha_flag = 1;
11066 break;
11067 }
11068
11069 /* vary beta */
11070 for (beta_val = BETA_START; beta_val <= BETA_END; beta_val++) {
11071 beta_flag = 0;
11072 switch (beta_val) {
11073 case 0:
11074 beta[0] = beta[1] = 0.0;
11075 beta_flag = 1;
11076 break;
11077 case 1:
11078 beta[0] = 1.0;
11079 beta[1] = 0.0;
11080 beta_flag = 1;
11081 break;
11082 }
11083
11084
11085 /* varying extra precs */
11086 for (prec_val = PREC_START; prec_val <= PREC_END; prec_val++) {
11087 switch (prec_val) {
11088 case 0:
11089 eps_int = power(2, -BITS_D);
11090 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
11091 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
11092 prec = blas_prec_double;
11093 break;
11094 case 1:
11095 eps_int = power(2, -BITS_D);
11096 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_double),
11097 (double) BLAS_fpinfo_x(blas_emin, blas_prec_double));
11098 prec = blas_prec_double;
11099 break;
11100 case 2:
11101 default:
11102 eps_int = power(2, -BITS_E);
11103 un_int = pow((double) BLAS_fpinfo_x(blas_base, blas_prec_extra),
11104 (double) BLAS_fpinfo_x(blas_emin, blas_prec_extra));
11105 prec = blas_prec_extra;
11106 break;
11107 }
11108
11109 /* vary norm -- underflow, approx 1, overflow */
11110 for (norm = NORM_START; norm <= NORM_END; norm++) {
11111
11112 /* number of tests */
11113 for (test_no = 0; test_no < ntests; test_no++) {
11114
11115 /* vary storage format */
11116 for (order_val = ORDER_START; order_val <= ORDER_END; order_val++) {
11117
11118 order_type = (order_val == 0) ? blas_colmajor : blas_rowmajor;
11119
11120 /* vary upper / lower variation */
11121 for (uplo_val = UPLO_START; uplo_val <= UPLO_END; uplo_val++) {
11122
11123 uplo_type = (uplo_val == 0) ? blas_upper : blas_lower;
11124
11125 /* vary lda = n, n+1, 2*n */
11126 for (lda_val = LDA_START; lda_val <= LDA_END; lda_val++) {
11127
11128 lda = (lda_val == 0) ? n : (lda_val == 1) ? n + 1 : 2 * n;
11129
11130 saved_seed = *seed;
11131 /* For the sake of speed, we throw out this case at random */
11132 if (xrand(seed) >= test_prob)
11133 continue;
11134
11135 alpha_flag = 0;
11136 switch (alpha_val) {
11137 case 0:
11138 alpha[0] = alpha[1] = 0.0;
11139 alpha_flag = 1;
11140 break;
11141 case 1:
11142 alpha[0] = 1.0;
11143 alpha[1] = 0.0;
11144 alpha_flag = 1;
11145 break;
11146 }
11147 beta_flag = 0;
11148 switch (beta_val) {
11149 case 0:
11150 beta[0] = beta[1] = 0.0;
11151 beta_flag = 1;
11152 break;
11153 case 1:
11154 beta[0] = 1.0;
11155 beta[1] = 0.0;
11156 beta_flag = 1;
11157 break;
11158 }
11159
11160 /* finally we are here to generate the test case */
11161 BLAS_zsymv2_d_d_testgen(norm, order_type,
11162 uplo_type, n, &alpha, alpha_flag, a,
11163 lda, head_x_gen, tail_x_gen, &beta,
11164 beta_flag, y_gen, seed, head_r_true,
11165 tail_r_true);
11166 test_count++;
11167
11168 /* vary incx = -2, -1, 1, 2 */
11169 for (incx_val = INCX_START; incx_val <= INCX_END;
11170 incx_val++) {
11171
11172 incx = incx_val;
11173 if (0 == incx)
11174 continue;
11175
11176 /* vary incy = -2, -1, 1, 2 */
11177 for (incy_val = INCY_START; incy_val <= INCY_END;
11178 incy_val++) {
11179
11180 incy = incy_val;
11181 if (0 == incy)
11182 continue;
11183
11184 /* copy generated vector with appropriate incs. */
11185 zcopy_vector(y_gen, n, 1, y, incy);
11186 dcopy_vector(head_x_gen, n, 1, head_x, incx);
11187 dcopy_vector(tail_x_gen, n, 1, tail_x, incx);
11188
11189 /* call symv2 routines to be tested */
11190 FPU_FIX_STOP;
11191 BLAS_zsymv2_d_d_x(order_type,
11192 uplo_type, n, alpha, a, lda, head_x,
11193 tail_x, incx, beta, y, incy, prec);
11194 FPU_FIX_START;
11195
11196 /* now compute the ratio using test_BLAS_xdot */
11197 /* copy a row from A, use x, run dot test */
11198
11199 incyi = incy;
11200 incyi *= 2;
11201 yi0 = (incy > 0) ? 0 : (-n + 1) * incyi;
11202
11203 for (i = 0, yi = yi0, ri = 0;
11204 i < n; i++, yi += incyi, ri += incri) {
11205 dsy_copy_row(order_type, uplo_type, n, a, lda, a_vec,
11206 i);
11207
11208 /* just use the x vector - it was unchanged (in theory) */
11209 rin[0] = y_gen[i];
11210 rin[1] = y_gen[i + 1];
11211 rout[0] = y[yi];
11212 rout[1] = y[yi + 1];
11213 head_r_true_elem[0] = head_r_true[ri];
11214 head_r_true_elem[1] = head_r_true[ri + 1];
11215 tail_r_true_elem[0] = tail_r_true[ri];
11216 tail_r_true_elem[1] = tail_r_true[ri + 1];
11217
11218 test_BLAS_zdot2_d_d(n, blas_no_conj, alpha, beta,
11219 rin, rout, head_r_true_elem,
11220 tail_r_true_elem, a_vec, 1,
11221 head_x, tail_x, incx, eps_int,
11222 un_int, &ratios[i]);
11223
11224 /* take the max ratio */
11225 if (i == 0) {
11226 ratio = ratios[0];
11227
11228 /* The !<= below causes NaN errors to be included.
11229 * Note that (NaN > 0) is false */
11230 } else if (!(ratios[i] <= ratio)) {
11231 ratio = ratios[i];
11232 }
11233
11234 } /* end of dot-test loop */
11235
11236
11237 /* The !<= below causes NaN errors to be included.
11238 * Note that (NaN > 0) is false */
11239 if (!(ratio <= thresh)) {
11240
11241 if (debug == 3) {
11242 printf("\n\t\tTest # %d\n", test_count);
11243 printf("y type : z, a type : d, x type : d\n");
11244 printf("Seed = %d\t", saved_seed);
11245 printf("n %d\n", n);
11246 printf("LDA %d INCX %d INCY %d\n", lda, incx,
11247 incx);
11248
11249 if (order_type == blas_rowmajor)
11250 printf("row ");
11251 else
11252 printf("col ");
11253
11254 if (uplo_type == blas_upper)
11255 printf("upper ");
11256 else
11257 printf("lower ");
11258
11259 printf("NORM %d, ALPHA %d, BETA %d\n",
11260 norm, alpha_val, beta_val);
11261
11262 /* print out info */
11263 printf("alpha = ");
11264 printf("(%24.16e, %24.16e)", alpha[0], alpha[1]);;
11265 printf(" ");
11266 printf("beta = ");
11267 printf("(%24.16e, %24.16e)", beta[0], beta[1]);;
11268 printf("\n");
11269
11270 printf("a\n");
11271 dsy_print_matrix(a, n, lda, order_type, uplo_type);
11272 dprint_vector(head_x, n, incx, "head_x");
11273 dprint_vector(tail_x, n, incx, "tail_x");
11274 zprint_vector(y_gen, n, incy, "y_gen");
11275 zprint_vector(y, n, incy, "y");
11276 zprint_vector(head_r_true, n, 1, "head_r_true");
11277 dprint_vector(ratios, n, 1, "ratios");
11278 printf("ratio = %g\n", ratio);
11279 }
11280 bad_ratio_count++;
11281 if (bad_ratio_count >= MAX_BAD_TESTS) {
11282 printf("\ntoo many failures, exiting....");
11283 printf("\nTesting and compilation");
11284 printf(" are incomplete\n\n");
11285 goto end;
11286 }
11287 if (!(ratio <= TOTAL_FAILURE_THRESHOLD)) {
11288 printf("\nFlagrant ratio error, exiting...");
11289 printf("\nTesting and compilation");
11290 printf(" are incomplete\n\n");
11291 goto end;
11292 }
11293 }
11294
11295 if (!(ratio <= ratio_max))
11296 ratio_max = ratio;
11297
11298 if (ratio != 0.0 && !(ratio >= ratio_min))
11299 ratio_min = ratio;
11300
11301 } /* end of incy loop */
11302
11303 } /* end of incx loop */
11304
11305 } /* end of lda loop */
11306
11307 } /* end of uplo loop */
11308
11309 } /* end of order loop */
11310
11311 } /* end of nr test loop */
11312
11313 } /* end of norm loop */
11314
11315
11316 } /* end of prec loop */
11317
11318 } /* end of beta loop */
11319
11320 } /* end of alpha loop */
11321
11322 end:
11323 FPU_FIX_STOP;
11324
11325 blas_free(y);
11326 blas_free(a);
11327 blas_free(y_gen);
11328 blas_free(head_x);
11329 blas_free(tail_x);
11330 blas_free(head_x_gen);
11331 blas_free(tail_x_gen);
11332 blas_free(head_r_true);
11333 blas_free(tail_r_true);
11334 blas_free(ratios);
11335 blas_free(a_vec);
11336
11337 *max_ratio = ratio_max;
11338 *min_ratio = ratio_min;
11339 *num_tests = test_count;
11340 *num_bad_ratio = bad_ratio_count;
11341
11342 }
11343
main(int argc,char ** argv)11344 int main(int argc, char **argv)
11345 {
11346 int nsizes, ntests, debug;
11347 double thresh, test_prob;
11348 double total_min_ratio, total_max_ratio;
11349 int total_bad_ratios;
11350 int seed, num_bad_ratio, num_tests;
11351 int total_tests, nr_failed_routines = 0, nr_routines = 0;
11352 double min_ratio, max_ratio;
11353 const char *base_routine = "symv2";
11354 char *fname;
11355 int n;
11356
11357 int i;
11358 int n_data[NUM_DATA][1] = { {4}, {2}, {3}, {8}, {10}, {1}, {7} };
11359
11360 if (argc != 6) {
11361 printf("Usage:\n");
11362 printf("do_test_symv2 <nsizes> <ntests> <thresh> <debug> <test_prob>\n");
11363 printf(" <nsizes>: number of sizes to be run.\n");
11364 printf
11365 (" <ntests>: the number of tests performed for each set of attributes\n");
11366 printf
11367 (" <thresh>: to catch bad ratios if it is greater than <thresh>\n");
11368 printf(" <debug>: 0, 1, 2, or 3; \n");
11369 printf(" if 0, no printing \n");
11370 printf(" if 1, print error summary only if tests fail\n");
11371 printf(" if 2, print error summary for each n\n");
11372 printf(" if 3, print complete info each test fails \n");
11373 printf("<test_prob>: probability of preforming a given \n");
11374 printf(" test case: 0.0 does no tests, 1.0 does all tests\n");
11375 return -1;
11376 } else {
11377 nsizes = atoi(argv[1]);
11378 ntests = atoi(argv[2]);
11379 thresh = atof(argv[3]);
11380 debug = atoi(argv[4]);
11381 test_prob = atof(argv[5]);
11382 }
11383
11384 seed = 1999;
11385
11386 if (nsizes < 0 || ntests < 0 || debug < 0 || debug > 3)
11387 BLAS_error("Testing symv2", 0, 0, NULL);
11388
11389 printf("Testing %s...\n", base_routine);
11390 printf("INPUT: nsizes = %d, ntests = %d, thresh = %4.2f, debug = %d\n\n",
11391 nsizes, ntests, thresh, debug);
11392
11393
11394
11395 if (nsizes < 0 || nsizes > NUM_DATA)
11396 BLAS_error("do_test_symv2", -1, nsizes, NULL);
11397
11398 fname = "BLAS_dsymv2_d_s";
11399 printf("Testing %s...\n", fname);
11400 total_tests = 0;
11401 total_bad_ratios = 0;
11402 total_min_ratio = 1e308;
11403 total_max_ratio = 0.0;
11404 for (i = 0; i < nsizes; i++) {
11405 n = n_data[i][0];
11406
11407 do_test_dsymv2_d_s(n, ntests, &seed, thresh, debug,
11408 test_prob,
11409 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11410
11411 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11412 printf(" [%d %d]: ", n, n);
11413 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11414 num_bad_ratio, num_tests, min_ratio, max_ratio);
11415 }
11416
11417 total_tests += num_tests;
11418 total_bad_ratios += num_bad_ratio;
11419 if (total_min_ratio > min_ratio)
11420 total_min_ratio = min_ratio;
11421 if (total_max_ratio < max_ratio)
11422 total_max_ratio = max_ratio;
11423 }
11424
11425 nr_routines++;
11426 if (total_bad_ratios == 0)
11427 printf("PASS> ");
11428 else {
11429 printf("FAIL> ");
11430 nr_failed_routines++;
11431 }
11432 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11433 fname, total_bad_ratios, total_tests, max_ratio);
11434
11435 fname = "BLAS_dsymv2_s_d";
11436 printf("Testing %s...\n", fname);
11437 total_tests = 0;
11438 total_bad_ratios = 0;
11439 total_min_ratio = 1e308;
11440 total_max_ratio = 0.0;
11441 for (i = 0; i < nsizes; i++) {
11442 n = n_data[i][0];
11443
11444 do_test_dsymv2_s_d(n, ntests, &seed, thresh, debug,
11445 test_prob,
11446 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11447
11448 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11449 printf(" [%d %d]: ", n, n);
11450 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11451 num_bad_ratio, num_tests, min_ratio, max_ratio);
11452 }
11453
11454 total_tests += num_tests;
11455 total_bad_ratios += num_bad_ratio;
11456 if (total_min_ratio > min_ratio)
11457 total_min_ratio = min_ratio;
11458 if (total_max_ratio < max_ratio)
11459 total_max_ratio = max_ratio;
11460 }
11461
11462 nr_routines++;
11463 if (total_bad_ratios == 0)
11464 printf("PASS> ");
11465 else {
11466 printf("FAIL> ");
11467 nr_failed_routines++;
11468 }
11469 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11470 fname, total_bad_ratios, total_tests, max_ratio);
11471
11472 fname = "BLAS_dsymv2_s_s";
11473 printf("Testing %s...\n", fname);
11474 total_tests = 0;
11475 total_bad_ratios = 0;
11476 total_min_ratio = 1e308;
11477 total_max_ratio = 0.0;
11478 for (i = 0; i < nsizes; i++) {
11479 n = n_data[i][0];
11480
11481 do_test_dsymv2_s_s(n, ntests, &seed, thresh, debug,
11482 test_prob,
11483 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11484
11485 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11486 printf(" [%d %d]: ", n, n);
11487 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11488 num_bad_ratio, num_tests, min_ratio, max_ratio);
11489 }
11490
11491 total_tests += num_tests;
11492 total_bad_ratios += num_bad_ratio;
11493 if (total_min_ratio > min_ratio)
11494 total_min_ratio = min_ratio;
11495 if (total_max_ratio < max_ratio)
11496 total_max_ratio = max_ratio;
11497 }
11498
11499 nr_routines++;
11500 if (total_bad_ratios == 0)
11501 printf("PASS> ");
11502 else {
11503 printf("FAIL> ");
11504 nr_failed_routines++;
11505 }
11506 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11507 fname, total_bad_ratios, total_tests, max_ratio);
11508
11509 fname = "BLAS_zsymv2_z_c";
11510 printf("Testing %s...\n", fname);
11511 total_tests = 0;
11512 total_bad_ratios = 0;
11513 total_min_ratio = 1e308;
11514 total_max_ratio = 0.0;
11515 for (i = 0; i < nsizes; i++) {
11516 n = n_data[i][0];
11517
11518 do_test_zsymv2_z_c(n, ntests, &seed, thresh, debug,
11519 test_prob,
11520 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11521
11522 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11523 printf(" [%d %d]: ", n, n);
11524 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11525 num_bad_ratio, num_tests, min_ratio, max_ratio);
11526 }
11527
11528 total_tests += num_tests;
11529 total_bad_ratios += num_bad_ratio;
11530 if (total_min_ratio > min_ratio)
11531 total_min_ratio = min_ratio;
11532 if (total_max_ratio < max_ratio)
11533 total_max_ratio = max_ratio;
11534 }
11535
11536 nr_routines++;
11537 if (total_bad_ratios == 0)
11538 printf("PASS> ");
11539 else {
11540 printf("FAIL> ");
11541 nr_failed_routines++;
11542 }
11543 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11544 fname, total_bad_ratios, total_tests, max_ratio);
11545
11546 fname = "BLAS_zsymv2_c_z";
11547 printf("Testing %s...\n", fname);
11548 total_tests = 0;
11549 total_bad_ratios = 0;
11550 total_min_ratio = 1e308;
11551 total_max_ratio = 0.0;
11552 for (i = 0; i < nsizes; i++) {
11553 n = n_data[i][0];
11554
11555 do_test_zsymv2_c_z(n, ntests, &seed, thresh, debug,
11556 test_prob,
11557 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11558
11559 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11560 printf(" [%d %d]: ", n, n);
11561 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11562 num_bad_ratio, num_tests, min_ratio, max_ratio);
11563 }
11564
11565 total_tests += num_tests;
11566 total_bad_ratios += num_bad_ratio;
11567 if (total_min_ratio > min_ratio)
11568 total_min_ratio = min_ratio;
11569 if (total_max_ratio < max_ratio)
11570 total_max_ratio = max_ratio;
11571 }
11572
11573 nr_routines++;
11574 if (total_bad_ratios == 0)
11575 printf("PASS> ");
11576 else {
11577 printf("FAIL> ");
11578 nr_failed_routines++;
11579 }
11580 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11581 fname, total_bad_ratios, total_tests, max_ratio);
11582
11583 fname = "BLAS_zsymv2_c_c";
11584 printf("Testing %s...\n", fname);
11585 total_tests = 0;
11586 total_bad_ratios = 0;
11587 total_min_ratio = 1e308;
11588 total_max_ratio = 0.0;
11589 for (i = 0; i < nsizes; i++) {
11590 n = n_data[i][0];
11591
11592 do_test_zsymv2_c_c(n, ntests, &seed, thresh, debug,
11593 test_prob,
11594 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11595
11596 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11597 printf(" [%d %d]: ", n, n);
11598 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11599 num_bad_ratio, num_tests, min_ratio, max_ratio);
11600 }
11601
11602 total_tests += num_tests;
11603 total_bad_ratios += num_bad_ratio;
11604 if (total_min_ratio > min_ratio)
11605 total_min_ratio = min_ratio;
11606 if (total_max_ratio < max_ratio)
11607 total_max_ratio = max_ratio;
11608 }
11609
11610 nr_routines++;
11611 if (total_bad_ratios == 0)
11612 printf("PASS> ");
11613 else {
11614 printf("FAIL> ");
11615 nr_failed_routines++;
11616 }
11617 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11618 fname, total_bad_ratios, total_tests, max_ratio);
11619
11620 fname = "BLAS_csymv2_c_s";
11621 printf("Testing %s...\n", fname);
11622 total_tests = 0;
11623 total_bad_ratios = 0;
11624 total_min_ratio = 1e308;
11625 total_max_ratio = 0.0;
11626 for (i = 0; i < nsizes; i++) {
11627 n = n_data[i][0];
11628
11629 do_test_csymv2_c_s(n, ntests, &seed, thresh, debug,
11630 test_prob,
11631 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11632
11633 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11634 printf(" [%d %d]: ", n, n);
11635 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11636 num_bad_ratio, num_tests, min_ratio, max_ratio);
11637 }
11638
11639 total_tests += num_tests;
11640 total_bad_ratios += num_bad_ratio;
11641 if (total_min_ratio > min_ratio)
11642 total_min_ratio = min_ratio;
11643 if (total_max_ratio < max_ratio)
11644 total_max_ratio = max_ratio;
11645 }
11646
11647 nr_routines++;
11648 if (total_bad_ratios == 0)
11649 printf("PASS> ");
11650 else {
11651 printf("FAIL> ");
11652 nr_failed_routines++;
11653 }
11654 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11655 fname, total_bad_ratios, total_tests, max_ratio);
11656
11657 fname = "BLAS_csymv2_s_c";
11658 printf("Testing %s...\n", fname);
11659 total_tests = 0;
11660 total_bad_ratios = 0;
11661 total_min_ratio = 1e308;
11662 total_max_ratio = 0.0;
11663 for (i = 0; i < nsizes; i++) {
11664 n = n_data[i][0];
11665
11666 do_test_csymv2_s_c(n, ntests, &seed, thresh, debug,
11667 test_prob,
11668 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11669
11670 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11671 printf(" [%d %d]: ", n, n);
11672 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11673 num_bad_ratio, num_tests, min_ratio, max_ratio);
11674 }
11675
11676 total_tests += num_tests;
11677 total_bad_ratios += num_bad_ratio;
11678 if (total_min_ratio > min_ratio)
11679 total_min_ratio = min_ratio;
11680 if (total_max_ratio < max_ratio)
11681 total_max_ratio = max_ratio;
11682 }
11683
11684 nr_routines++;
11685 if (total_bad_ratios == 0)
11686 printf("PASS> ");
11687 else {
11688 printf("FAIL> ");
11689 nr_failed_routines++;
11690 }
11691 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11692 fname, total_bad_ratios, total_tests, max_ratio);
11693
11694 fname = "BLAS_csymv2_s_s";
11695 printf("Testing %s...\n", fname);
11696 total_tests = 0;
11697 total_bad_ratios = 0;
11698 total_min_ratio = 1e308;
11699 total_max_ratio = 0.0;
11700 for (i = 0; i < nsizes; i++) {
11701 n = n_data[i][0];
11702
11703 do_test_csymv2_s_s(n, ntests, &seed, thresh, debug,
11704 test_prob,
11705 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11706
11707 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11708 printf(" [%d %d]: ", n, n);
11709 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11710 num_bad_ratio, num_tests, min_ratio, max_ratio);
11711 }
11712
11713 total_tests += num_tests;
11714 total_bad_ratios += num_bad_ratio;
11715 if (total_min_ratio > min_ratio)
11716 total_min_ratio = min_ratio;
11717 if (total_max_ratio < max_ratio)
11718 total_max_ratio = max_ratio;
11719 }
11720
11721 nr_routines++;
11722 if (total_bad_ratios == 0)
11723 printf("PASS> ");
11724 else {
11725 printf("FAIL> ");
11726 nr_failed_routines++;
11727 }
11728 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11729 fname, total_bad_ratios, total_tests, max_ratio);
11730
11731 fname = "BLAS_zsymv2_z_d";
11732 printf("Testing %s...\n", fname);
11733 total_tests = 0;
11734 total_bad_ratios = 0;
11735 total_min_ratio = 1e308;
11736 total_max_ratio = 0.0;
11737 for (i = 0; i < nsizes; i++) {
11738 n = n_data[i][0];
11739
11740 do_test_zsymv2_z_d(n, ntests, &seed, thresh, debug,
11741 test_prob,
11742 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11743
11744 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11745 printf(" [%d %d]: ", n, n);
11746 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11747 num_bad_ratio, num_tests, min_ratio, max_ratio);
11748 }
11749
11750 total_tests += num_tests;
11751 total_bad_ratios += num_bad_ratio;
11752 if (total_min_ratio > min_ratio)
11753 total_min_ratio = min_ratio;
11754 if (total_max_ratio < max_ratio)
11755 total_max_ratio = max_ratio;
11756 }
11757
11758 nr_routines++;
11759 if (total_bad_ratios == 0)
11760 printf("PASS> ");
11761 else {
11762 printf("FAIL> ");
11763 nr_failed_routines++;
11764 }
11765 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11766 fname, total_bad_ratios, total_tests, max_ratio);
11767
11768 fname = "BLAS_zsymv2_d_z";
11769 printf("Testing %s...\n", fname);
11770 total_tests = 0;
11771 total_bad_ratios = 0;
11772 total_min_ratio = 1e308;
11773 total_max_ratio = 0.0;
11774 for (i = 0; i < nsizes; i++) {
11775 n = n_data[i][0];
11776
11777 do_test_zsymv2_d_z(n, ntests, &seed, thresh, debug,
11778 test_prob,
11779 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11780
11781 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11782 printf(" [%d %d]: ", n, n);
11783 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11784 num_bad_ratio, num_tests, min_ratio, max_ratio);
11785 }
11786
11787 total_tests += num_tests;
11788 total_bad_ratios += num_bad_ratio;
11789 if (total_min_ratio > min_ratio)
11790 total_min_ratio = min_ratio;
11791 if (total_max_ratio < max_ratio)
11792 total_max_ratio = max_ratio;
11793 }
11794
11795 nr_routines++;
11796 if (total_bad_ratios == 0)
11797 printf("PASS> ");
11798 else {
11799 printf("FAIL> ");
11800 nr_failed_routines++;
11801 }
11802 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11803 fname, total_bad_ratios, total_tests, max_ratio);
11804
11805 fname = "BLAS_zsymv2_d_d";
11806 printf("Testing %s...\n", fname);
11807 total_tests = 0;
11808 total_bad_ratios = 0;
11809 total_min_ratio = 1e308;
11810 total_max_ratio = 0.0;
11811 for (i = 0; i < nsizes; i++) {
11812 n = n_data[i][0];
11813
11814 do_test_zsymv2_d_d(n, ntests, &seed, thresh, debug,
11815 test_prob,
11816 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11817
11818 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11819 printf(" [%d %d]: ", n, n);
11820 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11821 num_bad_ratio, num_tests, min_ratio, max_ratio);
11822 }
11823
11824 total_tests += num_tests;
11825 total_bad_ratios += num_bad_ratio;
11826 if (total_min_ratio > min_ratio)
11827 total_min_ratio = min_ratio;
11828 if (total_max_ratio < max_ratio)
11829 total_max_ratio = max_ratio;
11830 }
11831
11832 nr_routines++;
11833 if (total_bad_ratios == 0)
11834 printf("PASS> ");
11835 else {
11836 printf("FAIL> ");
11837 nr_failed_routines++;
11838 }
11839 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11840 fname, total_bad_ratios, total_tests, max_ratio);
11841
11842 fname = "BLAS_ssymv2_x";
11843 printf("Testing %s...\n", fname);
11844 total_tests = 0;
11845 total_bad_ratios = 0;
11846 total_min_ratio = 1e308;
11847 total_max_ratio = 0.0;
11848 for (i = 0; i < nsizes; i++) {
11849 n = n_data[i][0];
11850
11851 do_test_ssymv2_x(n, ntests, &seed, thresh, debug,
11852 test_prob,
11853 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11854
11855 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11856 printf(" [%d %d]: ", n, n);
11857 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11858 num_bad_ratio, num_tests, min_ratio, max_ratio);
11859 }
11860
11861 total_tests += num_tests;
11862 total_bad_ratios += num_bad_ratio;
11863 if (total_min_ratio > min_ratio)
11864 total_min_ratio = min_ratio;
11865 if (total_max_ratio < max_ratio)
11866 total_max_ratio = max_ratio;
11867 }
11868
11869 nr_routines++;
11870 if (total_bad_ratios == 0)
11871 printf("PASS> ");
11872 else {
11873 printf("FAIL> ");
11874 nr_failed_routines++;
11875 }
11876 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11877 fname, total_bad_ratios, total_tests, max_ratio);
11878
11879 fname = "BLAS_dsymv2_x";
11880 printf("Testing %s...\n", fname);
11881 total_tests = 0;
11882 total_bad_ratios = 0;
11883 total_min_ratio = 1e308;
11884 total_max_ratio = 0.0;
11885 for (i = 0; i < nsizes; i++) {
11886 n = n_data[i][0];
11887
11888 do_test_dsymv2_x(n, ntests, &seed, thresh, debug,
11889 test_prob,
11890 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11891
11892 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11893 printf(" [%d %d]: ", n, n);
11894 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11895 num_bad_ratio, num_tests, min_ratio, max_ratio);
11896 }
11897
11898 total_tests += num_tests;
11899 total_bad_ratios += num_bad_ratio;
11900 if (total_min_ratio > min_ratio)
11901 total_min_ratio = min_ratio;
11902 if (total_max_ratio < max_ratio)
11903 total_max_ratio = max_ratio;
11904 }
11905
11906 nr_routines++;
11907 if (total_bad_ratios == 0)
11908 printf("PASS> ");
11909 else {
11910 printf("FAIL> ");
11911 nr_failed_routines++;
11912 }
11913 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11914 fname, total_bad_ratios, total_tests, max_ratio);
11915
11916 fname = "BLAS_csymv2_x";
11917 printf("Testing %s...\n", fname);
11918 total_tests = 0;
11919 total_bad_ratios = 0;
11920 total_min_ratio = 1e308;
11921 total_max_ratio = 0.0;
11922 for (i = 0; i < nsizes; i++) {
11923 n = n_data[i][0];
11924
11925 do_test_csymv2_x(n, ntests, &seed, thresh, debug,
11926 test_prob,
11927 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11928
11929 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11930 printf(" [%d %d]: ", n, n);
11931 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11932 num_bad_ratio, num_tests, min_ratio, max_ratio);
11933 }
11934
11935 total_tests += num_tests;
11936 total_bad_ratios += num_bad_ratio;
11937 if (total_min_ratio > min_ratio)
11938 total_min_ratio = min_ratio;
11939 if (total_max_ratio < max_ratio)
11940 total_max_ratio = max_ratio;
11941 }
11942
11943 nr_routines++;
11944 if (total_bad_ratios == 0)
11945 printf("PASS> ");
11946 else {
11947 printf("FAIL> ");
11948 nr_failed_routines++;
11949 }
11950 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11951 fname, total_bad_ratios, total_tests, max_ratio);
11952
11953 fname = "BLAS_zsymv2_x";
11954 printf("Testing %s...\n", fname);
11955 total_tests = 0;
11956 total_bad_ratios = 0;
11957 total_min_ratio = 1e308;
11958 total_max_ratio = 0.0;
11959 for (i = 0; i < nsizes; i++) {
11960 n = n_data[i][0];
11961
11962 do_test_zsymv2_x(n, ntests, &seed, thresh, debug,
11963 test_prob,
11964 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
11965
11966 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
11967 printf(" [%d %d]: ", n, n);
11968 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
11969 num_bad_ratio, num_tests, min_ratio, max_ratio);
11970 }
11971
11972 total_tests += num_tests;
11973 total_bad_ratios += num_bad_ratio;
11974 if (total_min_ratio > min_ratio)
11975 total_min_ratio = min_ratio;
11976 if (total_max_ratio < max_ratio)
11977 total_max_ratio = max_ratio;
11978 }
11979
11980 nr_routines++;
11981 if (total_bad_ratios == 0)
11982 printf("PASS> ");
11983 else {
11984 printf("FAIL> ");
11985 nr_failed_routines++;
11986 }
11987 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
11988 fname, total_bad_ratios, total_tests, max_ratio);
11989
11990 fname = "BLAS_dsymv2_d_s_x";
11991 printf("Testing %s...\n", fname);
11992 total_tests = 0;
11993 total_bad_ratios = 0;
11994 total_min_ratio = 1e308;
11995 total_max_ratio = 0.0;
11996 for (i = 0; i < nsizes; i++) {
11997 n = n_data[i][0];
11998
11999 do_test_dsymv2_d_s_x(n, ntests, &seed, thresh, debug,
12000 test_prob,
12001 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12002
12003 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12004 printf(" [%d %d]: ", n, n);
12005 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12006 num_bad_ratio, num_tests, min_ratio, max_ratio);
12007 }
12008
12009 total_tests += num_tests;
12010 total_bad_ratios += num_bad_ratio;
12011 if (total_min_ratio > min_ratio)
12012 total_min_ratio = min_ratio;
12013 if (total_max_ratio < max_ratio)
12014 total_max_ratio = max_ratio;
12015 }
12016
12017 nr_routines++;
12018 if (total_bad_ratios == 0)
12019 printf("PASS> ");
12020 else {
12021 printf("FAIL> ");
12022 nr_failed_routines++;
12023 }
12024 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12025 fname, total_bad_ratios, total_tests, max_ratio);
12026
12027 fname = "BLAS_dsymv2_s_d_x";
12028 printf("Testing %s...\n", fname);
12029 total_tests = 0;
12030 total_bad_ratios = 0;
12031 total_min_ratio = 1e308;
12032 total_max_ratio = 0.0;
12033 for (i = 0; i < nsizes; i++) {
12034 n = n_data[i][0];
12035
12036 do_test_dsymv2_s_d_x(n, ntests, &seed, thresh, debug,
12037 test_prob,
12038 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12039
12040 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12041 printf(" [%d %d]: ", n, n);
12042 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12043 num_bad_ratio, num_tests, min_ratio, max_ratio);
12044 }
12045
12046 total_tests += num_tests;
12047 total_bad_ratios += num_bad_ratio;
12048 if (total_min_ratio > min_ratio)
12049 total_min_ratio = min_ratio;
12050 if (total_max_ratio < max_ratio)
12051 total_max_ratio = max_ratio;
12052 }
12053
12054 nr_routines++;
12055 if (total_bad_ratios == 0)
12056 printf("PASS> ");
12057 else {
12058 printf("FAIL> ");
12059 nr_failed_routines++;
12060 }
12061 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12062 fname, total_bad_ratios, total_tests, max_ratio);
12063
12064 fname = "BLAS_dsymv2_s_s_x";
12065 printf("Testing %s...\n", fname);
12066 total_tests = 0;
12067 total_bad_ratios = 0;
12068 total_min_ratio = 1e308;
12069 total_max_ratio = 0.0;
12070 for (i = 0; i < nsizes; i++) {
12071 n = n_data[i][0];
12072
12073 do_test_dsymv2_s_s_x(n, ntests, &seed, thresh, debug,
12074 test_prob,
12075 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12076
12077 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12078 printf(" [%d %d]: ", n, n);
12079 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12080 num_bad_ratio, num_tests, min_ratio, max_ratio);
12081 }
12082
12083 total_tests += num_tests;
12084 total_bad_ratios += num_bad_ratio;
12085 if (total_min_ratio > min_ratio)
12086 total_min_ratio = min_ratio;
12087 if (total_max_ratio < max_ratio)
12088 total_max_ratio = max_ratio;
12089 }
12090
12091 nr_routines++;
12092 if (total_bad_ratios == 0)
12093 printf("PASS> ");
12094 else {
12095 printf("FAIL> ");
12096 nr_failed_routines++;
12097 }
12098 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12099 fname, total_bad_ratios, total_tests, max_ratio);
12100
12101 fname = "BLAS_zsymv2_z_c_x";
12102 printf("Testing %s...\n", fname);
12103 total_tests = 0;
12104 total_bad_ratios = 0;
12105 total_min_ratio = 1e308;
12106 total_max_ratio = 0.0;
12107 for (i = 0; i < nsizes; i++) {
12108 n = n_data[i][0];
12109
12110 do_test_zsymv2_z_c_x(n, ntests, &seed, thresh, debug,
12111 test_prob,
12112 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12113
12114 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12115 printf(" [%d %d]: ", n, n);
12116 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12117 num_bad_ratio, num_tests, min_ratio, max_ratio);
12118 }
12119
12120 total_tests += num_tests;
12121 total_bad_ratios += num_bad_ratio;
12122 if (total_min_ratio > min_ratio)
12123 total_min_ratio = min_ratio;
12124 if (total_max_ratio < max_ratio)
12125 total_max_ratio = max_ratio;
12126 }
12127
12128 nr_routines++;
12129 if (total_bad_ratios == 0)
12130 printf("PASS> ");
12131 else {
12132 printf("FAIL> ");
12133 nr_failed_routines++;
12134 }
12135 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12136 fname, total_bad_ratios, total_tests, max_ratio);
12137
12138 fname = "BLAS_zsymv2_c_z_x";
12139 printf("Testing %s...\n", fname);
12140 total_tests = 0;
12141 total_bad_ratios = 0;
12142 total_min_ratio = 1e308;
12143 total_max_ratio = 0.0;
12144 for (i = 0; i < nsizes; i++) {
12145 n = n_data[i][0];
12146
12147 do_test_zsymv2_c_z_x(n, ntests, &seed, thresh, debug,
12148 test_prob,
12149 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12150
12151 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12152 printf(" [%d %d]: ", n, n);
12153 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12154 num_bad_ratio, num_tests, min_ratio, max_ratio);
12155 }
12156
12157 total_tests += num_tests;
12158 total_bad_ratios += num_bad_ratio;
12159 if (total_min_ratio > min_ratio)
12160 total_min_ratio = min_ratio;
12161 if (total_max_ratio < max_ratio)
12162 total_max_ratio = max_ratio;
12163 }
12164
12165 nr_routines++;
12166 if (total_bad_ratios == 0)
12167 printf("PASS> ");
12168 else {
12169 printf("FAIL> ");
12170 nr_failed_routines++;
12171 }
12172 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12173 fname, total_bad_ratios, total_tests, max_ratio);
12174
12175 fname = "BLAS_zsymv2_c_c_x";
12176 printf("Testing %s...\n", fname);
12177 total_tests = 0;
12178 total_bad_ratios = 0;
12179 total_min_ratio = 1e308;
12180 total_max_ratio = 0.0;
12181 for (i = 0; i < nsizes; i++) {
12182 n = n_data[i][0];
12183
12184 do_test_zsymv2_c_c_x(n, ntests, &seed, thresh, debug,
12185 test_prob,
12186 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12187
12188 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12189 printf(" [%d %d]: ", n, n);
12190 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12191 num_bad_ratio, num_tests, min_ratio, max_ratio);
12192 }
12193
12194 total_tests += num_tests;
12195 total_bad_ratios += num_bad_ratio;
12196 if (total_min_ratio > min_ratio)
12197 total_min_ratio = min_ratio;
12198 if (total_max_ratio < max_ratio)
12199 total_max_ratio = max_ratio;
12200 }
12201
12202 nr_routines++;
12203 if (total_bad_ratios == 0)
12204 printf("PASS> ");
12205 else {
12206 printf("FAIL> ");
12207 nr_failed_routines++;
12208 }
12209 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12210 fname, total_bad_ratios, total_tests, max_ratio);
12211
12212 fname = "BLAS_csymv2_c_s_x";
12213 printf("Testing %s...\n", fname);
12214 total_tests = 0;
12215 total_bad_ratios = 0;
12216 total_min_ratio = 1e308;
12217 total_max_ratio = 0.0;
12218 for (i = 0; i < nsizes; i++) {
12219 n = n_data[i][0];
12220
12221 do_test_csymv2_c_s_x(n, ntests, &seed, thresh, debug,
12222 test_prob,
12223 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12224
12225 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12226 printf(" [%d %d]: ", n, n);
12227 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12228 num_bad_ratio, num_tests, min_ratio, max_ratio);
12229 }
12230
12231 total_tests += num_tests;
12232 total_bad_ratios += num_bad_ratio;
12233 if (total_min_ratio > min_ratio)
12234 total_min_ratio = min_ratio;
12235 if (total_max_ratio < max_ratio)
12236 total_max_ratio = max_ratio;
12237 }
12238
12239 nr_routines++;
12240 if (total_bad_ratios == 0)
12241 printf("PASS> ");
12242 else {
12243 printf("FAIL> ");
12244 nr_failed_routines++;
12245 }
12246 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12247 fname, total_bad_ratios, total_tests, max_ratio);
12248
12249 fname = "BLAS_csymv2_s_c_x";
12250 printf("Testing %s...\n", fname);
12251 total_tests = 0;
12252 total_bad_ratios = 0;
12253 total_min_ratio = 1e308;
12254 total_max_ratio = 0.0;
12255 for (i = 0; i < nsizes; i++) {
12256 n = n_data[i][0];
12257
12258 do_test_csymv2_s_c_x(n, ntests, &seed, thresh, debug,
12259 test_prob,
12260 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12261
12262 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12263 printf(" [%d %d]: ", n, n);
12264 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12265 num_bad_ratio, num_tests, min_ratio, max_ratio);
12266 }
12267
12268 total_tests += num_tests;
12269 total_bad_ratios += num_bad_ratio;
12270 if (total_min_ratio > min_ratio)
12271 total_min_ratio = min_ratio;
12272 if (total_max_ratio < max_ratio)
12273 total_max_ratio = max_ratio;
12274 }
12275
12276 nr_routines++;
12277 if (total_bad_ratios == 0)
12278 printf("PASS> ");
12279 else {
12280 printf("FAIL> ");
12281 nr_failed_routines++;
12282 }
12283 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12284 fname, total_bad_ratios, total_tests, max_ratio);
12285
12286 fname = "BLAS_csymv2_s_s_x";
12287 printf("Testing %s...\n", fname);
12288 total_tests = 0;
12289 total_bad_ratios = 0;
12290 total_min_ratio = 1e308;
12291 total_max_ratio = 0.0;
12292 for (i = 0; i < nsizes; i++) {
12293 n = n_data[i][0];
12294
12295 do_test_csymv2_s_s_x(n, ntests, &seed, thresh, debug,
12296 test_prob,
12297 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12298
12299 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12300 printf(" [%d %d]: ", n, n);
12301 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12302 num_bad_ratio, num_tests, min_ratio, max_ratio);
12303 }
12304
12305 total_tests += num_tests;
12306 total_bad_ratios += num_bad_ratio;
12307 if (total_min_ratio > min_ratio)
12308 total_min_ratio = min_ratio;
12309 if (total_max_ratio < max_ratio)
12310 total_max_ratio = max_ratio;
12311 }
12312
12313 nr_routines++;
12314 if (total_bad_ratios == 0)
12315 printf("PASS> ");
12316 else {
12317 printf("FAIL> ");
12318 nr_failed_routines++;
12319 }
12320 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12321 fname, total_bad_ratios, total_tests, max_ratio);
12322
12323 fname = "BLAS_zsymv2_z_d_x";
12324 printf("Testing %s...\n", fname);
12325 total_tests = 0;
12326 total_bad_ratios = 0;
12327 total_min_ratio = 1e308;
12328 total_max_ratio = 0.0;
12329 for (i = 0; i < nsizes; i++) {
12330 n = n_data[i][0];
12331
12332 do_test_zsymv2_z_d_x(n, ntests, &seed, thresh, debug,
12333 test_prob,
12334 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12335
12336 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12337 printf(" [%d %d]: ", n, n);
12338 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12339 num_bad_ratio, num_tests, min_ratio, max_ratio);
12340 }
12341
12342 total_tests += num_tests;
12343 total_bad_ratios += num_bad_ratio;
12344 if (total_min_ratio > min_ratio)
12345 total_min_ratio = min_ratio;
12346 if (total_max_ratio < max_ratio)
12347 total_max_ratio = max_ratio;
12348 }
12349
12350 nr_routines++;
12351 if (total_bad_ratios == 0)
12352 printf("PASS> ");
12353 else {
12354 printf("FAIL> ");
12355 nr_failed_routines++;
12356 }
12357 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12358 fname, total_bad_ratios, total_tests, max_ratio);
12359
12360 fname = "BLAS_zsymv2_d_z_x";
12361 printf("Testing %s...\n", fname);
12362 total_tests = 0;
12363 total_bad_ratios = 0;
12364 total_min_ratio = 1e308;
12365 total_max_ratio = 0.0;
12366 for (i = 0; i < nsizes; i++) {
12367 n = n_data[i][0];
12368
12369 do_test_zsymv2_d_z_x(n, ntests, &seed, thresh, debug,
12370 test_prob,
12371 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12372
12373 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12374 printf(" [%d %d]: ", n, n);
12375 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12376 num_bad_ratio, num_tests, min_ratio, max_ratio);
12377 }
12378
12379 total_tests += num_tests;
12380 total_bad_ratios += num_bad_ratio;
12381 if (total_min_ratio > min_ratio)
12382 total_min_ratio = min_ratio;
12383 if (total_max_ratio < max_ratio)
12384 total_max_ratio = max_ratio;
12385 }
12386
12387 nr_routines++;
12388 if (total_bad_ratios == 0)
12389 printf("PASS> ");
12390 else {
12391 printf("FAIL> ");
12392 nr_failed_routines++;
12393 }
12394 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12395 fname, total_bad_ratios, total_tests, max_ratio);
12396
12397 fname = "BLAS_zsymv2_d_d_x";
12398 printf("Testing %s...\n", fname);
12399 total_tests = 0;
12400 total_bad_ratios = 0;
12401 total_min_ratio = 1e308;
12402 total_max_ratio = 0.0;
12403 for (i = 0; i < nsizes; i++) {
12404 n = n_data[i][0];
12405
12406 do_test_zsymv2_d_d_x(n, ntests, &seed, thresh, debug,
12407 test_prob,
12408 &min_ratio, &max_ratio, &num_bad_ratio, &num_tests);
12409
12410 if (debug == 2 || (debug == 1 && num_bad_ratio > 0)) {
12411 printf(" [%d %d]: ", n, n);
12412 printf("bad/total = %d/%d, min_ratio = %g, max_ratio = %g\n",
12413 num_bad_ratio, num_tests, min_ratio, max_ratio);
12414 }
12415
12416 total_tests += num_tests;
12417 total_bad_ratios += num_bad_ratio;
12418 if (total_min_ratio > min_ratio)
12419 total_min_ratio = min_ratio;
12420 if (total_max_ratio < max_ratio)
12421 total_max_ratio = max_ratio;
12422 }
12423
12424 nr_routines++;
12425 if (total_bad_ratios == 0)
12426 printf("PASS> ");
12427 else {
12428 printf("FAIL> ");
12429 nr_failed_routines++;
12430 }
12431 printf("%-24s: bad/total = %d/%d, max_ratio = %.2e\n\n",
12432 fname, total_bad_ratios, total_tests, max_ratio);
12433
12434
12435
12436 printf("\n");
12437 if (nr_failed_routines)
12438 printf("FAILED ");
12439 else
12440 printf("PASSED ");
12441 printf("%-10s: FAIL/TOTAL = %d/%d\n",
12442 base_routine, nr_failed_routines, nr_routines);
12443
12444 return 0;
12445 }
12446