84 for (
int i = 0; i < 2*nNodes; i++)
86 cout <<
"\tm[" << i <<
"] = "; cin >> mom[i];
92 for(
int j = 0; j < nNodes; j++)
94 cout <<
"\twe[" << j <<
"] = "; cin >> we[j];
95 cout <<
"\tvi[" << j <<
"] = "; cin >> vi[j];
101 for(
int k = 0; k < 2*nNodes; k++)
103 for (
int i = 0; i < nNodes; i++)
111 mom[k] += we[i]*pow(vi[i],k);
118 for(
int i = 0; i < 2*nNodes; i++)
120 cout <<
"\tm[" << i <<
"] = " << m[i] << endl;
126 int noMoms = 2*nNodes;
127 for (
int i = 0; i < noMoms; i++)
129 if (moments[i] < 0.0)
131 cout <<
"m[" << i <<
"] is negative!" << endl;
141 for (
int i = 2*nNodes; i >= 0; i--)
149 for (
int i = 0; i < 2*nNodes; i++)
157 for (
int r = 0; r < 2*nNodes; r++)
159 for (
int c = 0; c < 2*nNodes; c++)
161 differenceTable[r][c] = 0.0;
168 cout << endl <<
"Table of Difference: \n";
169 for (
int r = 0; r < 2*nNodes; r++)
171 for (
int c = 0; c < 2*nNodes; c++)
174 cout.setf(ios::fixed);
175 cout.setf(ios::showpoint);
177 cout << differenceTable[r][c] <<
" ";
185 for (
int i = 0; i < 2*nNodes; i++)
187 differenceTable[i][0] = log(mom[i]);
189 for (
int j = 1; j <= 2*nNodes; j++)
191 for (
int k = 0; k < (2*nNodes - j); k++)
193 differenceTable[k][j] = differenceTable[k+1][j-1]-differenceTable[k][j-1];
201 for (
int r = 0; r < (2*nNodes-2); r++)
203 if (differenceTable[r][2] < 0.0)
215 for (
unsigned int i = 0; i < v.size(); ++i)
219 return (sqrt(result));
void printDifferenceTable(double **differenceTable, int nNodes)
prints the difference table
void denormalizeMom(double *m, double M0, int nNodes)
de-normalizes the moments
void printMoms(const double *m, int nNodes)
prints moments
void enterMoments(double *mom, const int nNodes)
input the moments
bool momentsPositivite(const double *moments, int &nNodes)
void buildDifferenceTable(double **differenceTable, double *mom, int nNodes)
constructs the difference table
void enterWeightsNodes(double *we, double *vi, int nNodes)
inputs weights and nodes of quadrature
m
Bubble Growth Application Recipe.
void initializeDifferenceTable(double **differenceTable, int nNodes)
initializes the difference table
void weightsNodesToMoms(double *mom, double *we, double *vi, int nNodes)
converts weights and nodes to moments
double vectorNorm(vector< double > const &v)
normalized vector used in McGraw correction algorithm
void normalizeMom(double *m, int nNodes)
normalizes the moments
int isRealizable(double **differenceTable, int nNodes)
checks if the moments are realizable