SERVING THE QUANTITATIVE FINANCE COMMUNITY

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

C++11 and C++14 Articles

August 10th, 2017, 7:31 am

Here is the first article of a series

http://onlinelibrary.wiley.com/doi/10.1 ... 10606/epdf
 
User avatar
Cuchulainn
Topic Author
Posts: 56001
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++11 and C++14 Articles

August 10th, 2017, 7:35 am

The next article will show how to design the Alternating Direction Explicit (ADE) method in C++11 for the Anchoring problem with Alan and Paul (WLD2014):

http://onlinelibrary.wiley.com/doi/10.1 ... 10366/epdf

preview

.. The focus is on applying the author’s system decomposition techniques (Duffy 2004) in combination with the new features in C++11 to produce a customisable software framework that first reproduces the numerical results in WLD 2014 and that can be extended to other kinds of PDEs and finite difference schemes. We realise a certain level of flexibility in the new framework due to the following features:

. Each subsystem has a single major responsibility and it has well-defined and narrow interfaces. Complex mathematical operations are hidden behind these interfaces.
. We model PDEs as compositions of universal function wrappers based on the functional programming model. In this way we avoid code bloat and proliferation of classes that arise when creating traditional class hierarchies based on subtype polymorphism or the Curiously Recurring Template Pattern (CRTP).
. We begin with the C++ code that we used to implement the Alternating Direction Explicit (ADE) in WLD 2014 and we port it to code that fits into the software framework.
. Lambda functions are very in helping reduce code bloat, especially when configuring the application. In particular, their use promotes code readability and maintainability.
..
 
User avatar
Cuchulainn
Topic Author
Posts: 56001
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++11 and C++14 Articles

September 24th, 2017, 5:40 pm

C++11 for a class of path-dependent options.

http://onlinelibrary.wiley.com/doi/10.1 ... 10620/epdf
 
User avatar
Cuchulainn
Topic Author
Posts: 56001
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++11 and C++14 Articles

October 25th, 2017, 5:54 pm

The PDE in transformed coordinates in  the anchoring model is:

[$]\begin{array}{ll}
\frac{\partial V}{\partial t} = \frac{1}{2} \sigma^{2} \left( \frac{S}{A} \right) x^{2} (1 - x)^{2} \frac{\partial^{2} V}{\partial x^{2}} + \left\{ r x (1 - x) - \sigma^{2} x^{2} (1 - x)^{2} \right\} \frac{\partial V}{\partial x}\\
\\
\;\;\;\;\;\;\;\;+ \left( \gamma (S - A) (1 - y)^{2} / b \right) \frac{\partial V}{\partial y} - r V \\
\\
0 < x < 1, \;\;\; 0 < y < 1
\left( S = \frac{ax}{1 - x}, A = \frac{by}{1 - y} \right).
\end{array}
[$]

The FDM is fine when we give the usual BS BC for x and no BC in y (just use upwinding). See artilcle.

The *question* now is: I want to use MOL so how we we specify the BC (or is it a PDE) for [$]y \in Set({{0,1}})[$]?

I have a hunch but am not saying :)

I would like to compare NDSolve and Boost.odeint.
 
User avatar
ppauper
Posts: 67515
Joined: November 15th, 2001, 1:29 pm

Re: C++11 and C++14 Articles

November 13th, 2017, 8:13 pm

Cuchulainn wrote:
C++11 for a class of path-dependent options.

http://onlinelibrary.wiley.com/doi/10.1 ... 10620/epdf

the first thing I noticed was the typo, Dataism Education
 
User avatar
Cuchulainn
Topic Author
Posts: 56001
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++11 and C++14 Articles

November 13th, 2017, 10:03 pm

ppauper wrote:
Cuchulainn wrote:
C++11 for a class of path-dependent options.

http://onlinelibrary.wiley.com/doi/10.1 ... 10620/epdf

the first thing I noticed was the typo, Dataism Education

Next time iI will fill that bio stuff in myself _before_  I send the stuff. 
Anyways, I can be contacted at dduffy at dataism dot nl 
To err is human. 

BTW did you read the rest of the article(s)?
 
User avatar
ISayMoo
Posts: 778
Joined: September 30th, 2015, 8:30 pm

Re: C++11 and C++14 Articles

November 13th, 2017, 10:52 pm

Dataism is a new data-driven school of painting.
 
User avatar
Cuchulainn
Topic Author
Posts: 56001
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++11 and C++14 Articles

November 13th, 2017, 11:22 pm

ISayMoo wrote:
Dataism is a new data-driven school of painting.

Dataism is a form of artistic anarchy that challenged  the social, political and cultural values of the time.

We display our data driven art just opposite  Fighting 69th Armory Show at Lexington and 24th.
 
User avatar
ppauper
Posts: 67515
Joined: November 15th, 2001, 1:29 pm

Re: C++11 and C++14 Articles

November 16th, 2017, 10:52 am

Cuchulainn wrote:
ppauper wrote:
Cuchulainn wrote:
C++11 for a class of path-dependent options.

http://onlinelibrary.wiley.com/doi/10.1 ... 10620/epdf

the first thing I noticed was the typo, Dataism Education

Next time iI will fill that bio stuff in myself _before_  I send the stuff. 
Anyways, I can be contacted at dduffy at dataism dot nl 
To err is human. 

BTW did you read the rest of the article(s)?

skimmed it
I think I vaguely know one of your references, black chick called lucy?
Campbell, L.J. and Yin, B. 2006. On the Stability of Alternating-Direction Explicit Methods for Advection-Diffusion Equations. New York: Wiley Interscience.
p49 below eqn 6, you say,  "instantiating." Is that a real word?
and in (5) you use A which you don't seem to define until later in Section 4
 
