Daylight v4.9
Release Date: 1 February 2008


expression - Syntax for Expression Evaluator


The toolkit includes a generic expression evaluator which is used for the dt_fp_similarity(3) function. The syntax of the expression language is straightforward. All computations are performed using double arithmetic.

There are two basic types, variables and constants.

The variables are one of:

a - count of bits on in fp1, not on in fp2
b - count of bits on in fp2, not on in fp1
c - count of bits on in both fp1 and fp2
d - count of bits off in both fp1 and fp2

Constants are always double-precision numbers expressed as either a whole number or a decimal number (exponent notation is not supported). Examples include: 1, 1.0, 1.00004, 243.333.

Unary Operators are (x refers to any valid subexpression):

-x       Negation
sqrt(x)  Square root

Binary Operators are (x1 and x2 refer to valid subexpressions):

x1+x2       Addition
x1-x2       Subtraction
x1*x2       Multiplication
x1/x2       Division
x1^x2       Raise x1 to the x2 power
min(x1,x2)  Minimum
max(x1,x2)  Maximum

Parentheses are used to modify operator association (left-to-right) and precedence from the default:

-       Unary negation
^       Exponentiation
*, /    Multiplication/division
+, -    Binary addition/subtraction

In addition to the above, the expression evaluator recognizes the following built-in named expressions:

TANIMOTO         -  c/(a+b+c)
EUCLID           -  sqrt((c+d)/(a+b+c+d))
DICE             -  (2.0*c)/((a+c)+(b+c))
COSINE           -  c/sqrt((a+c)*(b+c))
KULCZYNSKI       -  0.5*((c/(a+c))+(c/(b+c)))
JACCARD          -  c/(a+b+c)
RUSSELL/RAO      -  c/(a+b+c+d)
MATCHING         -  (c+d)/(a+b+c+d)
HAMMAN           -  ((c+d)-(a+b))/(a+b+c+d)
ROGERS/TANIMOTO  -  (c+d)/((a+b)+(a+b+c+d))
FORBES           -  (c*(a+b+c+d))/((a+c)*(b+c))
SIMPSON          -  c/min((a+c),(b+c))
PEARSON          -  (c*d-a*b)/sqrt((a+c)*(b+c)*(a+d)*(b+d))
YULE             -  (c*d-a*b)/(c*d+a*b)
MAHNATTAN        -  (a+b)/(a+b+c+d)

Related Topics