Hi,
I am trying to compile Quantlib on SUN Solaris 10 using SUN CC (I tried v5.7, v5.8 and v5.10, btw...) Appearantly the SUN compiler is somehow missing operator== implementations for e.g. ExchangeRateManager, because I get the following error: libtool: compile: CC -DHAVE_CONFIG_H -I. -I. -I../../ql -I../.. -I../.. -I/home/spenglan/local/include/boost-1_38 -erroff=wvarhidemem,hidevf,hidevfinvb,wbadinitl,badargtypel2w -errtags=yes -KPIC -features=rtti -template=wholeclass -instances=global -g -xs -fast -library=rwtools7,iostream,no%stlport4,Crun -xarch=v8plusa -fsimple=1 -mt -Drindex=rindex -Dindex=index -D__solaris_sparc__ -O3 -c exchangeratemanager.cpp -KPIC -DPIC -o .libs/exchangeratemanager.o "/home/spenglan/SUNWspro/prod/include/CC/Cstd/./list.cc", line 173: Error, badbinaryop: The operation "QuantLib::ExchangeRateManager::Entry == const QuantLib::ExchangeRateManager::Entry" is illegal. "/home/spenglan/SUNWspro/prod/include/CC/Cstd/./list", line 468: Where, temwhileinst: While instantiating "std::list<QuantLib::ExchangeRateManager::Entry>::remove(const QuantLib::ExchangeRateManager::Entry&)". "/home/spenglan/SUNWspro/prod/include/CC/Cstd/./list", line 468: Where, teminstend: Instantiated from non-template code. 1 Error(s) detected. Perhaps I am using a bad compiler switch. When I add an operator== in Quantlib::ExchangeRateManager::Entry (doing memberwise comparison), I get the same error above for Quantlib::ExchangeRateManager This can't be correct that the compiler does not generate implicit operator== methods himself, right? Rgds, Andreas ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
On Wed, 2009-02-18 at 17:03 +0100, Andreas Spengler wrote:
> I am trying to compile Quantlib on SUN Solaris 10 using SUN CC (I tried > v5.7, v5.8 and v5.10, btw...) > > Appearantly the SUN compiler is somehow missing operator== implementations > for e.g. ExchangeRateManager, because I get the following error: > > "/home/spenglan/SUNWspro/prod/include/CC/Cstd/./list.cc", line 173: Error, > badbinaryop: The operation "QuantLib::ExchangeRateManager::Entry == const > QuantLib::ExchangeRateManager::Entry" is illegal. > "/home/spenglan/SUNWspro/prod/include/CC/Cstd/./list", line 468: > Where, temwhileinst: While instantiating > "std::list<QuantLib::ExchangeRateManager::Entry>::remove(const > QuantLib::ExchangeRateManager::Entry&)". Andreas, the compiler does not generate operator==, but that's the expected behavior. The problem is that your compiler is trying to instantiate list::remove, which requires an operator==. But that's wrong, since list::remove is not being used and hence should not be instantiated. > Perhaps I am using a bad compiler switch. Maybe. Looking at your command line: > libtool: compile: CC -DHAVE_CONFIG_H -I. -I. -I../../ql -I../.. -I../.. > -I/home/spenglan/local/include/boost-1_38 > -erroff=wvarhidemem,hidevf,hidevfinvb,wbadinitl,badargtypel2w -errtags=yes > -KPIC -features=rtti -template=wholeclass -instances=global -g -xs -fast > -library=rwtools7,iostream,no%stlport4,Crun -xarch=v8plusa -fsimple=1 -mt > -Drindex=rindex -Dindex=index -D__solaris_sparc__ -O3 -c > exchangeratemanager.cpp -KPIC -DPIC -o .libs/exchangeratemanager.o a likely candidate would be -template=wholeclass. I don't have a Solaris box available to check it, but if it tells the compiler to instantiate all methods in a template class instead of just the ones that are used, then it would cause the error above. May you have a look at your compiler documentation and check whether the above works as I guessed (and if so, how can you specify the correct behavior instead?) Luigi -- I've finally learned what `upward compatible' means. It means we get to keep all our old mistakes. -- Dennie van Tassel ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Luigi,
Luigi Ballabio schrieb: > Looking at your command line: > >> libtool: compile: CC -DHAVE_CONFIG_H -I. -I. -I../../ql -I../.. -I../.. >> -I/home/spenglan/local/include/boost-1_38 >> -erroff=wvarhidemem,hidevf,hidevfinvb,wbadinitl,badargtypel2w -errtags=yes >> -KPIC -features=rtti -template=wholeclass -instances=global -g -xs -fast >> -library=rwtools7,iostream,no%stlport4,Crun -xarch=v8plusa -fsimple=1 -mt >> -Drindex=rindex -Dindex=index -D__solaris_sparc__ -O3 -c >> exchangeratemanager.cpp -KPIC -DPIC -o .libs/exchangeratemanager.o > > a likely candidate would be -template=wholeclass. I don't have a Solaris > box available to check it, but if it tells the compiler to instantiate > all methods in a template class instead of just the ones that are used, > then it would cause the error above. May you have a look at your > compiler documentation and check whether the above works as I guessed > (and if so, how can you specify the correct behavior instead?) I should have guessed it. Unfortunately I somehow thought, that memberwise comparison is added implicitly (like the copy constructor and assignment operator are)... I looked up this in the Sun compiler C++ user reference - and will try it out tomorrow: "When the compiler implicitly instantiates a template class, it instantiates the static data members, the constructor, and the destructor. However, the compiler does not implicitly instantiate any other member function unless the function is explicitly referenced. To force the compiler to instantiate all member functions when implicitly instantiating a class, use the -template=wholeclass compiler option. To turn this option off, specify -template=no%wholeclass, which is the default." Rgds, Andreas ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
In reply to this post by Andreas Spengler-2
Ok,
> I looked up this in the Sun compiler C++ user reference - and will try > it out tomorrow: removing the "-template=wholeclass" switch now takes me through to the experimental subdir and dies at fdmstepconditioncomposite.cpp: libtool: compile: CC -DHAVE_CONFIG_H -I. -I. -I../../../ql -I../../.. -I../../.. -I/home/spenglan/local/include/boost-1_38 -erroff=wvarhidemem,hidevf,hidevfinvb,wbadinitl,badargtypel2w -errtags=yes -KPIC -features=rtti -instances=global -fast -library=Cstd,iostream,no%stlport4,Crun -xarch=v8plusa -fsimple=1 -mt -Drindex=rindex -Dindex=index -D__solaris_sparc__ -c fdmstepconditioncomposite.cpp -KPIC -DPIC -o .libs/fdmstepconditioncomposite.o "../../../ql/math/array.hpp", line 544: Warning (Anachronism), badargtype2w: Formal argument x of type double(*)(double) in call to std::ptr_fun<double, double>(double(*)(double)) is being passed extern "C" double(*)(double). "../../../ql/math/array.hpp", line 551: Warning (Anachronism), badargtype2w: Formal argument x of type double(*)(double) in call to std::ptr_fun<double, double>(double(*)(double)) is being passed extern "C" double(*)(double). "../../../ql/math/array.hpp", line 558: Warning (Anachronism), badargtype2w: Formal argument x of type double(*)(double) in call to std::ptr_fun<double, double>(double(*)(double)) is being passed extern "C" double(*)(double). "../../../ql/math/array.hpp", line 565: Warning (Anachronism), badargtype2w: Formal argument x of type double(*)(double) in call to std::ptr_fun<double, double>(double(*)(double)) is being passed extern "C" double(*)(double). "fdmstepconditioncomposite.cpp", line 37: Error, nomatchoverin: Could not find a match for std::vector<double>::vector(__rwstd::__rb_tree<double, double, __rwstd::__ident<double, double>, std::less<double>, std::allocator<double>>::const_iterator, __rwstd::__rb_tree<double, double, __rwstd::__ident<double, double>, std::less<double>, std::allocator<double>>::const_iterator) needed in QuantLib::FdmStepConditionComposite::FdmStepConditionComposite(const std::list<std::vector<double> >&, const std::list<boost::shared_ptr<QuantLib::StepCondition<QuantLib::Array>> >&). 1 Error(s) and 4 Warning(s) detected. I am a bit at my wits end here... Would it perhaps be possible to disable experimental code in the first place? Rgds, Andreas ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
On Thu, 2009-02-19 at 11:10 +0100, Andreas Spengler wrote:
> removing the "-template=wholeclass" switch now takes me through to the > experimental subdir and dies at fdmstepconditioncomposite.cpp: > > libtool: compile: CC -DHAVE_CONFIG_H -I. -I. -I../../../ql -I../../.. > -I../../.. -I/home/spenglan/local/include/boost-1_38 > -erroff=wvarhidemem,hidevf,hidevfinvb,wbadinitl,badargtypel2w -errtags=yes > -KPIC -features=rtti -instances=global -fast > -library=Cstd,iostream,no%stlport4,Crun -xarch=v8plusa -fsimple=1 -mt > -Drindex=rindex -Dindex=index -D__solaris_sparc__ -c > fdmstepconditioncomposite.cpp -KPIC -DPIC -o > .libs/fdmstepconditioncomposite.o > "fdmstepconditioncomposite.cpp", line 37: Error, nomatchoverin: Could not > find a match for std::vector<double>::vector(__rwstd::__rb_tree<double, > double, __rwstd::__ident<double, double>, std::less<double>, > std::allocator<double>>::const_iterator, __rwstd::__rb_tree<double, > double, __rwstd::__ident<double, double>, std::less<double>, > std::allocator<double>>::const_iterator) needed in > QuantLib::FdmStepConditionComposite::FdmStepConditionComposite(const > std::list<std::vector<double> >&, const > std::list<boost::shared_ptr<QuantLib::StepCondition<QuantLib::Array>> >&). > 1 Error(s) and 4 Warning(s) detected. std::vector is supposed to have a constructor taking two iterators---which is called in the offending line, viz. stoppingTimes_ = std::vector<Time>(allStoppingTimes.begin(), allStoppingTimes.end()); but your compiler's STL implementation, apparently, does not provide it. (Which is a bit strange---how old is it? May you check the <vector> header?) You can work around it by rewriting the above line, for instance as: stoppingTimes_ = std::vector<Time>(); std::copy(allStoppingTimes.begin(), allStoppingTimes.end(), std::back_inserter(stoppingTimes_)); or as an explicit loop that inserts into stoppingTimes_ all the elements of allStoppingTimes---whatever you feel more comfortable with. > I am a bit at my wits end here... Would it perhaps be possible to disable > experimental code in the first place? Possibly (it's might be a bit harder to disable it in the test-suite, though) but you'll probably find calls to that constructor in the core library, too. You'll have to fix them in the same way. Luigi -- Poets have been mysteriously silent on the subject of cheese. -- Gilbert K. Chesterton ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi,
> std::vector is supposed to have a constructor taking two > iterators but your compiler's STL implementation, apparently, does not > provide it. Appearantly, the SUN CC standard stl implementation is bollocks. Using "-library=stlport4" (as needed for the compilation of boost, btw.) solved the problem... Sorry for the fuss, Andreas ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
On Thu, 2009-02-19 at 16:05 +0100, Andreas Spengler wrote:
> Using "-library=stlport4" (as needed for the compilation of boost, btw.) > solved the problem... > > Sorry for the fuss, No problem. It's good to know in case someone else stumbles into it. Luigi -- So little done, so much to do. -- Cecil Rhodes ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
In reply to this post by Andreas Spengler-2
Es schrieb Andreas Spengler
> Using "-library=stlport4" (as needed for the compilation of boost, btw.) > solved the problem... Well, quite; in some files, the math functions like pow have to be qualified with std:: STLport has no "using" statements to put those into the global namespace... Rgds, Andreas ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
On Thu, 2009-02-19 at 16:34 +0100, Andreas Spengler wrote:
> > Using "-library=stlport4" (as needed for the compilation of boost, btw.) > > solved the problem... > > Well, quite; in some files, the math functions like pow have to be > qualified with std:: Can you send me a list of those? Thanks, Luigi -- The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka!" but "That's funny..." -- Isaac Asimov ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
In reply to this post by Andreas Spengler-2
> Can you send me a list of those?
Course. The following files had to be adapted because of missing std:: qualifier before some mathematical functions: ./ql/models/marketmodels/models/alphafinder.cpp ./ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp ./ql/models/marketmodels/evolvers/lognormalfwdrateeulerconstrained.cpp ./ql/cashflows/rangeaccrual.cpp ./ql/processes/hullwhiteprocess.cpp ./ql/processes/hestonprocess.cpp ./ql/processes/gjrgarchprocess.cpp ./ql/math/randomnumbers/latticersg.cpp ./ql/math/randomnumbers/latticerules.cpp ./ql/math/surface.cpp ./ql/math/quadratic.cpp ./ql/math/integrals/kronrodintegral.cpp ./ql/math/matrixutilities/basisincompleteordered.cpp ./ql/math/optimization/spherecylinder.cpp ./ql/experimental/credit/onefactorgaussiancopula.cpp ./ql/experimental/credit/cdsoption.cpp ./ql/experimental/credit/onefactorstudentcopula.cpp ./ql/experimental/amortizingbonds/amortizingfixedratebond.cpp ./ql/experimental/varianceoption/integralhestonvarianceoptionengine.cpp ./ql/experimental/finitedifferences/fdhestonrebateengine.cpp ./ql/experimental/finitedifferences/fdblackscholesrebateengine.cpp ./ql/experimental/finitedifferences/fdblackscholesvanillaengine.cpp ./ql/experimental/finitedifferences/fdhestonvanillaengine.cpp ./ql/experimental/finitedifferences/fdblackscholesbarrierengine.cpp ./ql/experimental/finitedifferences/fdhestonbarrierengine.cpp ./ql/experimental/lattices/extendedbinomialtree.cpp ./ql/pricingengines/blackformula.cpp ./ql/methods/lattices/binomialtree.cpp ./ql/termstructures/volatility/swaption/swaptionvolcube1.cpp Furthermore, I had to add an "#include <math.h>" line in the following three files, because some define's (M_PI_2 and the like) were not found... ./ql/math/randomnumbers/sobolrsg.cpp ./ql/math/integrals/gaussianorthogonalpolynomial.cpp ./ql/pricingengines/vanilla/analyticgjrgarchengine.cpp In ./ql/instruments/bond.cpp I had to do the following change, because you can't modify a const iterator: *** ./ql/instruments/bond.cpp.orig Fri Feb 20 10:46:22 2009 --- ./ql/instruments/bond.cpp Fri Feb 20 10:46:50 2009 *************** *** 200,206 **** redemptions_.push_back(cashflows.back()); ! std::sort(cashflows_.begin(), --cashflows_.end(), earlier_than<boost::shared_ptr<CashFlow> >()); } --- 200,206 ---- redemptions_.push_back(cashflows.back()); ! std::sort(cashflows_.begin(), cashflows_.end()-1, earlier_than<boost::shared_ptr<CashFlow> >()); } *************** *** 222,228 **** // lower_bound, *i is the earliest date which is greater or // equal than d. Its index is greater or equal to 1. std::vector<Date>::const_iterator i = ! std::lower_bound(++notionalSchedule_.begin(), notionalSchedule_.end(), d); Size index = std::distance(notionalSchedule_.begin(), i); --- 222,228 ---- // lower_bound, *i is the earliest date which is greater or // equal than d. Its index is greater or equal to 1. std::vector<Date>::const_iterator i = ! std::lower_bound(notionalSchedule_.begin()+1, notionalSchedule_.end(), d); Size index = std::distance(notionalSchedule_.begin(), i); Now I only keep getting an error in ql/models/marketmodels/models/alphafinder.cpp (maybe because of the empty namespace surrounding the declaration): "alphafinder.cpp", line 386: Error, nomatchoverin: Could not find a match for::Bisection<::T,::Value>(double, double, double, double, QuantLib::AlphaFinder) needed in QuantLib::AlphaFinder::solve(double, int, const std::vector<double>&, const std::vector<double>&, const std::vector<double>&, double, double, double, double, double, double, int, double&, double&, double&, std::vector<double>&). "alphafinder.cpp", line 394: Error, nomatchoverin: Could not find a match for::Bisection<::T,::Value>(double, double, double, double, QuantLib::AlphaFinder) needed in QuantLib::AlphaFinder::solve(double, int, const std::vector<double>&, const std::vector<double>&, const std::vector<double>&, double, double, double, double, double, double, int, double&, double&, double&, std::vector<double>&). "alphafinder.cpp", line 466: Error, nomatchoverin: Could not find a match for::FindLowestOK<::T,::Value>(double, double, double, QuantLib::AlphaFinder) needed in QuantLib::AlphaFinder::solveWithMaxHomogeneity(double, int, const std::vector<double>&, const std::vector<double>&, const std::vector<double>&, double, double, double, double, double, double, int, double&, double&, double&, std::vector<double>&). "alphafinder.cpp", line 473: Error, nomatchoverin: Could not find a match for::FindLowestOK<::T,::Value>(double, double, double, QuantLib::AlphaFinder) needed in QuantLib::AlphaFinder::solveWithMaxHomogeneity(double, int, const std::vector<double>&, const std::vector<double>&, const std::vector<double>&, double, double, double, double, double, double, int, double&, double&, double&, std::vector<double>&). "alphafinder.cpp", line 484: Error, nomatchoverin: Could not find a match for::FindHighestOK<::T,::Value>(double, double, double, QuantLib::AlphaFinder) needed in QuantLib::AlphaFinder::solveWithMaxHomogeneity(double, int, const std::vector<double>&, const std::vector<double>&, const std::vector<double>&, double, double, double, double, double, double, int, double&, double&, double&, std::vector<double>&). "alphafinder.cpp", line 513: Error, nomatchoverin: Could not find a match for::FindHighestOK<::T,::Value>(double, double, double, QuantLib::AlphaFinder) needed in QuantLib::AlphaFinder::solveWithMaxHomogeneity(double, int, const std::vector<double>&, const std::vector<double>&, const std::vector<double>&, double, double, double, double, double, double, int, double&, double&, double&, std::vector<double>&). "alphafinder.cpp", line 520: Error, nomatchoverin: Could not find a match for::FindLowestOK<::T,::Value>(double, double, double, QuantLib::AlphaFinder) needed in QuantLib::AlphaFinder::solveWithMaxHomogeneity(double, int, const std::vector<double>&, const std::vector<double>&, const std::vector<double>&, double, double, double, double, double, double, int, double&, double&, double&, std::vector<double>&). "alphafinder.cpp", line 533: Error, nomatchoverin: Could not find a match for::Minimize<::T,::Value,::Condition>(double, double, double, QuantLib::AlphaFinder, bool) needed in QuantLib::AlphaFinder::solveWithMaxHomogeneity(double, int, const std::vector<double>&, const std::vector<double>&, const std::vector<double>&, double, double, double, double, double, double, int, double&, double&, double&, std::vector<double>&). 8 Error(s) detected. Rgds, Andreas ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Also in ql/models/marketmodels/models
*** capletcoterminalalphacalibration.cpp.orig Fri Feb 20 15:11:46 2009 --- capletcoterminalalphacalibration.cpp Fri Feb 20 15:12:00 2009 *************** *** 128,134 **** std::vector<std::vector<Volatility> > newVols; std::vector<Volatility> theseNewVols(numberOfRates); std::vector<Volatility> firstRateVols(numberOfRates); ! firstRateVols[0] = sqrt(displacedSwapVariances[0]->variances()[0]); std::vector<Volatility> secondRateVols(numberOfRates); std::vector<Real> correlations(numberOfRates); newVols.push_back(firstRateVols); --- 128,134 ---- std::vector<std::vector<Volatility> > newVols; std::vector<Volatility> theseNewVols(numberOfRates); std::vector<Volatility> firstRateVols(numberOfRates); ! firstRateVols[0] = std::sqrt(displacedSwapVariances[0]->variances()[0]); std::vector<Volatility> secondRateVols(numberOfRates); std::vector<Real> correlations(numberOfRates); newVols.push_back(firstRateVols); *************** *** 146,152 **** const std::vector<Real>& var = displacedSwapVariances[i+1]->variances(); for (Size j =0; j < i+2; ++j) ! secondRateVols[j] = sqrt(var[j]); for (Size k=0; k < i+1; k++) { Real correlation=0.0; --- 146,152 ---- const std::vector<Real>& var = displacedSwapVariances[i+1]->variances(); for (Size j =0; j < i+2; ++j) ! secondRateVols[j] = std::sqrt(var[j]); for (Size k=0; k < i+1; k++) { Real correlation=0.0; ---------------------------------------------------------------------------- *** capletcoterminalperiodic.cpp.orig Fri Feb 20 15:09:51 2009 --- capletcoterminalperiodic.cpp Fri Feb 20 15:10:05 2009 *************** *** 151,157 **** for (Size i=0; i < numberBigRates; ++i) { ! modelSwaptionVols[i] = sqrt(swaptionTotCovariance[i][i]/periodsmm->evolution().rateTimes()[i]); Real scale = marketSwaptionVols[i]/modelSwaptionVols[i]; scalingFactors[i] *= scale; // since applied to vol --- 151,157 ---- for (Size i=0; i < numberBigRates; ++i) { ! modelSwaptionVols[i] = std::sqrt(swaptionTotCovariance[i][i]/periodsmm->evolution().rateTimes()[i]); Real scale = marketSwaptionVols[i]/modelSwaptionVols[i]; scalingFactors[i] *= scale; // since applied to vol *************** *** 162,168 **** for (Size i=0; i < numberBigRates; ++i) modelSwaptionVolsMatrix[iterationsDone][i] = modelSwaptionVols[i]; ! periodSwaptionRmsError = sqrt(totalSwaptionError/numberBigRates); errorImprovement = previousError -periodSwaptionRmsError; previousError = periodSwaptionRmsError; } --- 162,168 ---- for (Size i=0; i < numberBigRates; ++i) modelSwaptionVolsMatrix[iterationsDone][i] = modelSwaptionVols[i]; ! periodSwaptionRmsError = std::sqrt(totalSwaptionError/numberBigRates); errorImprovement = previousError -periodSwaptionRmsError; previousError = periodSwaptionRmsError; } --------------------------------------------------------------------------- *** capletcoterminalswaptioncalibration.cpp.orig Fri Feb 20 15:07:52 2009 --- capletcoterminalswaptioncalibration.cpp Fri Feb 20 15:08:29 2009 *************** *** 134,140 **** for (Size j=0; j<numberOfRates; ++j) for (Size k=0; k < CovarianceSwapPseudos[i].columns(); ++k) CovarianceSwapPseudos[i][j][k] *= ! sqrt(swapTimeInhomogeneousVariances[i][j]); CovarianceSwapMarginalCovs[i] = CovarianceSwapPseudos[i] * transpose(CovarianceSwapPseudos[i]); --- 134,140 ---- for (Size j=0; j<numberOfRates; ++j) for (Size k=0; k < CovarianceSwapPseudos[i].columns(); ++k) CovarianceSwapPseudos[i][j][k] *= ! std::sqrt(swapTimeInhomogeneousVariances[i][j]); CovarianceSwapMarginalCovs[i] = CovarianceSwapPseudos[i] * transpose(CovarianceSwapPseudos[i]); *************** *** 162,168 **** for (Size k=0; k<numberOfFactors; ++k) correlation += thisPseudo[i-1][k]*thisPseudo[i][k]; almostTotCovariance[i] += correlation * ! sqrt(swapTimeInhomogeneousVariances[j][i] * swapTimeInhomogeneousVariances[j][i-1]); } if (i>0) { --- 162,168 ---- for (Size k=0; k<numberOfFactors; ++k) correlation += thisPseudo[i-1][k]*thisPseudo[i][k]; almostTotCovariance[i] += correlation * ! std::sqrt(swapTimeInhomogeneousVariances[j][i] * swapTimeInhomogeneousVariances[j][i-1]); } if (i>0) { *************** *** 171,177 **** for (Size k=0; k<numberOfFactors; ++k) correlation += thisPseudo[i-1][k]*thisPseudo[i][k]; leftCovariance[i] = correlation * ! sqrt(swapTimeInhomogeneousVariances[j][i] * swapTimeInhomogeneousVariances[j][i-1]); } } --- 171,177 ---- for (Size k=0; k<numberOfFactors; ++k) correlation += thisPseudo[i-1][k]*thisPseudo[i][k]; leftCovariance[i] = correlation * ! std::sqrt(swapTimeInhomogeneousVariances[j][i] * swapTimeInhomogeneousVariances[j][i-1]); } } *************** *** 260,272 **** // pick up the minimum vol for the caplet root = minimum; } else if (lowestRoot) { ! root = (-linearPart-sqrt(disc))/(2.0*quadraticPart); } else { if (minimum>1.0) ! root = (-linearPart-sqrt(disc))/(2.0*quadraticPart); else { rightUsed = true; ! root = (-linearPart+sqrt(disc))/(2.0*quadraticPart); } } --- 260,272 ---- // pick up the minimum vol for the caplet root = minimum; } else if (lowestRoot) { ! root = (-linearPart-std::sqrt(disc))/(2.0*quadraticPart); } else { if (minimum>1.0) ! root = (-linearPart-std::sqrt(disc))/(2.0*quadraticPart); else { rightUsed = true; ! root = (-linearPart+std::sqrt(disc))/(2.0*quadraticPart); } } *************** *** 274,280 **** Real varianceToFind = totVariance[i]-varianceFound; Real mult = varianceToFind/swapTimeInhomogeneousVariances[i][i]; if (mult<=0.0 && rightUsed) { ! root = (-linearPart-sqrt(disc))/(2.0*quadraticPart); varianceFound = root*root*almostTotVariance[i]; varianceToFind = totVariance[i]-varianceFound; mult = varianceToFind/swapTimeInhomogeneousVariances[i][i]; --- 274,280 ---- Real varianceToFind = totVariance[i]-varianceFound; Real mult = varianceToFind/swapTimeInhomogeneousVariances[i][i]; if (mult<=0.0 && rightUsed) { ! root = (-linearPart-std::sqrt(disc))/(2.0*quadraticPart); varianceFound = root*root*almostTotVariance[i]; varianceToFind = totVariance[i]-varianceFound; mult = varianceToFind/swapTimeInhomogeneousVariances[i][i]; ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
In reply to this post by Andreas Spengler-2
On Fri, 2009-02-20 at 15:03 +0100, Andreas Spengler wrote:
> > Can you send me a list of those? > > Course. The following files had to be adapted because of missing std:: > qualifier before some mathematical functions: > > [...list of files...] Can you send me a diff of those, so we're sure I don't miss some instance? (Just send it to me, it will probably be too large for the list.) > In ./ql/instruments/bond.cpp I had to do the following change, because you > can't modify a const iterator: These two are strange. You _can_ modify a const iterator (you wouldn't be able to iterate otherwise, which kind of defeats the whole purpose...) You just can't modify the object it points to. What was the error message? > Now I only keep getting an error in > ql/models/marketmodels/models/alphafinder.cpp (maybe because of the empty > namespace surrounding the declaration): Does it compile if you remove the surrounding namespace? Thanks, Luigi -- The young man knows the rules, but the old man knows the exceptions. -- O. W. Holmes ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Luigi,
Es schrieb Luigi Ballabio > Can you send me a diff of those, so we're sure I don't miss some > instance? (Just send it to me, it will probably be too large for the > list.) I didn't keep the originals of those files so I will have to diff them against another copy, and then send them to you directly... > These two are strange. You _can_ modify a const iterator (you wouldn't > be able to iterate otherwise, which kind of defeats the whole > purpose...) You just can't modify the object it points to. What was the > error message? "bond.cpp", line 203: Error, badunaryop: Operand for operator "--" must be an lvalue. "bond.cpp", line 225: Error, badunaryop: Operand for operator "++" must be an lvalue. 2 Error(s) detected. >> Now I only keep getting an error in >> ql/models/marketmodels/models/alphafinder.cpp (maybe because of the >> empty namespace surrounding the declaration): > > Does it compile if you remove the surrounding namespace? No. I also tried giving the namespace a name and adapt the usage of Bisection further down in the file, but it didn't help. Somehow the compiler thinks the second template parameter (function pointer) doesn't match, because the compiler looks for "Bisection<::T,::Value>"... Rgds, Andreas ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Luigi,
I looked up "function pointer template" with google and ended up at http://coding.derkeiler.com/Archive/C_CPP/comp.lang.cpp/2004-03/3445.html, which basically states "what do you need the function pointer template for"? ;-) So I tried passing the function pointers as arguments, which gets compiled now: *** alphafinder.cpp.orig Fri Feb 20 15:57:37 2009 --- alphafinder.cpp Fri Feb 20 16:56:25 2009 *************** *** 25,36 **** namespace { ! template<class T, Real (T::*Value)(Real) > Real Bisection(Real target, Real low, Real high, Real tolerance, ! T& theObject) { Real x=0.5*(low+high); Real y=(theObject.*Value)(x); --- 25,37 ---- namespace { ! template<class T> Real Bisection(Real target, Real low, Real high, Real tolerance, ! T& theObject, ! Real (T::*Value)(Real)) { Real x=0.5*(low+high); Real y=(theObject.*Value)(x); *************** *** 41,56 **** x = 0.5*(low+high); y = (theObject.*Value)(x); ! } while ((fabs(high-low) > tolerance)); return x; } ! template<class T, bool (T::*Value)(Real) > Real FindHighestOK(Real low, Real high, Real tolerance, ! T& theObject) { Real x=0.5*(low+high); bool ok=(theObject.*Value)(x); --- 42,58 ---- x = 0.5*(low+high); y = (theObject.*Value)(x); ! } while ((std::fabs(high-low) > tolerance)); return x; } ! template<class T> Real FindHighestOK(Real low, Real high, Real tolerance, ! T& theObject, ! bool (T::*Value)(Real)) { Real x=0.5*(low+high); bool ok=(theObject.*Value)(x); *************** *** 61,76 **** x = 0.5*(low+high); ok = (theObject.*Value)(x); ! } while ((fabs(high-low) > tolerance)); return x; } ! template<class T, bool (T::*Value)(Real) > Real FindLowestOK(Real low, Real high, Real tolerance, ! T& theObject) { Real x=0.5*(low+high); bool ok=(theObject.*Value)(x); --- 63,79 ---- x = 0.5*(low+high); ok = (theObject.*Value)(x); ! } while ((std::fabs(high-low) > tolerance)); return x; } ! template<class T> Real FindLowestOK(Real low, Real high, Real tolerance, ! T& theObject, ! bool (T::*Value)(Real)) { Real x=0.5*(low+high); bool ok=(theObject.*Value)(x); *************** *** 81,102 **** x = 0.5*(low+high); ok = (theObject.*Value)(x); ! } while ( (fabs(high-low) > tolerance) ); return x; } ! template<class T, Real (T::*Value)(Real), bool (T::*Condition)(Real) > Real Minimize(Real low, Real high, Real tolerance, T& theObject, bool& failed) { Real leftValue = (theObject.*Value)(low); Real rightValue = (theObject.*Value)(high); ! Real W = 0.5*(3.0-sqrt(5.0)); Real x=W*low+(1-W)*high; Real midValue = (theObject.*Value)(x); --- 84,107 ---- x = 0.5*(low+high); ok = (theObject.*Value)(x); ! } while ( (std::fabs(high-low) > tolerance) ); return x; } ! template<class T> Real Minimize(Real low, Real high, Real tolerance, T& theObject, + Real (T::*Value)(Real), + bool (T::*Condition)(Real), bool& failed) { Real leftValue = (theObject.*Value)(low); Real rightValue = (theObject.*Value)(high); ! Real W = 0.5*(3.0-std::sqrt(5.0)); Real x=W*low+(1-W)*high; Real midValue = (theObject.*Value)(x); *************** *** 379,398 **** if (bottomValue <= targetVariance) { // then find root of increasing function // (or as if increasing function) ! alpha = Bisection<AlphaFinder, &AlphaFinder::valueAtTurningPoint>( ! targetVariance, ! bottomAlpha, ! bilimit, ! tolerance, ! *this); } else { // find root of decreasing function (or as if decreasing function) ! alpha=Bisection<AlphaFinder, &AlphaFinder::minusValueAtTurningPoint>( ! -targetVariance, ! bilimit, ! topAlpha, ! tolerance, ! *this); } finalPart(alpha, stepindex, --- 384,405 ---- if (bottomValue <= targetVariance) { // then find root of increasing function // (or as if increasing function) ! alpha = Bisection<AlphaFinder>( ! targetVariance, ! bottomAlpha, ! bilimit, ! tolerance, ! *this, ! &AlphaFinder::valueAtTurningPoint); } else { // find root of decreasing function (or as if decreasing function) ! alpha=Bisection<AlphaFinder>( ! -targetVariance, ! bilimit, ! topAlpha, ! tolerance, ! *this, ! &AlphaFinder::minusValueAtTurningPoint); } finalPart(alpha, stepindex, *************** *** 460,477 **** // lower alpha is bad if (alpha0OK) { // must die somewhere in between ! alpha1 = FindLowestOK<AlphaFinder, &AlphaFinder::testIfSolutionExists>( alphaMin, alpha0, tolerance, ! *this); } else { // alphaMaxOK must be true to get here ! alpha1 = FindLowestOK<AlphaFinder, &AlphaFinder::testIfSolutionExists>( alpha0, alphaMax, tolerance, ! *this); } } --- 467,486 ---- // lower alpha is bad if (alpha0OK) { // must die somewhere in between ! alpha1 = FindLowestOK<AlphaFinder>( alphaMin, alpha0, tolerance, ! *this, ! &AlphaFinder::testIfSolutionExists); } else { // alphaMaxOK must be true to get here ! alpha1 = FindLowestOK<AlphaFinder>( alpha0, alphaMax, tolerance, ! *this, ! &AlphaFinder::testIfSolutionExists); } } *************** *** 478,488 **** if (!alphaMaxOK) { // higher alpha is bad ! alpha2 = FindHighestOK<AlphaFinder, &AlphaFinder::testIfSolutionExists>( alpha1, alphaMax, tolerance, ! *this); } else alpha2= alphaMax; } --- 487,498 ---- if (!alphaMaxOK) { // higher alpha is bad ! alpha2 = FindHighestOK<AlphaFinder>( alpha1, alphaMax, tolerance, ! *this, ! &AlphaFinder::testIfSolutionExists); } else alpha2= alphaMax; } *************** *** 507,524 **** if (foundUpOK) { alpha1 = alphaUp; ! alpha2 = FindHighestOK<AlphaFinder, &AlphaFinder::testIfSolutionExists>( alpha1, alphaMax, tolerance, ! *this); } else { alpha2 = alphaDown; ! alpha1 = FindLowestOK<AlphaFinder, &AlphaFinder::testIfSolutionExists>( alphaMin, alpha2, tolerance, ! *this); } } --- 517,536 ---- if (foundUpOK) { alpha1 = alphaUp; ! alpha2 = FindHighestOK<AlphaFinder>( alpha1, alphaMax, tolerance, ! *this, ! &AlphaFinder::testIfSolutionExists); } else { alpha2 = alphaDown; ! alpha1 = FindLowestOK<AlphaFinder>( alphaMin, alpha2, tolerance, ! *this, ! &AlphaFinder::testIfSolutionExists); } } *************** *** 525,535 **** // we have now found alpha1, alpha2 such that solution exists // at endpoints. we now want to minimize within that interval bool failed; ! alpha = Minimize<AlphaFinder, &AlphaFinder::homogeneityfailure, &AlphaFinder::testIfSolutionExists>( alpha1, alpha2, tolerance, *this, failed) ; finalPart(alpha, --- 537,549 ---- // we have now found alpha1, alpha2 such that solution exists // at endpoints. we now want to minimize within that interval bool failed; ! alpha = Minimize<AlphaFinder>( alpha1, alpha2, tolerance, *this, + &AlphaFinder::homogeneityfailure, + &AlphaFinder::testIfSolutionExists, failed) ; finalPart(alpha, --------------------------------------------------------------------------- Rgds, Andreas ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Free forum by Nabble | Edit this page |