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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
double wmodel ( double (*model)[1], double f2, double f4, double f22 ,
double f42, double (*data)[3], int l){
//this function does the w(theta) calculation for the model
double wtheta = 0 ;
int x;
for (x=0 ; x < l ; ++x){
model[x] = 1 + f2*f22*1/2*(3* pow(cos(data[x][2]),2) *-1 )
+ f4*f42* 1/8*(35*pow(cos(data[x][2]),4)
- 30 *pow(cos(data[x][2]),4) + 3);
}
return (0);
}
int main () {
//FILLING DATA ARRAYS
// ask user for dat file
ifstream dat;
do {
cout << "Input filename where the raw data exist-->";
char filename [50];
cin.getline(filename,50);
dat.open(filename);
if (!dat.is_open())
cout << "File Does Not Exist!" << endl ;
} while (!dat.is_open());
double (*data)[3]= new double [15][3];
int x = 0 ;
int l = 0 ;
double a,b,c,d,e,f;
while ( dat >> a >> b >> c){
data[x][0] = a;
data[x][1] = b;
data[x][2] = c;
// cout << data[x][0] << endl; // to check
++x;
++l;
}
dat.close();
// fill values from giant text file that I typed by hand!!
ifstream table;
do {
cout << "Input filename where the data table exist-->";
char file [50];
cin.getline(file,50);
table.open(file);
if (!table.is_open())
cout << "File Does Not Exist!" << endl ;
} while (!table.is_open());
double (*values)[6] = new double[500][6];
//array from 1967 table values are:
// jf , ji,l1,l2,f2,f4
x = 0 ;
int length = 0 ;
while (table >> a >> b >> c >> d >> e >> f){
values [x][0] = a;
values [x][1] = b;
values [x][2] = c;
values [x][3] = d;
values [x][4] = e;
values [x][5] = f;
//cout << values [x][0]<< " " << values [x][5] << endl;
++x;
++length ;
}
table.close();
double conf2, conf4;
for ( x = 0 ; x<length+1 ; ++x) {
if (jm==values[x][1] and jf==values[x][0] and l2==values[x][3]){
conf2 = values [x][4];
conf4 = values [x][5];
}
}
// find model values
double f2,f4;
double (*model)[1] = new double[15][1];
wmodel(model, f2, f4 , conf2, conf4, data,l);
|