#include "globals.h" #define PI 3.14159 float CalculateError(float* E) { //Calculate the error between the Reference Spectrum and the Simulated Spectrum float sumE = 0.0; int nVals = RefSpectrum[currentSpec].size(); float nu; for(int i=0; i minMSE && i < 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(int i=0; i