Cython std::future - cython

How to wrap a C++ function that is returning std::future in Cython?
std::future<int> fooAsync();
Such that when invoking this function in Python you're not waiting for the result and can check it later.

Related

Looking for an Objective Function package in Julia

I am trying to identify/source an objective function package in Julia that has common objective functions (such as Rastrigin, Schwefel, etc.) in-built, so I do not need to retype the function via an f(x) = ... declaration.
Does such a package exist, and if so, what is it called?

what is the difference between a 'function call' and a 'callback function'?

function call
Per MDN, A function call is an expression that passes control and
arguments (if any) to a function and has the form: expression
(expression-listopt)
callback function
A callback function is a lucky function that gets passed into the enclosing higher-order function: The callback function gets executed (called) inside the higher order function, but not necessarily immediately.
https://thenewstack.io/mastering-javascript-callbacks-bind-apply-call/
function call is term related to program syntax. it related to generally programs and programming languages. There are no predefined semantic, just term which used to describe programs.
callback function is term related to program execution semantic. In some kind callback function is function call with scope, which pass as parameter to another function or method, some parameters of callback function can be free variables and callback function executed generally after method or function in which it was passed.

Undefined reference error during building the code for a couple of statement functions

I am receiving "Undefined reference error to ..." errors for a couple of statement functions while building my code. It compiles successfully.
My program section of code starts with the below statement functions after defining the necessary parameter and dimensions. In addition, I have other functions/subroutines in the CONTAINS section of the module.
PROGRAM ......
DIMENSIONS bla bla
!***** FUNCTIONS *****
!***FREE ENERGIES PER VOLUME OF INDIVIDUAL PHASES
FL(X)=((1.-X)*GCU_L+R*T*((1.-X)*DLOG(1.-X)))
DFI(X)=2.*CC*(X-0.435)/VM
*****************************
VM=20.65D-6
R=8.3145
T=250. + 273.
TEMP=T
GCU_L=5194.277+120.973331*T
bla bla
END PROGRAM
Build errors that I am receiving:
gfortran -Wall -o "123456" "123456.f90" (in directory: /Geany)
/tmp/ccwapaHQ.o: In function `__mymodule_MOD_fsteady':
123456.f90:(.text+0x7e3a): undefined reference to `fl_'
123456.f90:(.text+0x7ea9): undefined reference to `dfi_'
**DELETED THE REST**
collect2: error: ld returned 1 exit status
Compilation failed.
I thought copying the statement functions to contain section of my MODULE may solve the errors. However, it produces the following compilation errors...
gfortran -Wall -c "123456.f90" (in directory: /Geany)
Compilation failed.
123456.f90:523.127:
FL(X)=((1.-X)*GCU_L+R*T*((1.-X)*DLOG(1.-X)))
1
DFI(X)=2.*CC*(X-0.435)/VM
1
Error: Unexpected STATEMENT FUNCTION statement in CONTAINS section at (1)
123456.f90:1332.16:
USE myModule
1
Fatal Error: Can't open module file 'mymodule.mod' for reading at (1): No such file or directory
The first thing to say is that statement functions are obsolescent in current Fortran, and I'd suggest that you consider avoiding their use.
However, your first sub-question isn't really specific to statement functions, but scope. Your functions are declared/defined in the main program: you can't expect them to be available in a module which is use associated by that program any more than you'd expect a variable to be. Use association goes the other way, making entities in the module available in the main program (or other thing using the module).
Statement functions differ a little from internal procedures in that they can't be actual arguments to a procedure reference in a module. You could pass a "proper" function contained in the main program to a module procedure, just not a statement function.
Your attempt to move the statement functions into the module itself is the second sub-question. You cannot define a statement function in a module. It cannot be before the contains statement and it cannot be after (in the standard these are covered by a restriction each).
It's hard to see that you will lose anything by changing your statement function in the main program to a full function of the module (after the contains).

#cython.wraparound(False) cast integer CORE GENERATED Error

In cython when my code is compiled with
#cython.wraparound(True)
and I use the following cast function to convert (cast) a float to an integer
cdef DTYPE_t_I float_int(np.float_t val):
return <DTYPE_t_I>val
it runs ok
BUT
when I turn off
#cython.wraparound(False)
the code compiles normally and when it runs it gives the following error
CORE GENERATED
It happens compiling in linux with gcc and windows with MGS
What is wrong? Should it be like this?
Because I am trying to gain speed, I would like to know to switch off these flag.

Programming a function in Maple

What is the equivalent to a procedural C function in Maple? Maple tells me that a module cannot except parameters.
A Maple module can be applied to arguments and thus act as a function call if it has an exported member named ModuleApply.
In that case a function call (involving module m) of the form m(...arguments...) will invoke the call m:-ModuleApply(...arguments...).
See ModuleApply