#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#define pi 3.14
#define N 8
int main (){
int i,k,u,v,x,y;
double fxy[N][N]={0.0}, c[N][N]={0.0},z[N][N]={0.0},a[N],b[N];
srand(time(NULL));
for(x=0;x<N;x++){
for(y=0;y<N;y++){
fxy[x][y]=1;//rand() %250 +1;
}}
for(u=0;u<N;u++){
for(v=0;v<N;v++){
c[u][v]=0.0;
if(u==0)
a[u]=(double)(1/sqrt(2.0));
else
a[u]=1.0;
if(v==0)
b[v]=(double)(1/sqrt(2.0));
else
b[v]=1.0;
for(x=0;x<N;x++){
for(y=0;y<N;y++){
c[u][v]+=fxy[x][y]*cos((double)((double)(2*x+1)*(double)u*(double)pi/(double)(2*N)))*cos((double)((double)(2*y+1)*(double)v*(double)pi/(double)(2*N)));
}}
c[u][v]*=((double)(2.0/N)*(double)a[u]*(double)b[v]);
printf("%d,%d = %.3lf\t",u+1,v+1,c[u][v]);
}}
printf("\n");
for(u=0;u<N;u++){
for(v=0;v<N;v++){
for(x=0;x<N;x++){
for(y=0;y<N;y++){
z[u][v]+=c[x][y]*a[u]*b[v]*cos((double)((double)(2*x+1)*(double)u*(double)pi/(double)(2*N)))*cos((double)((double)(2*y+1)*(double)v*(double)pi/(double)(2*N)));
}}
z[u][v]*=(double)(2.0/N);
printf("%d,%d = %.3lf\t",u+1,v+1,z[u][v]);
}}
}
Hiç yorum yok:
Yorum Gönder