User Tools

Site Tools



Expressions are used in Frida at many different places. Some important uses are:

In calculator mode:

. 4+7            # yields 11
. sin(pi/2)      # yields 1
. y[2,0,7]       # yields the y value of file 2, spectrum 0, point 7

In operations like ox, oy, op0, …:

3 > oy x^2       # in file 3 (a data file), set y:=x^2
5 > op0 y[4,0,j] # in file 5 (a curve file), initialize p0 with a value taken from file 4

In commands dp, mr, md, evaluated as boolean to select data points:

3 > dp y<10      # show all points with y<10
3 > mr x>0       # retain points with x>0, delete all other points
3 > md x<=0      # another way of saying the same

Expressions are the standard means to define a fit curve:

8 > cc p0+p1*t   # create a curve to fit file 8, using an affine-linear function


In the following, a very basic variant of Backus-Naur form is used. A dot as in <an_integer_value.> indicates that the meaning of this node is so obvious that a formal definition is not needed.

  <arithmetic_expr>                     # arithmetic expression
  <function_evaluation>                 # built-in function
  resol ( <shift> )                     # Dirac delta function, copies a given resolution function
  conv ( <theory>, <shift> )            # convolutes 'theory' with a given resolution function
  <numeric_value>                       # like 1.23
  <variable_reference>                  # like x[3,0,j]
  t                                     # running variable for curve evaluation
  <curve_reference> ( <expr> )          # like c[4](x-0.2)

The special expressions resol, conv, t are explained in curves.

  ( <expr> )                            # parentheses around expression change nothing
  - <expr>                              # negative value
  ! <expr>                              # boolean negation
  <expr> <bin_op> <expr>                # binary operator, see below
  <expr> ? <expr> : <expr>              # conditional evaluation (lower precedence than all bin_op's)
bin_op: # ordered by decreasing precedence
  +-                                    # error ( e.g. 193+-2 )
  ^                                     # exponentiation
  over                                  # binomial coefficient, 5 over 3 = 5!/3!/2! = 10
  * | / | mod | div                     # multiplication, division, remainder, integer division
  + | -                                 # addition, subtraction
  > | >= | <= | <                       # comparison
  == | !=                               # equality, inequality
  xor                                   # boolean exclusive or
  &&                                    # boolean and
  ||                                    # boolean or
  ln ( <expr> )                         # natural logarithm
  ...                                   # many more functions of one argument
  min ( <expr>, <expr> )                # the smaller of the two arguments
  ...                                   # some more functions of two arguments
  rehavneg ( <expr>, <expr>, <expr> )   # real part of the Havrialiak-Negami function
  ...                                   # some more functions of three arguments

for a full listing of built-in functions, see built-in functions, or use hf at the FRIDA main level

  <an_integer_number.>                  # like 8 or -17
  <a_floating_point_number.>            # like .2 or 2.72 or -3.7e-3
  pi | e                                # these two mathematic constants are hard-coded
  var_label                             # e.g. y, meaning y[k,j,i] with k,j,i given by context
  var_label [ <expr> ]                  # e.g. p0[8]
  jvar_label [ <expr>, <expr> ]         # e.g. z2[6,3]
  ivar_label [ <expr>, <expr>, <expr> ] # e.g. x[6,3,18]

Note: above, “[” and “]” are not BNF notation to indicate an optional argument; they stand for real brackets. Actually, all indices are optional: if omitted, the default values k,j,i are filled in, depending on position.

  k                                     # number of file in online memory   
  r<num.>                               # file constants r0, r1, ...
  dr<num.>                              # error thereof (not yet implemented)
  nj                                    # number of spectra
  jvar_label                            # j-dependent variable (j is the spectrum index)
  j                                     # index of spectrum
  z<num.>                               # z variables z0, z1, ...
  dz<num.>                              # error thereof (not yet implemented)
  p<num.>                               # curve parameters p0, p1, ...
  dp<num.>                              # error thereof (not yet implemented)
  cq<num.>                              # curve quality cq0, cq1, cq2
  ni                                    # number of data points
  ivar_label                            # i-dependent variable (i is the data point index)
  i                                     # index of data point
  x                                     # x value
  y                                     # y value
  dy                                    # error thereof
  c                                     # c, meaning c[k,j], with k,j given by context
  c [ <expr> ]                          # e.g. c[3], meaning c[3,j], with j given by context
  c [ <expr>, <expr> ]                  # e.g. c[3,0]

Same note as for variable_reference: “[” and “]” are not BNF notation to indicate an optional argument; they stand for real brackets. All indices are optional: if omitted, the default values k,j are filled in, depending on position.

Context-dependent evaluation: running variables k,j,i

How expressions are evaluated depends on the context in which they are used. For instance, the way dirac and conv are evaluated depends on whether or not a convolutand is set. See curves for more on this.

In evaluating variable references like x or y[0,k-3,j] implicit or explicit use is made of running indices k, j, i. A reference without index, like x, is just a shortcut for x[k,j,i]. Any of these indices may be omitted:

  • x[8] stands for x[8,j,i];
  • x[,3] stands for x[k,3,i];
  • x[,,0]] stands for x[k,j,0]; and so on.

Depending on context, loops are performed over k, j, i.

Loop over k

The variable k stands for the number of a file in the online memory. Whenever a command is performed for a given file selection, this can be seen as running a loop over k. For instance, in the simple command

3-5 > . y[,0,3]

the value y[k,0,3] is shown, with k taking successively the values 3, 4, 5, as given by the preset file selection indicated in the prompt.

A more complex example: files 10 to 13 are curve files. Then the command

? > 10:13 cd k-8

means, that curve file 10 shall be fitted to data file 10-8=2, curve file 11 to data file 3, and so on.

Loops over j and i

A command like oy implies a loop over j and i:

4 > oy x^2

is executed as follows:

for all j with 0<=j<nj:
  for all i with 0<=i<ni[j]:
    let y[k,j,i] := x[k,j,i]^2

In contrast, a command like oz0 or op2 or oi implies a loop over j only.

Not up to date.