Expressions
Expressions are used throughout Frida: in calculator mode, to transform data, to select points, and to define fit curves.
Uses
Calculator mode:
. 4+7 # yields 11
. sin(pi/2) # yields 1
. y[2,0,7] # y value of file 2, spectrum 0, point 7Transforming variables (ox, oy, op0, …):
3 > oy x^2 # set y := x^2 for all points in file 3
5 > op0 y[4,0,j] # initialize p0 from values in file 4Selecting points (dp, mr, md):
3 > dp y<10 # show all points with y < 10
3 > mr x>0 # retain only points where x > 0
3 > md x<=0 # equivalent: delete points where x ≤ 0Defining fit curves:
8 > cc p0 + p1*t # affine-linear fit curve for file 8Syntax
Top-level
expr:
<arithmetic_expr>
<function_evaluation>
resol ( <shift> ) # Dirac delta / resolution copy
conv ( <theory>, <shift> ) # convolution with resolution
<numeric_value>
<variable_reference>
t # running variable for curve evaluation
<curve_reference> ( <expr> ) # e.g. c[4](x-0.2)See Curves & fitting for resol and conv.
Arithmetic
arithmetic_expr:
( <expr> )
- <expr> # negation
! <expr> # boolean negation
<expr> <bin_op> <expr>
<expr> ? <expr> : <expr> # conditional (lowest precedence)Binary operators (decreasing precedence)
| Operator | Meaning |
|---|---|
+- |
error propagation (e.g. 193+-2) |
^ |
exponentiation |
over |
binomial coefficient (5 over 3 = 10) |
* / mod div |
multiply, divide, remainder, integer division |
+ - |
add, subtract |
> >= <= < |
comparison |
== != |
equality, inequality |
xor |
boolean exclusive or |
&& |
boolean and |
|| |
boolean or |
Numeric literals
numeric_value:
<integer> # e.g. 8 or -17
<floating point> # e.g. .2, 2.72, -3.7e-3
pi | e # hard-coded constantsVariable references
All indices are optional. Omitted indices are filled from the current context values k, j, i.
var_label:
k file number in memory
r0, r1, … file constants
dr0, … errors of file constants (not yet implemented)
nj number of spectra
jvar_label: (one index: j)
j spectrum index
z0, z1, … z coordinates
dz0, … errors of z coordinates (not yet implemented)
p0, p1, … fit parameters
dp0, … parameter errors
cq0-cq2 fit quality metrics
ni number of data points
ivar_label: (two indices: j, i)
i data point index
x x value
y y value
dy error of yShorthand examples:
xmeansx[k,j,i]x[8]meansx[8,j,i]x[,3]meansx[k,3,i]x[,,0]meansx[k,j,0]
Curve references
c # c[k,j] with k, j from context
c[<k>] # c[k,j] with j from context
c[<k>,<j>] # fully specifiedSee Indices & Loops for how Frida loops over files, spectra, and points, with worked examples of cross-workspace arithmetic.