Hi,

std::find seems to find the specific iterator by equaling to some value, not by comparison. So how can I utilize find and distance to fulfill the requirement in this exerse?

And also, I don't quite get the concept adapter and how to adapt existing STL algorithms. Could you give a concrete code example of adapter?

It is really so hard to continue learning something with so insufficient code example, even requiring you to answer...

Exercise1.5.4: I don't understand how to use std::find and std::distance]]>

@APalley]]>

Was wondering how will the career progression will be from a Model Validation role? Is it possible to move to a Desk Quant Role or something more challenging in the future?

Any views will be highly appreciated.]]>

I am trying to price a down-and-in barrier call option. Lyuu's book gives a simple combinatorial formula for the probability that the underlying hits the barrier and makes \(j\) upward moves, as

\({{n}\choose{n-2h+j}}p^{j}q^{n-j}\)

However, when I implement the algorithm in Python, the option value isn't close to the Black-Scholes price, no matter what \(n\)(number of time steps), I choose. Am I doing something fundamentally wrong? This is my code snippet:...

Pricing a down-and-in barrier call option using the combinatorial formula]]>

1.For exercise 1.6.2, I found out that if I add a bracket outside the ?: expressions, things can go well. If I remove the brackets, there exists a problem. But I don't think the brackets are necessary. So, what is the difference?

I think both of them will show the same result.

2. I met with a question before about the use of brackets.

What is the difference between the below two macros? Will the brackets matter?

#define power(x) (x)*(x)

#define power(x)...

About the use of brackets in 1.6.2]]>

Here was the header file declaration:

Code (C++):

- void Scale(auto d) ;

Code (C++):

- template <typename T>
- void C<T>::Scale(auto d)

error C3533: a parameter cannot have a type that contains 'auto'

How annoying! G++ let me get away with this!

I don't want to declare the parameter as T, because it's legitimate to scale an integer vector by a double, isn't...

auto scaling]]>

When computing the average for std::complex<int>, I noticed it can only be divided by an int number or a std::complex<int>; so as a result of int division, the average I found is not accurate.(My average function is Sum()/T(N)). For example if I have a tuple with

std::complex<int> a(1, 2) and std::complex<int> b(2, 3),

after I call my average function, it will just give me (1,2) instead of (1.5, 2.5).

Is this what's expected for this question, or I have to improve my average...

.2 Average of std::complex<int>]]>

Code (C++):

- C<T> C<T>::operator + (const C<T>& rhs)
- { C<T> result(rhs);
- return result; }

Code (C++):

- C<int> c3 (c1 + c2);

Thanks,

Chapin

Both files are under the same source file.

@APalley]]>

***************

int x,n;

x=3;

n=2;

x=x<<n;

printf("%d",&x);

***************

but I get 3340544 instead of 12.

Is anyone here can help me out of this? Is there anything wrong with my code? Thanks a lot.@APalley]]>

https://www.quantnet.com/threads/c-online-certificate-students-intro-thread.7522/]]>

I have some questions from the part Comparing Lambda Functions with Function Objects and Free Functions in assignment.

1. When I tried to accumulate the complex array by std::multiplies like below, it gave me a complier error - no viable conversion for C-style cast from 'std::_1::multiplies<std::_1::complex<double>>' to 'Complex ' (aka 'complex<double>'). I don't understand why it gave this error even these two are exactly same stuff.

Complex acc1a =...

exercise 2]]>

Thanks,

FQ]]>

while ((cur_char = getchar()) != 4) //not working!

{

scanf("%s", &atc1.descriptions);

Clearly, it's not working. Anyway to correct it if I want to get the description from the keyboard?

Or we should simply hardcode it in the main()?

Also, I found that for scanf(), with & or without & in the second argument both work. Why is that?

Best,

FQ]]>