#include double IRR::IRR_ERROR=-1E30; int IRR::IRR_MAX_ITERATIONS=50; double IRR::IRR_ACCURACY=1.0E-5; double IRR::irr(Array &cashflows) { double x1=0.00; double x2=.20; double dx=0.00; double f1; double f2; double f; double rtb; double xmid; double fmid; int index; // create initial bracket with root somewhere between bot,top f1=pv(cashflows,x1); f2=pv(cashflows,x2); for(index=0;index0.00)return IRR_ERROR; f=pv(cashflows,x1); if(f<0.00) { rtb=x1; dx=x2-x1; } else { rtb=x2; dx=x1-x2; } for(index=0;index &cashflows,double rate) { double npv=0.00; for(int index=0;index &cashflows,double rate) { double pv=0.00; for(int index=0;index &cashflows,double rate) { double pv=0.00; for(int index=0;index