Page 6 of 10

C++ quiz --- generic programming

Posted: December 2nd, 2014, 1:53 pm
by Cuchulainn
Thank you all for your patience. I have cleaned up the code (the idea from Luigi and Josuttis 2012 page 31).

C++ quiz --- generic programming

Posted: December 2nd, 2014, 7:48 pm
by Cuchulainn
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

C++ quiz --- generic programming

Posted: December 2nd, 2014, 7:54 pm
by Cuchulainn
more stuff (it all works)

C++ quiz --- generic programming

Posted: December 2nd, 2014, 8:22 pm
by Cuchulainn
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?

C++ quiz --- generic programming

Posted: December 3rd, 2014, 8:47 am
by Cuchulainn
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.

C++ quiz --- generic programming

Posted: December 3rd, 2014, 7:05 pm
by Cuchulainn
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

C++ quiz --- generic programming

Posted: December 16th, 2014, 8:13 pm
by Cuchulainn

C++ quiz --- generic programming

Posted: January 10th, 2015, 12:43 pm
by Cuchulainn
Homotopy functions in C++11 almost maths