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