if/else trinary boolean operator

This document describes the syntax of the if - else boolean operator. (MML).



if - else syntax

The if - else boolean operator is used only with equations that specify exact numerical relationships between variables. Arbitrary nesting of if - else operators is allowed.

if - else statements can have one of the following forms:

      var, var2, var3;
      var = if (expr1) expr2;
      var2 = if (expr1) expr2 else expr3;
      var3 = if (expr1) expr2 else (if (expr4) expr5 else expr3);         


where exprX are algebraic expression of variables, with expr1 and expr4 being of the boolean type. See Algebraic Expression Syntax for further information.

if - else example


// if else syntax:
math if_else {
  realDomain t;
  t.min=0; t.max=2*PI; t.delta=0.1;
  real amp = 1;
  real phase = 0;
  real u(t), v(t), w(t), x(t);
  u = amp*sin(t-phase);
  v = amp*cos(t-phase);
  w = if (t < PI) (u + v) else (u);
  x = if(t > PI) (u + v) else ( if (phase > 0) u else u-v );


 (Java required)


Comments or Questions?

Give feedback

Model development and archiving support at https://www.imagwiki.nibib.nih.gov/physiome provided by the following grants: NIH U01HL122199 Analyzing the Cardiac Power Grid, 09/15/2015 - 05/31/2020, NIH/NIBIB BE08407 Software Integration, JSim and SBW 6/1/09-5/31/13; NIH/NHLBI T15 HL88516-01 Modeling for Heart, Lung and Blood: From Cell to Organ, 4/1/07-3/31/11; NSF BES-0506477 Adaptive Multi-Scale Model Simulation, 8/15/05-7/31/08; NIH/NHLBI R01 HL073598 Core 3: 3D Imaging and Computer Modeling of the Respiratory Tract, 9/1/04-8/31/09; as well as prior support from NIH/NCRR P41 RR01243 Simulation Resource in Circulatory Mass Transport and Exchange, 12/1/1980-11/30/01 and NIH/NIBIB R01 EB001973 JSim: A Simulation Analysis Platform, 3/1/02-2/28/07.