User avatar
Cuchulainn
Topic Author
Posts: 56001
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++11 and C++14 Articles

November 16th, 2017, 9:42 pm

ppauper wrote:
Cuchulainn wrote:
ppauper wrote:
the first thing I noticed was the typo, Dataism Education

Next time iI will fill that bio stuff in myself _before_  I send the stuff. 
Anyways, I can be contacted at dduffy at dataism dot nl 
To err is human. 

BTW did you read the rest of the article(s)?

skimmed it
I think I vaguely know one of your references, black chick called lucy?
Campbell, L.J. and Yin, B. 2006. On the Stability of Alternating-Direction Explicit Methods for Advection-Diffusion Equations. New York: Wiley Interscience.
p49 below eqn 6, you say,  "instantiating." Is that a real word?
and in (5) you use A which you don't seem to define until later in Section 4

I think you are correct. To the point article.
https://carleton.ca/math/people/lucy-campbell/
"instantiating" is kind of C++ urban jargon.
I don't normally do forward references. I'l check it out. On the other hand, 'A' is defined in the earlier paper with Alan and Paul (Paul and Alan) so i am covered to a certain extent.
 
User avatar
Cuchulainn
Topic Author
Posts: 56001
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++11 and C++14 Articles

January 9th, 2018, 9:30 pm

Black Scholes for pure mathematicians 

https://www.maths.tcd.ie/pub/ims/bull75/Duffy.pdf
 
User avatar
Cuchulainn
Topic Author
Posts: 56001
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++11 and C++14 Articles

January 24th, 2018, 11:46 am

Abstract
In this article we introduce a defined and repeatable process to analyze, design,
and implement software systems using a combination of techniques taken from
Structured Analysis  and the object-oriented programming style. We use top-down
system decomposition and bottom-up programming techniques to create software
systems. We also show how to leverage the new multi-paradigm features in C++ to
promote maintainability and extendibility of the resulting code, and how to integrate
C++ multi-threading and multi-tasking libraries with our model. As an example
to reduce the scope, we introduce a model for Monte Carlo option pricing that we
design and realize using several different language features in C++. The steps in the
transformation from problem description to code are applicable to other kinds of
system (for example, PDE and risk applications), as well as other programming
languages (for example, C#). This article represents a continuation of the work in Duffy
(2017), Duffy and Palley (2017), and Wilmott, Lewis, and Duffy (2014).

http://onlinelibrary.wiley.com/doi/10.1 ... 10647/epdf
 
User avatar
Cuchulainn
Topic Author
Posts: 56001
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++11 and C++14 Articles

January 24th, 2018, 12:01 pm

The above article is my 2 cents attempt to address some of the following pesky stuff.

//
On the topic of "illogical class hierarchies" (I would call them incorrect in the mathematical sense), looking back complaining about OOP is caused by going overboard and applying the technology incorrectly IMO. My own list of no nos that caused distress were:

1. Multiple inheritance was not a good idea. C++ does not support interface keyword. The AI community used MI a lot in the 90s.

2. Not evertyhing is an object. Behavioural commonality is not structural commonality.This messes up class hierarchies.

3. Deep class hierarchies are usually incorrect and not maintainable, especially with MI. For CAD, all you need is depth 1 and make sure each class has 1 major responsibility. Combine with composition and Visitor pattern. Separation of Concerns is key!

4. "Tiny classes" are not classes; they are not even objects. Just think of many many Command classes. Just use lambda functions.

5. Virtual functions and multiple classes are not needed; instead, use a single class with one or more std::function instances.

6. (Sapir-Whorf) At the time. some developers used GOF patterns left, right and centre. What happened in many cases is life started with the (GOF) solution and work back to the problem. Like Newton-Raphson, convergence is not a given.

7. Classes are context-sensitive (aka unstable). Many classes live in the head of their creator who may have incomplete information about the problem domain.

8. Our group had 1-7 on  our radar screens for some time. Especially for fixed-priced projects. For developers on an hourly rate things can be slightly different. Parkinson's Law and gold-plating might kick in.

9. Class hierarchies are neither sufficient nor necessary.

Festina lente
 
User avatar
ISayMoo
Posts: 778
Joined: September 30th, 2015, 8:30 pm

Re: C++11 and C++14 Articles

January 24th, 2018, 1:02 pm

Lambda functions have this annoying feature that this does not work:

auto l1 = [](double x) { return x*x; };
auto l2 = [](double x) { return 1.0 / x; };

auto l = use_l2 ? l2 : l1;

At least in VS 2015. Why can't two lambdas of the same signature be treated as instances of the same type???
 
User avatar
Cuchulainn
Topic Author
Posts: 56001
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++11 and C++14 Articles

January 24th, 2018, 1:30 pm

What's that use_l2 thing? bool?
What error do you get exactly?

I see that auto chokes every now and then.Then use decltype/declval or even this


#include <functional>
#include <iostream>

int main()
{

   std::function<double(double)> l1 = [](double x) { return x*x; };
   std::function<double(double)> l2 = [](double x) { return 1.0 / x; };

   bool b = false;
   std::function<double (double)> f = b ? l2 : l1;
   std::cout << f(2.0) << '\n'; // 4

   b = true;
   std::function<double(double)> f2 = b ? l2 : l1;
   std::cout << f2(2.0) << '\n'; // .5

}
Last edited by Cuchulainn on January 24th, 2018, 1:44 pm
ABOUT WILMOTT

PW by JB

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


JOBS BOARD

JOBS BOARD

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