Changeset 14004


Ignore:
Timestamp:
Nov 10, 2019 11:39:37 AM (4 weeks ago)
Author:
Christian Andersson
Message:

Merged the domain checks feature to trunk. Related to ticket:5868

Location:
trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/CHANGELOG.txt

    r13980 r14004  
    11================= Unreleased ==================
     2; Feature ; Minor ; Runtime ; #5868
     3Added a compiler flag 'mathematical_domain_checks' which determines if
     4domain checks is to be performed for all mathematical functions.
     5
    26# Change ; Minor ; Compiler; #5870
    37Debug log now contains checksums of all generated c-files.
  • trunk/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CCodeGenExpressions.jrag

    r13897 r14004  
    3636    @Override
    3737    public void FAbsExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    38         str.print("jmi_abs(");
     38        str.print("JMI_ABS_EQUATION(");
    3939        p.print(getFExp(), str, indent);
     40        str.print(")");
     41    }
     42   
     43    @Override
     44    public void FSignExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
     45        str.print("JMI_SIGN_EQUATION(");
     46        p.print(getFExp(), str, indent);
     47        str.print(")");
     48    }
     49   
     50    @Override
     51    public void FMinMaxExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
     52        str.print("JMI_" + builtInName().toUpperCase() + "_EQUATION(");
     53        p.print(getX(), str, indent);
     54        str.print(", ");
     55        p.print(getY(), str, indent);
    4056        str.print(")");
    4157    }
     
    105121    public void FDivFuncExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    106122        str.print("((long)");
    107         if (inFunction()) {
    108             str.format("jmi_divide_function(\"%s\", ", containingFFunctionDecl().name());
    109         } else {
    110             str.print("jmi_divide_equation(jmi, ");
    111         }
    112         p.print(getX(),str,indent);
    113         str.print(",");
    114         p.print(getY(),str,indent);
    115         str.print(",");
    116         str.print("\""+prettyPrint("")+"\")");
     123        prettyPrintGuarded(p.ExecStep, str, indent, getX(), getY());
    117124        str.print(")");
    118125    }
     
    265272
    266273    @Override
    267     public void FMinMaxExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    268         str.print("jmi_" + builtInName() + "(");
    269         p.print(getX(), str, indent);
    270         str.print(", ");
    271         p.print(getY(), str, indent);
    272         str.print(")");
    273     }
    274 
    275     @Override
    276274    public void FNoEventExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    277275        str.print('(');
     
    312310
    313311    @Override
    314     public void FSignExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    315         str.print("jmi_sign(");
    316         p.print(getFExp(), str, indent);
    317         str.print(")");
    318     }
    319 
    320     @Override
    321312    public void FSizeExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    322313        size().printSize_C(p, str, indent, getFExp(), dimension());
     
    427418    protected void RuntimeCallComputation.prettyPrintHead(CodePrinter.ExecuteCodePrinter p, CodeStream str, String indent, FExp ctx, FExp[] inputs, FExp[] outputs) {
    428419        boolean func = ctx.inFunction();
    429         str.print("jmi_");
    430         str.print(p.guardedFunctionName(ctx));
    431         str.print(func ? "_function(" : "_equation(");
     420        str.print(("jmi_" + p.guardedFunctionName(ctx) + (func ? "_function(" : "_equation(")).toUpperCase());
    432421        str.print(func ? "\"" + ctx.containingFFunctionDecl().name() + "\", ": "jmi, ");
    433422        p.codePrinter().print(this, str, indent, CFuncParamDirection.INPUT, Arrays.asList(inputs));
     
    460449    eq FDotDivExp.guardedFunctionName_C()           = "divide";
    461450    eq FDotPowExp.guardedFunctionName_C()           = "pow";
     451    eq FDivFuncExp.guardedFunctionName_C()          = "divide";
    462452    eq FBuiltInFunctionCall.guardedFunctionName_C() = builtInName();
    463453
     
    524514        }
    525515    }
    526 
    527     @Override
    528     public void FExpExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
     516   
     517    @Override
     518    public void FMathematicalFunctionCall.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    529519        prettyPrintGuarded(p.ExecStep, str, indent, getFExp());
    530520    }
    531 
    532     @Override
    533     public void  FLogExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    534         prettyPrintGuarded(p.ExecStep, str, indent, getFExp());
    535     }
    536 
    537     @Override
    538     public void  FLog10Exp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    539         prettyPrintGuarded(p.ExecStep, str, indent, getFExp());
    540     }
    541 
    542     @Override
    543     public void  FSinhExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    544         prettyPrintGuarded(p.ExecStep, str, indent, getFExp());
    545     }
    546 
    547     @Override
    548     public void  FCoshExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    549         prettyPrintGuarded(p.ExecStep, str, indent, getFExp());
    550     }
    551 
    552     @Override
    553     public void  FTanExp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
    554         prettyPrintGuarded(p.ExecStep, str, indent, getFExp());
    555     }
    556 
     521   
    557522    @Override
    558523    public void FAtan2Exp.prettyPrint_C(CodePrinter p, CodeStream str, String indent) {
  • trunk/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CGenerator.jrag

    r13798 r14004  
    310310   
    311311    }
    312 
     312   
     313    /**
     314     * C: defines for the C code
     315     */
     316    public class DAETag_C_defines extends DAETag {
     317       
     318        public DAETag_C_defines(AbstractGenerator myGenerator, FClass fclass) {
     319            super("C_defines", myGenerator, fclass);
     320        }
     321       
     322        public void generate(CodeStream genPrinter) {
     323            if (fclass.myOptions().mathematical_domain_checks.getValue()) {
     324                genPrinter.print("#define MATHEMATICAL_DOMAIN_CHECKS");
     325            }
     326        }
     327    }
    313328    /**
    314329     * C: macros for C variable aliases
  • trunk/Compiler/ModelicaCBackEnd/templates/FMIBase/base.c

    r13908 r14004  
    179179    /* Initialize globals struct */
    180180    (*jmi)->globals = calloc(1, sizeof(jmi_globals_t));
    181 
     181   
     182    /* Log specific runtime information */
     183    jmi_log_node((*jmi)->log, logInfo, "JMIRuntime", MATHEMATICAL_DOMAIN_CHECKS_MSG);
     184   
    182185    return 0;
    183186}
  • trunk/Compiler/ModelicaCBackEnd/templates/FMIBase/base.h

    r12878 r14004  
    1313    <http://www.ibm.com/developerworks/library/os-cpl.html/>.
    1414*/
     15
     16$C_defines$
    1517
    1618#include <stdio.h>
  • trunk/Compiler/ModelicaCBackEnd/test/modelica/CCodeGenAlgorithmTests.mo

    r13357 r14004  
    16801680    int ef = 0;
    16811681    JMI_DYNAMIC_INIT()
    1682     _x_0 = sin(_time * 10.0);
     1682    _x_0 = JMI_SIN_EQUATION(jmi, _time * 10.0, \"sin(time * 10)\");
    16831683    if (jmi->atInitial || jmi->atEvent) {
    16841684        _sw(1) = jmi_turn_switch(jmi, _x_0 - (0.7), _sw(1), JMI_REL_LT);
     
    17021702    int ef = 0;
    17031703    JMI_DYNAMIC_INIT()
    1704     _x_0 = sin(_time * 10.0);
     1704    _x_0 = JMI_SIN_EQUATION(jmi, _time * 10.0, \"sin(time * 10)\");
    17051705    if (jmi->atInitial || jmi->atEvent) {
    17061706        _sw(0) = jmi_turn_switch(jmi, _x_0 - (0.7), _sw(0), JMI_REL_GEQ);
     
    24122412        _x_2 = (tmp_3);
    24132413        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    2414             (*res)[0] = jmi_divide_equation(jmi, _x_2, 2, \"x / 2\") - (_y_3);
     2414            (*res)[0] = JMI_DIVIDE_EQUATION(jmi, _x_2, 2, \"x / 2\") - (_y_3);
    24152415        }
    24162416    }
  • trunk/Compiler/ModelicaCBackEnd/test/modelica/CCodeGenArrayTests.mo

    r13846 r14004  
    4949    }
    5050    temp_1_v = temp_2_v;
    51     y_v = sqrt(temp_1_v);
     51    y_v = JMI_SQRT_FUNCTION(\"CCodeGenArrayTests.VectorLength1.f\", temp_1_v, \"sqrt(temp_1)\");
    5252    JMI_RET(GEN, y_o, y_v)
    5353    JMI_DYNAMIC_FREE()
  • trunk/Compiler/ModelicaCBackEnd/test/modelica/CCodeGenDynamicStatesTests.mo

    r13168 r14004  
    3333        annotation(__JModelica(UnitTesting(tests={
    3434            CCodeGenTestCase(
    35                 name="DynamicStates_ThreeDSOneEq",
     35                name="ThreeDSOneEq",
    3636                description="Test code gen for dynamic state model with three states in one equation",
    3737                dynamic_states=true,
     
    8383        _a3_2 = __ds_1_s1_5;
    8484        _a1_0 = __ds_1_s2_6;
    85         _a2_1 = jmi_divide_equation(jmi, 1, (_a1_0 * _a3_2), \"1 / (ds(1, a1) * ds(1, a3))\");
     85        _a2_1 = JMI_DIVIDE_EQUATION(jmi, 1, (_a1_0 * _a3_2), \"1 / (ds(1, a1) * ds(1, a3))\");
    8686        __ds_1_a1_4 = _a2_1;
    8787    } else if (jmi_dynamic_state_check_is_state(jmi, 0, 5, 4)) {
    8888        _a2_1 = __ds_1_s1_5;
    8989        _a1_0 = __ds_1_s2_6;
    90         _a3_2 = jmi_divide_equation(jmi, 1, (_a1_0 * _a2_1), \"1 / (ds(1, a1) * ds(1, a2))\");
     90        _a3_2 = JMI_DIVIDE_EQUATION(jmi, 1, (_a1_0 * _a2_1), \"1 / (ds(1, a1) * ds(1, a2))\");
    9191        __ds_1_a1_4 = _a3_2;
    9292    } else if (jmi_dynamic_state_check_is_state(jmi, 0, 5, 6)) {
    9393        _a2_1 = __ds_1_s1_5;
    9494        _a3_2 = __ds_1_s2_6;
    95         _a1_0 = jmi_divide_equation(jmi, 1, (_a2_1 * _a3_2), \"1 / (ds(1, a2) * ds(1, a3))\");
     95        _a1_0 = JMI_DIVIDE_EQUATION(jmi, 1, (_a2_1 * _a3_2), \"1 / (ds(1, a2) * ds(1, a3))\");
    9696        __ds_1_a1_4 = _a1_0;
    9797    }
     
    423423        annotation(__JModelica(UnitTesting(tests={
    424424            CCodeGenTestCase(
    425                 name="DynamicStates_Pendulum",
     425                name="Pendulum",
    426426                description="Test code gen for dynamic state related parts of the pendulum model",
    427427                dynamic_states=true,
     
    501501        __der_y_10 = __ds_1_s1_12;
    502502        _der_y_18 = __der_y_10;
    503         _der_x_17 = jmi_divide_equation(jmi, (- 2 * _y_3 * _der_y_18), (2 * _x_2), \"(- 2 * ds(2, y) * dynDer(y)) / (2 * ds(2, x))\");
     503        _der_x_17 = JMI_DIVIDE_EQUATION(jmi, (- 2 * _y_3 * _der_y_18), (2 * _x_2), \"(- 2 * ds(2, y) * dynDer(y)) / (2 * ds(2, x))\");
    504504        __der_x_9 = _der_x_17;
    505505        __ds_1_a1_11 = __der_x_9;
     
    507507        __der_x_9 = __ds_1_s1_12;
    508508        _der_x_17 = __der_x_9;
    509         _der_y_18 = jmi_divide_equation(jmi, (- 2 * _x_2 * _der_x_17), (2 * _y_3), \"(- 2 * ds(2, x) * dynDer(x)) / (2 * ds(2, y))\");
     509        _der_y_18 = JMI_DIVIDE_EQUATION(jmi, (- 2 * _x_2 * _der_x_17), (2 * _y_3), \"(- 2 * ds(2, x) * dynDer(x)) / (2 * ds(2, y))\");
    510510        __der_y_10 = _der_y_18;
    511511        __ds_1_a1_11 = __der_y_10;
     
    538538        x[0] = 7;
    539539    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    540         (*res)[0] = jmi_max(jmi_max(1.0, 1.0), jmi_abs(_L_0));
     540        (*res)[0] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, 1.0), JMI_ABS_EQUATION(_L_0));
    541541    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    542542        x[0] = _y_3;
     
    561561        x[0] = 6;
    562562    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    563         (*res)[0] = jmi_max(jmi_max(1.0, 1.0), jmi_abs(_L_0));
     563        (*res)[0] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, 1.0), JMI_ABS_EQUATION(_L_0));
    564564    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    565565        x[0] = _x_2;
     
    11511151        name="PreBlock1",
    11521152        description="Dynamic state block inside pre block",
    1153         template="
    1154 $C_dae_blocks_residual_functions$
    1155 ",
    1156     generatedCode="
     1153        template="$C_dae_blocks_residual_functions$",
     1154        generatedCode="
    11571155static int dae_block_1(jmi_t* jmi, jmi_real_t* x, jmi_real_t* residual, int evaluation_mode) {
    11581156    /***** Block: 1.2 *****/
     
    12361234        if (jmi_dynamic_state_check_is_state(jmi, 0, 4)) {
    12371235            _a1_0 = __ds_1_s1_7;
    1238             _a2_1 = jmi_divide_equation(jmi, COND_EXP_EQ(LOG_EXP_AND(_b2_3, LOG_EXP_NOT(pre_b2_3)), JMI_TRUE, 1.0, _time), _a1_0, \"(if b2 and not pre(b2) then 1 else time) / ds(1, a1)\");
     1236            _a2_1 = JMI_DIVIDE_EQUATION(jmi, COND_EXP_EQ(LOG_EXP_AND(_b2_3, LOG_EXP_NOT(pre_b2_3)), JMI_TRUE, 1.0, _time), _a1_0, \"(if b2 and not pre(b2) then 1 else time) / ds(1, a1)\");
    12391237            __ds_1_a1_6 = _a2_1;
    12401238        } else if (jmi_dynamic_state_check_is_state(jmi, 0, 5)) {
    12411239            _a2_1 = __ds_1_s1_7;
    1242             _a1_0 = jmi_divide_equation(jmi, COND_EXP_EQ(LOG_EXP_AND(_b2_3, LOG_EXP_NOT(pre_b2_3)), JMI_TRUE, 1.0, _time), _a2_1, \"(if b2 and not pre(b2) then 1 else time) / ds(1, a2)\");
     1240            _a1_0 = JMI_DIVIDE_EQUATION(jmi, COND_EXP_EQ(LOG_EXP_AND(_b2_3, LOG_EXP_NOT(pre_b2_3)), JMI_TRUE, 1.0, _time), _a2_1, \"(if b2 and not pre(b2) then 1 else time) / ds(1, a2)\");
    12431241            __ds_1_a1_6 = _a1_0;
    12441242        }
     
    12501248    return ef;
    12511249}
     1250
    12521251")})));
    12531252end PreBlock1;
  • trunk/Compiler/ModelicaCBackEnd/test/modelica/CCodeGenGlobalsTests.mo

    r13908 r14004  
    10491049    i_0ie = floor((2) - (1));
    10501050    for (i_0i = 1; i_0in <= i_0ie; i_0i = 1 + (++i_0in)) {
    1051         y_v = jmi_pow_function(\"CCodeGenGlobalsTests.GlobalVariables.GlobalConstantForPowInt1.f\", y_v, jmi_array_val_1(JMI_GLOBAL(CCodeGenGlobalsTests_GlobalVariables_GlobalConstantForPowInt1_f_c), i_0i), \"y ^ global(CCodeGenGlobalsTests.GlobalVariables.GlobalConstantForPowInt1.f.c[i])\");
     1051        y_v = JMI_POW_FUNCTION(\"CCodeGenGlobalsTests.GlobalVariables.GlobalConstantForPowInt1.f\", y_v, jmi_array_val_1(JMI_GLOBAL(CCodeGenGlobalsTests_GlobalVariables_GlobalConstantForPowInt1_f_c), i_0i), \"y ^ global(CCodeGenGlobalsTests.GlobalVariables.GlobalConstantForPowInt1.f.c[i])\");
    10521052    }
    10531053    JMI_RET(GEN, y_o, y_v)
  • trunk/Compiler/ModelicaCBackEnd/test/modelica/CCodeGenJacobianTests.mo

    r13097 r14004  
    100100        x[1] = 3;
    101101    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    102         (*res)[0] = jmi_max(jmi_abs(_b_2_4), jmi_max(1.0, jmi_abs(2.0)));
     102        (*res)[0] = JMI_MAX_EQUATION(JMI_ABS_EQUATION(_b_2_4), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(2.0)));
    103103    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    104104        x[0] = _x_3_2;
     
    109109            _x_3_2 = x[0];
    110110        }
    111         _x_2_1 = jmi_divide_equation(jmi, (- _b_3_5 + _x_3_2), -2, \"(- b[3] + x[3]) / -2\");
    112         _x_1_0 = jmi_divide_equation(jmi, (- _b_1_3 + _x_2_1), -2, \"(- b[1] + x[2]) / -2\");
     111        _x_2_1 = JMI_DIVIDE_EQUATION(jmi, (- _b_3_5 + _x_3_2), -2, \"(- b[3] + x[3]) / -2\");
     112        _x_1_0 = JMI_DIVIDE_EQUATION(jmi, (- _b_1_3 + _x_2_1), -2, \"(- b[1] + x[2]) / -2\");
    113113        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    114114            (*res)[0] = _x_1_0 + 2 * _x_3_2 - (_b_2_4);
     
    302302        x[1] = 8;
    303303    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    304         (*res)[0] = jmi_max(jmi_abs(_b_3_5), jmi_max(jmi_abs(2.0), 1.0));
     304        (*res)[0] = JMI_MAX_EQUATION(JMI_ABS_EQUATION(_b_3_5), JMI_MAX_EQUATION(JMI_ABS_EQUATION(2.0), 1.0));
    305305    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    306306        x[0] = _x_3_2;
     
    501501        x[1] = 3;
    502502    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    503         (*res)[0] = jmi_max(jmi_abs(_b_2_4), jmi_max(1.0, jmi_abs(2.0)));
     503        (*res)[0] = JMI_MAX_EQUATION(JMI_ABS_EQUATION(_b_2_4), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(2.0)));
    504504    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    505505        x[0] = _x_3_2;
     
    529529            _x_3_2 = x[0];
    530530        }
    531         _x_2_1 = jmi_divide_equation(jmi, (- _b_3_5 + _x_3_2), -2, \"(- b[3] + x[3]) / -2\");
    532         _x_1_0 = jmi_divide_equation(jmi, (- _b_1_3 + _x_2_1), -2, \"(- b[1] + x[2]) / -2\");
     531        _x_2_1 = JMI_DIVIDE_EQUATION(jmi, (- _b_3_5 + _x_3_2), -2, \"(- b[3] + x[3]) / -2\");
     532        _x_1_0 = JMI_DIVIDE_EQUATION(jmi, (- _b_1_3 + _x_2_1), -2, \"(- b[1] + x[2]) / -2\");
    533533        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    534534            (*res)[0] = _x_1_0 + 2 * _x_3_2 - (_b_2_4);
     
    575575        x[1] = 3;
    576576    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    577         (*res)[0] = jmi_max(jmi_abs(_b_2_4), jmi_max(1.0, jmi_abs(2.0)));
     577        (*res)[0] = JMI_MAX_EQUATION(JMI_ABS_EQUATION(_b_2_4), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(2.0)));
    578578    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    579579        x[0] = _x_3_2;
     
    584584            _x_3_2 = x[0];
    585585        }
    586         _x_2_1 = jmi_divide_equation(jmi, (- _b_3_5 + _x_3_2), -2, \"(- b[3] + x[3]) / -2\");
    587         _x_1_0 = jmi_divide_equation(jmi, (- _b_1_3 + _x_2_1), -2, \"(- b[1] + x[2]) / -2\");
     586        _x_2_1 = JMI_DIVIDE_EQUATION(jmi, (- _b_3_5 + _x_3_2), -2, \"(- b[3] + x[3]) / -2\");
     587        _x_1_0 = JMI_DIVIDE_EQUATION(jmi, (- _b_1_3 + _x_2_1), -2, \"(- b[1] + x[2]) / -2\");
    588588        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    589589            (*res)[0] = _x_1_0 + 2 * _x_3_2 - (_b_2_4);
     
    777777        x[0] = jmi->offs_sw + 0;
    778778    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    779         (*res)[0] = jmi_max(jmi_abs(_b_1_3), jmi_max(jmi_max(jmi_abs(2.0), 1.0), jmi_max(1.0, 1.0)));
     779        (*res)[0] = JMI_MAX_EQUATION(JMI_ABS_EQUATION(_b_1_3), JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_ABS_EQUATION(2.0), 1.0), JMI_MAX_EQUATION(1.0, 1.0)));
    780780    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    781781        x[0] = _x_1_0;
     
    805805            _x_1_0 = x[0];
    806806        }
    807         _x_3_2 = jmi_divide_equation(jmi, (- _b_2_4 + _x_1_0), -2, \"(- b[2] + x[1]) / -2\");
    808         _x_2_1 = jmi_divide_equation(jmi, (- _b_3_5 + _x_3_2), -2, \"(- b[3] + x[3]) / -2\");
     807        _x_3_2 = JMI_DIVIDE_EQUATION(jmi, (- _b_2_4 + _x_1_0), -2, \"(- b[2] + x[1]) / -2\");
     808        _x_2_1 = JMI_DIVIDE_EQUATION(jmi, (- _b_3_5 + _x_3_2), -2, \"(- b[3] + x[3]) / -2\");
    809809        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    810810            if (evaluation_mode & JMI_BLOCK_EVALUATE_NON_REALS) {
  • trunk/Compiler/ModelicaCBackEnd/test/modelica/CCodeGenTests.mo

    r13944 r14004  
    1717
    1818package CCodeGenTests
     19
     20model DomainChecks1
     21    Real x1 = abs(time);
     22    Real x2 = cos(time);
     23    Real x3 = sin(time);
     24    Real x4 = tan(time);
     25    Real x5 = acos(time);
     26    Real x6 = asin(time);
     27    Real x7 = atan(time);
     28    Real x8 = log(time);
     29    Real x9 = log10(time);
     30    Real x10= exp(time);
     31    Real x11= time^10;
     32    Real x12= sqrt(time);
     33    Real x13= sinh(time);
     34    Real x14= cosh(time);
     35    Real x15= tanh(time);
     36    Real x16= atan2(time, 2*time);
     37    Real x17= time / x16;
     38    Real x18= sign(time);
     39    Real x19= max(time, x16);
     40    Real x20= min(time, x16);
     41    Real x21= div(time, 2*time);
     42
     43    function operators
     44        input Real t;
     45        output Real[16] o;
     46    algorithm
     47        o[1] := cos(t);
     48        o[2] := sin(t);
     49        o[3] := acos(t);
     50        o[4] := asin(t);
     51        o[5] := atan(t);
     52        o[6] := log(t);
     53        o[7] := log10(t);
     54        o[8] := exp(t);
     55        o[9] := t^10;
     56        o[10]:= sqrt(time);
     57        o[11]:= cosh(time);
     58        o[12]:= sinh(time);
     59        o[13]:= tanh(time);
     60        o[14]:= atan2(time, 2*time);
     61        o[15]:= t / o[1];
     62        o[16]:= div(time, 2*time);
     63    end operators;
     64   
     65    Real o[16] = operators(time);
     66   
     67annotation(__JModelica(UnitTesting(tests={
     68    CCodeGenTestCase(
     69        name="DomainChecks1",
     70        description="Test of domain check generation",
     71        mathematical_domain_checks=true,
     72        inline_functions="none",
     73        template="
     74$C_ode_derivatives$
     75$C_functions$
     76",
     77        generatedCode="
     78
     79int model_ode_derivatives_base(jmi_t* jmi) {
     80    int ef = 0;
     81    JMI_DYNAMIC_INIT()
     82    JMI_ARR(STACK, jmi_real_t, jmi_array_t, tmp_1, 16, 1)
     83    _x1_0 = JMI_ABS_EQUATION(_time);
     84    _x2_1 = JMI_COS_EQUATION(jmi, _time, \"cos(time)\");
     85    _x3_2 = JMI_SIN_EQUATION(jmi, _time, \"sin(time)\");
     86    _x4_3 = JMI_TAN_EQUATION(jmi, _time, \"tan(time)\");
     87    _x5_4 = JMI_ACOS_EQUATION(jmi, _time, \"acos(time)\");
     88    _x6_5 = JMI_ASIN_EQUATION(jmi, _time, \"asin(time)\");
     89    _x7_6 = JMI_ATAN_EQUATION(jmi, _time, \"atan(time)\");
     90    _x8_7 = JMI_LOG_EQUATION(jmi, _time, \"log(time)\");
     91    _x9_8 = JMI_LOG10_EQUATION(jmi, _time, \"log10(time)\");
     92    _x10_9 = JMI_EXP_EQUATION(jmi, _time, \"exp(time)\");
     93    _x11_10 = JMI_POW_EQUATION(jmi, _time, 10, \"time ^ 10\");
     94    _x12_11 = JMI_SQRT_EQUATION(jmi, _time, \"sqrt(time)\");
     95    _x13_12 = JMI_SINH_EQUATION(jmi, _time, \"sinh(time)\");
     96    _x14_13 = JMI_COSH_EQUATION(jmi, _time, \"cosh(time)\");
     97    _x15_14 = JMI_TANH_EQUATION(jmi, _time, \"tanh(time)\");
     98    _x16_15 = JMI_ATAN2_EQUATION(jmi, _time, 2.0 * _time, \"atan2(time, 2 * time)\");
     99    _x17_16 = JMI_DIVIDE_EQUATION(jmi, _time, _x16_15, \"time / x16\");
     100    _x18_17 = JMI_SIGN_EQUATION(_time);
     101    _x19_18 = JMI_MAX_EQUATION(_time, _x16_15);
     102    _x20_19 = JMI_MIN_EQUATION(_time, _x16_15);
     103    if (jmi->atInitial || jmi->atEvent) {
     104        _sw(0) = jmi_turn_switch(jmi, ((long)JMI_DIVIDE_EQUATION(jmi, _time, 2.0 * _time, \"div(time, 2 * time)\")) - (pre_temp_2_37), _sw(0), JMI_REL_LT);
     105    }
     106    if (jmi->atInitial || jmi->atEvent) {
     107        _sw(1) = jmi_turn_switch(jmi, ((long)JMI_DIVIDE_EQUATION(jmi, _time, 2.0 * _time, \"div(time, 2 * time)\")) - (pre_temp_2_37 + 1.0), _sw(1), JMI_REL_GEQ);
     108    }
     109    _temp_2_37 = COND_EXP_EQ(LOG_EXP_OR(LOG_EXP_OR(_sw(0), _sw(1)), _atInitial), JMI_TRUE, ((long)JMI_DIVIDE_EQUATION(jmi, _time, 2.0 * _time, \"div(time, 2 * time)\")), pre_temp_2_37);
     110    pre_temp_2_37 = _temp_2_37;
     111    _x21_20 = _temp_2_37;
     112    JMI_ARRAY_INIT_1(STACK, jmi_real_t, jmi_array_t, tmp_1, 16, 1, 16)
     113    func_CCodeGenTests_DomainChecks1_operators_def0(_time, tmp_1);
     114    memcpy(&_o_1_21, &jmi_array_val_1(tmp_1, 1), 16 * sizeof(jmi_real_t));
     115    JMI_DYNAMIC_FREE()
     116    return ef;
     117}
     118
     119void func_CCodeGenTests_DomainChecks1_operators_def0(jmi_real_t t_v, jmi_array_t* o_a) {
     120    JMI_DYNAMIC_INIT()
     121    JMI_ARR(STACK, jmi_real_t, jmi_array_t, o_an, 16, 1)
     122    if (o_a == NULL) {
     123        JMI_ARRAY_INIT_1(STACK, jmi_real_t, jmi_array_t, o_an, 16, 1, 16)
     124        o_a = o_an;
     125    }
     126    jmi_array_ref_1(o_a, 1) = JMI_COS_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", t_v, \"cos(t)\");
     127    jmi_array_ref_1(o_a, 2) = JMI_SIN_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", t_v, \"sin(t)\");
     128    jmi_array_ref_1(o_a, 3) = JMI_ACOS_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", t_v, \"acos(t)\");
     129    jmi_array_ref_1(o_a, 4) = JMI_ASIN_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", t_v, \"asin(t)\");
     130    jmi_array_ref_1(o_a, 5) = JMI_ATAN_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", t_v, \"atan(t)\");
     131    jmi_array_ref_1(o_a, 6) = JMI_LOG_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", t_v, \"log(t)\");
     132    jmi_array_ref_1(o_a, 7) = JMI_LOG10_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", t_v, \"log10(t)\");
     133    jmi_array_ref_1(o_a, 8) = JMI_EXP_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", t_v, \"exp(t)\");
     134    jmi_array_ref_1(o_a, 9) = JMI_POW_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", t_v, 10, \"t ^ 10\");
     135    jmi_array_ref_1(o_a, 10) = JMI_SQRT_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", _time, \"sqrt(time)\");
     136    jmi_array_ref_1(o_a, 11) = JMI_COSH_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", _time, \"cosh(time)\");
     137    jmi_array_ref_1(o_a, 12) = JMI_SINH_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", _time, \"sinh(time)\");
     138    jmi_array_ref_1(o_a, 13) = JMI_TANH_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", _time, \"tanh(time)\");
     139    jmi_array_ref_1(o_a, 14) = JMI_ATAN2_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", _time, 2.0 * _time, \"atan2(time, 2 * time)\");
     140    jmi_array_ref_1(o_a, 15) = JMI_DIVIDE_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", t_v, jmi_array_val_1(o_a, 1), \"t / o[1]\");
     141    jmi_array_ref_1(o_a, 16) = ((long)JMI_DIVIDE_FUNCTION(\"CCodeGenTests.DomainChecks1.operators\", _time, 2.0 * _time, \"div(time, 2 * time)\"));
     142    JMI_DYNAMIC_FREE()
     143    return;
     144}
     145
     146")})));
     147end DomainChecks1;
     148
     149model DomainChecks2
     150    Real x1 = abs(time);
     151
     152annotation(__JModelica(UnitTesting(tests={
     153    CCodeGenTestCase(
     154        name="DomainChecks2",
     155        description="Test of domain check generation",
     156        mathematical_domain_checks=false,
     157        inline_functions="none",
     158        template="$C_defines$",
     159        generatedCode="")})));
     160end DomainChecks2;
     161
     162model DomainChecks3
     163    Real x1 = abs(time);
     164
     165annotation(__JModelica(UnitTesting(tests={
     166    CCodeGenTestCase(
     167        name="DomainChecks3",
     168        description="Test of domain check generation",
     169        mathematical_domain_checks=true,
     170        inline_functions="none",
     171        template="$C_defines$",
     172        generatedCode="#define MATHEMATICAL_DOMAIN_CHECKS
     173")})));
     174end DomainChecks3;
    19175
    20176model CCodeGenTest1
     
    145301        generatedCode="
    146302    (*res)[0] = _y_1 - (_der_x_2);
    147     (*res)[1] = (COND_EXP_EQ(COND_EXP_LE(_time, jmi_divide_equation(jmi, 3.141592653589793, 2.0, \"3.141592653589793 / 2\"), JMI_TRUE, JMI_FALSE), JMI_TRUE, sin(_time), _x_0)) - (_der_x_2);
     303    (*res)[1] = (COND_EXP_EQ(COND_EXP_LE(_time, JMI_DIVIDE_EQUATION(jmi, 3.141592653589793, 2.0, \"3.141592653589793 / 2\"), JMI_TRUE, JMI_FALSE), JMI_TRUE, JMI_SIN_EQUATION(jmi, _time, \"sin(time)\"), _x_0)) - (_der_x_2);
    148304")})));
    149305end CCodeGenTest4;
     
    377533  der(x) = (x-0.3)^0.3 + (x-0.3)^3;
    378534
    379     annotation(__JModelica(UnitTesting(tests={
    380         CCodeGenTestCase(
    381             name="CCodeGenTest12",
    382             description="C code generation: test that x^2 is represented by x*x in the generated code.",
    383             variability_propagation=false,
    384             generate_ode=false,
    385             generate_dae=true,
    386             template="$C_DAE_equation_residuals$",
    387             generatedCode="
    388     (*res)[0] = jmi_pow_equation(jmi, (_x_0 - 0.3),0.3,\"(x - 0.3) ^ 0.3\") + (1.0 * ((_x_0 - 0.3)) * ((_x_0 - 0.3)) * ((_x_0 - 0.3))) - (_der_x_1);
     535annotation(__JModelica(UnitTesting(tests={
     536    CCodeGenTestCase(
     537        name="CCodeGenTest12",
     538        description="C code generation: test that x^2 is represented by x*x in the generated code.",
     539        variability_propagation=false,
     540        generate_ode=false,
     541        generate_dae=true,
     542        template="$C_DAE_equation_residuals$",
     543        generatedCode="
     544    (*res)[0] = JMI_POW_EQUATION(jmi, (_x_0 - 0.3), 0.3, \"(x - 0.3) ^ 0.3\") + (1.0 * ((_x_0 - 0.3)) * ((_x_0 - 0.3)) * ((_x_0 - 0.3))) - (_der_x_1);
    389545")})));
    390546end CCodeGenTest12;
     
    704860    Real x = time / f("a", time);
    705861
    706     annotation(__JModelica(UnitTesting(tests={
    707         CCodeGenTestCase(
    708             name="CCodeGenTest19",
    709             description="Check that quotes in divisions are escaped in the string representation",
    710             template="$C_ode_derivatives$",
    711             generatedCode="
     862annotation(__JModelica(UnitTesting(tests={
     863    CCodeGenTestCase(
     864        name="CCodeGenTest19",
     865        description="Check that quotes in divisions are escaped in the string representation",
     866        template="$C_ode_derivatives$",
     867        generatedCode="
    712868
    713869int model_ode_derivatives_base(jmi_t* jmi) {
    714870    int ef = 0;
    715871    JMI_DYNAMIC_INIT()
    716     _x_0 = jmi_divide_equation(jmi, _time,func_CCodeGenTests_CCodeGenTest19_f_exp0(\"a\", _time),\"time / CCodeGenTests.CCodeGenTest19.f(\\\"a\\\", time)\");
     872    _x_0 = JMI_DIVIDE_EQUATION(jmi, _time, func_CCodeGenTests_CCodeGenTest19_f_exp0(\"a\", _time), \"time / CCodeGenTests.CCodeGenTest19.f(\\\"a\\\", time)\");
    717873    JMI_DYNAMIC_FREE()
    718874    return ef;
     
    9681124    int ef = 0;
    9691125    JMI_DYNAMIC_INIT()
    970     _der_x_1 = jmi_divide_equation(jmi, _x_0, 1234, \"x / 1234\");
     1126    _der_x_1 = JMI_DIVIDE_EQUATION(jmi, _x_0, 1234, \"x / 1234\");
    9711127    JMI_DYNAMIC_FREE()
    9721128    return ef;
     
    12531409    _a_c3_f_7 = - _b_c6_f_19;
    12541410    _a_c2_f_4 = - _a_c1_f_1 - _a_c3_f_7;
    1255     __stream_s_1_21 = jmi_max(_a_c2_f_4, 0.0) + jmi_max(_a_c3_f_7, 0.0);
    1256     __stream_alpha_1_22 = (COND_EXP_EQ(COND_EXP_GT(__stream_s_1_21, jmi_in_stream_eps(jmi) * 0.1, JMI_TRUE, JMI_FALSE), JMI_TRUE, 1.0, COND_EXP_EQ(COND_EXP_GT(__stream_s_1_21, 0.0, JMI_TRUE, JMI_FALSE), JMI_TRUE, jmi_divide_equation(jmi, __stream_s_1_21, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_1 / (_inStreamEpsilon * 0.1)\") * (jmi_divide_equation(jmi, __stream_s_1_21, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_1 / (_inStreamEpsilon * 0.1)\") * (3.0 - 2.0 * __stream_s_1_21)), 0.0)));
    1257     __stream_positiveMax_1_23 = __stream_alpha_1_22 * jmi_max(_a_c2_f_4, 0.0) + (1 - __stream_alpha_1_22) * (jmi_in_stream_eps(jmi) * 0.1);
     1411    __stream_s_1_21 = JMI_MAX_EQUATION(_a_c2_f_4, 0.0) + JMI_MAX_EQUATION(_a_c3_f_7, 0.0);
     1412    __stream_alpha_1_22 = (COND_EXP_EQ(COND_EXP_GT(__stream_s_1_21, jmi_in_stream_eps(jmi) * 0.1, JMI_TRUE, JMI_FALSE), JMI_TRUE, 1.0, COND_EXP_EQ(COND_EXP_GT(__stream_s_1_21, 0.0, JMI_TRUE, JMI_FALSE), JMI_TRUE, JMI_DIVIDE_EQUATION(jmi, __stream_s_1_21, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_1 / (_inStreamEpsilon * 0.1)\") * (JMI_DIVIDE_EQUATION(jmi, __stream_s_1_21, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_1 / (_inStreamEpsilon * 0.1)\") * (3.0 - 2.0 * __stream_s_1_21)), 0.0)));
     1413    __stream_positiveMax_1_23 = __stream_alpha_1_22 * JMI_MAX_EQUATION(_a_c2_f_4, 0.0) + (1 - __stream_alpha_1_22) * (jmi_in_stream_eps(jmi) * 0.1);
    12581414    _b_c5_s_17 = 5;
    1259     __stream_positiveMax_2_24 = __stream_alpha_1_22 * jmi_max(_a_c3_f_7, 0.0) + (1 - __stream_alpha_1_22) * (jmi_in_stream_eps(jmi) * 0.1);
     1415    __stream_positiveMax_2_24 = __stream_alpha_1_22 * JMI_MAX_EQUATION(_a_c3_f_7, 0.0) + (1 - __stream_alpha_1_22) * (jmi_in_stream_eps(jmi) * 0.1);
    12601416    _b_c6_s_20 = 6;
    1261     _a_c1_s_2 = jmi_divide_equation(jmi, (__stream_positiveMax_1_23 * _b_c5_s_17 + __stream_positiveMax_2_24 * _b_c6_s_20), (__stream_positiveMax_1_23 + __stream_positiveMax_2_24), \"(_stream_positiveMax_1 * b.c5.s + _stream_positiveMax_2 * b.c6.s) / (_stream_positiveMax_1 + _stream_positiveMax_2)\");
     1417    _a_c1_s_2 = JMI_DIVIDE_EQUATION(jmi, (__stream_positiveMax_1_23 * _b_c5_s_17 + __stream_positiveMax_2_24 * _b_c6_s_20), (__stream_positiveMax_1_23 + __stream_positiveMax_2_24), \"(_stream_positiveMax_1 * b.c5.s + _stream_positiveMax_2 * b.c6.s) / (_stream_positiveMax_1 + _stream_positiveMax_2)\");
    12621418    _a_c2_p_3 = _a_c1_p_0;
    1263     __stream_s_2_25 = jmi_max(_a_c1_f_1, 0.0) + jmi_max(_a_c3_f_7, 0.0);
    1264     __stream_alpha_2_26 = (COND_EXP_EQ(COND_EXP_GT(__stream_s_2_25, jmi_in_stream_eps(jmi) * 0.1, JMI_TRUE, JMI_FALSE), JMI_TRUE, 1.0, COND_EXP_EQ(COND_EXP_GT(__stream_s_2_25, 0.0, JMI_TRUE, JMI_FALSE), JMI_TRUE, jmi_divide_equation(jmi, __stream_s_2_25, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_2 / (_inStreamEpsilon * 0.1)\") * (jmi_divide_equation(jmi, __stream_s_2_25, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_2 / (_inStreamEpsilon * 0.1)\") * (3.0 - 2.0 * __stream_s_2_25)), 0.0)));
    1265     __stream_positiveMax_3_27 = __stream_alpha_2_26 * jmi_max(_a_c1_f_1, 0.0) + (1 - __stream_alpha_2_26) * (jmi_in_stream_eps(jmi) * 0.1);
     1419    __stream_s_2_25 = JMI_MAX_EQUATION(_a_c1_f_1, 0.0) + JMI_MAX_EQUATION(_a_c3_f_7, 0.0);
     1420    __stream_alpha_2_26 = (COND_EXP_EQ(COND_EXP_GT(__stream_s_2_25, jmi_in_stream_eps(jmi) * 0.1, JMI_TRUE, JMI_FALSE), JMI_TRUE, 1.0, COND_EXP_EQ(COND_EXP_GT(__stream_s_2_25, 0.0, JMI_TRUE, JMI_FALSE), JMI_TRUE, JMI_DIVIDE_EQUATION(jmi, __stream_s_2_25, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_2 / (_inStreamEpsilon * 0.1)\") * (JMI_DIVIDE_EQUATION(jmi, __stream_s_2_25, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_2 / (_inStreamEpsilon * 0.1)\") * (3.0 - 2.0 * __stream_s_2_25)), 0.0)));
     1421    __stream_positiveMax_3_27 = __stream_alpha_2_26 * JMI_MAX_EQUATION(_a_c1_f_1, 0.0) + (1 - __stream_alpha_2_26) * (jmi_in_stream_eps(jmi) * 0.1);
    12661422    _b_c4_s_14 = 4;
    1267     __stream_positiveMax_4_28 = __stream_alpha_2_26 * jmi_max(_a_c3_f_7, 0.0) + (1 - __stream_alpha_2_26) * (jmi_in_stream_eps(jmi) * 0.1);
    1268     _a_c2_s_5 = jmi_divide_equation(jmi, (__stream_positiveMax_3_27 * _b_c4_s_14 + __stream_positiveMax_4_28 * _b_c6_s_20), (__stream_positiveMax_3_27 + __stream_positiveMax_4_28), \"(_stream_positiveMax_3 * b.c4.s + _stream_positiveMax_4 * b.c6.s) / (_stream_positiveMax_3 + _stream_positiveMax_4)\");
     1423    __stream_positiveMax_4_28 = __stream_alpha_2_26 * JMI_MAX_EQUATION(_a_c3_f_7, 0.0) + (1 - __stream_alpha_2_26) * (jmi_in_stream_eps(jmi) * 0.1);
     1424    _a_c2_s_5 = JMI_DIVIDE_EQUATION(jmi, (__stream_positiveMax_3_27 * _b_c4_s_14 + __stream_positiveMax_4_28 * _b_c6_s_20), (__stream_positiveMax_3_27 + __stream_positiveMax_4_28), \"(_stream_positiveMax_3 * b.c4.s + _stream_positiveMax_4 * b.c6.s) / (_stream_positiveMax_3 + _stream_positiveMax_4)\");
    12691425    _a_c3_p_6 = _a_c2_p_3;
    1270     __stream_s_3_29 = jmi_max(_a_c1_f_1, 0.0) + jmi_max(_a_c2_f_4, 0.0);
    1271     __stream_alpha_3_30 = (COND_EXP_EQ(COND_EXP_GT(__stream_s_3_29, jmi_in_stream_eps(jmi) * 0.1, JMI_TRUE, JMI_FALSE), JMI_TRUE, 1.0, COND_EXP_EQ(COND_EXP_GT(__stream_s_3_29, 0.0, JMI_TRUE, JMI_FALSE), JMI_TRUE, jmi_divide_equation(jmi, __stream_s_3_29, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_3 / (_inStreamEpsilon * 0.1)\") * (jmi_divide_equation(jmi, __stream_s_3_29, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_3 / (_inStreamEpsilon * 0.1)\") * (3.0 - 2.0 * __stream_s_3_29)), 0.0)));
    1272     __stream_positiveMax_5_31 = __stream_alpha_3_30 * jmi_max(_a_c1_f_1, 0.0) + (1 - __stream_alpha_3_30) * (jmi_in_stream_eps(jmi) * 0.1);
    1273     __stream_positiveMax_6_32 = __stream_alpha_3_30 * jmi_max(_a_c2_f_4, 0.0) + (1 - __stream_alpha_3_30) * (jmi_in_stream_eps(jmi) * 0.1);
    1274     _a_c3_s_8 = jmi_divide_equation(jmi, (__stream_positiveMax_5_31 * _b_c4_s_14 + __stream_positiveMax_6_32 * _b_c5_s_17), (__stream_positiveMax_5_31 + __stream_positiveMax_6_32), \"(_stream_positiveMax_5 * b.c4.s + _stream_positiveMax_6 * b.c5.s) / (_stream_positiveMax_5 + _stream_positiveMax_6)\");
     1426    __stream_s_3_29 = JMI_MAX_EQUATION(_a_c1_f_1, 0.0) + JMI_MAX_EQUATION(_a_c2_f_4, 0.0);
     1427    __stream_alpha_3_30 = (COND_EXP_EQ(COND_EXP_GT(__stream_s_3_29, jmi_in_stream_eps(jmi) * 0.1, JMI_TRUE, JMI_FALSE), JMI_TRUE, 1.0, COND_EXP_EQ(COND_EXP_GT(__stream_s_3_29, 0.0, JMI_TRUE, JMI_FALSE), JMI_TRUE, JMI_DIVIDE_EQUATION(jmi, __stream_s_3_29, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_3 / (_inStreamEpsilon * 0.1)\") * (JMI_DIVIDE_EQUATION(jmi, __stream_s_3_29, (jmi_in_stream_eps(jmi) * 0.1), \"_stream_s_3 / (_inStreamEpsilon * 0.1)\") * (3.0 - 2.0 * __stream_s_3_29)), 0.0)));
     1428    __stream_positiveMax_5_31 = __stream_alpha_3_30 * JMI_MAX_EQUATION(_a_c1_f_1, 0.0) + (1 - __stream_alpha_3_30) * (jmi_in_stream_eps(jmi) * 0.1);
     1429    __stream_positiveMax_6_32 = __stream_alpha_3_30 * JMI_MAX_EQUATION(_a_c2_f_4, 0.0) + (1 - __stream_alpha_3_30) * (jmi_in_stream_eps(jmi) * 0.1);
     1430    _a_c3_s_8 = JMI_DIVIDE_EQUATION(jmi, (__stream_positiveMax_5_31 * _b_c4_s_14 + __stream_positiveMax_6_32 * _b_c5_s_17), (__stream_positiveMax_5_31 + __stream_positiveMax_6_32), \"(_stream_positiveMax_5 * b.c4.s + _stream_positiveMax_6 * b.c5.s) / (_stream_positiveMax_5 + _stream_positiveMax_6)\");
    12751431    _a_x1_9 = _b_c4_s_14;
    12761432    _a_x2_10 = _b_c5_s_17;
     
    18201976        template="$C_DAE_equation_residuals$",
    18211977        generatedCode="
    1822     (*res)[0] = jmi_divide_equation(jmi, _y_1_1_4 * _y_1_1_4, jmi_pow_equation(jmi, (_y_1_1_4 + _y_1_1_4 - 2), _y_1_1_4, \"(y[1,1] .+ y[1,1] .- 2) .^ y[1,1]\"), \"y[1,1] .* y[1,1] ./ (y[1,1] .+ y[1,1] .- 2) .^ y[1,1]\") - (_x_1_1_0);
    1823     (*res)[1] = jmi_divide_equation(jmi, _y_1_2_5 * _y_1_2_5, jmi_pow_equation(jmi, (_y_1_2_5 + _y_1_2_5 - 2), _y_1_2_5, \"(y[1,2] .+ y[1,2] .- 2) .^ y[1,2]\"), \"y[1,2] .* y[1,2] ./ (y[1,2] .+ y[1,2] .- 2) .^ y[1,2]\") - (_x_1_2_1);
    1824     (*res)[2] = jmi_divide_equation(jmi, _y_2_1_6 * _y_2_1_6, jmi_pow_equation(jmi, (_y_2_1_6 + _y_2_1_6 - 2), _y_2_1_6, \"(y[2,1] .+ y[2,1] .- 2) .^ y[2,1]\"), \"y[2,1] .* y[2,1] ./ (y[2,1] .+ y[2,1] .- 2) .^ y[2,1]\") - (_x_2_1_2);
    1825     (*res)[3] = jmi_divide_equation(jmi, _y_2_2_7 * _y_2_2_7, jmi_pow_equation(jmi, (_y_2_2_7 + _y_2_2_7 - 2), _y_2_2_7, \"(y[2,2] .+ y[2,2] .- 2) .^ y[2,2]\"), \"y[2,2] .* y[2,2] ./ (y[2,2] .+ y[2,2] .- 2) .^ y[2,2]\") - (_x_2_2_3);
     1978    (*res)[0] = JMI_DIVIDE_EQUATION(jmi, _y_1_1_4 * _y_1_1_4, JMI_POW_EQUATION(jmi, (_y_1_1_4 + _y_1_1_4 - 2), _y_1_1_4, \"(y[1,1] .+ y[1,1] .- 2) .^ y[1,1]\"), \"y[1,1] .* y[1,1] ./ (y[1,1] .+ y[1,1] .- 2) .^ y[1,1]\") - (_x_1_1_0);
     1979    (*res)[1] = JMI_DIVIDE_EQUATION(jmi, _y_1_2_5 * _y_1_2_5, JMI_POW_EQUATION(jmi, (_y_1_2_5 + _y_1_2_5 - 2), _y_1_2_5, \"(y[1,2] .+ y[1,2] .- 2) .^ y[1,2]\"), \"y[1,2] .* y[1,2] ./ (y[1,2] .+ y[1,2] .- 2) .^ y[1,2]\") - (_x_1_2_1);
     1980    (*res)[2] = JMI_DIVIDE_EQUATION(jmi, _y_2_1_6 * _y_2_1_6, JMI_POW_EQUATION(jmi, (_y_2_1_6 + _y_2_1_6 - 2), _y_2_1_6, \"(y[2,1] .+ y[2,1] .- 2) .^ y[2,1]\"), \"y[2,1] .* y[2,1] ./ (y[2,1] .+ y[2,1] .- 2) .^ y[2,1]\") - (_x_2_1_2);
     1981    (*res)[3] = JMI_DIVIDE_EQUATION(jmi, _y_2_2_7 * _y_2_2_7, JMI_POW_EQUATION(jmi, (_y_2_2_7 + _y_2_2_7 - 2), _y_2_2_7, \"(y[2,2] .+ y[2,2] .- 2) .^ y[2,2]\"), \"y[2,2] .* y[2,2] ./ (y[2,2] .+ y[2,2] .- 2) .^ y[2,2]\") - (_x_2_2_3);
    18261982    (*res)[4] = 1 - (_y_1_1_4);
    18271983    (*res)[5] = 2 - (_y_1_2_5);
     
    18391995    Real y = exp(time) + f(time);
    18401996   
    1841     annotation(__JModelica(UnitTesting(tests={
    1842         CCodeGenTestCase(
    1843             name="CCodeGenExpOp",
    1844             description="C code generation of exp operator",
    1845             inline_functions="none",
    1846             template="
     1997annotation(__JModelica(UnitTesting(tests={
     1998    CCodeGenTestCase(
     1999        name="CCodeGenExpOp",
     2000        description="C code generation of exp operator",
     2001        inline_functions="none",
     2002        template="
    18472003$C_ode_derivatives$
    18482004$C_functions$
    18492005",
    1850             generatedCode="
     2006        generatedCode="
    18512007
    18522008int model_ode_derivatives_base(jmi_t* jmi) {
    18532009    int ef = 0;
    18542010    JMI_DYNAMIC_INIT()
    1855     _y_0 = jmi_exp_equation(jmi, _time,\"exp(time)\") + func_CCodeGenTests_CCodeGenExpOp_f_exp0(_time);
     2011    _y_0 = JMI_EXP_EQUATION(jmi, _time, \"exp(time)\") + func_CCodeGenTests_CCodeGenExpOp_f_exp0(_time);
    18562012    JMI_DYNAMIC_FREE()
    18572013    return ef;
     
    18612017    JMI_DYNAMIC_INIT()
    18622018    JMI_DEF(REA, y_v)
    1863     y_v = jmi_exp_function(\"CCodeGenTests.CCodeGenExpOp.f\", x_v,\"exp(x)\");
     2019    y_v = JMI_EXP_FUNCTION(\"CCodeGenTests.CCodeGenExpOp.f\", x_v, \"exp(x)\");
    18642020    JMI_RET(GEN, y_o, y_v)
    18652021    JMI_DYNAMIC_FREE()
     
    18842040    Real y = log(time) + f(time);
    18852041   
    1886     annotation(__JModelica(UnitTesting(tests={
    1887         CCodeGenTestCase(
    1888             name="CCodeGenLogOp",
    1889             description="C code generation of log operator",
    1890             inline_functions="none",
    1891             template="
     2042annotation(__JModelica(UnitTesting(tests={
     2043    CCodeGenTestCase(
     2044        name="CCodeGenLogOp",
     2045        description="C code generation of log operator",
     2046        inline_functions="none",
     2047        template="
    18922048$C_ode_derivatives$
    18932049$C_functions$
    18942050",
    1895             generatedCode="
     2051        generatedCode="
    18962052
    18972053int model_ode_derivatives_base(jmi_t* jmi) {
    18982054    int ef = 0;
    18992055    JMI_DYNAMIC_INIT()
    1900     _y_0 = jmi_log_equation(jmi, _time,\"log(time)\") + func_CCodeGenTests_CCodeGenLogOp_f_exp0(_time);
     2056    _y_0 = JMI_LOG_EQUATION(jmi, _time, \"log(time)\") + func_CCodeGenTests_CCodeGenLogOp_f_exp0(_time);
    19012057    JMI_DYNAMIC_FREE()
    19022058    return ef;
     
    19062062    JMI_DYNAMIC_INIT()
    19072063    JMI_DEF(REA, y_v)
    1908     y_v = jmi_log_function(\"CCodeGenTests.CCodeGenLogOp.f\", x_v,\"log(x)\");
     2064    y_v = JMI_LOG_FUNCTION(\"CCodeGenTests.CCodeGenLogOp.f\", x_v, \"log(x)\");
    19092065    JMI_RET(GEN, y_o, y_v)
    19102066    JMI_DYNAMIC_FREE()
     
    19292085    Real y = log10(time) + f(time);
    19302086   
    1931     annotation(__JModelica(UnitTesting(tests={
    1932         CCodeGenTestCase(
    1933             name="CCodeGenLog10Op",
    1934             description="C code generation of log10 operator",
    1935             inline_functions="none",
    1936             template="
     2087annotation(__JModelica(UnitTesting(tests={
     2088    CCodeGenTestCase(
     2089        name="CCodeGenLog10Op",
     2090        description="C code generation of log10 operator",
     2091        inline_functions="none",
     2092        template="
    19372093$C_ode_derivatives$
    19382094$C_functions$
    19392095",
    1940             generatedCode="
     2096        generatedCode="
    19412097
    19422098int model_ode_derivatives_base(jmi_t* jmi) {
    19432099    int ef = 0;
    19442100    JMI_DYNAMIC_INIT()
    1945     _y_0 = jmi_log10_equation(jmi, _time,\"log10(time)\") + func_CCodeGenTests_CCodeGenLog10Op_f_exp0(_time);
     2101    _y_0 = JMI_LOG10_EQUATION(jmi, _time, \"log10(time)\") + func_CCodeGenTests_CCodeGenLog10Op_f_exp0(_time);
    19462102    JMI_DYNAMIC_FREE()
    19472103    return ef;
     
    19512107    JMI_DYNAMIC_INIT()
    19522108    JMI_DEF(REA, y_v)
    1953     y_v = jmi_log10_function(\"CCodeGenTests.CCodeGenLog10Op.f\", x_v,\"log10(x)\");
     2109    y_v = JMI_LOG10_FUNCTION(\"CCodeGenTests.CCodeGenLog10Op.f\", x_v, \"log10(x)\");
    19542110    JMI_RET(GEN, y_o, y_v)
    19552111    JMI_DYNAMIC_FREE()
     
    19742130    Real y = sinh(time) + f(time);
    19752131   
    1976     annotation(__JModelica(UnitTesting(tests={
    1977         CCodeGenTestCase(
    1978             name="CCodeGenSinhOp",
    1979             description="C code generation of sinh operator",
    1980             inline_functions="none",
    1981             template="
     2132annotation(__JModelica(UnitTesting(tests={
     2133    CCodeGenTestCase(
     2134        name="CCodeGenSinhOp",
     2135        description="C code generation of sinh operator",
     2136        inline_functions="none",
     2137        template="
    19822138$C_ode_derivatives$
    19832139$C_functions$
    19842140",
    1985             generatedCode="
     2141        generatedCode="
    19862142
    19872143int model_ode_derivatives_base(jmi_t* jmi) {
    19882144    int ef = 0;
    19892145    JMI_DYNAMIC_INIT()
    1990     _y_0 = jmi_sinh_equation(jmi, _time,\"sinh(time)\") + func_CCodeGenTests_CCodeGenSinhOp_f_exp0(_time);
     2146    _y_0 = JMI_SINH_EQUATION(jmi, _time, \"sinh(time)\") + func_CCodeGenTests_CCodeGenSinhOp_f_exp0(_time);
    19912147    JMI_DYNAMIC_FREE()
    19922148    return ef;
     
    19962152    JMI_DYNAMIC_INIT()
    19972153    JMI_DEF(REA, y_v)
    1998     y_v = jmi_sinh_function(\"CCodeGenTests.CCodeGenSinhOp.f\", x_v,\"sinh(x)\");
     2154    y_v = JMI_SINH_FUNCTION(\"CCodeGenTests.CCodeGenSinhOp.f\", x_v, \"sinh(x)\");
    19992155    JMI_RET(GEN, y_o, y_v)
    20002156    JMI_DYNAMIC_FREE()
     
    20192175    Real y = cosh(time) + f(time);
    20202176   
    2021     annotation(__JModelica(UnitTesting(tests={
    2022         CCodeGenTestCase(
    2023             name="CCodeGenCoshOp",
    2024             description="C code generation of cosh operator",
    2025             inline_functions="none",
    2026             template="
     2177annotation(__JModelica(UnitTesting(tests={
     2178    CCodeGenTestCase(
     2179        name="CCodeGenCoshOp",
     2180        description="C code generation of cosh operator",
     2181        inline_functions="none",
     2182        template="
    20272183$C_ode_derivatives$
    20282184$C_functions$
    20292185",
    2030             generatedCode="
     2186        generatedCode="
    20312187
    20322188int model_ode_derivatives_base(jmi_t* jmi) {
    20332189    int ef = 0;
    20342190    JMI_DYNAMIC_INIT()
    2035     _y_0 = jmi_cosh_equation(jmi, _time,\"cosh(time)\") + func_CCodeGenTests_CCodeGenCoshOp_f_exp0(_time);
     2191    _y_0 = JMI_COSH_EQUATION(jmi, _time, \"cosh(time)\") + func_CCodeGenTests_CCodeGenCoshOp_f_exp0(_time);
    20362192    JMI_DYNAMIC_FREE()
    20372193    return ef;
     
    20412197    JMI_DYNAMIC_INIT()
    20422198    JMI_DEF(REA, y_v)
    2043     y_v = jmi_cosh_function(\"CCodeGenTests.CCodeGenCoshOp.f\", x_v,\"cosh(x)\");
     2199    y_v = JMI_COSH_FUNCTION(\"CCodeGenTests.CCodeGenCoshOp.f\", x_v, \"cosh(x)\");
    20442200    JMI_RET(GEN, y_o, y_v)
    20452201    JMI_DYNAMIC_FREE()
     
    20642220    Real y = tan(time) + f(time);
    20652221   
    2066     annotation(__JModelica(UnitTesting(tests={
    2067         CCodeGenTestCase(
    2068             name="CCodeGenTanOp",
    2069             description="C code generation of tan operator",
    2070             inline_functions="none",
    2071             template="
     2222annotation(__JModelica(UnitTesting(tests={
     2223    CCodeGenTestCase(
     2224        name="CCodeGenTanOp",
     2225        description="C code generation of tan operator",
     2226        inline_functions="none",
     2227        template="
    20722228$C_ode_derivatives$
    20732229$C_functions$
    20742230",
    2075             generatedCode="
     2231        generatedCode="
    20762232
    20772233int model_ode_derivatives_base(jmi_t* jmi) {
    20782234    int ef = 0;
    20792235    JMI_DYNAMIC_INIT()
    2080     _y_0 = jmi_tan_equation(jmi, _time,\"tan(time)\") + func_CCodeGenTests_CCodeGenTanOp_f_exp0(_time);
     2236    _y_0 = JMI_TAN_EQUATION(jmi, _time, \"tan(time)\") + func_CCodeGenTests_CCodeGenTanOp_f_exp0(_time);
    20812237    JMI_DYNAMIC_FREE()
    20822238    return ef;
     
    20862242    JMI_DYNAMIC_INIT()
    20872243    JMI_DEF(REA, y_v)
    2088     y_v = jmi_tan_function(\"CCodeGenTests.CCodeGenTanOp.f\", x_v,\"tan(x)\");
     2244    y_v = JMI_TAN_FUNCTION(\"CCodeGenTests.CCodeGenTanOp.f\", x_v, \"tan(x)\");
    20892245    JMI_RET(GEN, y_o, y_v)
    20902246    JMI_DYNAMIC_FREE()
     
    21232279    int ef = 0;
    21242280    JMI_DYNAMIC_INIT()
    2125     _y_0 = jmi_atan2_equation(jmi, _time, _time + 1.0, \"atan2(time, time + 1)\") + func_CCodeGenTests_CCodeGenATan2Op_f_exp0(_time);
     2281    _y_0 = JMI_ATAN2_EQUATION(jmi, _time, _time + 1.0, \"atan2(time, time + 1)\") + func_CCodeGenTests_CCodeGenATan2Op_f_exp0(_time);
    21262282    JMI_DYNAMIC_FREE()
    21272283    return ef;
     
    21312287    JMI_DYNAMIC_INIT()
    21322288    JMI_DEF(REA, y_v)
    2133     y_v = jmi_atan2_function(\"CCodeGenTests.CCodeGenATan2Op.f\", x_v, x_v + 1.0, \"atan2(x, x + 1)\");
     2289    y_v = JMI_ATAN2_FUNCTION(\"CCodeGenTests.CCodeGenATan2Op.f\", x_v, x_v + 1.0, \"atan2(x, x + 1)\");
    21342290    JMI_RET(GEN, y_o, y_v)
    21352291    JMI_DYNAMIC_FREE()
     
    21672323    (*res)[2] = 3 - (_x_2_1_2);
    21682324    (*res)[3] = 4 - (_x_2_2_3);
    2169     (*res)[4] = jmi_min(jmi_min(_x_1_1_0, _x_1_2_1), jmi_min(_x_2_1_2, _x_2_2_3)) - (_y1_4);
    2170     (*res)[5] = jmi_min(1.0, 2.0) - (_y2_5);
    2171     (*res)[6] = jmi_max(jmi_max(_x_1_1_0, _x_1_2_1), jmi_max(_x_2_1_2, _x_2_2_3)) - (_y3_6);
    2172     (*res)[7] = jmi_max(1.0, 2.0) - (_y4_7);
     2325    (*res)[4] = JMI_MIN_EQUATION(JMI_MIN_EQUATION(_x_1_1_0, _x_1_2_1), JMI_MIN_EQUATION(_x_2_1_2, _x_2_2_3)) - (_y1_4);
     2326    (*res)[5] = JMI_MIN_EQUATION(1.0, 2.0) - (_y2_5);
     2327    (*res)[6] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(_x_1_1_0, _x_1_2_1), JMI_MAX_EQUATION(_x_2_1_2, _x_2_2_3)) - (_y3_6);
     2328    (*res)[7] = JMI_MAX_EQUATION(1.0, 2.0) - (_y4_7);
    21732329")})));
    21742330end CCodeGenMinMax;
     
    34693625    {a, b[1],b[2],c,b[3],d} = F({e, f[1], f[2], g, f[3], h});
    34703626   
    3471     annotation(__JModelica(UnitTesting(tests={
    3472         CCodeGenTestCase(
    3473             name="CFunctionTest23",
    3474             description="memcpy for parts of array (both of input and output)",
    3475             template="$C_ode_derivatives$",
    3476             generatedCode="
     3627annotation(__JModelica(UnitTesting(tests={
     3628    CCodeGenTestCase(
     3629        name="CFunctionTest23",
     3630        description="memcpy for parts of array (both of input and output)",
     3631        template="$C_ode_derivatives$",
     3632        generatedCode="
    34773633
    34783634int model_ode_derivatives_base(jmi_t* jmi) {
     
    34823638    JMI_ARR(STACK, jmi_real_t, jmi_array_t, tmp_2, 6, 1)
    34833639    _e_3 = _time;
    3484     _f_1_7 = sin(_time - 0.5);
    3485     _f_2_8 = sin(_time);
    3486     _g_10 = cos(_time);
    3487     _f_3_9 = sin(_time + 0.5);
    3488     _h_11 = - cos(_time);
     3640    _f_1_7 = JMI_SIN_EQUATION(jmi, _time - 0.5, \"sin(time - 0.5)\");
     3641    _f_2_8 = JMI_SIN_EQUATION(jmi, _time, \"sin(time)\");
     3642    _g_10 = JMI_COS_EQUATION(jmi, _time, \"cos(time)\");
     3643    _f_3_9 = JMI_SIN_EQUATION(jmi, _time + 0.5, \"sin(time + 0.5)\");
     3644    _h_11 = - JMI_COS_EQUATION(jmi, _time, \"cos(time)\");
    34893645    JMI_ARRAY_INIT_1(STACK, jmi_real_t, jmi_array_t, tmp_1, 6, 1, 6)
    34903646    JMI_ARRAY_INIT_1(STACK, jmi_real_t, jmi_array_t, tmp_2, 6, 1, 6)
     
    35903746        temp_2_v = temp_2_v + jmi_array_val_1(x_a, i1_2i);
    35913747    }
    3592     n_v = floor(jmi_divide_function(\"CCodeGenTests.FuncWithArray.g\", temp_1_v, temp_2_v, \"temp_1 / temp_2\"));
     3748    n_v = floor(JMI_DIVIDE_FUNCTION(\"CCodeGenTests.FuncWithArray.g\", temp_1_v, temp_2_v, \"temp_1 / temp_2\"));
    35933749    JMI_RET(GEN, n_o, n_v)
    35943750    JMI_DYNAMIC_FREE()
     
    39324088    int i_1ii;
    39334089    x_v = 0;
    3934     JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, temp_1_a, jmi_max(n_v, 0.0), 1, jmi_max(n_v, 0.0))
     4090    JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, temp_1_a, JMI_MAX_EQUATION(n_v, 0.0), 1, JMI_MAX_EQUATION(n_v, 0.0))
    39354091    i1_0in = 0;
    3936     i1_0ie = floor((jmi_max(n_v, 0.0)) - (1));
     4092    i1_0ie = floor((JMI_MAX_EQUATION(n_v, 0.0)) - (1));
    39374093    for (i1_0i = 1; i1_0in <= i1_0ie; i1_0i = 1 + (++i1_0in)) {
    39384094        jmi_array_ref_1(temp_1_a, i1_0i) = (1.0 * (i1_0i) * (i1_0i));
     
    44544610    jmi_int_t i1_2in;
    44554611    out_v = 1.0;
    4456     if (COND_EXP_EQ(jmi_max(floor(2.0 - (i_v + 1.0)) + 1.0, 0.0), 2.0, JMI_TRUE, JMI_FALSE) == JMI_FALSE) {
     4612    if (COND_EXP_EQ(JMI_MAX_EQUATION(floor(2.0 - (i_v + 1.0)) + 1.0, 0.0), 2.0, JMI_TRUE, JMI_FALSE) == JMI_FALSE) {
    44574613        jmi_assert_failed(\"Mismatching sizes in CCodeGenTests.CArrayInput6.f1\", JMI_ASSERT_ERROR);
    44584614    }
    4459     JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, temp_1_a, jmi_max(floor(2.0 - (i_v + 1.0)) + 1.0, 0.0), 1, jmi_max(floor(2.0 - (i_v + 1.0)) + 1.0, 0.0))
     4615    JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, temp_1_a, JMI_MAX_EQUATION(floor(2.0 - (i_v + 1.0)) + 1.0, 0.0), 1, JMI_MAX_EQUATION(floor(2.0 - (i_v + 1.0)) + 1.0, 0.0))
    44604616    i1_0in = 0;
    4461     i1_0ie = floor((jmi_max(floor(2.0 - (i_v + 1.0)) + 1.0, 0.0)) - (1));
     4617    i1_0ie = floor((JMI_MAX_EQUATION(floor(2.0 - (i_v + 1.0)) + 1.0, 0.0)) - (1));
    44624618    for (i1_0i = 1; i1_0in <= i1_0ie; i1_0i = 1 + (++i1_0in)) {
    44634619        jmi_array_ref_1(temp_1_a, i1_0i) = i_v + 1 + (i1_0i - 1);
    44644620    }
    44654621    if (COND_EXP_LT(func_CCodeGenTests_CArrayInput6_f2_exp1(temp_1_a), 4, JMI_TRUE, JMI_FALSE)) {
    4466         if (COND_EXP_EQ(jmi_max(floor(6.0 - (i_v + 5.0)) + 1.0, 0.0), 2.0, JMI_TRUE, JMI_FALSE) == JMI_FALSE) {
     4622        if (COND_EXP_EQ(JMI_MAX_EQUATION(floor(6.0 - (i_v + 5.0)) + 1.0, 0.0), 2.0, JMI_TRUE, JMI_FALSE) == JMI_FALSE) {
    44674623            jmi_assert_failed(\"Mismatching sizes in CCodeGenTests.CArrayInput6.f1\", JMI_ASSERT_ERROR);
    44684624        }
    4469         JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, temp_2_a, jmi_max(floor(6.0 - (i_v + 5.0)) + 1.0, 0.0), 1, jmi_max(floor(6.0 - (i_v + 5.0)) + 1.0, 0.0))
     4625        JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, temp_2_a, JMI_MAX_EQUATION(floor(6.0 - (i_v + 5.0)) + 1.0, 0.0), 1, JMI_MAX_EQUATION(floor(6.0 - (i_v + 5.0)) + 1.0, 0.0))
    44704626        i1_1in = 0;
    4471         i1_1ie = floor((jmi_max(floor(6.0 - (i_v + 5.0)) + 1.0, 0.0)) - (1));
     4627        i1_1ie = floor((JMI_MAX_EQUATION(floor(6.0 - (i_v + 5.0)) + 1.0, 0.0)) - (1));
    44724628        for (i1_1i = 1; i1_1in <= i1_1ie; i1_1i = 1 + (++i1_1in)) {
    44734629            jmi_array_ref_1(temp_2_a, i1_1i) = i_v + 5 + (i1_1i - 1);
     
    44754631        out_v = func_CCodeGenTests_CArrayInput6_f2_exp1(temp_2_a);
    44764632    } else {
    4477         if (COND_EXP_EQ(jmi_max(floor(8.0 - (i_v + 7.0)) + 1.0, 0.0), 2.0, JMI_TRUE, JMI_FALSE) == JMI_FALSE) {
     4633        if (COND_EXP_EQ(JMI_MAX_EQUATION(floor(8.0 - (i_v + 7.0)) + 1.0, 0.0), 2.0, JMI_TRUE, JMI_FALSE) == JMI_FALSE) {
    44784634            jmi_assert_failed(\"Mismatching sizes in CCodeGenTests.CArrayInput6.f1\", JMI_ASSERT_ERROR);
    44794635        }
    4480         JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, temp_3_a, jmi_max(floor(8.0 - (i_v + 7.0)) + 1.0, 0.0), 1, jmi_max(floor(8.0 - (i_v + 7.0)) + 1.0, 0.0))
     4636        JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, temp_3_a, JMI_MAX_EQUATION(floor(8.0 - (i_v + 7.0)) + 1.0, 0.0), 1, JMI_MAX_EQUATION(floor(8.0 - (i_v + 7.0)) + 1.0, 0.0))
    44814637        i1_2in = 0;
    4482         i1_2ie = floor((jmi_max(floor(8.0 - (i_v + 7.0)) + 1.0, 0.0)) - (1));
     4638        i1_2ie = floor((JMI_MAX_EQUATION(floor(8.0 - (i_v + 7.0)) + 1.0, 0.0)) - (1));
    44834639        for (i1_2i = 1; i1_2in <= i1_2ie; i1_2i = 1 + (++i1_2in)) {
    44844640            jmi_array_ref_1(temp_3_a, i1_2i) = i_v + 7 + (i1_2i - 1);
     
    51465302 Real y = -2;
    51475303
    5148     annotation(__JModelica(UnitTesting(tests={
    5149         CCodeGenTestCase(
    5150             name="CAbsTest1",
    5151             description="C code generation for abs() operator",
    5152             variability_propagation=false,
    5153             generate_ode=false,
    5154             generate_dae=true,
    5155             template="$C_DAE_equation_residuals$",
    5156             generatedCode="
    5157     (*res)[0] = jmi_abs(_y_1) - (_x_0);
     5304annotation(__JModelica(UnitTesting(tests={
     5305    CCodeGenTestCase(
     5306        name="CAbsTest1",
     5307        description="C code generation for abs() operator",
     5308        variability_propagation=false,
     5309        generate_ode=false,
     5310        generate_dae=true,
     5311        template="$C_DAE_equation_residuals$",
     5312        generatedCode="
     5313    (*res)[0] = JMI_ABS_EQUATION(_y_1) - (_x_0);
    51585314    (*res)[1] = -2 - (_y_1);
    51595315")})));
     
    57515907    i_0ie = floor((m_v) - (1));
    57525908    for (i_0i = 1; i_0in <= i_0ie; i_0i = 1 + (++i_0in)) {
    5753         JMI_ARRAY_INIT_1(HEAP, R1_1_r, R1_1_ra, temp_1_a, jmi_max(m_v, 0.0), 1, jmi_max(m_v, 0.0))
     5909        JMI_ARRAY_INIT_1(HEAP, R1_1_r, R1_1_ra, temp_1_a, JMI_MAX_EQUATION(m_v, 0.0), 1, JMI_MAX_EQUATION(m_v, 0.0))
    57545910        i1_1in = 0;
    5755         i1_1ie = floor((jmi_max(m_v, 0.0)) - (1));
     5911        i1_1ie = floor((JMI_MAX_EQUATION(m_v, 0.0)) - (1));
    57565912        for (i1_1i = 1; i1_1in <= i1_1ie; i1_1i = 1 + (++i1_1in)) {
    57575913            JMI_ARRAY_INIT_1(STACK, R2_0_r, R2_0_ra, temp_2_a, 1, 1, 1)
     
    57935949    return;
    57945950}
     5951
    57955952")})));
    57965953end CUnknownArray7;
     
    60676224    i_0ie = floor((jmi_array_size(x_a, 0)) - (1));
    60686225    for (i_0i = 1; i_0in <= i_0ie; i_0i = 1 + (++i_0in)) {
    6069         JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, temp_1_a, (jmi_array_size(x_a, 0) + jmi_max(i_0i, 0.0)), 1, jmi_array_size(x_a, 0) + jmi_max(i_0i, 0.0))
     6226        JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, temp_1_a, (jmi_array_size(x_a, 0) + JMI_MAX_EQUATION(i_0i, 0.0)), 1, jmi_array_size(x_a, 0) + JMI_MAX_EQUATION(i_0i, 0.0))
    60706227        i1_1in = 0;
    60716228        i1_1ie = floor((jmi_array_size(x_a, 0)) - (1));
     
    60746231        }
    60756232        i1_2in = 0;
    6076         i1_2ie = floor((jmi_max(i_0i, 0.0)) - (1));
     6233        i1_2ie = floor((JMI_MAX_EQUATION(i_0i, 0.0)) - (1));
    60776234        for (i1_2i = 1; i1_2in <= i1_2ie; i1_2i = 1 + (++i1_2in)) {
    60786235            jmi_array_ref_1(temp_1_a, i1_2i + jmi_array_size(x_a, 0)) = i1_2i;
     
    74177574        template="$C_DAE_equation_residuals$",
    74187575        generatedCode="
    7419     (*res)[0] = jmi_pow_equation(jmi, 10, 10, \"10 ^ 10\") - (_x_0);
     7576    (*res)[0] = JMI_POW_EQUATION(jmi, 10, 10, \"10 ^ 10\") - (_x_0);
    74207577")})));
    74217578end CIntegerExp4;
     
    74347591        template="$C_DAE_equation_residuals$",
    74357592        generatedCode="
    7436     (*res)[0] = jmi_pow_equation(jmi, 10, -10, \"10 ^ -10\") - (_x_0);
     7593    (*res)[0] = JMI_POW_EQUATION(jmi, 10, -10, \"10 ^ -10\") - (_x_0);
    74377594")})));
    74387595end CIntegerExp5;
     
    78107967        generatedCode="
    78117968    jmi_real_t nSamp;
    7812     if (SURELY_LT_ZERO(COND_EXP_EQ(LOG_EXP_NOT(_atInitial), JMI_TRUE, _time - (pre__sampleItr_1_4 * jmi_divide_equation(jmi, 2, 3, \"(2 / 3)\")), 1.0))) {
    7813         jmi_min_time_event(nextTimeEvent, 1, 0, pre__sampleItr_1_4 * jmi_divide_equation(jmi, 2, 3, \"(2 / 3)\"));
    7814     }
    7815     if (SURELY_LT_ZERO(_time - ((pre__sampleItr_1_4 + 1.0) * jmi_divide_equation(jmi, 2.0, 3.0, \"(2 / 3)\")))) {
    7816         jmi_min_time_event(nextTimeEvent, 1, 0, (pre__sampleItr_1_4 + 1.0) * jmi_divide_equation(jmi, 2.0, 3.0, \"(2 / 3)\"));
    7817     }
    7818     if (SURELY_LT_ZERO(COND_EXP_EQ(LOG_EXP_NOT(_atInitial), JMI_TRUE, _time - (pre__sampleItr_2_6 * jmi_divide_equation(jmi, 1, 3, \"(1 / 3)\")), 1.0))) {
    7819         jmi_min_time_event(nextTimeEvent, 1, 0, pre__sampleItr_2_6 * jmi_divide_equation(jmi, 1, 3, \"(1 / 3)\"));
    7820     }
    7821     if (SURELY_LT_ZERO(_time - ((pre__sampleItr_2_6 + 1.0) * jmi_divide_equation(jmi, 1.0, 3.0, \"(1 / 3)\")))) {
    7822         jmi_min_time_event(nextTimeEvent, 1, 0, (pre__sampleItr_2_6 + 1.0) * jmi_divide_equation(jmi, 1.0, 3.0, \"(1 / 3)\"));
     7969    if (SURELY_LT_ZERO(COND_EXP_EQ(LOG_EXP_NOT(_atInitial), JMI_TRUE, _time - (pre__sampleItr_1_4 * JMI_DIVIDE_EQUATION(jmi, 2, 3, \"(2 / 3)\")), 1.0))) {
     7970        jmi_min_time_event(nextTimeEvent, 1, 0, pre__sampleItr_1_4 * JMI_DIVIDE_EQUATION(jmi, 2, 3, \"(2 / 3)\"));
     7971    }
     7972    if (SURELY_LT_ZERO(_time - ((pre__sampleItr_1_4 + 1.0) * JMI_DIVIDE_EQUATION(jmi, 2.0, 3.0, \"(2 / 3)\")))) {
     7973        jmi_min_time_event(nextTimeEvent, 1, 0, (pre__sampleItr_1_4 + 1.0) * JMI_DIVIDE_EQUATION(jmi, 2.0, 3.0, \"(2 / 3)\"));
     7974    }
     7975    if (SURELY_LT_ZERO(COND_EXP_EQ(LOG_EXP_NOT(_atInitial), JMI_TRUE, _time - (pre__sampleItr_2_6 * JMI_DIVIDE_EQUATION(jmi, 1, 3, \"(1 / 3)\")), 1.0))) {
     7976        jmi_min_time_event(nextTimeEvent, 1, 0, pre__sampleItr_2_6 * JMI_DIVIDE_EQUATION(jmi, 1, 3, \"(1 / 3)\"));
     7977    }
     7978    if (SURELY_LT_ZERO(_time - ((pre__sampleItr_2_6 + 1.0) * JMI_DIVIDE_EQUATION(jmi, 1.0, 3.0, \"(1 / 3)\")))) {
     7979        jmi_min_time_event(nextTimeEvent, 1, 0, (pre__sampleItr_2_6 + 1.0) * JMI_DIVIDE_EQUATION(jmi, 1.0, 3.0, \"(1 / 3)\"));
    78237980    }
    78247981 
     
    78297986    _der_dummy_13 = 0;
    78307987    if (jmi->atInitial || jmi->atEvent) {
    7831         _sw(3) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_2_6 + 1.0) * jmi_divide_equation(jmi, 1.0, 3.0, \"(1 / 3)\")), _sw(3), JMI_REL_LT);
     7988        _sw(3) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_2_6 + 1.0) * JMI_DIVIDE_EQUATION(jmi, 1.0, 3.0, \"(1 / 3)\")), _sw(3), JMI_REL_LT);
    78327989    }
    78337990    if (jmi->atInitial || jmi->atEvent) {
    7834         _sw(2) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_2_6 * jmi_divide_equation(jmi, 1, 3, \"(1 / 3)\")), _sw(2), JMI_REL_GEQ);
     7991        _sw(2) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_2_6 * JMI_DIVIDE_EQUATION(jmi, 1, 3, \"(1 / 3)\")), _sw(2), JMI_REL_GEQ);
    78357992    }
    78367993    ef |= jmi_solve_block_residual(jmi->dae_block_residuals[0]);
    78377994    if (jmi->atInitial || jmi->atEvent) {
    7838         _sw(1) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_1_4 + 1.0) * jmi_divide_equation(jmi, 2.0, 3.0, \"(2 / 3)\")), _sw(1), JMI_REL_LT);
     7995        _sw(1) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_1_4 + 1.0) * JMI_DIVIDE_EQUATION(jmi, 2.0, 3.0, \"(2 / 3)\")), _sw(1), JMI_REL_LT);
    78397996    }
    78407997    if (jmi->atInitial || jmi->atEvent) {
    7841         _sw(0) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_1_4 * jmi_divide_equation(jmi, 2, 3, \"(2 / 3)\")), _sw(0), JMI_REL_GEQ);
     7998        _sw(0) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_1_4 * JMI_DIVIDE_EQUATION(jmi, 2, 3, \"(2 / 3)\")), _sw(0), JMI_REL_GEQ);
    78427999    }
    78438000    ef |= jmi_solve_block_residual(jmi->dae_block_residuals[1]);
     
    78548011        _sw_init(0) = jmi_turn_switch_time(jmi, _time - (0.0), _sw_init(0), JMI_REL_LT);
    78558012    }
    7856     __sampleItr_1_4 = COND_EXP_EQ(_sw_init(0), JMI_TRUE, 0.0, ceil(jmi_divide_equation(jmi, _time, jmi_divide_equation(jmi, 2.0, 3.0, \"(2 / 3)\"), \"time / (2 / 3)\")));
     8013    __sampleItr_1_4 = COND_EXP_EQ(_sw_init(0), JMI_TRUE, 0.0, ceil(JMI_DIVIDE_EQUATION(jmi, _time, JMI_DIVIDE_EQUATION(jmi, 2.0, 3.0, \"(2 / 3)\"), \"time / (2 / 3)\")));
    78578014    pre__sampleItr_1_4 = __sampleItr_1_4;
    78588015    if (jmi->atInitial || jmi->atEvent) {
    7859         _sw(0) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_1_4 * jmi_divide_equation(jmi, 2, 3, \"(2 / 3)\")), _sw(0), JMI_REL_GEQ);
     8016        _sw(0) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_1_4 * JMI_DIVIDE_EQUATION(jmi, 2, 3, \"(2 / 3)\")), _sw(0), JMI_REL_GEQ);
    78608017    }
    78618018    _temp_1_3 = LOG_EXP_AND(LOG_EXP_NOT(_atInitial), _sw(0));
    78628019    if (jmi->atInitial || jmi->atEvent) {
    7863         _sw(1) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_1_4 + 1.0) * jmi_divide_equation(jmi, 2.0, 3.0, \"(2 / 3)\")), _sw(1), JMI_REL_LT);
     8020        _sw(1) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_1_4 + 1.0) * JMI_DIVIDE_EQUATION(jmi, 2.0, 3.0, \"(2 / 3)\")), _sw(1), JMI_REL_LT);
    78648021    }
    78658022    if (_sw(1) == JMI_FALSE) {
     
    78698026        _sw_init(0) = jmi_turn_switch_time(jmi, _time - (0.0), _sw_init(0), JMI_REL_LT);
    78708027    }
    7871     __sampleItr_2_6 = COND_EXP_EQ(_sw_init(0), JMI_TRUE, 0.0, ceil(jmi_divide_equation(jmi, _time, jmi_divide_equation(jmi, 1.0, 3.0, \"(1 / 3)\"), \"time / (1 / 3)\")));
     8028    __sampleItr_2_6 = COND_EXP_EQ(_sw_init(0), JMI_TRUE, 0.0, ceil(JMI_DIVIDE_EQUATION(jmi, _time, JMI_DIVIDE_EQUATION(jmi, 1.0, 3.0, \"(1 / 3)\"), \"time / (1 / 3)\")));
    78728029    pre__sampleItr_2_6 = __sampleItr_2_6;
    78738030    if (jmi->atInitial || jmi->atEvent) {
    7874         _sw(2) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_2_6 * jmi_divide_equation(jmi, 1, 3, \"(1 / 3)\")), _sw(2), JMI_REL_GEQ);
     8031        _sw(2) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_2_6 * JMI_DIVIDE_EQUATION(jmi, 1, 3, \"(1 / 3)\")), _sw(2), JMI_REL_GEQ);
    78758032    }
    78768033    _temp_2_5 = LOG_EXP_AND(LOG_EXP_NOT(_atInitial), _sw(2));
    78778034    if (jmi->atInitial || jmi->atEvent) {
    7878         _sw(3) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_2_6 + 1.0) * jmi_divide_equation(jmi, 1.0, 3.0, \"(1 / 3)\")), _sw(3), JMI_REL_LT);
     8035        _sw(3) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_2_6 + 1.0) * JMI_DIVIDE_EQUATION(jmi, 1.0, 3.0, \"(1 / 3)\")), _sw(3), JMI_REL_LT);
    78798036    }
    78808037    if (_sw(3) == JMI_FALSE) {
     
    79108067        }
    79118068        if (evaluation_mode & JMI_BLOCK_EVALUATE_NON_REALS) {
    7912             _sw(3) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_2_6 + 1.0) * jmi_divide_equation(jmi, 1.0, 3.0, \"(1 / 3)\")), _sw(3), JMI_REL_LT);
     8069            _sw(3) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_2_6 + 1.0) * JMI_DIVIDE_EQUATION(jmi, 1.0, 3.0, \"(1 / 3)\")), _sw(3), JMI_REL_LT);
    79138070        }
    79148071        if (_sw(3) == JMI_FALSE) {
     
    79178074        if (evaluation_mode & JMI_BLOCK_EVALUATE_NON_REALS) {
    79188075            if (evaluation_mode & JMI_BLOCK_EVALUATE_NON_REALS) {
    7919                 _sw(2) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_2_6 * jmi_divide_equation(jmi, 1, 3, \"(1 / 3)\")), _sw(2), JMI_REL_GEQ);
     8076                _sw(2) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_2_6 * JMI_DIVIDE_EQUATION(jmi, 1, 3, \"(1 / 3)\")), _sw(2), JMI_REL_GEQ);
    79208077            }
    79218078            _temp_2_5 = LOG_EXP_AND(LOG_EXP_NOT(_atInitial), _sw(2));
     
    79508107        }
    79518108        if (evaluation_mode & JMI_BLOCK_EVALUATE_NON_REALS) {
    7952             _sw(1) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_1_4 + 1.0) * jmi_divide_equation(jmi, 2.0, 3.0, \"(2 / 3)\")), _sw(1), JMI_REL_LT);
     8109            _sw(1) = jmi_turn_switch_time(jmi, _time - ((pre__sampleItr_1_4 + 1.0) * JMI_DIVIDE_EQUATION(jmi, 2.0, 3.0, \"(2 / 3)\")), _sw(1), JMI_REL_LT);
    79538110        }
    79548111        if (_sw(1) == JMI_FALSE) {
     
    79578114        if (evaluation_mode & JMI_BLOCK_EVALUATE_NON_REALS) {
    79588115            if (evaluation_mode & JMI_BLOCK_EVALUATE_NON_REALS) {
    7959                 _sw(0) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_1_4 * jmi_divide_equation(jmi, 2, 3, \"(2 / 3)\")), _sw(0), JMI_REL_GEQ);
     8116                _sw(0) = jmi_turn_switch_time(jmi, _time - (pre__sampleItr_1_4 * JMI_DIVIDE_EQUATION(jmi, 2, 3, \"(2 / 3)\")), _sw(0), JMI_REL_GEQ);
    79608117            }
    79618118            _temp_1_3 = LOG_EXP_AND(LOG_EXP_NOT(_atInitial), _sw(0));
     
    80458202        _sw_init(0) = jmi_turn_switch_time(jmi, _time - (0.0), _sw_init(0), JMI_REL_LT);
    80468203    }
    8047     __sampleItr_1_12 = COND_EXP_EQ(_sw_init(0), JMI_TRUE, 0.0, ceil(jmi_divide_equation(jmi, _time, _h_11, \"time / h\")));
     8204    __sampleItr_1_12 = COND_EXP_EQ(_sw_init(0), JMI_TRUE, 0.0, ceil(JMI_DIVIDE_EQUATION(jmi, _time, _h_11, \"time / h\")));
    80488205    pre__sampleItr_1_12 = __sampleItr_1_12;
    80498206    if (jmi->atInitial || jmi->atEvent) {
     
    81188275    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    81198276        (*res)[0] = 1;
    8120         (*res)[1] = jmi_max(1.0, jmi_max(jmi_abs(_a_c_8), jmi_abs(_b_c_9)));
     8277        (*res)[1] = JMI_MAX_EQUATION(1.0, JMI_MAX_EQUATION(JMI_ABS_EQUATION(_a_c_8), JMI_ABS_EQUATION(_b_c_9)));
    81218278    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    81228279        x[0] = pre_x_c_3;
     
    82658422        _sw_init(0) = jmi_turn_switch_time(jmi, _time - (0.0), _sw_init(0), JMI_REL_LT);
    82668423    }
    8267     __sampleItr_1_13 = COND_EXP_EQ(_sw_init(0), JMI_TRUE, 0.0, ceil(jmi_divide_equation(jmi, _time, _h_11, \"time / h\")));
     8424    __sampleItr_1_13 = COND_EXP_EQ(_sw_init(0), JMI_TRUE, 0.0, ceil(JMI_DIVIDE_EQUATION(jmi, _time, _h_11, \"time / h\")));
    82688425    pre__sampleItr_1_13 = __sampleItr_1_13;
    82698426    if (jmi->atInitial || jmi->atEvent) {
     
    85258682        }
    85268683        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    8527             (*res)[0] = COND_EXP_EQ(LOG_EXP_AND(_temp_1_6, LOG_EXP_NOT(pre_temp_1_6)), JMI_TRUE, sin(_x_0) + 3.0, pre_x_0) - (_x_0);
     8684            (*res)[0] = COND_EXP_EQ(LOG_EXP_AND(_temp_1_6, LOG_EXP_NOT(pre_temp_1_6)), JMI_TRUE, JMI_SIN_EQUATION(jmi, _x_0, \"sin(x)\") + 3.0, pre_x_0) - (_x_0);
    85288685        }
    85298686    }
     
    92149371    JMI_DEF(REA, tmp_6)
    92159372    if (_sw(0)) {
    9216         func_CCodeGenTests_dummyFunc_def0(jmi_divide_equation(jmi, _time * _time * _time, 2.0, \"time * time * time / 2\"), &tmp_1, &tmp_2);
     9373        func_CCodeGenTests_dummyFunc_def0(JMI_DIVIDE_EQUATION(jmi, _time * _time * _time, 2.0, \"time * time * time / 2\"), &tmp_1, &tmp_2);
    92179374        _x_0 = (tmp_1);
    92189375        _y_1 = (tmp_2);
     
    989310050        }
    989410051        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    9895             (*res)[0] = _z1_2 + 2 - (sin(_z1_2) * 3);
     10052            (*res)[0] = _z1_2 + 2 - (JMI_SIN_EQUATION(jmi, _z1_2, \"sin(z1)\") * 3);
    989610053        }
    989710054    }
     
    991710074        }
    991810075        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    9919             (*res)[0] = _z1_2 + 2 - (sin(_z1_2) * 3);
     10076            (*res)[0] = _z1_2 + 2 - (JMI_SIN_EQUATION(jmi, _z1_2, \"sin(z1)\") * 3);
    992010077        }
    992110078    }
     
    1005910216        (*res)[0] = 1;
    1006010217        (*res)[1] = 1;
    10061         (*res)[2] = jmi_max(1.0, jmi_max(jmi_max(jmi_abs(_f0_1), jmi_abs(_f1_2)), jmi_max(jmi_max(jmi_abs(_f0_1), jmi_abs(_f1_2)), jmi_abs(_f0_1))));
    10062         (*res)[3] = jmi_max(jmi_abs(_m_0), jmi_max(1.0, 1.0));
     10218        (*res)[2] = JMI_MAX_EQUATION(1.0, JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_ABS_EQUATION(_f0_1), JMI_ABS_EQUATION(_f1_2)), JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_ABS_EQUATION(_f0_1), JMI_ABS_EQUATION(_f1_2)), JMI_ABS_EQUATION(_f0_1))));
     10219        (*res)[3] = JMI_MAX_EQUATION(JMI_ABS_EQUATION(_m_0), JMI_MAX_EQUATION(1.0, 1.0));
    1006310220    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1006410221        x[0] = _a_4;
     
    1014110298        (*res)[0] = 1;
    1014210299        (*res)[1] = 1;
    10143         (*res)[2] = jmi_max(1.0, jmi_max(jmi_max(jmi_abs(_f0_1), jmi_abs(_f1_2)), jmi_max(jmi_max(jmi_abs(_f0_1), jmi_abs(_f1_2)), jmi_abs(_f0_1))));
    10144         (*res)[3] = jmi_max(jmi_abs(_m_0), jmi_max(1.0, 1.0));
     10300        (*res)[2] = JMI_MAX_EQUATION(1.0, JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_ABS_EQUATION(_f0_1), JMI_ABS_EQUATION(_f1_2)), JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_ABS_EQUATION(_f0_1), JMI_ABS_EQUATION(_f1_2)), JMI_ABS_EQUATION(_f0_1))));
     10301        (*res)[3] = JMI_MAX_EQUATION(JMI_ABS_EQUATION(_m_0), JMI_MAX_EQUATION(1.0, 1.0));
    1014510302    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1014610303        x[0] = _a_4;
     
    1019410351    JMI_DYNAMIC_INIT()
    1019510352    _der_dummy_15 = 1;
    10196     _u_6 = 2 * sin(_time);
     10353    _u_6 = 2 * JMI_SIN_EQUATION(jmi, _time, \"sin(time)\");
    1019710354    if (jmi->atInitial || jmi->atEvent) {
    1019810355        _sw(2) = jmi_turn_switch(jmi, _v_3 - (0.0), _sw(2), JMI_REL_GT);
     
    1021110368    JMI_DYNAMIC_INIT()
    1021210369    _der_dummy_15 = 1;
    10213     _u_6 = 2 * sin(_time);
     10370    _u_6 = 2 * JMI_SIN_EQUATION(jmi, _time, \"sin(time)\");
    1021410371    pre_mode_10 = 2;
    1021510372    _v_3 = 0.0;
     
    1056610723        x[1] = 7;
    1056710724    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    10568         (*res)[0] = jmi_max(jmi_max(jmi_abs(_p_12) * jmi_abs(_A_2_1_2), jmi_abs(_p_12) * jmi_abs(_A_2_2_3)), 1.0);
    10569         (*res)[1] = jmi_max(jmi_max(jmi_abs(_p_12) * jmi_abs(_A_1_1_0), jmi_abs(_p_12) * jmi_abs(_A_1_2_1)), 1.0);
     10725        (*res)[0] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_ABS_EQUATION(_p_12) * JMI_ABS_EQUATION(_A_2_1_2), JMI_ABS_EQUATION(_p_12) * JMI_ABS_EQUATION(_A_2_2_3)), 1.0);
     10726        (*res)[1] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_ABS_EQUATION(_p_12) * JMI_ABS_EQUATION(_A_1_1_0), JMI_ABS_EQUATION(_p_12) * JMI_ABS_EQUATION(_A_1_2_1)), 1.0);
    1057010727    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1057110728        x[0] = _y_2_7;
     
    1063010787        x[1] = 9;
    1063110788    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    10632         (*res)[0] = jmi_max(jmi_max(jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_2_1_2), jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_2_2_3)), jmi_max(1.0, jmi_abs(2.0)));
    10633         (*res)[1] = jmi_max(jmi_max(jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_1_1_0), jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_1_2_1)), jmi_max(1.0, jmi_abs(2.0)));
     10789        (*res)[0] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_2_1_2), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_2_2_3)), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(2.0)));
     10790        (*res)[1] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_1_1_0), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_1_2_1)), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(2.0)));
    1063410791    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1063510792        x[0] = _z_2_9;
     
    1066410821        x[1] = 11;
    1066510822    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    10666         (*res)[0] = jmi_max(jmi_max(jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_2_1_2), jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_2_2_3)), jmi_max(1.0, jmi_abs(3.0)));
    10667         (*res)[1] = jmi_max(jmi_max(jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_1_1_0), jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_1_2_1)), jmi_max(1.0, jmi_abs(3.0)));
     10823        (*res)[0] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_2_1_2), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_2_2_3)), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(3.0)));
     10824        (*res)[1] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_1_1_0), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_1_2_1)), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(3.0)));
    1066810825    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1066910826        x[0] = _w_2_11;
     
    1073310890        x[1] = 7;
    1073410891    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    10735         (*res)[0] = jmi_max(jmi_max(jmi_abs(_p_12) * jmi_abs(_A_2_1_2), jmi_abs(_p_12) * jmi_abs(_A_2_2_3)), 1.0);
    10736         (*res)[1] = jmi_max(jmi_max(jmi_abs(_p_12) * jmi_abs(_A_1_1_0), jmi_abs(_p_12) * jmi_abs(_A_1_2_1)), 1.0);
     10892        (*res)[0] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_ABS_EQUATION(_p_12) * JMI_ABS_EQUATION(_A_2_1_2), JMI_ABS_EQUATION(_p_12) * JMI_ABS_EQUATION(_A_2_2_3)), 1.0);
     10893        (*res)[1] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_ABS_EQUATION(_p_12) * JMI_ABS_EQUATION(_A_1_1_0), JMI_ABS_EQUATION(_p_12) * JMI_ABS_EQUATION(_A_1_2_1)), 1.0);
    1073710894    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1073810895        x[0] = _y_2_7;
     
    1076710924        x[1] = 9;
    1076810925    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    10769         (*res)[0] = jmi_max(jmi_max(jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_2_1_2), jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_2_2_3)), jmi_max(1.0, jmi_abs(2.0)));
    10770         (*res)[1] = jmi_max(jmi_max(jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_1_1_0), jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_1_2_1)), jmi_max(1.0, jmi_abs(2.0)));
     10926        (*res)[0] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_2_1_2), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_2_2_3)), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(2.0)));
     10927        (*res)[1] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_1_1_0), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_1_2_1)), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(2.0)));
    1077110928    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1077210929        x[0] = _z_2_9;
     
    1080110958        x[1] = 11;
    1080210959    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    10803         (*res)[0] = jmi_max(jmi_max(jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_2_1_2), jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_2_2_3)), jmi_max(1.0, jmi_abs(3.0)));
    10804         (*res)[1] = jmi_max(jmi_max(jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_1_1_0), jmi_max(1.0, jmi_abs(1.0)) * jmi_abs(_A_1_2_1)), jmi_max(1.0, jmi_abs(3.0)));
     10960        (*res)[0] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_2_1_2), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_2_2_3)), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(3.0)));
     10961        (*res)[1] = JMI_MAX_EQUATION(JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_1_1_0), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(1.0)) * JMI_ABS_EQUATION(_A_1_2_1)), JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(3.0)));
    1080510962    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1080610963        x[0] = _w_2_11;
     
    1089611053        }
    1089711054        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    10898             (*res)[0] = sin(_b_1) * COND_EXP_EQ(_d_2, JMI_TRUE, 1.0, 2.0) - (_a_0);
     11055            (*res)[0] = JMI_SIN_EQUATION(jmi, _b_1, \"sin(b)\") * COND_EXP_EQ(_d_2, JMI_TRUE, 1.0, 2.0) - (_a_0);
    1089911056            (*res)[1] = 1 - _b_1 - (_a_0);
    1090011057        }
     
    1093711094        }
    1093811095        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    10939             (*res)[0] = sin(_b_1) * COND_EXP_EQ(_d_2, JMI_TRUE, 1.0, 2.0) - (_a_0);
     11096            (*res)[0] = JMI_SIN_EQUATION(jmi, _b_1, \"sin(b)\") * COND_EXP_EQ(_d_2, JMI_TRUE, 1.0, 2.0) - (_a_0);
    1094011097            (*res)[1] = 1 - _b_1 - (_a_0);
    1094111098        }
     
    1196812125        JMI_RECORD_STATIC(R_0_r, tmp_2)
    1196912126        tmp_2->y = _p_y_0;
    11970         (*res)[0] = jmi_max(jmi_abs(func_CCodeGenTests_BlockTest22_f_exp0(tmp_2)), 1.0);
     12127        (*res)[0] = JMI_MAX_EQUATION(JMI_ABS_EQUATION(func_CCodeGenTests_BlockTest22_f_exp0(tmp_2)), 1.0);
    1197112128    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1197212129        x[0] = _x_1;
     
    1207012227        name="BlockTest25",
    1207112228        description="Nominal with global constant in record",
     12229        variability_propagation=false,
    1207212230        template="$C_dae_blocks_residual_functions$",
    12073         variability_propagation=false,
    1207412231        generatedCode="
    1207512232static int dae_block_0(jmi_t* jmi, jmi_real_t* x, jmi_real_t* residual, int evaluation_mode) {
     
    1208112238        x[0] = 1;
    1208212239    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    12083         (*res)[0] = jmi_max(1.0, jmi_max(jmi_abs(jmi_array_rec_1(JMI_GLOBAL(CCodeGenTests_BlockTest25_f_p), _i_0)->y), 1.0));
     12240        (*res)[0] = JMI_MAX_EQUATION(1.0, JMI_MAX_EQUATION(JMI_ABS_EQUATION(jmi_array_rec_1(JMI_GLOBAL(CCodeGenTests_BlockTest25_f_p), _i_0)->y), 1.0));
    1208412241    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1208512242        x[0] = _x_1;
     
    1209512252    return ef;
    1209612253}
     12254
    1209712255")})));
    1209812256end BlockTest25;
     
    1213412292        }
    1213512293        if (evaluation_mode & JMI_BLOCK_EVALUATE) {
    12136             (*res)[0] = asin(_b_1) - (_a_0);
     12294            (*res)[0] = JMI_ASIN_EQUATION(jmi, _b_1, \"asin(b)\") - (_a_0);
    1213712295        }
    1213812296    }
     
    1285613014        x[2] = 7;
    1285713015    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    12858         (*res)[0] = jmi_max(1.0, jmi_abs(_R3_10));
    12859         (*res)[1] = jmi_max(1.0, jmi_abs(_R2_9));
     13016        (*res)[0] = JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(_R3_10));
     13017        (*res)[1] = JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(_R2_9));
    1286013018    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1286113019        x[0] = _i2_5;
     
    1297613134        x[1] = jmi->offs_sw + 1;
    1297713135    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    12978         (*res)[0] = jmi_max(jmi_abs(_m_0), jmi_max(1.0, 1.0));
     13136        (*res)[0] = JMI_MAX_EQUATION(JMI_ABS_EQUATION(_m_0), JMI_MAX_EQUATION(1.0, 1.0));
    1297913137    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1298013138        x[0] = _sa_7;
     
    1306313221        x[1] = jmi->offs_sw + 0;
    1306413222    } else if (evaluation_mode == JMI_BLOCK_EQUATION_NOMINAL_AUTO) {
    13065         (*res)[0] = jmi_max(jmi_abs(_m_0), jmi_max(1.0, 1.0));
     13223        (*res)[0] = JMI_MAX_EQUATION(JMI_ABS_EQUATION(_m_0), JMI_MAX_EQUATION(1.0, 1.0));
    1306613224    } else if (evaluation_mode == JMI_BLOCK_INITIALIZE) {
    1306713225        x[0] = _sa_7;
     
    1370113859        }
    1370213860    }
    13703     lda_v = jmi_max(1.0, jmi_array_size(A_a, 0));
    13704     ldb_v = jmi_max(1.0, jmi_array_size(b_a, 0));
     13861    lda_v = JMI_MAX_EQUATION(1.0, jmi_array_size(A_a, 0));
     13862    ldb_v = JMI_MAX_EQUATION(1.0, jmi_array_size(b_a, 0));
    1370513863    JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, ipiv_a, jmi_array_size(A_a, 0), 1, jmi_array_size(A_a, 0))
    1370613864    tmp_1 = (int)1;
     
    1381013968        }
    1381113969    }
    13812     lda_v = jmi_max(1.0, jmi_array_size(A_a, 0));
    13813     ldb_v = jmi_max(1.0, jmi_array_size(B_a, 0));
     13970    lda_v = JMI_MAX_EQUATION(1.0, jmi_array_size(A_a, 0));
     13971    ldb_v = JMI_MAX_EQUATION(1.0, jmi_array_size(B_a, 0));
    1381413972    JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, ipiv_a, jmi_array_size(A_a, 0), 1, jmi_array_size(A_a, 0))
    1381513973    JMI_ARRAY_INIT_2(HEAP, jmi_real_t, jmi_array_t, tmp_1, jmi_array_size(Awork_a, 0) * jmi_array_size(Awork_a, 1), 2, jmi_array_size(Awork_a, 0), jmi_array_size(Awork_a, 1))
     
    1438614544    }
    1438714545    if (jmi->atInitial || jmi->atEvent) {
    14388         _sw(0) = jmi_turn_switch(jmi, jmi_divide_equation(jmi, (pre_j_17 + 1.0), 4.0, \"(pre(j) + 1) / 4\") - (pre_temp_2_20), _sw(0), JMI_REL_LT);
     14546        _sw(0) = jmi_turn_switch(jmi, JMI_DIVIDE_EQUATION(jmi, (pre_j_17 + 1.0), 4.0, \"(pre(j) + 1) / 4\") - (pre_temp_2_20), _sw(0), JMI_REL_LT);
    1438914547    }
    1439014548    if (jmi->atInitial || jmi->atEvent) {
    14391         _sw(1) = jmi_turn_switch(jmi, jmi_divide_equation(jmi, (pre_j_17 + 1.0), 4.0, \"(pre(j) + 1) / 4\") - (pre_temp_2_20 + 1.0), _sw(1), JMI_REL_GEQ);
     14549        _sw(1) = jmi_turn_switch(jmi, JMI_DIVIDE_EQUATION(jmi, (pre_j_17 + 1.0), 4.0, \"(pre(j) + 1) / 4\") - (pre_temp_2_20 + 1.0), _sw(1), JMI_REL_GEQ);
    1439214550    }
    1439314551    ef |= jmi_solve_block_residual(jmi->dae_block_residuals[0]);
     
    1443514593    }
    1443614594    if (jmi->atInitial || jmi->atEvent) {
    14437         _sw(0) = jmi_turn_switch(jmi, jmi_divide_equation(jmi, (pre_j_16 + 1.0), 4.0, \"(pre(j) + 1) / 4\") - (pre_temp_2_20), _sw(0), JMI_REL_LT);
     14595        _sw(0) = jmi_turn_switch(jmi, JMI_DIVIDE_EQUATION(jmi, (pre_j_16 + 1.0), 4.0, \"(pre(j) + 1) / 4\") - (pre_temp_2_20), _sw(0), JMI_REL_LT);
    1443814596    }
    1443914597    if (jmi->atInitial || jmi->atEvent) {
    14440         _sw(1) = jmi_turn_switch(jmi, jmi_divide_equation(jmi, (pre_j_16 + 1.0), 4.0, \"(pre(j) + 1) / 4\") - (pre_temp_2_20 + 1.0), _sw(1), JMI_REL_GEQ);
     14598        _sw(1) = jmi_turn_switch(jmi, JMI_DIVIDE_EQUATION(jmi, (pre_j_16 + 1.0), 4.0, \"(pre(j) + 1) / 4\") - (pre_temp_2_20 + 1.0), _sw(1), JMI_REL_GEQ);
    1444114599    }
    1444214600    ef |= jmi_solve_block_residual(jmi->dae_block_residuals[0]);
     
    1513115289        jmi_array_ref_1(tmp_1, 1) = 0.1;
    1513215290        jmi_array_ref_1(tmp_1, 2) = 0.5;
    15133         _sw(0) = jmi_turn_switch(jmi, (_time + _p_0 - (_x_1)) / jmi_max(jmi_max(1.0, jmi_abs(_p_0)), jmi_abs(func_CCodeGenTests_TestRelationalOp10_f_exp0(tmp_1))), _sw(0), JMI_REL_GT);
     15291        _sw(0) = jmi_turn_switch(jmi, (_time + _p_0 - (_x_1)) / JMI_MAX_EQUATION(JMI_MAX_EQUATION(1.0, JMI_ABS_EQUATION(_p_0)), JMI_ABS_EQUATION(func_CCodeGenTests_TestRelationalOp10_f_exp0(tmp_1))), _sw(0), JMI_REL_GT);
    1513415292    }
    1513515293    _b1_2 = _sw(0);
     
    1528815446    b = cos(time);
    1528915447   
    15290     annotation(__JModelica(UnitTesting(tests={
    15291         CCodeGenTestCase(
    15292             name="TestRelationalOp14",
    15293             description="Test inline bug which caused exception during code gen (related to switch index)",
    15294             template="
     15448annotation(__JModelica(UnitTesting(tests={
     15449    CCodeGenTestCase(
     15450        name="TestRelationalOp14",
     15451        description="Test inline bug which caused exception during code gen (related to switch index)",
     15452        template="
    1529515453$C_ode_time_events$
    1529615454$C_ode_derivatives$
    1529715455",
    15298             generatedCode="
    15299 
     15456        generatedCode="
    1530015457    jmi_real_t nSamp;
    1530115458
    1530215459
    15303 
    15304 
    1530515460int model_ode_derivatives_base(jmi_t* jmi) {
    1530615461    int ef = 0;
    1530715462    JMI_DYNAMIC_INIT()
    15308     _b_1 = cos(_time);
     15463    _b_1 = JMI_COS_EQUATION(jmi, _time, \"cos(time)\");
    1530915464    if (jmi->atInitial || jmi->atEvent) {
    1531015465        _sw(0) = jmi_turn_switch(jmi, _b_1 - (0.0), _sw(0), JMI_REL_GT);
     
    1532815483    Real c = if b > 0.0 then b else -b;
    1532915484   
    15330     annotation(__JModelica(UnitTesting(tests={
    15331         CCodeGenTestCase(
    15332             name="TestRelationalOp14B",
    15333             description="Test inline bug which caused exception during code gen (related to switch index)",
    15334             template="
     15485annotation(__JModelica(UnitTesting(tests={
     15486    CCodeGenTestCase(
     15487        name="TestRelationalOp14B",
     15488        description="Test inline bug which caused exception during code gen (related to switch index)",
     15489        template="
    1533515490$C_ode_time_events$
    1533615491$C_ode_derivatives$
    1533715492",
    15338             generatedCode="
     15493        generatedCode="
    1533915494    jmi_real_t nSamp;
    1534015495
     
    1534315498    int ef = 0;
    1534415499    JMI_DYNAMIC_INIT()
    15345     _b_1 = cos(_time);
     15500    _b_1 = JMI_COS_EQUATION(jmi, _time, \"cos(time)\");
    1534615501    if (jmi->atInitial || jmi->atEvent) {
    1534715502        _sw(0) = jmi_turn_switch(jmi, _b_1 - (0.0), _sw(0), JMI_REL_GT);
     
    1537815533    JMI_DYNAMIC_INIT()
    1537915534    if (jmi->atInitial || jmi->atEvent) {
    15380         _sw(0) = jmi_turn_switch(jmi, sin(_time) - (0.0), _sw(0), JMI_REL_GT);
     15535        _sw(0) = jmi_turn_switch(jmi, JMI_SIN_EQUATION(jmi, _time, \"sin(time)\") - (0.0), _sw(0), JMI_REL_GT);
    1538115536    }
    1538215537    if (jmi->atInitial || jmi->atEvent) {
    15383         _sw(1) = jmi_turn_switch(jmi, cos(_time) - (0.0), _sw(1), JMI_REL_GT);
     15538        _sw(1) = jmi_turn_switch(jmi, JMI_COS_EQUATION(jmi, _time, \"cos(time)\") - (0.0), _sw(1), JMI_REL_GT);
    1538415539    }
    1538515540    _a_0 = COND_EXP_EQ(LOG_EXP_AND(_sw(0), _sw(1)), JMI_TRUE, 1.0, _time);
    1538615541    if (jmi->atInitial || jmi->atEvent) {
    15387         _sw(0) = jmi_turn_switch(jmi, sin(_time) - (0.0), _sw(0), JMI_REL_GT);
     15542        _sw(0) = jmi_turn_switch(jmi, JMI_SIN_EQUATION(jmi, _time, \"sin(time)\") - (0.0), _sw(0), JMI_REL_GT);
    1538815543    }
    1538915544    if (jmi->atInitial || jmi->atEvent) {
    15390         _sw(2) = jmi_turn_switch(jmi, cos(_time) - (0.0), _sw(2), JMI_REL_GT);
     15545        _sw(2) = jmi_turn_switch(jmi, JMI_COS_EQUATION(jmi, _time, \"cos(time)\") - (0.0), _sw(2), JMI_REL_GT);
    1539115546    }
    1539215547    _b_1 = COND_EXP_EQ(LOG_EXP_AND(_sw(0), _sw(2)), JMI_TRUE, _time, 1.0);
     
    1539715552    int ef = 0;
    1539815553    JMI_DYNAMIC_INIT()
    15399     (*res)[0] = sin(_time) - (0.0);
    15400     (*res)[1] = COND_EXP_EQ(_sw(0), JMI_TRUE, cos(_time) - (0.0), 1.0);
    15401     (*res)[2] = COND_EXP_EQ(_sw(0), JMI_TRUE, cos(_time) - (0.0), 1.0);
     15554    (*res)[0] = JMI_SIN_EQUATION(jmi, _time, \"sin(time)\") - (0.0);
     15555    (*res)[1] = COND_EXP_EQ(_sw(0), JMI_TRUE, JMI_COS_EQUATION(jmi, _time, \"cos(time)\") - (0.0), 1.0);
     15556    (*res)[2] = COND_EXP_EQ(_sw(0), JMI_TRUE, JMI_COS_EQUATION(jmi, _time, \"cos(time)\") - (0.0), 1.0);
    1540215557    JMI_DYNAMIC_FREE()
    1540315558    return ef;
     
    1542515580    JMI_DYNAMIC_INIT()
    1542615581    if (jmi->atInitial || jmi->atEvent) {
    15427         _sw(0) = jmi_turn_switch(jmi, sin(_time) - (0.0), _sw(0), JMI_REL_GT);
     15582        _sw(0) = jmi_turn_switch(jmi, JMI_SIN_EQUATION(jmi, _time, \"sin(time)\") - (0.0), _sw(0), JMI_REL_GT);
    1542815583    }
    1542915584    if (jmi->atInitial || jmi->atEvent) {
    15430         _sw(1) = jmi_turn_switch(jmi, cos(_time) - (0.0), _sw(1), JMI_REL_GT);
     15585        _sw(1) = jmi_turn_switch(jmi, JMI_COS_EQUATION(jmi, _time, \"cos(time)\") - (0.0), _sw(1), JMI_REL_GT);
    1543115586    }
    1543215587    if (jmi->atInitial || jmi->atEvent) {
    15433         _sw(2) = jmi_turn_switch(jmi, cos(_time + 0.5) - (0.0), _sw(2), JMI_REL_GT);
     15588        _sw(2) = jmi_turn_switch(jmi, JMI_COS_EQUATION(jmi, _time + 0.5, \"cos(time + 0.5)\") - (0.0), _sw(2), JMI_REL_GT);
    1543415589    }
    1543515590    _a_0 = COND_EXP_EQ(LOG_EXP_AND(LOG_EXP_AND(_sw(0), _sw(1)), _sw(2)), JMI_TRUE, 1.0, _time);
    1543615591    if (jmi->atInitial || jmi->atEvent) {
    15437         _sw(0) = jmi_turn_switch(jmi, sin(_time) - (0.0), _sw(0), JMI_REL_GT);
     15592        _sw(0) = jmi_turn_switch(jmi, JMI_SIN_EQUATION(jmi, _time, \"sin(time)\") - (0.0), _sw(0), JMI_REL_GT);
    1543815593    }
    1543915594    if (jmi->atInitial || jmi->atEvent) {
    15440         _sw(3) = jmi_turn_switch(jmi, cos(_time) - (0.0), _sw(3), JMI_REL_GT);
     15595        _sw(3) = jmi_turn_switch(jmi, JMI_COS_EQUATION(jmi, _time, \"cos(time)\") - (0.0), _sw(3), JMI_REL_GT);
    1544115596    }
    1544215597    if (jmi->atInitial || jmi->atEvent) {
    15443         _sw(4) = jmi_turn_switch(jmi, cos(_time + 0.5) - (0.0), _sw(4), JMI_REL_GT);
     15598        _sw(4) = jmi_turn_switch(jmi, JMI_COS_EQUATION(jmi, _time + 0.5, \"cos(time + 0.5)\") - (0.0), _sw(4), JMI_REL_GT);
    1544415599    }
    1544515600    _b_1 = COND_EXP_EQ(LOG_EXP_AND(LOG_EXP_AND(_sw(0), _sw(3)), _sw(4)), JMI_TRUE, _time, 1.0);
     
    1545015605    int ef = 0;
    1545115606    JMI_DYNAMIC_INIT()
    15452     (*res)[0] = sin(_time) - (0.0);
    15453     (*res)[1] = COND_EXP_EQ(_sw(0), JMI_TRUE, cos(_time) - (0.0), 1.0);
    15454     (*res)[2] = COND_EXP_EQ(LOG_EXP_AND(_sw(0), _sw(1)), JMI_TRUE, cos(_time + 0.5) - (0.0), 1.0);
    15455     (*res)[3] = COND_EXP_EQ(_sw(0), JMI_TRUE, cos(_time) - (0.0), 1.0);
    15456     (*res)[4] = COND_EXP_EQ(LOG_EXP_AND(_sw(0), _sw(3)), JMI_TRUE, cos(_time + 0.5) - (0.0), 1.0);
     15607    (*res)[0] = JMI_SIN_EQUATION(jmi, _time, \"sin(time)\") - (0.0);
     15608    (*res)[1] = COND_EXP_EQ(_sw(0), JMI_TRUE, JMI_COS_EQUATION(jmi, _time, \"cos(time)\") - (0.0), 1.0);
     15609    (*res)[2] = COND_EXP_EQ(LOG_EXP_AND(_sw(0), _sw(1)), JMI_TRUE, JMI_COS_EQUATION(jmi, _time + 0.5, \"cos(time + 0.5)\") - (0.0), 1.0);
     15610    (*res)[3] = COND_EXP_EQ(_sw(0), JMI_TRUE, JMI_COS_EQUATION(jmi, _time, \"cos(time)\") - (0.0), 1.0);
     15611    (*res)[4] = COND_EXP_EQ(LOG_EXP_AND(_sw(0), _sw(3)), JMI_TRUE, JMI_COS_EQUATION(jmi, _time + 0.5, \"cos(time + 0.5)\") - (0.0), 1.0);
    1545715612    JMI_DYNAMIC_FREE()
    1545815613    return ef;
     
    1547115626    end when;
    1547215627
    15473     annotation(__JModelica(UnitTesting(tests={
    15474         CCodeGenTestCase(
    15475             name="TestRelationalOp17",
    15476             description="Ensure that switches in DAE isn't eliminated for switch in initDAE'",
    15477             template="
     15628annotation(__JModelica(UnitTesting(tests={
     15629    CCodeGenTestCase(
     15630        name="TestRelationalOp17",
     15631        description="Ensure that switches in DAE isn't eliminated for switch in initDAE'",
     15632        template="
    1547815633$C_ode_derivatives$
    1547915634$C_DAE_event_indicator_residuals$
    1548015635$C_DAE_initial_event_indicator_residuals$
    1548115636",
    15482             generatedCode="
     15637        generatedCode="
     15638
    1548315639int model_ode_derivatives_base(jmi_t* jmi) {
    1548415640    int ef = 0;
    1548515641    JMI_DYNAMIC_INIT()
    15486     _x_0 = sin(_time);
     15642    _x_0 = JMI_SIN_EQUATION(jmi, _time, \"sin(time)\");
    1548715643    if (jmi->atInitial || jmi->atEvent) {
    1548815644        _sw(1) = jmi_turn_switch(jmi, _x_0 - (-0.5), _sw(1), JMI_REL_LT);
     
    1620516361    JMI_ARRAY_INIT_1(HEAP, jmi_string_t, jmi_string_array_t, s_a, n_v, 1, n_v)
    1620616362    y_v = x_v;
    16207     JMI_ARRAY_INIT_1(HEAP, jmi_string_t, jmi_string_array_t, temp_1_a, jmi_max(n_v, 0.0), 1, jmi_max(n_v, 0.0))
     16363    JMI_ARRAY_INIT_1(HEAP, jmi_string_t, jmi_string_array_t, temp_1_a, JMI_MAX_EQUATION(n_v, 0.0), 1, JMI_MAX_EQUATION(n_v, 0.0))
    1620816364    i1_0in = 0;
    16209     i1_0ie = floor((jmi_max(n_v, 0.0)) - (1));
     16365    i1_0ie = floor((JMI_MAX_EQUATION(n_v, 0.0)) - (1));
    1621016366    for (i1_0i = 1; i1_0in <= i1_0ie; i1_0i = 1 + (++i1_0in)) {
    1621116367        JMI_ASG(STR, jmi_array_ref_1(temp_1_a, i1_0i), \"str\")
     
    1772917885    Real y = abs(time + 0.5);
    1773017886
    17731     annotation(__JModelica(UnitTesting(tests={
    17732         CCodeGenTestCase(
    17733             name="SwitchesAsNoEvent1",
    17734             description="Test so that no switches are generated when generate_event_switches is set to false.",
    17735             generate_event_switches=false,
    17736             template="
     17887annotation(__JModelica(UnitTesting(tests={
     17888    CCodeGenTestCase(
     17889        name="SwitchesAsNoEvent1",
     17890        description="Test so that no switches are generated when generate_event_switches is set to false.",
     17891        generate_event_switches=false,
     17892        template="
    1773717893$C_DAE_initial_relations$
    1773817894$C_DAE_relations$
    1773917895$C_ode_derivatives$
    1774017896",
    17741             generatedCode="
     17897        generatedCode="
    1774217898static const int N_initial_relations = 0;
    1774317899static const int DAE_initial_relations[] = { -1 };
     
    1775017906    _x_0 = COND_EXP_GT(_time, 0.5, JMI_TRUE, JMI_FALSE);
    1775117907    pre_x_0 = _x_0;
    17752     _y_1 = jmi_abs(_time + 0.5);
     17908    _y_1 = JMI_ABS_EQUATION(_time + 0.5);
    1775317909    JMI_DYNAMIC_FREE()
    1775417910    return ef;
     
    1776317919    x = time / (sum(a_really_long_variable_name));
    1776417920
    17765     annotation(__JModelica(UnitTesting(tests={
    17766         CCodeGenTestCase(
    17767             name="TruncDivString1",
    17768             description="Test code gen for active switch indexes in block.",
    17769             eliminate_linear_equations=false,
    17770             template="$C_ode_derivatives$",
    17771             generatedCode="
     17921annotation(__JModelica(UnitTesting(tests={
     17922    CCodeGenTestCase(
     17923        name="TruncDivString1",
     17924        description="Test code gen for active switch indexes in block.",
     17925        eliminate_linear_equations=false,
     17926        template="$C_ode_derivatives$",
     17927        generatedCode="
    1777217928
    1777317929int model_ode_derivatives_base(jmi_t* jmi) {
     
    1779917955    _a_really_long_variable_name_5_4_23 = _time;
    1780017956    _a_really_long_variable_name_5_5_24 = _time;
    17801     _x_25 = jmi_divide_equation(jmi, _time,(_a_really_long_variable_name_1_1_0 + _a_really_long_variable_name_1_2_1 + (_a_really_long_variable_name_1_3_2 + _a_really_long_variable_name_1_4_3) + (_a_really_long_variable_name_1_5_4 + _a_really_long_variable_name_2_1_5 + _a_really_long_variable_name_2_2_6) + (_a_really_long_variable_name_2_3_7 + _a_really_long_variable_name_2_4_8 + _a_really_long_variable_name_2_5_9 + (_a_really_long_variable_name_3_1_10 + _a_really_long_variable_name_3_2_11 + _a_really_long_variable_name_3_3_12)) + (_a_really_long_variable_name_3_4_13 + _a_really_long_variable_name_3_5_14 + _a_really_long_variable_name_4_1_15 + (_a_really_long_variable_name_4_2_16 + _a_really_long_variable_name_4_3_17 + _a_really_long_variable_name_4_4_18) + (_a_really_long_variable_name_4_5_19 + _a_really_long_variable_name_5_1_20 + _a_really_long_variable_name_5_2_21 + (_a_really_long_variable_name_5_3_22 + _a_really_long_variable_name_5_4_23 + _a_really_long_variable_name_5_5_24)))),\"(truncated) time / (a_really_long_variable_name[1,1] + a_really_long_variable_name[1,2] + (a_really_long_variable_name[1,3] + a_really_long_variable_name[1,4]) + (a_really_long_variable_name[1,5] + a_really_long_variable_name[2,1] + a_really_long_variable_name[2,2]) + (a_really_long_variable_name[2,3] + a_really_long_variable_name[2,4] + a_really_long_variable_name[2,5] + (a_really_long_variable_name[3,1] + a_really_long_variable_name[3,2] + a_really_long_variable_name[3,3])) + (a_really_long_variable...\");
     17957    _x_25 = JMI_DIVIDE_EQUATION(jmi, _time, (_a_really_long_variable_name_1_1_0 + _a_really_long_variable_name_1_2_1 + (_a_really_long_variable_name_1_3_2 + _a_really_long_variable_name_1_4_3) + (_a_really_long_variable_name_1_5_4 + _a_really_long_variable_name_2_1_5 + _a_really_long_variable_name_2_2_6) + (_a_really_long_variable_name_2_3_7 + _a_really_long_variable_name_2_4_8 + _a_really_long_variable_name_2_5_9 + (_a_really_long_variable_name_3_1_10 + _a_really_long_variable_name_3_2_11 + _a_really_long_variable_name_3_3_12)) + (_a_really_long_variable_name_3_4_13 + _a_really_long_variable_name_3_5_14 + _a_really_long_variable_name_4_1_15 + (_a_really_long_variable_name_4_2_16 + _a_really_long_variable_name_4_3_17 + _a_really_long_variable_name_4_4_18) + (_a_really_long_variable_name_4_5_19 + _a_really_long_variable_name_5_1_20 + _a_really_long_variable_name_5_2_21 + (_a_really_long_variable_name_5_3_22 + _a_really_long_variable_name_5_4_23 + _a_really_long_variable_name_5_5_24)))), \"(truncated) time / (a_really_long_variable_name[1,1] + a_really_long_variable_name[1,2] + (a_really_long_variable_name[1,3] + a_really_long_variable_name[1,4]) + (a_really_long_variable_name[1,5] + a_really_long_variable_name[2,1] + a_really_long_variable_name[2,2]) + (a_really_long_variable_name[2,3] + a_really_long_variable_name[2,4] + a_really_long_variable_name[2,5] + (a_really_long_variable_name[3,1] + a_really_long_variable_name[3,2] + a_really_long_variable_name[3,3])) + (a_really_long_variable...\");
    1780217958    JMI_DYNAMIC_FREE()
    1780317959    return ef;
     
    2011820274    int ef = 0;
    2011920275    JMI_DYNAMIC_INIT()
    20120     _tmp_2 = sin(_time * 100.0);
     20276    _tmp_2 = JMI_SIN_EQUATION(jmi, _time * 100.0, \"sin(time * 100)\");
    2012120277    if (jmi->atInitial || jmi->atEvent) {
    2012220278        _sw(0) = jmi_turn_switch(jmi, __eventIndicator_1_3, _sw(0), JMI_REL_GEQ);
     
    2014220298    }
    2014320299    ef |= jmi_solve_block_residual(jmi->dae_block_residuals[0]);
    20144     _tmp_2 = sin(_time * 100.0);
     20300    _tmp_2 = JMI_SIN_EQUATION(jmi, _time * 100.0, \"sin(time * 100)\");
    2014520301    __eventIndicator_2_4 = jmi_delay_first_event_indicator_exp(jmi, 0, _tmp_2);
    2014620302    __eventIndicator_3_5 = jmi_delay_second_event_indicator_exp(jmi, 0, _tmp_2);
  • trunk/Compiler/ModelicaCompiler/module.options

    r13719 r14004  
    465465
    466466********************************************************************************
     467BOOLEAN mathematical_domain_checks compiler uncommon true
     468
     469"If enabled, all mathematical operators will be checked for its correct domain
     470and provide log messages when an operator is evaluated outside its correct
     471domain."
     472
     473********************************************************************************
  • trunk/Python/src/tests_jmodelica/files/Modelica/OperatorTests.mo

    r9348 r14004  
    11package OperatorTests "Some tests for operators"
     2
     3model DomainChecks
     4    Real x1 = abs(time);
     5    Real x2 = cos(time);
     6    Real x3 = sin(time);
     7    Real x4 = tan(time);
     8    Real x5 = acos(time);
     9    Real x6 = asin(time);
     10    Real x7 = atan(time);
     11    Real x8 = log(time);
     12    Real x9 = log10(time);
     13    Real x10= exp(time);
     14    Real x11= time^10;
     15    Real x12= sqrt(time);
     16    Real x13= sinh(time);
     17    Real x14= cosh(time);
     18    Real x15= tanh(time);
     19    Real x16= atan2(time, 2*time);
     20    Real x17= time / x16;
     21    Real x18= sign(time);
     22    Real x19= max(time, x16);
     23    Real x20= min(time, x16);
     24    Real x21= div(time, 2*time);
     25
     26    function operators
     27        input Real t;
     28        output Real[16] o;
     29    algorithm
     30        o[1] := cos(t);
     31        o[2] := sin(t);
     32        o[3] := acos(t);
     33        o[4] := asin(t);
     34        o[5] := atan(t);
     35        o[6] := log(t);
     36        o[7] := log10(t);
     37        o[8] := exp(t);
     38        o[9] := t^10;
     39        o[10]:= sqrt(time);
     40        o[11]:= cosh(time);
     41        o[12]:= sinh(time);
     42        o[13]:= tanh(time);
     43        o[14]:= atan2(time, 2*time);
     44        o[15]:= t / o[1];
     45        o[16]:= div(time, 2*time);
     46    end operators;
     47   
     48    Real o[16] = operators(time);
     49end DomainChecks;
    250
    351model HomotopyTest
  • trunk/Python/src/tests_jmodelica/general/test_operators.py

    r11351 r14004  
    2222from pymodelica.compiler_exceptions import CompilerError
    2323
     24class TestDomainChecks(SimulationTest):
     25    @testattr(stddist_full = True)
     26    def test_domain_checks1(self):
     27        SimulationTest.setup_class_base('OperatorTests.mo',
     28            'OperatorTests.DomainChecks', options={"mathematical_domain_checks":True})
     29           
     30        model = load_fmu("OperatorTests_DomainChecks.fmu", log_level=6)
     31       
     32        target_msg = "Using mathematical functions with domain checks."
     33        found_msg = False
     34        for msg in model.get_log():
     35            print msg
     36            if target_msg in msg:
     37                found_msg = True
     38                break
     39       
     40        assert found_msg, "Could not find the message '{}' in the log.".format(target_msg)
     41       
     42    @testattr(stddist_full = True)
     43    def test_domain_checks2(self):
     44        SimulationTest.setup_class_base('OperatorTests.mo',
     45            'OperatorTests.DomainChecks', options={"mathematical_domain_checks":False})
     46       
     47        model = load_fmu("OperatorTests_DomainChecks.fmu", log_level=6)
     48       
     49        target_msg = "Using mathematical functions without any domain checks, caution is advised."
     50        found_msg = False
     51        for msg in model.get_log():
     52            if target_msg in msg:
     53                found_msg = True
     54                break
     55       
     56        assert found_msg, "Could not find the message '{}' in the log.".format(target_msg)
     57
    2458class TestHomotopy(SimulationTest):
    2559    """
  • trunk/RuntimeLibrary/src

  • trunk/RuntimeLibrary/src/jmi/jmi_linear_algebra.c

    r9915 r14004  
    2222#include <math.h>
    2323#include <stdlib.h>
     24
     25/* Computes y = x.*y (element-wise multiplication)*/
     26void jmi_linear_algebra_dxemy(jmi_real_t* x, jmi_real_t* y, jmi_int_t N) {
     27    jmi_int_t i;
     28   
     29    for (i = 0; i < N; i++) {
     30        y[i] = y[i]*x[i];
     31    }
     32}
    2433
    2534/* Computes a = sqrt( sum( (wi*xi)^2) / N) */
     
    117126/* Find the index of the max absolute value */
    118127jmi_int_t jmi_linear_algebra_idamax(jmi_real_t *x, jmi_int_t N) {
    119     int i = 0;
    120     int j=0;
     128    int i = 0, j = 0;
     129
    121130    jmi_real_t cmax = JMI_ABS(x[i]);
    122     for(i=1; i<N; i++) {
    123         if(JMI_ABS(x[i])>cmax) {
     131    jmi_real_t tmp;
     132    for(i=1; i < N; i++) {
     133        tmp = JMI_ABS(x[i]);
     134        if(tmp > cmax) {
     135            cmax = tmp;
    124136            j=i;
    125137        }
  • trunk/RuntimeLibrary/src/jmi/jmi_linear_algebra.h

    r9911 r14004  
    150150jmi_real_t jmi_linear_algebra_dlange(jmi_real_t* A, jmi_int_t N, char norm_type);
    151151
     152/**
     153 * \brief Computes the element-wise multiplication of two vectors
     154 *
     155 * @param jmi_real_t* A real pointer to the x vector.
     156 * @param jmi_real_t* A real pointer to the y vector (result saved in this vector).
     157 * @param jmi_int_t The number of elements.
     158 */
     159void jmi_linear_algebra_dxemy(jmi_real_t* x, jmi_real_t* y, jmi_int_t N);
    152160
    153161#endif
  • trunk/RuntimeLibrary/src/jmi/jmi_math.c

    r10859 r14004  
    2222
    2323
    24 void jmi_log_func_or_eq(jmi_t *jmi, const char cathegory_name[], const char func_name[], const char msg[], const char val[]) {
     24void jmi_log_func_or_eq(jmi_t *jmi, const char category_name[], const char func_name[], const char msg[], const char val[]) {
     25    if (jmi == NULL) jmi = jmi_get_current();
     26   
    2527    if (func_name != NULL) {
    2628        char buf[64];
    27         sprintf(buf, "%s%s", cathegory_name, "InFunc");
     29        sprintf(buf, "%s%s", category_name, "InFunc");
    2830        jmi_log_node(jmi->log, logWarning, buf, "<func: %s, exp: %s, val:%s>", func_name, msg, val);
    2931    } else {
    30         jmi_log_node(jmi->log, logWarning, cathegory_name, "<exp:%s, val: %s>", msg, val);
     32        jmi_log_node(jmi->log, logWarning, category_name, "<exp:%s, val: %s>", msg, val);
    3133    }
    3234}
     
    4547void jmi_inf_log(jmi_t *jmi, const char func_name[], const char msg[], jmi_real_t res, jmi_real_t x) {
    4648    if (((res - res) != 0)) {
    47         if (jmi == NULL) jmi = jmi_get_current();
    4849       
    4950        if (res > 0) {
     
    6768        sprintf(val, "%.14E, %.14E", num, den);
    6869       
    69         if (jmi == NULL) jmi = jmi_get_current();
    7070        jmi_log_func_or_eq(jmi, "DivideByZero", func_name, msg, val);
    7171    }
     
    152152        sprintf(val, "%.14E, %.14E", x, y);
    153153       
    154         if (jmi == NULL) jmi = jmi_get_current();
    155154        jmi_log_func_or_eq(jmi, "IllegalAtan2Input", func_name, msg, val);
    156155    }
     
    170169    jmi_real_t to_return = pow(x, y);
    171170
     171    /* The returned value is not a number */
    172172    if ((to_return - to_return) != 0) {
    173         /* The returned value is not a number */
    174         if (jmi == NULL)
    175             jmi = jmi_get_current();
    176173
    177174        /* Check that the inputs are in the domain of the function*/
     
    219216    jmi_real_t to_return = log(x);
    220217   
     218    /* The returned value is not a number */
    221219    if ((to_return - to_return) != 0) {
    222         /* The returned value is not a number */
    223         if (jmi == NULL) jmi = jmi_get_current();
    224220       
    225221        if (x == 0) {
     
    250246    jmi_real_t to_return = log10(x);
    251247   
     248    /* The returned value is not a number */
    252249    if ((to_return - to_return) != 0) {
    253         /* The returned value is not a number */
    254         if (jmi == NULL) jmi = jmi_get_current();
    255        
     250
    256251        if (x == 0) {
    257252            /* Pole problem, will return -JMI_INF */
  • trunk/RuntimeLibrary/src/jmi/jmi_math.h

    r10859 r14004  
    4444void jmi_log_func_or_eq(jmi_t *jmi, const char cathegory_name[], const char func_name[], const char msg[], const char val[]);
    4545
     46/* Macros used together with the domain check option */
     47#ifdef MATHEMATICAL_DOMAIN_CHECKS
     48    #define MATHEMATICAL_DOMAIN_CHECKS_MSG "Using mathematical functions with domain checks."
     49    #define JMI_ABS_EQUATION(x)   jmi_abs(x)
     50    #define JMI_MAX_EQUATION(x,y) jmi_max(x,y)
     51    #define JMI_MIN_EQUATION(x,y) jmi_min(x,y)
     52    #define JMI_SIGN_EQUATION(x)  jmi_sign(x)
     53    #define JMI_DIVIDE_FUNCTION(name, num, den, msg) jmi_divide_function(name, num, den, msg)
     54    #define JMI_DIVIDE_EQUATION(jmi, num, den, msg)  jmi_divide_equation(jmi,  num, den, msg)
     55    #define JMI_EXP_EQUATION(jmi, x, msg)            jmi_exp_equation(jmi, x, msg)     
     56    #define JMI_EXP_FUNCTION(name, x, msg)           jmi_exp_function(name, x, msg)     
     57    #define JMI_TAN_EQUATION(jmi, x, msg)            jmi_tan_equation(jmi, x, msg)     
     58    #define JMI_TAN_FUNCTION(name, x, msg)           jmi_tan_function(name, x, msg)     
     59    #define JMI_ATAN_EQUATION(jmi, x, msg)           jmi_atan_equation(jmi, x, msg)     
     60    #define JMI_ATAN_FUNCTION(name, x, msg)          jmi_atan_function(name, x, msg)   
     61    #define JMI_TANH_EQUATION(jmi, x, msg)           jmi_tanh_equation(jmi, x, msg)     
     62    #define JMI_TANH_FUNCTION(name, x, msg)          jmi_tanh_function(name, x, msg)   
     63    #define JMI_COS_EQUATION(jmi, x, msg)            jmi_cos_equation(jmi, x, msg)     
     64    #define JMI_COS_FUNCTION(name, x, msg)           jmi_cos_function(name, x, msg)     
     65    #define JMI_ACOS_EQUATION(jmi, x, msg)           jmi_acos_equation(jmi, x, msg)     
     66    #define JMI_ACOS_FUNCTION(name, x, msg)          jmi_acos_function(name, x, msg)   
     67    #define JMI_COSH_EQUATION(jmi, x, msg)           jmi_cosh_equation(jmi, x, msg)     
     68    #define JMI_COSH_FUNCTION(name, x, msg)          jmi_cosh_function(name, x, msg)   
     69    #define JMI_SIN_EQUATION(jmi, x, msg)            jmi_sin_equation(jmi, x, msg)     
     70    #define JMI_SIN_FUNCTION(name, x, msg)           jmi_sin_function(name, x, msg)     
     71    #define JMI_ASIN_EQUATION(jmi, x, msg)           jmi_asin_equation(jmi, x, msg)     
     72    #define JMI_ASIN_FUNCTION(name, x, msg)          jmi_asin_function(name, x, msg)   
     73    #define JMI_SINH_EQUATION(jmi, x, msg)           jmi_sinh_equation(jmi, x, msg)     
     74    #define JMI_SINH_FUNCTION(name, x, msg)          jmi_sinh_function(name, x, msg)   
     75    #define JMI_SQRT_EQUATION(jmi, x, msg)           jmi_sqrt_equation(jmi, x, msg)     
     76    #define JMI_SQRT_FUNCTION(name, x, msg)          jmi_sqrt_function(name, x, msg)   
     77    #define JMI_LOG_EQUATION(jmi, x, msg)            jmi_log_equation(jmi, x, msg)     
     78    #define JMI_LOG_FUNCTION(name, x, msg)           jmi_log_function(name, x, msg)     
     79    #define JMI_LOG10_EQUATION(jmi, x, msg)          jmi_log10_equation(jmi, x, msg)   
     80    #define JMI_LOG10_FUNCTION(name, x, msg)         jmi_log10_function(name, x, msg)   
     81    #define JMI_ATAN2_EQUATION(jmi, x, y, msg)       jmi_atan2_equation(jmi, x, y, msg)
     82    #define JMI_ATAN2_FUNCTION(name, x, y, msg)      jmi_atan2_function(name, x, y, msg)
     83    #define JMI_POW_EQUATION(jmi, x, y, msg)         jmi_pow_equation(jmi, x, y, msg)   
     84    #define JMI_POW_FUNCTION(name, x, y, msg)        jmi_pow_function(name, x, y, msg)
     85#else
     86    #define MATHEMATICAL_DOMAIN_CHECKS_MSG "Using mathematical functions without any domain checks, caution is advised."
     87    #define JMI_ABS_EQUATION(x)   JMI_ABS(x)
     88    #define JMI_MAX_EQUATION(x,y) JMI_MAX(x,y)
     89    #define JMI_MIN_EQUATION(x,y) JMI_MIN(x,y)
     90    #define JMI_SIGN_EQUATION(x)  JMI_SIGN(x)
     91    #define JMI_DIVIDE_FUNCTION(name, num, den, msg) ((jmi_real_t)(num)/(jmi_real_t)(den))
     92    #define JMI_DIVIDE_EQUATION(jmi, num, den, msg)  ((jmi_real_t)(num)/(jmi_real_t)(den))
     93    #define JMI_EXP_EQUATION(jmi, x, msg)            (exp((jmi_real_t)(x)))
     94    #define JMI_EXP_FUNCTION(name, x, msg)           (exp((jmi_real_t)(x)))
     95    #define JMI_TAN_EQUATION(jmi, x, msg)            (tan((jmi_real_t)(x)))
     96    #define JMI_TAN_FUNCTION(name, x, msg)           (tan((jmi_real_t)(x)))
     97    #define JMI_ATAN_EQUATION(jmi, x, msg)           (atan((jmi_real_t)(x)))
     98    #define JMI_ATAN_FUNCTION(name, x, msg)          (atan((jmi_real_t)(x)))
     99    #define JMI_TANH_EQUATION(jmi, x, msg)           (tanh((jmi_real_t)(x)))
     100    #define JMI_TANH_FUNCTION(name, x, msg)          (tanh((jmi_real_t)(x)))
     101    #define JMI_COS_EQUATION(jmi, x, msg)            (cos((jmi_real_t)(x)))
     102    #define JMI_COS_FUNCTION(name, x, msg)           (cos((jmi_real_t)(x)))
     103    #define JMI_ACOS_EQUATION(jmi, x, msg)           (acos((jmi_real_t)(x)))
     104    #define JMI_ACOS_FUNCTION(name, x, msg)          (acos((jmi_real_t)(x)))
     105    #define JMI_COSH_EQUATION(jmi, x, msg)           (cosh((jmi_real_t)(x)))
     106    #define JMI_COSH_FUNCTION(name, x, msg)          (cosh((jmi_real_t)(x)))
     107    #define JMI_SIN_EQUATION(jmi, x, msg)            (sin((jmi_real_t)(x)))
     108    #define JMI_SIN_FUNCTION(name, x, msg)           (sin((jmi_real_t)(x)))
     109    #define JMI_ASIN_EQUATION(jmi, x, msg)           (asin((jmi_real_t)(x)))
     110    #define JMI_ASIN_FUNCTION(name, x, msg)          (asin((jmi_real_t)(x)))
     111    #define JMI_SINH_EQUATION(jmi, x, msg)           (sinh((jmi_real_t)(x)))
     112    #define JMI_SINH_FUNCTION(name, x, msg)          (sinh((jmi_real_t)(x)))
     113    #define JMI_SQRT_EQUATION(jmi, x, msg)           (sqrt((jmi_real_t)(x)))
     114    #define JMI_SQRT_FUNCTION(name, x, msg)          (sqrt((jmi_real_t)(x)))
     115    #define JMI_LOG_EQUATION(jmi, x, msg)            (log((jmi_real_t)(x)))
     116    #define JMI_LOG_FUNCTION(name, x, msg)           (log((jmi_real_t)(x)))
     117    #define JMI_LOG10_EQUATION(jmi, x, msg)          (log10((jmi_real_t)(x)))
     118    #define JMI_LOG10_FUNCTION(name, x, msg)         (log10((jmi_real_t)(x)))
     119    #define JMI_ATAN2_EQUATION(jmi, x, y, msg)       (atan2((jmi_real_t)(x), (jmi_real_t)(y)))
     120    #define JMI_ATAN2_FUNCTION(name, x, y, msg)      (atan2((jmi_real_t)(x), (jmi_real_t)(y)))
     121    #define JMI_POW_EQUATION(jmi, x, y, msg)         (pow((jmi_real_t)(x), (jmi_real_t)(y)))
     122    #define JMI_POW_FUNCTION(name, x, y, msg)        (pow((jmi_real_t)(x), (jmi_real_t)(y)))
     123#endif
     124
     125jmi_real_t jmi_pow(jmi_t *jmi, const char func_name[], jmi_real_t x, jmi_real_t y, const char msg[]);
     126
    46127/**
    47128 * Function for checking if a vector contains NAN values. Returns the
  • trunk/RuntimeLibrary/src/jmi/jmi_math_ad.h

    r10859 r14004  
    1717    <http://www.ibm.com/developerworks/library/os-cpl.html/> respectively.
    1818*/
     19
     20#define JMI_AD_DIVIDE_FUNCTION(func_name, x, y, dx, dy, v, d, msg) jmi_ad_divide_function(func_name, x, y, dx, dy, v, d, msg)
     21#define JMI_AD_DIVIDE_EQUATION(jmi, x, y, dx, dy, v, d, msg)       jmi_ad_divide_equation(jmi, x, y, dx, dy, v, d, msg)
     22#define JMI_AD_SQRT_FUNCTION(func_name, x, dx, v, d, msg)          jmi_ad_sqrt_function(func_name, x, dx, v, d, msg)
     23#define JMI_AD_SQRT_EQUATION(jmi, x, dx, v, d, msg)                jmi_ad_sqrt_equation(jmi, x, dx, v, d, msg)
     24#define JMI_AD_ASIN_FUNCTION(func_name, x, dx, v, d, msg)          jmi_ad_asin_function(func_name, x, dx, v, d, msg)
     25#define JMI_AD_ASIN_EQUATION(jmi, x, dx, v, d, msg)                jmi_ad_asin_equation(jmi, x, dx, v, d, msg)
     26#define JMI_AD_ACOS_FUNCTION(func_name, x, dx, v, d, msg)          jmi_ad_acos_function(func_name, x, dx, v, d, msg)
     27#define JMI_AD_ACOS_EQUATION(jmi, x, dx, v, d, msg)                jmi_ad_acos_equation(jmi, x, dx, v, d, msg)
     28#define JMI_AD_ATAN2_FUNCTION(func_name, x, y, dx, dy, v, d, msg)  jmi_ad_atan2_function(func_name, x, y, dx, dy, v, d, msg)
     29#define JMI_AD_ATAN2_EQUATION(jmi, x, y, dx, dy, v, d, msg)        jmi_ad_atan2_equation(jmi, x, y, dx, dy, v, d, msg)
     30#define JMI_AD_POW_FUNCTION(func_name, x, y, dx, dy, v, d, msg)    jmi_ad_pow_function(func_name, x, y, dx, dy, v, d, msg)
     31#define JMI_AD_POW_EQUATION(jmi, x, y, dx, dy, v, d, msg)          jmi_ad_pow_equation(jmi, x, y, dx, dy, v, d, msg)
     32#define JMI_AD_EXP_FUNCTION(func_name, x, dx, v, d, msg)           jmi_ad_exp_function(func_name, x, dx, v, d, msg)
     33#define JMI_AD_EXP_EQUATION(jmi, x, dx, v, d, msg)                 jmi_ad_exp_equation(jmi, x, dx, v, d, msg)
     34#define JMI_AD_LOG_FUNCTION(func_name, x, dx, v, d, msg)           jmi_ad_log_function(func_name, x, dx, v, d, msg)
     35#define JMI_AD_LOG_EQUATION(jmi, x, dx, v, d, msg)                 jmi_ad_log_equation(jmi, x, dx, v, d, msg)
     36#define JMI_AD_LOG10_FUNCTION(func_name, x, dx, v, d, msg)         jmi_ad_log10_function(func_name, x, dx, v, d, msg)
     37#define JMI_AD_LOG10_EQUATION(jmi, x, dx, v, d, msg)               jmi_ad_log10_equation(jmi, x, dx, v, d, msg)
     38#define JMI_AD_SINH_FUNCTION(func_name, x, dx, v, d, msg)          jmi_ad_sinh_function(func_name, x, dx, v, d, msg)
     39#define JMI_AD_SINH_EQUATION(jmi, x, dx, v, d, msg)                jmi_ad_sinh_equation(jmi, x, dx, v, d, msg)
     40#define JMI_AD_COSH_FUNCTION(func_name, x, dx, v, d, msg)          jmi_ad_cosh_function(func_name, x, dx, v, d, msg)
     41#define JMI_AD_COSH_EQUATION(jmi, x, dx, v, d, msg)                jmi_ad_cosh_equation(jmi, x, dx, v, d, msg)
     42#define JMI_AD_TAN_FUNCTION(func_name, x, dx, v, d, msg)           jmi_ad_tan_function(func_name, x, dx, v, d, msg)
     43#define JMI_AD_TAN_EQUATION(jmi, x, dx, v, d, msg)                 jmi_ad_tan_equation(jmi, x, dx, v, d, msg)
     44#define JMI_AD_SIN_FUNCTION(func_name, x, dx, v, d, msg)           jmi_ad_sin_function(func_name, x, dx, v, d, msg)
     45#define JMI_AD_SIN_EQUATION(jmi, x, dx, v, d, msg)                 jmi_ad_sin_equation(jmi, x, dx, v, d, msg)
     46#define JMI_AD_COS_FUNCTION(func_name, x, dx, v, d, msg)           jmi_ad_cos_function(func_name, x, dx, v, d, msg)
     47#define JMI_AD_COS_EQUATION(jmi, x, dx, v, d, msg)                 jmi_ad_cos_equation(jmi, x, dx, v, d, msg)
     48#define JMI_AD_ATAN_FUNCTION(func_name, x, dx, v, d, msg)          jmi_ad_atan_function(func_name, x, dx, v, d, msg)
     49#define JMI_AD_ATAN_EQUATION(jmi, x, dx, v, d, msg)                jmi_ad_atan_equation(jmi, x, dx, v, d, msg)
     50#define JMI_AD_TANH_FUNCTION(func_name, x, dx, v, d, msg)          jmi_ad_tanh_function(func_name, x, dx, v, d, msg)
     51#define JMI_AD_TANH_EQUATION(jmi, x, dx, v, d, msg)                jmi_ad_tanh_equation(jmi, x, dx, v, d, msg)
     52
    1953
    2054void jmi_ad_divide_function(const char func_name[], jmi_real_t x, jmi_real_t y, jmi_real_t dx, jmi_real_t dy, jmi_real_t *v, jmi_real_t *d, const char msg[]);
  • trunk/RuntimeLibrary/src/jmi/jmi_me.c

    r12953 r14004  
    3333    retval = jmi_new(&jmi, jmi_callbacks);
    3434    if(retval != 0) {
    35         /* creating jmi struct failed */
     35        /* Creating jmi struct failed */
    3636        jmi_log_node(jmi_->log, logError, "StructCreationFailure","Creating internal struct failed.");
    3737        return retval;
     
    5858    jmi_->resource_location = resource_location;
    5959   
    60     /* set start values*/
     60    /* Set start values*/
    6161    if (jmi_init_eval_independent(jmi) != 0) {
    6262        return -1;
  • trunk/RuntimeLibrary/src/jmi/jmi_realtime_solver.c

    r11712 r14004  
    2525#include <string.h>
    2626
    27 #define JMI_REALTIME_SOLVER_MAX_ITER 20
     27#define JMI_REALTIME_SOLVER_MAX_ITER 10
    2828#define JMI_REALTIME_UPDATE_JACOBIAN_ITER 10
    2929#define JMI_REALTIME_PROGRESS_LOG_LEVEL 4
    30 
     30#define JMI_REALTIME_INFO_LOG_LEVEL 5
     31#define JMI_REALTIME_DEBUG_LOG_LEVEL 6
    3132
    3233static void progress_reset_char_log(jmi_block_solver_t* block) {
     
    176177   
    177178    /* Open log and log the Jacobian.*/
    178     if((block->callbacks->log_options.log_level >= 5)) {
     179    if((block->callbacks->log_options.log_level >= JMI_REALTIME_INFO_LOG_LEVEL)) {
    179180        destnode = jmi_log_enter_fmt(block->log, logInfo, "RealtimeSolver",
    180181                                     "Realtime solver invoked for <block:%s>", block->label);
    181182        jmi_log_reals(block->log, destnode, logInfo, "ivs", block->x, block->n);
    182         if((block->callbacks->log_options.log_level >= 6)) {
     183        if((block->callbacks->log_options.log_level >= JMI_REALTIME_DEBUG_LOG_LEVEL)) {
    183184            jmi_log_real_matrix(block->log, destnode, logInfo, "LU", solver->factorization, block->n, block->n);
    184185        }
     
    208209        /* Logging compute the id of the largest (weighted) step */
    209210        if (block->callbacks->log_options.log_level >= JMI_REALTIME_PROGRESS_LOG_LEVEL) {
    210             jmi_linear_algebra_ddot(solver->weights, block->res, block->n);
     211            jmi_linear_algebra_dxemy(solver->weights, block->res, block->n);
    211212            solver->last_wrms_id = jmi_linear_algebra_idamax(block->res, block->n);
    212213        }
     
    231232   
    232233    /* Close log.*/
    233     if((block->callbacks->log_options.log_level >= 5)) {
     234    if((block->callbacks->log_options.log_level >= JMI_REALTIME_INFO_LOG_LEVEL)) {
    234235        jmi_log_reals(block->log, destnode, logInfo, "ivs", block->x, block->n);
    235236        jmi_log_reals(block->log, destnode, logInfo, "residual", block->res, block->n);
Note: See TracChangeset for help on using the changeset viewer.