I am creating a series of parametric sympy functions dependent on x,y variables. Some of the functions turn out to be only dependent on some of the variables. therefore, when I call 'codegen', the interface of the created functions varies (sometimes it includes all variables, sometimes not). However, I want to be able to call the functions in a uniform manner in C.
To make a long story short, here's the example:
x,y = sympy.symbols("x,y")
S1 = x + y
S2 = x
d = {'S1':S1,'S2':S2}
for k in d.keys():
[(c_name, c_code), (h_name, c_header)] = codegen((k, d[k]), ...\
"C",func_name,header=False, empty=False)
print(c_code)
which outputs:
#include "S2.h"
#include <math.h>
double S2(double x) {
double S2_result;
S2_result = x;
return S2_result;
}
#include "S1.h"
#include <math.h>
double S1(double x, double y) {
double S1_result;
S1_result = x + y;
return S1_result;
}
My Question is: How do I make codegen create both function with an equal signature?