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
|
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
#include<cmath>
#include<sstream>
using namespace std;
string convertDoub(double number);
typedef struct CMAT{double el[9]; } cmat;
inline void matrixProd(cmat *am(double el[]), cmat *bm(double el[]), cmat *cm(double el[]));
//inline void matrixProd(cmat *am, cmat *bm, cmat *cm);
void amatrix(ifstream *rf, int frames, int residues, ofstream *amat)
{
double a[3][3], d[3][3], c[3][3], r[3][3], p[3][3];
//typedef struct CMAT{double xx; double xy; double xz; double yx; double yy; double yz; double zx; double zy; double zz} cmat;
cmat cm[residues];
cmat pm[residues];
string s;
c[0][0] = 1;
c[0][1] = 0;
c[0][2] = 0;
c[1][0] = 0;
c[1][1] = 1;
c[1][2] = 0;
c[2][0] = 0;
c[2][1] = 0;
c[2][2] = 1;
for(int resid = 0; resid < residues; resid++)
{
rf[0] >> cm[resid].el[0] >> cm[resid].el[1] >> cm[resid].el[2];
rf[0] >> cm[resid].el[3] >> cm[resid].el[4] >> cm[resid].el[5];
rf[0] >> cm[resid].el[6] >> cm[resid].el[7] >> cm[resid].el[8];
rf[0] >> pm[resid].el[0] >> pm[resid].el[1] >> pm[resid].el[2];
rf[0] >> pm[resid].el[3] >> pm[resid].el[4] >> pm[resid].el[5];
rf[0] >> pm[resid].el[6] >> pm[resid].el[7] >> pm[resid].el[8];
}
}
}
string convertDoub(double number)
{
stringstream ss; //create a stringstream
ss << number; //add number to the stream
return (ss.str()); //return a string with the contents of the stream
}
inline void matrixProd(cmat *am(double el[]), cmat *bm(double el[]), cmat *cm(double el[]))
//inline void matrixProd(cmat *am, cmat *bm, cmat *cm)
{
double sum;
for(int i = 0; i < 3 ; i++)
{
for(int k = 0; k < 3; k++)
{
sum = 0.0;
for(int j = 0; j < 3 ; j++)
{
sum = sum + am->el[0][3*i+j] * bm->el[0][3*j+k];
}
cm->el[0][3*i+k] = sum;
}
}
}
|