#include "globals.h" #include #define PI 3.14159 double CalculateError(double* E) { //Calculate the error between the Reference Spectrum and the Simulated Spectrum double sumE = 0.0; int nVals = RefSpectrum[currentSpec].size(); double nu; for(int i=0; i minMSE && j < maxFitIter) { //simulate a spectrum based on the current IR SimulateSpectrum(); //calculate the error term sumE = CalculateError(E); //estimate the new absorbance EstimateK(E); //use Kramers-Kronig to compute n for(unsigned int i=0; i