Rate ZeroInflationIndex::forecastFixing(const Date& fixingDate) const { // the term structure is relative to the fixing value at the base date. Date baseDate = zeroInflation_->baseDate(); QL_REQUIRE(!needsForecast(baseDate), name() << " index fixing at base date is not available"); Real baseFixing = fixing(baseDate); Date effectiveFixingDate; if (interpolated()) { effectiveFixingDate = fixingDate; } else { // start of period is the convention // so it's easier to do linear interpolation on fixings effectiveFixingDate = inflationPeriod(fixingDate, frequency()).first; } // no observation lag because it is the fixing for the date // but if index is not interpolated then that fixing is constant // for each period, hence the t uses the effectiveFixingDate // However, it's slightly safe to get the zeroRate with the // fixingDate to avoid potential problems at the edges of periods Time t = zeroInflation_->dayCounter().yearFraction(baseDate, effectiveFixingDate); bool forceLinearInterpolation = false; Rate zero = zeroInflation_->zeroRate(fixingDate, Period(0,Days), forceLinearInterpolation); // Annual compounding is the convention for zero inflation rates (or quotes) return baseFixing * std::pow(1.0 + zero, t); }
int main() { Time planning; Time coding(2, 40); Time fixing(5, 55); Time total; std::cout << "planning time = "; planning.Show(); std::cout << std::endl; std::cout << "coding time = "; coding.Show(); std::cout << std::endl; std::cout << "fixing time = "; fixing.Show(); std::cout << std::endl; total = coding.Sum(fixing); std::cout << "coding.Sum(fixing) = "; total.Show(); std::cout << std::endl; return 0; }
void main() { char *str; int len; printf("enter the length of string"); scanf("%d", &len); str = (char *)malloc(sizeof(char)*len); printf("enter the string"); scanf("%s", str); printf("%s",fixing(str, len)); _getch(); }
int main() { Time planning; Time coding(2, 40); Time fixing(5, 55); Time total; std::cout << "planning: "; planning.Show(); std::cout << "coding: "; coding.Show(); std::cout << "fixing: "; fixing.Show(); std::cout << "total: "; total = coding + fixing; total.Show(); Time morefixing(3, 28); std::cout << "more fixing: "; morefixing.Show(); std::cout << "total: "; total = total + morefixing; total.Show(); std::cout << "operator+():\n"; total = total.operator+(morefixing); total.Show(); std::cout << total; //przeci¹¿ona wersja '<<' zwracaj¹ca referencjê do ostream std::ofstream fout; fout.open("tst.txt"); std::cout << "overloading <<:\n"; operator<<(std::cout, total); //lub tak: std::cout << total; fout << total; //lub tak: operator<<(fout, total); //fout.close(); Time something(2, 40); Time res; res = operator*(2.5, something); operator<<(fout, res); fout.close(); return 0; }