1 #include <stdlib.h>
2 #include <stdio.h>
3 #include "blas_extended.h"
4 #include "blas_extended_test.h"
5
6 void
BLAS_sdot_x_testgen(int n,int n_fix2,int n_mix,int norm,enum blas_conj_type conj,float * alpha,int alpha_flag,float * beta,int beta_flag,double * x_l,double * x_t,float * y,int * seed,float * r,double * r_true_l,double * r_true_t)7 BLAS_sdot_x_testgen(int n, int n_fix2, int n_mix, int norm,
8 enum blas_conj_type conj,
9 float *alpha, int alpha_flag,
10 float *beta, int beta_flag,
11 double *x_l, double *x_t,
12 float *y, int *seed, float *r,
13 double *r_true_l, double *r_true_t)
14 /*
15 * Purpose
16 * =======
17 *
18 * This routine generates one row of the test inputs to BLAS_{s,d}_trsv_x.
19 *
20 * Arguments
21 * =========
22 *
23 * n (input) int
24 * The length of the vectors X and Y.
25 *
26 * n_fix2 (input) int
27 * Number of pairs in the vectors X and Y that are fixed in value,
28 *
29 * n_mix (input) int
30 * Number of pairs in the vectors X and Y with X(i) fixed
31 * and Y(i) free in value.
32 *
33 * norm (input) int
34 * = -1 : the vectors are scaled with norms near underflow.
35 * = 0 : the vectors have norms of order 1.
36 * = 1 : the vectors are scaled with norms near overflow.
37 *
38 * conj (input) enum blas_conj_type
39 *
40 * alpha (input/output) float*
41 * If alpha_flag = 1, alpha is input.
42 * If alpha_flag = 0, alpha is output.
43 *
44 * alpha_flag (input) int
45 * = 0 : alpha is free, and is output.
46 * = 1 : alpha is fixed on input.
47 *
48 * beta (input) float*
49 * If beta_flag = 1, beta is input.
50 * If beta_flag = 0, beta is output.
51 *
52 * beta_flag (input) int
53 * = 0 : beta is free, and is output.
54 * = 1 : beta is fixed on input.
55 *
56 * x_l (input) double*
57 * The leading part of the double-double X vector.
58 *
59 * x_t (input) double*
60 * The trailing part of the double-double X vector.
61 *
62 * y (input/output) float*
63 *
64 * seed (input/output) int*
65 * The seed for the random number generator.
66 *
67 * r (output) float*
68 * The generated scalar r that will be used as an input to DOT.
69 *
70 * r_true_l (output) double*
71 * The leading part of the truth in double-double.
72 *
73 * r_true_t (output) double*
74 * The trailing part of the truth in double-double.
75 *
76 */
77 {
78 /* Call generator now. */
79 testgen_BLAS_sdot_x(n, n_fix2, n_mix, norm, conj,
80 alpha, alpha_flag, beta, beta_flag,
81 x_l, x_t, y, seed, r, r_true_l, r_true_t);
82 } /* end BLAS_sdot_x_testgen */
83
84
85 void
BLAS_ddot_x_testgen(int n,int n_fix2,int n_mix,int norm,enum blas_conj_type conj,double * alpha,int alpha_flag,double * beta,int beta_flag,double * x_l,double * x_t,double * y,int * seed,double * r,double * r_true_l,double * r_true_t)86 BLAS_ddot_x_testgen(int n, int n_fix2, int n_mix, int norm,
87 enum blas_conj_type conj,
88 double *alpha, int alpha_flag,
89 double *beta, int beta_flag,
90 double *x_l, double *x_t,
91 double *y, int *seed, double *r,
92 double *r_true_l, double *r_true_t)
93 /*
94 * Purpose
95 * =======
96 *
97 * This routine generates the test inputs to BLAS_ddot_s_d{_x}.
98 *
99 * Arguments
100 * =========
101 *
102 * n (input) int
103 * The length of the vectors X and Y.
104 *
105 * n_fix2 (input) int
106 * Number of pairs in the vectors X and Y that are fixed in value,
107 *
108 * n_mix (input) int
109 * Number of pairs in the vectors X and Y with X(i) fixed
110 * and Y(i) free in value.
111 *
112 * norm (input) int
113 * = -1 : the vectors are scaled with norms near underflow.
114 * = 0 : the vectors have norms of order 1.
115 * = 1 : the vectors are scaled with norms near overflow.
116 *
117 * conj (input) enum blas_conj_type
118 *
119 * alpha (input/output) double*
120 * If alpha_flag = 1, alpha is input.
121 * If alpha_flag = 0, alpha is output.
122 *
123 * alpha_flag (input) int
124 * = 0 : alpha is free, and is output.
125 * = 1 : alpha is fixed on input.
126 *
127 * beta (input) double*
128 * If beta_flag = 1, beta is input.
129 * If beta_flag = 0, beta is output.
130 *
131 * beta_flag (input) int
132 * = 0 : beta is free, and is output.
133 * = 1 : beta is fixed on input.
134 *
135 * x_l (input) double*
136 * The leading part of the X vector in double-double.
137 *
138 * x_t (input) double*
139 * The trailing part of the X vector in double-double.
140 *
141 * y (input/output) double*
142 *
143 * seed (input/output) int*
144 * The seed for the random number generator.
145 *
146 * r (output) double*
147 * The generated scalar r that will be used as an input to DOT.
148 *
149 * r_true_l (output) double*
150 * The leading part of the truth in double-double.
151 *
152 * r_true_t (output) double*
153 * The trailing part of the truth in double-double.
154 *
155 */
156 {
157 int i;
158 float alpha_i;
159 float beta_i;
160 float r_i;
161 float *y_i;
162
163 alpha_i = *alpha;
164 beta_i = *beta;
165
166 y_i = (float *) malloc(n * sizeof(float));
167 if (y_i == NULL) {
168 printf("malloc failed\n");
169 exit(-1);
170 }
171 for (i = 0; i < n; ++i)
172 y_i[i] = y[i];
173
174 /*printf("dot_trsv0> r=%e, r_i=%e\n", *r, r_i); */
175 /* Call generator now. */
176 testgen_BLAS_sdot_x(n, n_fix2, n_mix, norm, conj,
177 &alpha_i, alpha_flag, &beta_i, beta_flag,
178 x_l, x_t, y_i, seed, &r_i, r_true_l, r_true_t);
179
180 *alpha = alpha_i;
181 *beta = beta_i;
182 *r = r_i;
183 /*printf("dot_trsv> r=%e, r_i=%e\n", *r, r_i); */
184
185 for (i = 0; i < n; ++i)
186 y[i] = y_i[i];
187
188 free(y_i);
189 } /* end BLAS_ddot_x_testgen */
190
191
192 void
BLAS_ddot_s_x_testgen(int n,int n_fix2,int n_mix,int norm,enum blas_conj_type conj,double * alpha,int alpha_flag,double * beta,int beta_flag,double * x_l,double * x_t,float * y,int * seed,double * r,double * r_true_l,double * r_true_t)193 BLAS_ddot_s_x_testgen(int n, int n_fix2, int n_mix, int norm,
194 enum blas_conj_type conj,
195 double *alpha, int alpha_flag,
196 double *beta, int beta_flag,
197 double *x_l, double *x_t,
198 float *y, int *seed, double *r,
199 double *r_true_l, double *r_true_t)
200 /*
201 * Purpose
202 * =======
203 *
204 * This routine generates the test inputs to BLAS_ddot_s_d{_x}.
205 *
206 * Arguments
207 * =========
208 *
209 * n (input) int
210 * The length of the vectors X and Y.
211 *
212 * n_fix2 (input) int
213 * Number of pairs in the vectors X and Y that are fixed in value,
214 *
215 * n_mix (input) int
216 * Number of pairs in the vectors X and Y with X(i) fixed
217 * and Y(i) free in value.
218 *
219 * norm (input) int
220 * = -1 : the vectors are scaled with norms near underflow.
221 * = 0 : the vectors have norms of order 1.
222 * = 1 : the vectors are scaled with norms near overflow.
223 *
224 * conj (input) enum blas_conj_type
225 *
226 * alpha (input/output) double*
227 * If alpha_flag = 1, alpha is input.
228 * If alpha_flag = 0, alpha is output.
229 *
230 * alpha_flag (input) int
231 * = 0 : alpha is free, and is output.
232 * = 1 : alpha is fixed on input.
233 *
234 * beta (input) double*
235 * If beta_flag = 1, beta is input.
236 * If beta_flag = 0, beta is output.
237 *
238 * beta_flag (input) int
239 * = 0 : beta is free, and is output.
240 * = 1 : beta is fixed on input.
241 *
242 * x_l (input) double*
243 * The leading part of the X vector in double-double.
244 *
245 * x_t (input) double*
246 * The trailing part of the X vector in double-double.
247 *
248 * y (input/output) float*
249 *
250 * seed (input/output) int*
251 * The seed for the random number generator.
252 *
253 * r (output) double*
254 * The generated scalar r that will be used as an input to DOT.
255 *
256 * r_true_l (output) double*
257 * The leading part of the truth in double-double.
258 *
259 * r_true_t (output) double*
260 * The trailing part of the truth in double-double.
261 *
262 */
263 {
264 float alpha_i;
265 float beta_i;
266 float r_i;
267
268 alpha_i = *alpha;
269 beta_i = *beta;
270
271 /* Call generator now. */
272 testgen_BLAS_sdot_x(n, n_fix2, n_mix, norm, conj,
273 &alpha_i, alpha_flag, &beta_i, beta_flag,
274 x_l, x_t, y, seed, &r_i, r_true_l, r_true_t);
275
276 *alpha = alpha_i;
277 *beta = beta_i;
278 *r = r_i;
279 } /* end BLAS_ddot_s_x_testgen */
280