Exemplo n.º 1
0
def _str_scal_func_init_data(method, name):
    expr = getattr(method, name + '_expr')
    init_data = 'double {0}_data = '.format(name)
    symbs = expr.free_symbols
    if any(symb in method.args for symb in symbs):
        init_data += "0.;"
    else:
        c = ccode(expr, dereference=dereference(method))
        init_data += '{0};'.format(c)
    return init_data
Exemplo n.º 2
0
def _str_scal_func_update(method, name, objlabel):
    expr = getattr(method, name + '_expr')
    update_h = '\nvoid {0}_update();'.format(name)
    update_cpp = '\nvoid {0}::{1}_update()'.format(objlabel, name) + '{'
    symbs = expr.free_symbols
    if any(symb in method.args for symb in symbs):
        c = ccode(expr, dereference=dereference(method))
        update_cpp += '\n_{0} = {1};'.format(name, c)
    update_cpp += '\n};'
    return update_h, update_cpp
Exemplo n.º 3
0
def _str_mat_func_update(method, name, objlabel):
    mat = sympy.Matrix(getattr(method, name + '_expr'))
    update_h = '\nvoid {0}_update();'.format(name)
    update_cpp = '\nvoid {0}::{1}_update()'.format(objlabel, name) + '{'
    for n in range(mat.shape[1]):
        for m in range(mat.shape[0]):
            expr = mat[m, n]
            symbs = expr.free_symbols
            if any(symb in method.args for symb in symbs):
                c = ccode(expr, dereference=dereference(method))
                update_cpp += '\n_{0}({1}, {2}) = {3};'.format(name, m, n, c)
    update_cpp += '\n};'
    return update_h, update_cpp
Exemplo n.º 4
0
def _str_mat_func_init_data(method, name):
    mat = sympy.Matrix(getattr(method, name + '_expr'))
    init_data = 'double {0}_data[] ='.format(name) + ' {'
    crop = False
    for n in range(mat.shape[1]):
        for m in range(mat.shape[0]):
            expr = mat[m, n]
            symbs = expr.free_symbols
            if any(symb in method.args for symb in symbs):
                init_data += "0, "
                crop = True
            else:
                c = ccode(expr, dereference=dereference(method))
                init_data += '{0}, '.format(c)
                crop = True
    if crop:
        init_data = init_data[:-2]
    init_data += '};'
    return init_data