Skip to main content

trend_row

Function trend_row 

Source
pub fn trend_row(t: u64, knots: &[u64], row: &mut [f64])
Expand description

Writes the trend regressors of time t into row: t itself, then the hinge max(0, t - s) of each changepoint s of knots, in order. The function needs no heap, so a device can build the row of each new value as it arrives.

§Panics

Panics if row does not hold knots.len() + 1 values.

§Examples

use backshift::trend_row;

let mut row = [0.0; 3];
trend_row(50, &[20, 80], &mut row);
assert_eq!(row, [50.0, 30.0, 0.0]);