Changeset 8556


Ignore:
Timestamp:
Mar 14, 2016 11:45:20 AM (4 years ago)
Author:
aramle
Message:

#4815 Introduced jmi_math.*.

Location:
trunk/RuntimeLibrary
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/RuntimeLibrary/Makefiles/Makefile.linux

    r8256 r8556  
    144144# Libraries necessary to link with jmi
    145145# Reused parts
    146 LIBS_FMU_STD = -ljmi "-L$(JMI_LIB_DIR)" $(EXT_LIB_DIRS) $(EXTERNAL_LIBS) -lModelicaExternalC
     146LIBS_FMU_STD = -ljmi "-L$(JMI_LIB_DIR)" $(EXT_LIB_DIRS) $(EXTERNAL_LIBS) -ljmi -lModelicaExternalC
    147147LIB_SUNDIALS = -L$(SUNDIALS_LIB_DIR) -l:libsundials_kinsol.a -l:libsundials_nvecserial.a
    148148LIB_MINPACK  = -L$(MINPACK_LIB_DIR) -l:libcminpack.a
  • trunk/RuntimeLibrary/Makefiles/Makefile.macosx

    r8256 r8556  
    143143# Libraries necessary to link with jmi
    144144# Reused parts
    145 LIBS_FMU_STD = -ljmi "-L$(JMI_LIB_DIR)" $(EXT_LIB_DIRS) $(EXTERNAL_LIBS) -lModelicaExternalC -static-libstdc++
     145LIBS_FMU_STD = -ljmi "-L$(JMI_LIB_DIR)" $(EXT_LIB_DIRS) $(EXTERNAL_LIBS) -ljmi -lModelicaExternalC -static-libstdc++
    146146LIB_SUNDIALS = -L$(SUNDIALS_LIB_DIR) $(SUNDIALS_HOME)/lib/libsundials_kinsol.a $(SUNDIALS_HOME)/lib/libsundials_nvecserial.a
    147147LIB_MINPACK  = -L$(MINPACK_LIB_DIR) ${JMODELICA_HOME}/ThirdParty/Minpack/lib/libcminpack.a
  • trunk/RuntimeLibrary/Makefiles/Makefile.windows

    r8410 r8556  
    9393SUNDIALS_HOME =
    9494
    95 MODULE_HOME =
    96 
    9795# STATIC PTHREADS home
    9896STATIC_PTHREADS_HOME = $(JMODELICA_HOME)/ThirdParty/pthreads
     
    174172SUNDIALS_LIB_DIR = $(SUNDIALS_HOME)/lib
    175173SUNDIALS_LIB_DIR64 = $(SUNDIALS_HOME)/lib64
    176 MODULE_LIB_DIR = $(MODULE_HOME)
    177174
    178175# Flags needed for specific libs
     
    185182LIB_MINPACK  = "-L$(MINPACK_LIB_DIR)" -l:libcminpack.a
    186183LIB_SUNDIALS = "-L$(SUNDIALS_LIB_DIR)" -l:libsundials_kinsol.a -l:libsundials_nvecserial.a -l:libsundials_cvode.a
    187 LIB_MODULE = "-L$(MODULE_LIB_DIR)" -l:libjmi_get_set_lazy.a
    188184STATIC_PTHREADS_CONT = $(shell dir "$(STATIC_PTHREADS_HOME)")
    189185ifneq ($(findstring ..,$(STATIC_PTHREADS_CONT)),)
     
    194190
    195191# Libraries necessary to link with jmi
    196 LIBS_FMU_STD = -ljmi "-L$(JMI_LIB_DIR)" $(EXT_LIB_DIRS) $(EXTERNAL_LIBS) -lModelicaExternalC -lstdc++ -static-libstdc++
    197 LIBS_FMU_ALL = $(LIBS_FMU_STD) $(LIB_SUNDIALS) $(LIB_MINPACK) $(LIB_PTHREADS) $(LIB_MODULE)
     192LIBS_FMU_STD = -ljmi "-L$(JMI_LIB_DIR)" $(EXT_LIB_DIRS) $(EXTERNAL_LIBS) -ljmi -lModelicaExternalC -lstdc++ -static-libstdc++
     193LIBS_FMU_ALL = $(LIBS_FMU_STD) $(LIB_SUNDIALS) $(LIB_MINPACK) $(LIB_PTHREADS)
    198194LIBS_FMUME10 = -lfmi1_me           $(LIBS_FMU_ALL)
    199195LIBS_FMUCS10 = -lfmi1_cs -lfmi1_me $(LIBS_FMU_ALL)
  • trunk/RuntimeLibrary/src/jmi/CMakeLists.txt

    r8504 r8556  
    3939    jmi_dynamic_state.h
    4040    jmi_chattering.h
     41    jmi_math.h
     42    jmi_types.h
    4143   
    4244    jmi_util.c
     
    5254    jmi_dynamic_state.c
    5355    jmi_chattering.c
     56    jmi_math.c
    5457
    5558    # Logging sources
  • trunk/RuntimeLibrary/src/jmi/jmi.c

    r8497 r8556  
    642642}
    643643
    644 jmi_ad_var_t jmi_sample(jmi_t* jmi, jmi_real_t offset, jmi_real_t h) {
    645     jmi_real_t t = jmi_get_t(jmi)[0];
    646     if (!jmi->atEvent || SURELY_LT_ZERO(t-offset)) {
    647       /*printf("jmi_sample1: %f %f %12.12f %12.12f\n",offset,fmod((t-offset),h),(t-offset));*/
    648         return JMI_FALSE;
    649     }
    650     /*  printf("jmi_sample2: %f %f %12.12f %12.12f\n",offset,h,fmod((t-offset),h),(t-offset));*/
    651     return ALMOST_ZERO(jmi_dremainder((t-offset),h));
    652 }
    653 
    654644int jmi_dae_F(jmi_t* jmi, jmi_real_t* res) {
    655645
  • trunk/RuntimeLibrary/src/jmi/jmi_me.h

    r7752 r8556  
    2323#include "stdio.h"
    2424
    25 #include "jmi.h"
    2625#include "jmi_util.h"
    2726#include "jmi_log.h"
     27#include "jmi_math.h"
     28#include "jmi_types.h"
    2829
    2930typedef unsigned int jmi_value_reference;
  • trunk/RuntimeLibrary/src/jmi/jmi_types.h

    r7884 r8556  
    2424#ifndef _JMI_TYPES_H
    2525#define _JMI_TYPES_H
     26
     27#include <stdio.h>
     28
    2629/* Typedef for the doubles used in the interface. */
    2730typedef double jmi_real_t; /*< Typedef for the real number
     
    3740               < representation used in the Runtime
    3841               < Library. */
     42               
     43/* Forward declaration of jmi structs */
     44typedef struct jmi_t jmi_t;                                         /**< \brief Forward declaration of struct. */
     45typedef struct jmi_dae_t jmi_dae_t;                                 /**< \brief Forward declaration of struct. */
     46typedef struct jmi_init_t jmi_init_t;                               /**< \brief Forward declaration of struct. */
     47typedef struct jmi_func_t jmi_func_t;                               /**< \brief Forward declaration of struct. */
     48typedef struct jmi_block_residual_t jmi_block_residual_t;           /**< \brief Forward declaration of struct. */
     49typedef struct jmi_cs_input_t jmi_cs_input_t;                       /**< \brief Forward declaration of struct. */
     50typedef struct jmi_ode_solver_t jmi_ode_solver_t;                   /**< \brief Forward declaration of struct. */
     51typedef struct jmi_ode_problem_t jmi_ode_problem_t;                 /**< \brief Forward declaration of struct. */
     52typedef struct jmi_color_info jmi_color_info;                       /**< \brief Forward declaration of struct. */
     53typedef struct jmi_simple_color_info_t jmi_simple_color_info_t;     /**< \brief Forward declaration of struct. */
     54typedef struct jmi_delay_t jmi_delay_t;                             /**< \brief Forward declaration of struct. */
     55typedef struct jmi_spatialdist_t jmi_spatialdist_t;                 /**< \brief Forward declaration of struct. */
     56typedef struct jmi_dynamic_state_set_t jmi_dynamic_state_set_t;     /**< \brief Forward declaration of struct. */
     57typedef struct jmi_modules_t jmi_modules_t;                         /**< \brief Forward declaration of struct. */
     58typedef struct jmi_module_t jmi_module_t;                           /**< \brief Forward declaration of struct. */
     59typedef struct jmi_chattering_t jmi_chattering_t;                   /**< \brief Forward declaration of struct. */
    3960
    4061#define JMI_MIN(X,Y) ((X) < (Y) ? (X) : (Y))
  • trunk/RuntimeLibrary/src/jmi/jmi_util.c

    r8547 r8556  
    2929#include <stdio.h>
    3030#include <assert.h>
     31#include "jmi_math.h"
    3132
    3233void jmi_min_time_event(jmi_time_event_t* event, int def, int phase, jmi_ad_var_t time) {
     
    4445}
    4546
    46 /* Helper function for logging warnings from the "_equation"- and "_function"-functions below */
    47 void static jmi_log_func_or_eq(jmi_t *jmi, const char cathegory_name[], const char func_name[], const char msg[], const char val[]) {
    48     if (func_name != NULL) {
    49         char buf[64];
    50         sprintf(buf, "%s%s", cathegory_name, "InFunc");
    51         jmi_log_node(jmi->log, logWarning, buf, "<func: %s, exp: %s, val:%s>", func_name, msg, val);
    52     } else {
    53         jmi_log_node(jmi->log, logWarning, cathegory_name, "<exp:%s, val: %s>", msg, val);
    54     }
    55 }
    56 
    57 int jmi_check_nan(jmi_t *jmi, jmi_real_t* val, size_t n_val, jmi_int_t* index_of_nan) {
    58     int i = 0;
    59     for (i = 0; i < n_val; i++) {
    60         if ( val[i] - val[i] != 0) {
    61             *index_of_nan = i;
    62             return JMI_ERROR;
    63         }
    64     }
    65     return JMI_OK;
    66 }
    67 
    68 void jmi_inf_log(jmi_t *jmi, const char func_name[], const char msg[], jmi_real_t res, jmi_real_t x) {
    69     if (((res - res) != 0)) {
    70         if (jmi == NULL) jmi = jmi_get_current();
    71        
    72         if (res > 0) {
    73             /* res is +inf */
    74             char val[64];
    75             sprintf(val, "%.14E", x);
    76             jmi_log_func_or_eq(jmi, "RangeError", func_name, msg, val);
    77         } else if (res < 0){
    78             /* res is -inf */
    79             char val[64];
    80             sprintf(val, "%.14E", x);
    81             jmi_log_func_or_eq(jmi, "RangeError", func_name, msg, val);
    82         }
    83     }
    84 }
    85 
    86 /*Some of these functions return types are a temporary remnant of CppAD*/
    87 jmi_ad_var_t static jmi_divide(jmi_t *jmi, const char func_name[], jmi_ad_var_t num, jmi_ad_var_t den, const char msg[]) {
    88     if (den == 0) {
    89         char val[64];
    90         sprintf(val, "%.14E, %.14E", num, den);
    91        
    92         if (jmi == NULL) jmi = jmi_get_current();
    93         jmi_log_func_or_eq(jmi, "DivideByZero", func_name, msg, val);
    94     }
    95    
    96     return num/den;
    97 }
    98 
    99 jmi_ad_var_t jmi_divide_function(const char func_name[], jmi_ad_var_t num, jmi_ad_var_t den, const char msg[]) {
    100     return jmi_divide(NULL, func_name, num, den, msg);
    101 }
    102 
    103 jmi_ad_var_t jmi_divide_equation(jmi_t *jmi, jmi_ad_var_t num, jmi_ad_var_t den, const char msg[]) {
    104     return jmi_divide(jmi, NULL, num, den, msg);
    105 }
    106 
    107 jmi_ad_var_t static jmi_pow(jmi_t *jmi, const char func_name[], jmi_ad_var_t x, jmi_ad_var_t y, const char msg[]) {
    108 
    109     jmi_ad_var_t to_return = pow(x, y);
    110    
    111     if ((to_return - to_return) != 0) {
    112         /* The returned value is not a number */
    113         if (jmi == NULL) jmi = jmi_get_current();
    114    
    115         /* Check that the inputs are in the domain of the function*/
    116         if (x > 0 || (x == 0 && y > 0) || (x < 0 && (int)y == y)) {
    117             /* Range problem, will return JMI_INF or -JMI_INF */
    118             char val[64];
    119             sprintf(val, "%.14E, %.14E", x, y);
    120             jmi_log_func_or_eq(jmi, "RangeError", func_name, msg, val);
    121         } else if (x == 0 && y < 0) {
    122             /* Pole error */
    123             char val[64];
    124             sprintf(val, "%.14E, %.14E", x, y);
    125             jmi_log_func_or_eq(jmi, "DivideByZero", func_name, msg, val);
    126         }
    127     }
    128     /* jmi_inf_log(jmi, func_name, msg, to_return); */
    129     return to_return;
    130 }
    131 
    132 jmi_ad_var_t jmi_pow_function(const char func_name[], jmi_ad_var_t x, jmi_ad_var_t y, const char msg[]) {
    133     return jmi_pow(NULL, func_name, x, y, msg);
    134 }
    135 
    136 jmi_ad_var_t jmi_pow_equation(jmi_t *jmi, jmi_ad_var_t x, jmi_ad_var_t y, const char msg[]) {
    137     return jmi_pow(jmi, NULL, x, y, msg);
    138 }
    139 
    140 jmi_ad_var_t static jmi_exp(jmi_t *jmi, const char func_name[], jmi_ad_var_t x, const char msg[]) {
    141 
    142     jmi_ad_var_t to_return = exp(x);
    143     jmi_inf_log(jmi, func_name, msg, to_return, x);
    144     return to_return;
    145 }
    146 
    147 jmi_ad_var_t jmi_exp_function(const char func_name[], jmi_ad_var_t x, const char msg[]) {
    148     return jmi_exp(NULL, func_name, x, msg);
    149 }
    150 
    151 jmi_ad_var_t jmi_exp_equation(jmi_t *jmi, jmi_ad_var_t x, const char msg[]) {
    152     return jmi_exp(jmi, NULL, x, msg);
    153 }
    154 
    155 jmi_ad_var_t static jmi_log(jmi_t *jmi, const char func_name[], jmi_ad_var_t x, const char msg[]) {
    156 
    157     jmi_ad_var_t to_return = log(x);
    158    
    159     if ((to_return - to_return) != 0) {
    160         /* The returned value is not a number */
    161         if (jmi == NULL) jmi = jmi_get_current();
    162        
    163         if (x == 0) {
    164             /* Pole problem, will return -JMI_INF */
    165             char val[64];
    166             sprintf(val, "%.14E", x);
    167             jmi_log_func_or_eq(jmi, "LogarithmOfZero", func_name, msg, val);
    168         } else if (x > 0) {
    169             /* Range problem, will return JMI_INF */
    170             char val[64];
    171             sprintf(val, "%.14E", x);
    172             jmi_log_func_or_eq(jmi, "LogarithmOfInf", func_name, msg, val);
    173         }
    174     }
    175     return to_return;
    176 }
    177 
    178 jmi_ad_var_t jmi_log_function(const char func_name[], jmi_ad_var_t x, const char msg[]) {
    179     return jmi_log(NULL, func_name, x, msg);
    180 }
    181 
    182 jmi_ad_var_t jmi_log_equation(jmi_t *jmi, jmi_ad_var_t x, const char msg[]) {
    183     return jmi_log(jmi, NULL, x, msg);
    184 }
    185 
    186 jmi_ad_var_t static jmi_log10(jmi_t *jmi, const char func_name[], jmi_ad_var_t x, const char msg[]) {
    187 
    188     jmi_ad_var_t to_return = log10(x);
    189    
    190     if ((to_return - to_return) != 0) {
    191         /* The returned value is not a number */
    192         if (jmi == NULL) jmi = jmi_get_current();
    193        
    194         if (x == 0) {
    195             /* Pole problem, will return -JMI_INF */
    196             char val[64];
    197             sprintf(val, "%.14E", x);
    198             jmi_log_func_or_eq(jmi, "LogarithmOfZero", func_name, msg, val);
    199         } else if (x > 0) {
    200             /* Infinity problem, will return JMI_INF */
    201             char val[64];
    202             sprintf(val, "%.14E", x);
    203             jmi_log_func_or_eq(jmi, "LogarithmOfInf", func_name, msg, val);
    204         }
    205     }
    206     return to_return;
    207 }
    208 
    209 jmi_ad_var_t jmi_log10_function(const char func_name[], jmi_ad_var_t x, const char msg[]) {
    210     return jmi_log10(NULL, func_name, x, msg);
    211 }
    212 
    213 jmi_ad_var_t jmi_log10_equation(jmi_t *jmi, jmi_ad_var_t x, const char msg[]) {
    214     return jmi_log10(jmi, NULL, x, msg);
    215 }
    216 
    217 jmi_ad_var_t static jmi_sinh(jmi_t *jmi, const char func_name[], jmi_ad_var_t x, const char msg[]) {
    218 
    219     jmi_ad_var_t to_return = sinh(x);
    220     jmi_inf_log(jmi, func_name, msg, to_return, x);
    221     return to_return;
    222 }
    223 
    224 jmi_ad_var_t jmi_sinh_function(const char func_name[], jmi_ad_var_t x, const char msg[]) {
    225     return jmi_sinh(NULL, func_name, x, msg);
    226 }
    227 
    228 jmi_ad_var_t jmi_sinh_equation(jmi_t *jmi, jmi_ad_var_t x, const char msg[]) {
    229     return jmi_sinh(jmi, NULL, x, msg);
    230 }
    231 
    232 jmi_ad_var_t static jmi_cosh(jmi_t *jmi, const char func_name[], jmi_ad_var_t x, const char msg[]) {
    233 
    234     jmi_ad_var_t to_return = cosh(x);
    235     jmi_inf_log(jmi, func_name, msg, to_return, x);
    236     return to_return;
    237 }
    238 
    239 jmi_ad_var_t jmi_cosh_function(const char func_name[], jmi_ad_var_t x, const char msg[]) {
    240     return jmi_cosh(NULL, func_name, x, msg);
    241 }
    242 
    243 jmi_ad_var_t jmi_cosh_equation(jmi_t *jmi, jmi_ad_var_t x, const char msg[]) {
    244     return jmi_cosh(jmi, NULL, x, msg);
    245 }
    246 
    247 jmi_ad_var_t static jmi_tan(jmi_t *jmi, const char func_name[], jmi_ad_var_t x, const char msg[]) {
    248 
    249     jmi_ad_var_t to_return = tan(x);
    250     jmi_inf_log(jmi, func_name, msg, to_return, x);
    251     return to_return;
    252 }
    253 
    254 jmi_ad_var_t jmi_tan_function(const char func_name[], jmi_ad_var_t x, const char msg[]) {
    255     return jmi_tan(NULL, func_name, x, msg);
    256 }
    257 
    258 jmi_ad_var_t jmi_tan_equation(jmi_t *jmi, jmi_ad_var_t x, const char msg[]) {
    259     return jmi_tan(jmi, NULL, x, msg);
    260 }
    261 
    26247void jmi_flag_termination(jmi_t *jmi, const char* msg) {
    26348    jmi->model_terminate = 1;
    26449    /* TODO: This is an informative message, not a warning, but is rather important. Change once log level is made separate from message category. */
    26550    jmi_log_node(jmi->log, logWarning, "SimulationTerminated", "<msg:%s>", msg);
    266 }
    267 
    268 jmi_ad_var_t jmi_abs(jmi_ad_var_t v) {
    269     return COND_EXP_GE(v, AD_WRAP_LITERAL(0), v, -v);
    270 }
    271 
    272 jmi_ad_var_t jmi_sign(jmi_ad_var_t v) {
    273     return COND_EXP_GT(v, AD_WRAP_LITERAL(0), AD_WRAP_LITERAL(1),
    274         COND_EXP_LT(v, AD_WRAP_LITERAL(0), AD_WRAP_LITERAL(-1), AD_WRAP_LITERAL(0)));
    275 }
    276 
    277 jmi_ad_var_t jmi_min(jmi_ad_var_t x, jmi_ad_var_t y) {
    278     return COND_EXP_LT(x, y, x ,y);
    279 }
    280 
    281 jmi_ad_var_t jmi_max(jmi_ad_var_t x, jmi_ad_var_t y) {
    282     return COND_EXP_GT(x, y, x ,y);
    283 }
    284 
    285 jmi_real_t jmi_dround(jmi_real_t x) {
    286         return (x >= 0)? floor(x + 0.5) : floor(x - 0.5);
    287 }
    288 
    289 jmi_real_t jmi_dremainder(jmi_real_t x, jmi_real_t y) {
    290         jmi_real_t res = fmod(x,y);
    291         return ((jmi_abs(res-y)/jmi_max(x,y))<JMI_ALMOST_EPS)? (res-y)/jmi_max(x,y) : res/jmi_max(x,y);
    29251}
    29352
  • trunk/RuntimeLibrary/src/jmi/jmi_util.h

    r8497 r8556  
    3737
    3838#include "jmi_dyn_mem.h"
     39#include "jmi_types.h"
     40#include "jmi_math.h"
    3941
    4042/**
     
    107109
    108110/* Forward declaration of jmi structs */
    109 typedef struct jmi_t jmi_t;                               /**< \brief Forward declaration of struct. */
    110 typedef struct jmi_dae_t jmi_dae_t;                       /**< \brief Forward declaration of struct. */
    111 typedef struct jmi_init_t jmi_init_t;                     /**< \brief Forward declaration of struct. */
    112 typedef struct jmi_func_t jmi_func_t;                     /**< \brief Forward declaration of struct. */
    113 typedef struct jmi_block_residual_t jmi_block_residual_t; /**< \brief Forward declaration of struct. */
    114 typedef struct jmi_cs_input_t jmi_cs_input_t;             /**< \brief Forward declaration of struct. */
    115 typedef struct jmi_ode_solver_t jmi_ode_solver_t;         /**< \brief Forward declaration of struct. */
    116 typedef struct jmi_ode_problem_t jmi_ode_problem_t;       /**< \brief Forward declaration of struct. */
    117 typedef struct jmi_color_info jmi_color_info;             /**< \brief Forward declaration of struct. */
    118 typedef struct jmi_simple_color_info_t jmi_simple_color_info_t;      /**< \brief Forward declaration of struct. */
    119 typedef struct jmi_delay_t jmi_delay_t;                   /**< \brief Forward declaration of struct. */
    120 typedef struct jmi_spatialdist_t jmi_spatialdist_t;       /**< \brief Forward declaration of struct. */
    121 typedef struct jmi_dynamic_state_set_t jmi_dynamic_state_set_t;       /**< \brief Forward declaration of struct. */
    122 typedef struct jmi_modules_t jmi_modules_t;               /**< \brief Forward declaration of struct. */
    123 typedef struct jmi_module_t jmi_module_t;                 /**< \brief Forward declaration of struct. */
    124111typedef struct jmi_chattering_t jmi_chattering_t;         /**< \brief Forward declaration of struct. */
    125112
     
    161148#define LOG_EXP_NOT(op)      (JMI_TRUE-(op))         /**< \brief Macro for logical expression not <br> */
    162149
    163 /* Define the machine epsilon */
    164 #define JMI_EPS 2.2204460492503131e-16
    165 #define JMI_ALMOST_EPS (JMI_EPS*100)
    166 
    167 #define ALMOST_ZERO(op) LOG_EXP_AND(ALMOST_LT_ZERO(op),ALMOST_GT_ZERO(op))
    168 #define ALMOST_LT_ZERO(op) (op<=JMI_ALMOST_EPS? JMI_TRUE: JMI_FALSE)
    169 #define ALMOST_GT_ZERO(op) (op>=-JMI_ALMOST_EPS? JMI_TRUE: JMI_FALSE)
    170 #define SURELY_LT_ZERO(op) (op<-JMI_ALMOST_EPS? JMI_TRUE: JMI_FALSE)
    171 #define SURELY_GT_ZERO(op) (op>JMI_ALMOST_EPS? JMI_TRUE: JMI_FALSE)
    172 
    173150
    174151/* Record creation macro */
     
    194171
    195172/**
    196  * Function for checking if a vector contains NAN values. Returns the
    197  * index of the NAN (if found) in the parameter index_of_nan
    198  */
    199 int jmi_check_nan(jmi_t *jmi, jmi_real_t* val, size_t n_val, jmi_int_t* index_of_nan);
    200 /**
    201  * Function to wrap division and report errors to the log, for use in functions.
    202  */
    203 jmi_ad_var_t jmi_divide_function(const char* name, jmi_ad_var_t num, jmi_ad_var_t den, const char* msg);
    204 
    205 /**
    206  * Function to wrap division and report errors to the log, for use in equations.
    207  */
    208 jmi_ad_var_t jmi_divide_equation(jmi_t *jmi, jmi_ad_var_t num, jmi_ad_var_t den, const char* msg);
    209 
    210 /**
    211  * Function to wrap the C pow function and report errors to the log, for use in functions.
    212  */
    213 jmi_ad_var_t jmi_pow_function(const char* name, jmi_ad_var_t x, jmi_ad_var_t y, const char* msg);
    214 
    215 /**
    216  * Function to wrap the C pow function and report errors to the log, for use in equations.
    217  */
    218 jmi_ad_var_t jmi_pow_equation(jmi_t *jmi, jmi_ad_var_t x, jmi_ad_var_t y, const char* msg);
    219 
    220 /**
    221  * Function to wrap the C exp function and report errors to the log, for use in functions.
    222  */
    223 jmi_ad_var_t jmi_exp_function(const char* name, jmi_ad_var_t x, const char* msg);
    224 
    225 /**
    226  * Function to wrap the C exp function and report errors to the log, for use in equations.
    227  */
    228 jmi_ad_var_t jmi_exp_equation(jmi_t *jmi, jmi_ad_var_t x, const char* msg);
    229 
    230 /**
    231  * Function to wrap the C log function and report errors to the log, for use in functions.
    232  */
    233 jmi_ad_var_t jmi_log_function(const char* name, jmi_ad_var_t x, const char* msg);
    234 
    235 /**
    236  * Function to wrap the C log function and report errors to the log, for use in equations.
    237  */
    238 jmi_ad_var_t jmi_log_equation(jmi_t *jmi, jmi_ad_var_t x, const char* msg);
    239 
    240 /**
    241  * Function to wrap the C log10 function and report errors to the log, for use in functions.
    242  */
    243 jmi_ad_var_t jmi_log10_function(const char* name, jmi_ad_var_t x, const char* msg);
    244 
    245 /**
    246  * Function to wrap the C log10 function and report errors to the log, for use in equations.
    247  */
    248 jmi_ad_var_t jmi_log10_equation(jmi_t *jmi, jmi_ad_var_t x, const char* msg);
    249 
    250 /**
    251  * Function to wrap the C sinh function and report errors to the log, for use in functions.
    252  */
    253 jmi_ad_var_t jmi_sinh_function(const char* name, jmi_ad_var_t x, const char* msg);
    254 
    255 /**
    256  * Function to wrap the C sinh function and report errors to the log, for use in equations.
    257  */
    258 jmi_ad_var_t jmi_sinh_equation(jmi_t *jmi, jmi_ad_var_t x, const char* msg);
    259 
    260 /**
    261  * Function to wrap the C cosh function and report errors to the log, for use in functions.
    262  */
    263 jmi_ad_var_t jmi_cosh_function(const char* name, jmi_ad_var_t x, const char* msg);
    264 
    265 /**
    266  * Function to wrap the C cosh function and report errors to the log, for use in equations.
    267  */
    268 jmi_ad_var_t jmi_cosh_equation(jmi_t *jmi, jmi_ad_var_t x, const char* msg);
    269 
    270 /**
    271  * Function to wrap the C tan function and report errors to the log, for use in functions.
    272  */
    273 jmi_ad_var_t jmi_tan_function(const char* name, jmi_ad_var_t x, const char* msg);
    274 
    275 /**
    276  * Function to wrap the C tan function and report errors to the log, for use in equations.
    277  */
    278 jmi_ad_var_t jmi_tan_equation(jmi_t *jmi, jmi_ad_var_t x, const char* msg);
    279 
    280 /**
    281173 * Set the terminate flag and log message.
    282174 */
    283175void jmi_flag_termination(jmi_t *jmi, const char* msg);
    284 
    285 /**
    286  * Function to get the absolute value.
    287  * Is a separate function to avoid evaluating expressions several times.
    288  */
    289 jmi_ad_var_t jmi_abs(jmi_ad_var_t v);
    290 
    291 /**
    292  * Function to get the absolute value.
    293  * Is a separate function to avoid evaluating expressions several times.
    294  */
    295 jmi_ad_var_t jmi_sign(jmi_ad_var_t v);
    296 
    297 /**
    298  * Function to get the smaller of two values.
    299  * Is a separate function to avoid evaluating expressions twice.
    300  */
    301 jmi_ad_var_t jmi_min(jmi_ad_var_t x, jmi_ad_var_t y);
    302 
    303 /**
    304  * Function to get the larger of two values.
    305  * Is a separate function to avoid evaluating expressions twice.
    306  */
    307 jmi_ad_var_t jmi_max(jmi_ad_var_t x, jmi_ad_var_t y);
    308 
    309 /**
    310  * The sample operator. Returns true if time = offset + i*h, i>=0 during
    311  * handling of an event. During continuous integration, false is returned.
    312  *
    313  */
    314 jmi_ad_var_t jmi_sample(jmi_t* jmi, jmi_real_t offset, jmi_real_t h);
    315 
    316 /**
    317  * The round function for double numbers.
    318  *
    319  */
    320 jmi_real_t jmi_dround(jmi_real_t x);
    321 
    322 /**
    323  * The remainder function for double numbers.
    324  *
    325  */
    326 jmi_real_t jmi_dremainder(jmi_real_t x, jmi_real_t y);
    327176
    328177/* @} */
Note: See TracChangeset for help on using the changeset viewer.