【Java开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了Java开源代码-d12r1F.java的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
import java.text.*;
public class d12r1F
{
void four1(double data[], int nn, int isign)
{
int n, j, i, m, mmax, istep;
double tempr, tempi, theta, wpr, wpi, wr, wi, wtemp;
n = 2 * nn;
j = 1;
for (i = 1; i <= n ; i = i + 2)
{
if (j > i)
{
tempr = data[j];
tempi = data[j + 1];
data[j] = data[i];
data[j + 1] = data[i + 1];
data[i] = tempr;
data[i + 1] = tempi;
}
m = n / 2;
while (m >= 2 && j > m)
{
j = j - m;
m = m / 2;
}
j = j + m;
}
mmax = 2;
while (n > mmax )
{
istep = 2 * mmax;
theta = 6.283 / (isign * mmax);
wpr = -2.0 * Math.sin(0.5 * theta) * Math.sin(0.5 * theta);
wpi = Math.sin(theta);
wr = 1.0;
wi = 0.0;
for (m = 1; m <= mmax; m = m + 2)
{
for (i = m; i <= n; i = i + istep)
{
j = i + mmax;
tempr = (double)wr * data[j] - (double)wi * data[j + 1];
tempi = (double)wr * data[j + 1] + (double)wi * data[j];
data[j] = data[i] - tempr;
data[j + 1] = data[i + 1] - tempi;
data[i] = data[i] + tempr;
data[i + 1] = data[i + 1] + tempi;
}
wtemp = wr;
wr = wr * wpr - wi * wpi + wr;
wi = wi * wpr + wtemp * wpi + wi;
}
mmax = istep;
}
}
void prntft(double data[], double nn2)
{
int n, m, mm;
DecimalFormat form = new DecimalFormat("0.000000");
System.out.println("n Real H(n) Imag H(n) Real H(N-n) Imag H(N-n)");
System.out.println();
System.out.print("0 ");
System.out.print(form.format(data[1]) + " ");
System.out.print(form.format(data[2]) + " ");
System.out.print(form.format(data[1]) + " ");
System.out.println(form.format(data[2]) + " ");
for (n = 3; n <= (nn2 / 2) + 1; n = n + 2)
{
m = (n - 1) / 2;
mm = (int)(nn2 + 2 - n);
System.out.print(m + " ");
System.out.print(form.format(data[n]) + " ");
System.out.print(form.format(data[n + 1]) + " ");
System.out.print(form.format(data[mm]) + " ");
System.out.println(form.format(data[mm + 1]) + " ");
}
}
}
上一篇:
d12r1.java
下一篇:
天亮之后