Serving the Quantitative Finance Community

  • 1
  • 3
  • 4
  • 5
  • 6
  • 7
  • 15
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- STL tricks

October 11th, 2013, 8:21 am

QuoteOriginally posted by: outrunInteresting! Do you have multiple f(a),..i.e. a set of points you want to linear interpolate on?I thik bind can do that indeed.The background is I solve Newton Raphson f(x) = 0 by embedding it in a homotopic mapping (discoverof which there several, hence my reason for a higher-order functionH(x,t) = (1-t)*(f(x) - f(a)) + t*f(x) where t in [0,1]H(x,t) = f(x) - (1-t)*f(a)So a is my seed for iteration, so just one of them (btw homotopy more robust than NR which broke down in a IR model....)So, I would like the homotopic mapping to be customisableHope it is clear. It is certainly a nice problem because it crops up.
Last edited by Cuchulainn on October 10th, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- STL tricks

October 11th, 2013, 8:34 am

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunInteresting! Do you have multiple f(a),..i.e. a set of points you want to linear interpolate on?I thik bind can do that indeed.The background is I solve Newton Raphson f(x) = 0 by embedding it in a homotopic mapping of which there several, hence my reason for a higher-order functionok, so during each iteration you only call this once and then throw it away because during the next iterator the bounds like f(a) (or in your case the homomorphic-mapping) might be updated. Then maybe it's easiest to just leave it as it is? .. but I know you want to know it anyway what about a simple lambda? mm, that doesn't seen to add any value... I give up! We've only just begun!I was preparing a 101 example. This article is sample Have a look as it is a typical example.See EQUATIONS (4) t/m (7). I want these as HOFs. No more, no less
Last edited by Cuchulainn on October 10th, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- STL tricks

October 11th, 2013, 8:47 am

Even simpler (001)Take f(x) and g(t) as given functions.Form HOF H(x,t) == f(x)*g(t).
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- STL tricks

October 11th, 2013, 9:24 am

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunInteresting! Do you have multiple f(a),..i.e. a set of points you want to linear interpolate on?I thik bind can do that indeed.The background is I solve Newton Raphson f(x) = 0 by embedding it in a homotopic mapping of which there several, hence my reason for a higher-order functionok, so during each iteration you only call this once and then throw it away because during the next iterator the bounds like f(a) (or in your case the homomorphic-mapping) might be updated. Then maybe it's easiest to just leave it as it is? .. but I know you want to know it anyway what about a simple lambda? mm, that doesn't seen to add any value... I give up! We've only just begun!I was preparing a 101 example. This article is sample Have a look as it is a typical example.See EQUATIONS (4) t/m (7). I want these as HOFs. No more, no less Ha! It only took me 5 sec so solve 4) analytically!!lambda = p(x) / [ p(x) - q(x) ]Wrong. Very.
Last edited by Cuchulainn on October 10th, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- STL tricks

October 11th, 2013, 9:26 am

QuoteOriginally posted by: CuchulainnEven simpler (001)Take f(x) and g(t) as given functions.Form HOF H(x,t) == f(x)*g(t).Again. That's the question!
Last edited by Cuchulainn on October 10th, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- STL tricks

October 11th, 2013, 10:58 am

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: CuchulainnEven simpler (001)Take f(x) and g(t) as given functions.Form HOF H(x,t) == f(x)*g(t).Again. That's the question!You roal is still not clear. What functionality are you missing by declaring?double HOF(double x, double t) { return f(x)*g(t); }Nope. Your function is not HOF. I want HOF as return type after which I will instantiate. Like hereQuoteIn computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. Specifically, this means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures.[1] Some programming language theorists require support for anonymous functions as well.[2] In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinary variables with a function type.[3] The term was coined by Christopher Strachey in the context of ?functions as first-class citizens? in the mid-1960s.[4]
Last edited by Cuchulainn on October 10th, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- STL tricks

October 11th, 2013, 11:33 am

QuoteOriginally posted by: outrunsomething like pair and make_pair then? the "pair-ish" type is instantiated with two type (those would be the functions,.. or actually a single type -a function with 1 argument-). It need an operator()(x,t)the make_pair return a pair object.No. I want a black box function as return type (NOT a double nor a pair), like this runnable code!!
Last edited by Cuchulainn on October 10th, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
ExSan
Posts: 493
Joined: April 12th, 2003, 10:40 am

C++ quiz --- STL tricks

October 11th, 2013, 11:33 am

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: CuchulainnEven simpler (001)Take f(x) and g(t) as given functions.Form HOF H(x,t) == f(x)*g(t).Again. That's the question!You roal is still not clear. What functionality are you missing by declaring?double HOF(double x, double t) { return f(x)*g(t); }Nope. Your function is not HOF. I want HOF as return type after which I will instantiate. Like hereQuoteIn computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. Specifically, this means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures.[1] Some programming language theorists require support for anonymous functions as well.[2] In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinary variables with a function type.[3] The term was coined by Christopher Strachey in the context of ?functions as first-class citizens? in the mid-1960s.[4] can you make a drawing, for me? it looks interesting, but still not very clear what are you looking for.I have a project in mind and this could be useful, some tensor treatmente
°°° About ExSan bit.ly/3U5bIdq °°°
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- STL tricks

October 11th, 2013, 11:37 am

I am looking for HOFNo drawing sorry it's all text. See my C++ code.EXX: How to model f(g(x)) etc.
Last edited by Cuchulainn on October 10th, 2013, 10:00 pm, edited 1 time in total.