📄 tst_cash_flow.cc
字号:
void test_cash_flow(){ cout << " testing cash flow algoritms " << endl; vector<double> times; times.push_back(1); times.push_back(2); vector<double> amounts; amounts.push_back(-100); amounts.push_back(110.51709); cout << " testing PV " << endl; cout << " pv 0 " << cash_flow_pv(times,amounts, 0 ) << endl; cout << " pv 0.1 " << cash_flow_pv(times,amounts, 0.1) << endl; cout << " discrete compounding " << endl; cout << " pv 0 " << cash_flow_pv_discrete(times,amounts, 0 ) << endl; cout << " pv 0.1 " << cash_flow_pv_discrete(times,amounts, 0.1) << endl; cout << " testing irr " << endl; amounts[0]=-100; amounts[1]=134.98588; cout << " irr (should be 0.30) " << cash_flow_irr(times,amounts) << endl; amounts[0]=100; amounts[1]=-134.98588; cout << " irr (should be 0.30) " << cash_flow_irr(times,amounts) << endl; times.push_back(3); amounts.push_back(30); cout << " irr (should be ?) " << cash_flow_irr(times,amounts) << endl; cout << " testing, is irr unique? " << endl; amounts[0]=-100; amounts[1]=110; amounts[2]=10; cout << " is irr unique (?) " << cash_flow_unique_irr(times,amounts) << endl; amounts[0]= -100; amounts[1]= 110; amounts[2]= -10; cout << " irr unique (?) " << cash_flow_unique_irr(times,amounts) << endl; amounts[0]= -10; amounts[1]= 20.0001; amounts[2]= -10; cout << " irr unique (?) " << cash_flow_unique_irr(times,amounts) << endl; cout << " irr: " << cash_flow_irr(times,amounts) << endl; amounts[0]= -10; amounts[1]= 19.999; amounts[2]= -10; cout << " irr unique ? (blows) " << cash_flow_unique_irr(times,amounts) << endl; cout << " irr: " << cash_flow_irr(times,amounts) << endl; amounts[0]= 10; amounts[1]= -21; amounts[2]= 10; cout << " irr unique (?) " << cash_flow_unique_irr(times,amounts) << endl; cout << " irr: " << cash_flow_irr(times,amounts) << endl; cout << "DONE testing cash flow algorithms" << endl;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -