# Special Operators

## sum

The sum operator sums the values of a quantity.
The operator only works on real float scalar.
p0y = sum(q0)          (sum from first value)
p0y = sum(q0,'yyyy mm dd hh mm ss.s') (sum from a selected time)
```
sum(q(k)) = q0(0) + q0(1) + ... + q0(k)

q0(0) is the first sample in the interval
q0(k) is the k'th sample in the interval
k = 0, 1, ... , n-1
n is number of samples in the interval

sum(q(k)'yyyy mm dd hh mm ss.s') =  q0(i) + q0(i+1) + ... + q0(k)
q0(i) is the first sample in the interval
with time greater or equal 'yyyy mm dd hh mm ss.s'
q0(k) is the k'th sample in the interval
k = i, i+1, ... , n-1

```

## diff

The diff operator calculate the diffence between the values of a quantity.
The operator only works on real float scalar.
p0y = diff(q0)
```
diff(q(k)) = q0(k+1) − q0(k)

q0(0) is the first sample in the data segment
q0(k) is the k'th sample in the data segment
k = 0, 1, ... , m-2
m is number of samples in the data segment

The time of the sample is set to the {t(k) + t(k+1)}/2
t(k) is the time of sample k
The number of samples in the data segment is reduced with one.

```

Updated Mar 20, 2009 by Bjørn Lybekk