// Test rlft3, interface 1 (2 Dimensions)
System.out.println("Testing rlft3, interface1");
Ran myran = new Ran(17);
for (i=0;i<2;i++) N *= nn[i];
double[][] data1=new double[nn[0]][nn[1]];
double[][] data2=new double[nn[0]][nn[1]];
double[] speq1=new double[2*nn[0]];
double[] speq2=new double[2*nn[0]];
// Round-trip test for random numbers
for (i=0;i<nn[0];i++) {
for (j=0;j<nn[1];j++) {
data1[i][j] = myran.doub();
data2[i][j] = (2.0/N)*data1[i][j];
}
}
rlft3(data2,speq2,1);
rlft3(data2,speq2,-1);
// System.out.printf(maxel(matsub(data1,data2)));
localflag = localflag || maxel(matsub(data1,data2)) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** rlft3, interface1: Round-trip test for random real values failed");
}
// Test delta-function in to sine-wave out, forward transform
for (i=0;i<nn[0];i++)
for (j=0;j<nn[1];j++) data1[i][j]=0.0;
data1[5][7]=1.0;
rlft3(data1,speq1,1);
for (i=0;i<nn[0];i++) {
for (j=0;j<nn[1]/2;j++) {
Complex r1 = Complex.I.mul(2.0*pi*5.0*i/nn[0]);
Complex r2 = Complex.I.mul(2.0*pi*7.0*j/nn[1]);
Complex r = r1.exp().mul(r2.exp());
data2[i][2*j] = r.re();
data2[i][2*j+1]= r.im();
/*
data2[i][2*j]= real(exp(2.0*pi*Complex(0.0,1.0)*5.0*double(i)/double(nn[0]))
*exp(2.0*pi*Complex(0.0,1.0)*7.0*double(j)/double(nn[1])));
data2[i][2*j+1]= imag(exp(2.0*pi*Complex(0.0,1.0)*5.0*double(i)/double(nn[0]))
*exp(2.0*pi*Complex(0.0,1.0)*7.0*double(j)/double(nn[1])));
*/
}
Complex r1 = Complex.I.mul(2.0*pi*5.0*i/nn[0]);
Complex r2 = Complex.I.mul(pi*7.0);
Complex r = r1.exp().mul(r2.exp());
speq2[2*i]=r.re();
speq2[2*i+1]=r.im();
/*
speq2[2*i]=real(exp(2.0*pi*Complex(0.0,1.0)*5.0*double(i)/double(nn[0]))*exp(pi*Complex(0.0,1.0)*7.0));
speq2[2*i+1]=imag(exp(2.0*pi*Complex(0.0,1.0)*5.0*double(i)/double(nn[0]))*exp(pi*Complex(0.0,1.0)*7.0));
*/
}
// System.out.printf(maxel(matsub(data1,data2)));
localflag = localflag || maxel(matsub(data1,data2)) > sbeps;
// System.out.printf(maxel(vecsub(speq1,speq2)));
localflag = localflag || maxel(vecsub(speq1,speq2)) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** rlft3: Forward transform of a chosen delta function did not give expected result");
}
// Test rlft3, interface 2 (3 Dimensions)
System.out.println("Testing rlft3, interface2");
N=1;
for (i=0;i<3;i++) N *= nn[i];
double[][][] data3=new double[nn[0]][nn[1]][nn[2]];
double[][][] data4=new double[nn[0]][nn[1]][nn[2]];
double[][] speq3=new double[nn[0]][2*nn[1]];
double[][] speq4=new double[nn[0]][2*nn[1]];
// Round-trip test for random numbers
for (i=0;i<nn[0];i++) {
for (j=0;j<nn[1];j++) {
for (k=0;k<nn[2];k++) {
data3[i][j][k] = myran.doub();
data4[i][j][k] = (2.0/N)*data3[i][j][k];
}
}
}
rlft3(data4,speq4,1);