1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#include <iostream>
#include <iomanip>
#include <fstream>
#include <math.h>
#include <complex>
using namespace std;
// ***************************
// declaration des constantes
// ***************************
const float STEP = 1; // pas de calcul
const int nthetaMAX = 91; // nombre de points de l'axe theta
const int nphiMAX = 361; // nombre de points de l'axe phi
const float dn = 2.3;
const float dm = 1.8;
const float d2r = M_PI/180;
const int N = 3;
const int M = 4;
int main()
{
float theta0,phi0,d2r,dn,dm,A0,B0,Ak,Bk;
int N,M;
int n1,n2,n3,n4;
int i =1;
complex<float> (*matrice)[nphiMAX] = new complex<float>[nthetaMAX][nphiMAX];
// ***************************
// declaration de paramettres
// ***************************
theta0 = 30;
phi0 = 136;
dn = 3.2;
dm = 2.7;
N = 5;
M = 8;
d2r = M_PI/180;
// **********************************
// Calcul des éléments de la matrice
// **********************************
A0 = -2*M_PI*dn*sin(theta0*STEP*d2r);
B0 = -2*M_PI*dm*cos(phi0*STEP*d2r);
for (n1 = 0; n1 < nthetaMAX-1; n1++){
for (n2 = 0; n2 < nphiMAX-1; n2++){
Ak = 2*M_PI*dn*sin(n1*STEP*d2r);
Bk = 2*M_PI*dm*cos(n2*STEP*d2r);
for (n3 = 0; n3 <= N-1; n3++){
for (n4 = 0; n4 <=M-1; n4++){
matrice [n1][n2]+= exp(complex<float>(0,n3*A0))*exp(complex<float>(0,n4*B0))*exp(complex<float>(0,n3*Ak))*exp(complex<float>(0,n4*Bk));
}
}
}
}
//cout << "printfile";
ofstream myfile;
myfile.open ("test.txt");
for (n1=0; n1 <= nthetaMAX-1; n1++){
for (n2=0; n2 <= nphiMAX-1; n2++){
myfile << (abs(matrice[n1][n2])) << " ";
}
myfile << endl;
}
myfile.close();
delete[](matrice);
} |
Partager