SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
Cuchulainn
Posts: 60518
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

ISO C++11 published

January 18th, 2016, 2:31 pm

QuoteOriginally posted by: outrunLol, I'm struggling.. that's where this is comming from.I know for a fact that this week someone is going to ask me if I would consider coding some derviative models in VS. I don't know yet if they use OO trees that grow their root all the way down into hell.Everyone except yourself uses DEEP OO trees. And if you're lucky they use multiple inheritance as well. Keep the faith.
Last edited by Cuchulainn on January 17th, 2016, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
 
User avatar
Cuchulainn
Posts: 60518
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

ISO C++11 published

January 18th, 2016, 3:11 pm

QuoteOriginally posted by: outrunWell I'm not gong to climb that tree, and I've never seen code getting accepted without someone being able to motivate why one design is chosen over another one.The someone has left the building, usually. And the code is undocumented. No what?
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
 
User avatar
Cuchulainn
Posts: 60518
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

ISO C++11 published

January 18th, 2016, 4:33 pm

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunWell I'm not gong to climb that tree, and I've never seen code getting accepted without someone being able to motivate why one design is chosen over another one.The someone has left the building, usually. And the code is undocumented. No what?Exactly, from what I've heard 3 developers left. Probably a coincidence ...and I'm sure it's all nicely documented. :-)As UML use cases? Usually, management has no budget for nice doc etc.
Last edited by Cuchulainn on January 17th, 2016, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

ISO C++11 published

January 19th, 2016, 7:41 am

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunUsing a local constexpr:Indeed! I tried that outside the scope of the function but it gave a compiler error. double CdfNormal(double x){ constexpr double sqrt2Inv = 1.0 / std::sqrt(2.0); return 0.5*(1.0 + std::erf(x * sqrt2Inv));}I still get error VS2015 " error C2131: expression did not evaluate to a constant1> CumulativeNormal.hpp(64): note: failure was caused by call of undefined function or one not declared 'constexpr'Unfortunately, math functions are not currently `constexpr` in the standard -- note the presence of a side-effect (setting `errno`):http://en.cppreference.com/w/cpp/error/ ... nctionsGCC supports this, but as of C++14 it's a non-conforming compiler extension:http://stackoverflow.com/questions/2774 ... ry-fuSeems that other compilers are also going to reject this:http://software.intel.com/en-us/article ... ibilityNot everyone agrees with this choice:http://groups.google.com/a/isocpp.org/f ... X-IHowever, you can still implement `constexpr` version of the algorithms; the following is worth a look:http://github.com/elbeno/constexprhttp: ... r/wikiEdit: it even includes random number generation and standard library algorithms (including numeric), which is pretty neat!
Last edited by Polter on January 18th, 2016, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 60518
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

ISO C++11 published

January 19th, 2016, 8:09 am

I have the feeling that constexpr is the C++ equivalent of COBOL global variables? On a Pareto 20/80 scale, what's the compelling reason to use it?VS2015 does however support ctor constexpr.It seem outrun's rant was a bit premature, what?
Last edited by Cuchulainn on January 18th, 2016, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
 
User avatar
Cuchulainn
Posts: 60518
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

ISO C++11 published

January 19th, 2016, 9:36 am

All constexprs are const but not all const objects are constexpr.And -in contrast to const - constexpr objects need not be immediately constructed.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

ISO C++11 published

January 19th, 2016, 11:54 am

Yeah, `constexpr` is a good replacement for template metaprogramming -- more readable (same syntax as "regular" C++) and compiles faster.Other than that -- you can also have some "fun" with `constexpr`:http://b.atch.se/posts/non-constant-con ... Disclaimer: The technique described in this post is primarily meant as "just another clever hack, diving into the dark corners of C++". I do not recommend anyone to incorporate the contents of this post into production code without considering its caveats.
 
User avatar
Cuchulainn
Posts: 60518
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

ISO C++11 published

January 20th, 2016, 11:11 am

Regarding <cmath> and <random> there seems to be no average/amortising or even worst complexity measures for the algorithms. Aka the number of arithmetic operations needed to compute something.Ex. A&S 26.3.3 I use std::erf for the inside integral and Tanh integration.Profiling is possible but that is trial and error.
Last edited by Cuchulainn on January 19th, 2016, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
 
User avatar
Cuchulainn
Posts: 60518
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

ISO C++11 published

January 20th, 2016, 12:07 pm

QuoteI also want to know this: * is erf slow compared to boost?* does is give valid (accurate, 80 bit) results for "long double"?* does boost multiprecision overload the std::erf for the multiprecision type? Or do I need to use boost:erf?Should be easy to determine. Boost mailing. A statistical regression framework is needed, does such a framework exist? My feeling is NO.So, press a button, let code run for 2 hours and look at report "std erf 20% slower than boost erf" etc.upper estimate possible. As well as accuracy estimate.
Last edited by Cuchulainn on January 19th, 2016, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On