How do I retrieve the results from a complex function in C++/python interactive mode?

  c++, python

I would like to get the return value of erf(complex input) in C++ codes.
then I can write codes like this:

std::complex erfi(const std::complex& z_in)
{
    Py_Initialize();
    PyRun_SimpleString("from scipy.special import erf");
    PyRun_SimpleString("from numpy import complex");
    PyRun_SimpleString("erfi = lambda z: complex(0.0,-1.)*erf(complex(0.0,1.0)*z)");
    PyRun_SimpleString("print(erfi(complex(0.75,1.25)))");
    //Here how to put the parameter z_in and retrieve the result of the lambda expression: erfi?
    Py_Finalize();
    ....

}

Regards, Thank you!

Source: Windows Questions C++

LEAVE A COMMENT