### Introduction

The Eval facility is an expandable and versatile class library for evaluating expressions of mixed type. It adds the Eval function to the STx programming language.

Eval supports real and complex numeric data as well as vectors and matrices of real and complex numbers. Eval supplies a large number of operations and functions for each kind of data, ranging from scalar and vector additions to statistical functions, order analysis, and signal processing (e.g. the Fourier transformation, several kinds of windowing functions, filtering functions, etc.).

The Eval functionality is an improvement over the historically grown evaluation functions already present in the STx macro language, including the int and num keywords and the position-dependent implicit argument evaluation. Eval combines all their functionality with a large and growing part of the functions that have traditionally been available only for SPU programmers. Over time, Eval is intended to provide a uniform and homogeneous means of accessing any of the diverse STx functions, regardless of their individual history.

### Benefits

- Eval offers a uniform and homogeneous interface to the numeric functions available in STx, including those that were available only to SPU programmers in the past.
- Eval empowers the STx programmer to use the programming design and style that best suits his or her needs, without being guided by existing restrictions like access only via SPUs. Thus, algorithmic problems may now be solved algorithmically, whereas the use of SPUs may be restricted to problems where there is a continuous flow of data that must be processed online.
- Eval offers support for reference arguments. This means that an Eval function may return more than one data item (be it a number, a vector, or a matrix), which is not possible with the existing int, num, and implicit argument evaluation because of their outdated design. The support for reference arguments makes the interfaces of many functions more natural and, in some cases, is a necessary condition for implementing them at all (as opposed to offering them as SPU atoms only). At this time, there is already a growing number of functions that make use of this feature.
- Due to the power of the already existing Eval functions, even complex calculations may be done by typing relatively simple formulae. By resulting in STx macro expressions that are shorter and more readable, this speeds up STx-based software development processes. It also both reduces the likelihood of programming errors happening and speeds up debugging and future maintenance.
- Due to its carefully laid-out design, Eval offers a very thorough and fine-grained kind of error checking and reporting that has not been possible with the outdated int, num, and implicit argument evaluation. Compared with the traditional evaluation routines, Eval offers more than 25 additional error codes and error messages, thereby helpfully pointing even the less experienced programmer to the cause of their error.
- Eval uses a manually laid-out, and manually optimized recursive descent parser (meaning that no excessively complicated or time-consuming compiling tools must be involved). This results in a very short and straightforward C++ source code that is easy to read and to extend and that compiles to a very compact and cache-effective binary object.
- The STx integration of research results has further improved with the availability of Eval due to the fact that researchers may directly integrate their algorithms with the Eval functionality instead of programming SPU atoms of their own, as was necessary in the past.

### Design

The Eval class implements a single-pass, recursive-descent parser for the following grammar:

The functionality of Eval is implemented in the CExEval class. Built-in functions are listed in a table both referring to their implementation and containing information of the number and kind of the arguments to the respective function. Adding a new built-in function is done by providing an implementation for the respective function and by adding an entry to the aforementioned table.

### Available Eval functions

The following is a short list of some of the most important Eval functions available so far:

- measurement functions: Cols, Rows, Min, Max, IMin, IMax, Sum, WSum, Abs, QDet
- vector initialization and transformation: Fill, Init, Rand, VSubC, VSubN, Select, Sort, VV, VVCat, VVSet, VMCol, VMRow, Interp,Trn
- trigonometric, transcendental, and other special functions: Sin, Cos, Tan, ASin, ACos, ATan, Exp, Sqrt, Log, Ln, Ld, Pi, E
- complex arithmetic: CR2P, CP2R, CR2Len, CR2Phi, CGet, CSet, CMul
- integration and differentiation: YDiff, YInt
- statistics: Avr, Var, StdDev, Corr, Median, Hist, Dist, ModClust, HAClust, EM (Expectation Maximization), Density
- data conversion: Lin2Log, Log2Lin, Hz2Cent, Cent2Hz, Hz2Bark, Bark2Hz, Hz2Mel, Mel2Hz, Hz2ERB, ERB2Hz
- signal windowing functions: Window, WHanning, WHamming, WBartlett, WTapRect, WNutTall, WFlatTop, WBlackman, WKaiser, WGauss
- signal processing: FFT, IFFT, DFT, Cepstrum, LPC, DCT, ZCross, IIR1, IIR2, FIR1, FIR2
- order spectrum analysis: otrack1, sig2osp, asp2osp, ticks2f1
- miscellaneous functions: IPeak, QInterp, RPoly, RPolyRef, HTH, ASeg1