The XSIM Expression Evaluator


1. Introduction

Mathematical expressions can be entered in a variety of places in XSIM. The constants and functions that may be used in these expressions are given below.

2. Evaluator Constants



Constant name

Value

Type

Comments

pi

3.1415...

double

Calculated as 4*atan(1)

e

2.7182...

double

Calculated as exp(1)

eps

~10^(-7)

float

Machine-dependent relative error

(See note)

deps

~10^(-16)

double

Machine-dependent relative error

(See note)

Note: eps and deps are the smallest values for which (1+eps) or (1+deps) is not equal to 1.

3. Evaluator Functions



Function name

# of arguments

Aliases

Comments

abs

1

absolute value

acos

1

arccos,

arccosine

inverse cosine (|arg| <= 1)

asin

1

arcsin,

arcsine

inverse sine (|arg| <= 1)

atan

1

arctan,

arctangent

inverse tangent

atan2

2

arctan2

inverse tangent(y,x)

bound

3

bound(lo,x,hi) returns lo<=x<=hi.

cos

1

cosine

cosh

1

hyperbolic cosine

erf

1

error function

erfc

1

complement of error function

exp

1

exponential

fract

1

fractional part of argument

int

1

integer part of argument

isdef

1

isdefined

isdef(x) returns TRUE if x is defined

log

1

ln

natural logarithm (arg > 0)

log10

1

base 10 logarithm (arg > 0)

log2

1

base 2 logarithm (arg > 0)

max

>0

maximum

maximum of arguments

min

>0

minimum

minimum of arguments

mod

2

modulo

remainder (double, real, int arguments)

pow

2

power

pow(x,y) = x**y (all numeric arg types)

ran

0

rand,

random

pseudo-random number from 0 <= x < 1

sin

1

sine

sine

sinh

1

hyperbolic sine

sqrt

1

square root (arg > 0)

tan

1

tangent

tangent

tanh

1

hyperbolic tangent

4. Conditional Expressions

The evaluator permits conditional expressions in a format which is familiar to C programmers:

      expression_1 ? expression_2 : expression_3

When the expression is evaluated, expression_1 is evaluated first. If it is true (non-zero), the expression is assigned the value resulting from the evaluation of expression_2. If expression_1 is false, the expression is assigned the value resulting from the evaluation of expression_3.

For example, the expression:

      Fp > 3.0 ? PSg : PSpc

is assigned the value of PSg when Fp is greater than 3.0 or PSpc otherwise.



Copyright 1995-1998, University of Washington
Last modified: 01:22pm PDT October 17, 1998