Serving the Quantitative Finance Community

  • 1
  • 4
  • 5
  • 6
  • 7
  • 8
  • 10
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 2nd, 2014, 1:53 pm

Thank you all for your patience. I have cleaned up the code (the idea from Luigi and Josuttis 2012 page 31).
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 2nd, 2014, 7:48 pm

QuoteOriginally posted by: outrunLooks nice Cuch!Does this automagically handle things likeauto h = k(x)*3*(g(x)+h(x))+5;?The think I find amazing with libs like boost multiprecision is that you can slip that any algorithm without modifying the algorithm, Just because the primitive operations are defined. I wonder what it would take to make it work with functions.Similar, libraries like TML (template matrix library?) do smart reductions.Yep, LOL. It's like doing maths in C++.That's a damn clever compiler
Last edited by Cuchulainn on December 1st, 2014, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 2nd, 2014, 7:54 pm

more stuff (it all works)
Last edited by Cuchulainn on December 1st, 2014, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 2nd, 2014, 8:22 pm

QuoteOriginally posted by: outrunvery cool. Nice to see something that simple(ish) to work that well!I just generalized Josuttis' example.It's amazing. Based on maths I can write a whole algebra in C++ (but I need templated autos). QuoteSimilar, libraries like TML (template matrix library?) do smart reductions.I was just thinking of doing this for matrices. After all, functions and matrices are just vector spaces. BTW, you probably mean MTLI need templated autos. C++14?
Last edited by Cuchulainn on December 2nd, 2014, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 3rd, 2014, 8:47 am

QuoteOriginally posted by: outrunIt can be done (I've been explained, never tried it myself) with expression templatesWhat is ideal, is BLAS like this, directly in application codeQuoteGeneric applications can be written in a natural notation, e.g. v += A*q - w;, while the library dispatches to the appropriate algorithms: matrix vector products vs. matrix products vs. vector scalar products etcetera. The goal is to encapsulate performance issues inside the library and provide scientists an intuitive interface. MTL4 is used in different finite element and finite volume packages, e.g.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 3rd, 2014, 7:05 pm

Can't get this working std::function<double (double)> F = std::exp; auto F2 = std::bind(::exp, std:laceholders::_1); auto F3 = ::exp; =================== Solutionstd::function<double(double)> f_sin = (double(*)(double))&std::sin;auto f_sin2 = (double(*)(double))&std::sin;auto fffff = 3 * f * f_sin * f_sin2;std::cout << "fffff " << fffff(2) << ", " << std::endl; LOL
Last edited by Cuchulainn on December 2nd, 2014, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 16th, 2014, 8:13 pm

Last edited by Cuchulainn on December 16th, 2014, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

January 10th, 2015, 12:43 pm

Homotopy functions in C++11 almost maths
Last edited by Cuchulainn on January 9th, 2015, 11:00 pm, edited 1 time in total.