28 int i, j, it, nCHin, nCHout, lenSig;
30 float** Q, **x, **y, **z, **Cx, **Cy, **Cz, **M, **Cr, **Mr, **Q_Cx, **Cp;
31 float** decor, **z_r, **eye_nCHout;
32 void* hCdf, *hCdf_res;
35 const float acceptedTolerance = 0.1f;
40 const int nIterations = 1000;
43 for(it=0; it<nIterations; it++){
45 nCHin = (int)(tmp*12.0f + 4.1f);
47 nCHout = (int)(tmp*12.0f + 4.1f);
49 lenSig = (int)(tmp*384.0f + 128.1f);
52 Q = (
float**)
calloc2d(nCHout, nCHin,
sizeof(
float));
53 for(i=0; i<
SAF_MIN(nCHin, nCHout); i++)
55 x = (
float**)
malloc2d(nCHin, lenSig,
sizeof(
float));
57 Cx = (
float**)
malloc2d(nCHin, nCHin,
sizeof(
float));
58 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans, nCHin, nCHin, lenSig, 1.0f,
64 y = (
float**)
malloc2d(nCHout, lenSig,
sizeof(
float));
66 Cy = (
float**)
malloc2d(nCHout, nCHout,
sizeof(
float));
67 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans, nCHout, nCHout, lenSig, 1.0f,
73 M = (
float**)
malloc2d(nCHout, nCHin,
sizeof(
float));
80 z = (
float**)
malloc2d(nCHout, lenSig,
sizeof(
float));
81 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nCHout, lenSig, nCHin, 1.0f,
85 Cz = (
float**)
malloc2d(nCHout, nCHout,
sizeof(
float));
86 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans, nCHout, nCHout, lenSig, 1.0f,
91 for(i=0; i<nCHout; i++)
92 for(j=0; j<nCHout; j++)
93 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, Cy[i][j], Cz[i][j]);
96 for(i=0; i<nCHout; i++)
97 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, Cy[i][i], Cz[i][i]);
101 Q_Cx = (
float**)
malloc2d(nCHout, nCHin,
sizeof(
float));
102 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nCHout, nCHin, nCHin, 1.0f,
106 Cp = (
float**)
malloc2d(nCHout, nCHout,
sizeof(
float));
107 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans, nCHout, nCHout, nCHin, 1.0f,
111 for(i=0; i<nCHout; i++)
112 for(j=0; j<nCHout; j++)
119 decor = (
float**)
malloc2d(nCHout, lenSig,
sizeof(
float));
124 M = (
float**)
malloc2d(nCHout, nCHin,
sizeof(
float));
126 Cr = (
float**)
malloc2d(nCHout, nCHout,
sizeof(
float));
129 Mr = (
float**)
calloc2d(nCHout, nCHout,
sizeof(
float));
130 eye_nCHout = (
float**)
calloc2d(nCHout, nCHout,
sizeof(
float));
131 for(i=0; i<nCHout; i++)
132 eye_nCHout[i][i] = 1.0f;
137 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nCHout, lenSig, nCHin, 1.0f,
141 z_r = (
float**)
malloc2d(nCHout, lenSig,
sizeof(
float));
142 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nCHout, lenSig, nCHout, 1.0f,
151 for(i=0; i<nCHout; i++)
152 for(j=0; j<nCHout; j++)
153 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, Cy[i][j], Cz[i][j]);
156 for(i=0; i<nCHout; i++)
157 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, Cy[i][i], Cz[i][i]);
182 int i, j, it, nCHin, nCHout, lenSig;
184 float_complex** Q, **x, **y, **z, **Cx, **Cy, **Cz, **M, **Cr, **Mr, **Q_Cx, **Cp;
185 float_complex** decor, **z_r, **eye_nCHout;
186 void* hCdf, *hCdf_res;
187 const float_complex calpha = cmplxf(1.0f, 0.0f), cbeta = cmplxf(0.0f, 0.0f);
190 const float acceptedTolerance = 0.1f;
195 const int nIterations = 300;
198 for(it=0; it<nIterations; it++){
200 nCHin = (int)(tmp*12.0f + 4.1f);
202 nCHout = (int)(tmp*12.0f + 4.1f);
204 lenSig = (int)(tmp*384.0f + 128.1f);
207 Q = (float_complex**)
calloc2d(nCHout, nCHin,
sizeof(float_complex));
208 for(i=0; i<
SAF_MIN(nCHin, nCHout); i++)
209 Q[i][i] = cmplxf(1.0f, 0.0f);
210 x = (float_complex**)
malloc2d(nCHin, lenSig,
sizeof(float_complex));
212 Cx = (float_complex**)
malloc2d(nCHin, nCHin,
sizeof(float_complex));
213 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasConjTrans, nCHin, nCHin, lenSig, &calpha,
219 y = (float_complex**)
malloc2d(nCHout, lenSig,
sizeof(float_complex));
221 Cy = (float_complex**)
malloc2d(nCHout, nCHout,
sizeof(float_complex));
222 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasConjTrans, nCHout, nCHout, lenSig, &calpha,
228 M = (float_complex**)
malloc2d(nCHout, nCHin,
sizeof(float_complex));
235 z = (float_complex**)
malloc2d(nCHout, lenSig,
sizeof(float_complex));
236 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nCHout, lenSig, nCHin, &calpha,
240 Cz = (float_complex**)
malloc2d(nCHout, nCHout,
sizeof(float_complex));
241 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasConjTrans, nCHout, nCHout, lenSig, &calpha,
246 for(i=0; i<nCHout; i++){
247 for(j=0; j<nCHout; j++){
248 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, crealf(Cy[i][j]), crealf(Cz[i][j]));
249 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, cimagf(Cy[i][j]), cimagf(Cz[i][j]));
254 for(i=0; i<nCHout; i++){
255 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, crealf(Cy[i][i]), crealf(Cz[i][i]));
256 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, cimagf(Cy[i][i]), cimagf(Cz[i][i]));
261 Q_Cx = (float_complex**)
malloc2d(nCHout, nCHin,
sizeof(float_complex));
262 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nCHout, nCHin, nCHin, &calpha,
266 Cp = (float_complex**)
malloc2d(nCHout, nCHout,
sizeof(float_complex));
267 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasConjTrans, nCHout, nCHout, nCHin, &calpha,
271 for(i=0; i<nCHout; i++)
272 for(j=0; j<nCHout; j++)
274 Cp[i][j] = cmplxf(0.0f, 0.0f);
279 decor = (float_complex**)
malloc2d(nCHout, lenSig,
sizeof(float_complex));
284 M = (float_complex**)
malloc2d(nCHout, nCHin,
sizeof(float_complex));
286 Cr = (float_complex**)
malloc2d(nCHout, nCHout,
sizeof(float_complex));
289 Mr = (float_complex**)
calloc2d(nCHout, nCHout,
sizeof(float_complex));
290 eye_nCHout = (float_complex**)
calloc2d(nCHout, nCHout,
sizeof(float_complex));
291 for(i=0; i<nCHout; i++)
292 eye_nCHout[i][i] = cmplxf(1.0f, 0.0f);
297 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nCHout, lenSig, nCHin, &calpha,
301 z_r = (float_complex**)
malloc2d(nCHout, lenSig,
sizeof(float_complex));
302 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nCHout, lenSig, nCHout, &calpha,
306 cblas_saxpy(2*nCHout*lenSig, 1.0f, (
const float*)
FLATTEN2D(z_r), 1, (
float*)
FLATTEN2D(z), 1);
311 for(i=0; i<nCHout; i++){
312 for(j=0; j<nCHout; j++){
313 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, crealf(Cy[i][j]), crealf(Cz[i][j]));
314 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, cimagf(Cy[i][j]), cimagf(Cz[i][j]));
319 for(i=0; i<nCHout; i++){
320 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, crealf(Cy[i][i]), crealf(Cz[i][i]));
321 TEST_ASSERT_FLOAT_WITHIN(acceptedTolerance, cimagf(Cy[i][i]), cimagf(Cz[i][i]));