Skip to content

LaTiS Arithmetic

Doug Lindholm edited this page Jun 3, 2015 · 4 revisions

The LaTiS DSL (Domain Specific Language) is designed to directly support mathematical operations. If your Dataset contains a Function that represents a time series of temperatures in Celcius (ds: time -> temp), you can convert to Fahrenheit by applying the operation directly to the Dataset (ds) without having to dig into the internals of the Dataset. Because LaTiS Datasets are immutable, the result will be a new Dataset.

ds * 8/5 + 32

There are rules such that arithmatic operations will be applied to range values leaving the domain values unchanged. The type of the first operand of a binary operation typically determines how it will be applied. Note that primitives can be implicitly converted to Scalar Variables. Arithmetic operations will result in numerical data values being represented as Reals (no Integer math, for now). Text Variables result in a NaN.

Let's take addition as an example to demonstrate how each type (Scalar, Tuple, Function) handles binary operations with another type of LaTiS Variable.

Rules for a Scalar (s) as the second operand:

Scalar (a): a + s

Tuple (a,b,c): (a+s, b+s, c+s)

Function d -> r: d -> r+s (applied to each sample)

Rules for a Tuple (x,y,z) as the second operand:

Scalar (a): (a+x, a+y, a+z)

Tuple (a,b,c): (a+x, b+y, c+z) Error if each Tuple doesn't have the same number of elements.

Function d -> r: d -> r+(x,y,z) where other rules apply based on the type of the range r.

Rules for a Function x -> y as the second operand. Other rules apply recursively.

Scalar (a): x -> a+y

Tuple (a,b,c): x -> (a,b,c) + y

Function d -> r: d -> r+y If the domain set of the second Function is not the same as the first, the second Function will be resampled onto the domain of the first based on a resampling strategy.

Clone this wiki locally