Hi,

I found this code posted on the internet and I am using it (or hope to use it) to aid me. (From: Fast Numerical Integration - CodeProject)

However, I am having problems with imaginary/complex numbers.

Main.cpp

I am getting the error: 'i' : undeclared identifierCode:#include <iostream> #include <cmath> #include <iomanip> #include "DEIntegrator.h" #include <complex> int main() { std::complex<double> i (0, 1); DemoFunction1 f1; int evaluations; double errorEstimate; std::cout << std::setprecision(15); double integral = DEIntegrator<DemoFunction1>::Integrate(f1, 0, 10, 1e-6, evaluations, errorEstimate); std::cout << integral << ", " << errorEstimate << ", " << evaluations << "\n"; system("pause"); return 0; } class DemoFunction1 { public: double operator()(double x) const { return (1/x) * ( 1 - (pow(((x-1)/(x+1)),(5))) * (pow(((x-i)/(x+i)),(1))) ); } };

Snippet from DEIntegrator.h

Code:#ifndef DEINTEGRATOR_H #define DEINTEGRATOR_H #include "DEIntegrationConstants.h" #include <float.h> #include <complex> /*! Numerical integration in one dimension using the double expontial method of M. Mori. */ template<class TFunctionObject> class DEIntegrator { public: /*! Integrate an analytic function over a finite interval. @return The value of the integral. */ static double Integrate (const TFunctionObject& f, double a, double b, double targetAbsoluteError, int& numFunctionEvaluations, double& errorEstimate) { // Apply the linear change of variables x = ct + d // $$\int_a^b f(x) dx = c \int_{-1}^1 f( ct + d ) dt$$ // c = (b-a)/2, d = (a+b)/2 double c = 0.5*(b - a); double d = 0.5*(a + b); return IntegrateCore (f, c, d, targetAbsoluteError, numFunctionEvaluations, errorEstimate, doubleExponentialAbcissas, doubleExponentialWeights); } etc. // More code etc.

Any help would be much appreciated?