julenum/nums
General package for numerical collection handling.
Index
fn Equal[S: ~[]T, T: numeric](a: S, b: S): bool
fn EqualApprox[S: ~[]T, T: ~f64 | ~cmplx128](a: S, b: S, tol: f64): bool
fn Sum[S: ~[]T, T: numeric](x: S): T
fn Add[S: ~[]T, T: numeric](mut z: S, x: S, y: S): S
fn Sub[S: ~[]T, T: numeric](mut z: S, x: S, y: S): S
fn Mul[S: ~[]T, T: numeric](mut z: S, x: S, y: S): S
fn Div[S: ~[]T, T: numeric](mut z: S, x: S, y: S): S
fn AddScalar[S: ~[]T, T: numeric](mut z: S, x: S, k: T): S
fn SubScalar[S: ~[]T, T: numeric](mut z: S, x: S, k: T): S
fn MulScalar[S: ~[]T, T: numeric](mut z: S, x: S, k: T): S
fn DivScalar[S: ~[]T, T: numeric](mut z: S, x: S, k: T): S
Equal
#disable boundary
fn Equal[S: ~[]T, T: numeric](a: S, b: S): boolReturns true when the slices have equal lengths and all elements are numerically identical.
EqualApprox
#disable boundary
fn EqualApprox[S: ~[]T, T: ~f64 | ~cmplx128](a: S, b: S, tol: f64): boolReturns true when the slices have equal lengths and all element pairs have an absolute tolerance less than tol or a relative tolerance less than tol.
Sum
#disable boundary
fn Sum[S: ~[]T, T: numeric](x: S): TReturns the sum of the elements of the slice.
Formula:
sum = Σᵢ [ xᵢ ]Add
fn Add[S: ~[]T, T: numeric](mut z: S, x: S, y: S): SSets z to the sum x+y and returning it. All slices must have same length.
Formula:
zᵢ = xᵢ+yᵢSub
fn Sub[S: ~[]T, T: numeric](mut z: S, x: S, y: S): SSets z to the difference x-y and returning it. All slices must have same length.
Formula:
zᵢ = xᵢ-yᵢMul
fn Mul[S: ~[]T, T: numeric](mut z: S, x: S, y: S): SSets z to the product x*y and returning it. All slices must have same length.
Formula:
zᵢ = xᵢ*yᵢDiv
fn Div[S: ~[]T, T: numeric](mut z: S, x: S, y: S): SSets z to the product x/y and returning it. All slices must have same length.
Formula:
zᵢ = xᵢ/yᵢAddScalar
fn AddScalar[S: ~[]T, T: numeric](mut z: S, x: S, k: T): SSets z to the sum x+k and returning it. All slices must have same length.
Formula:
zᵢ = xᵢ+kSubScalar
fn SubScalar[S: ~[]T, T: numeric](mut z: S, x: S, k: T): SSets z to the difference x-k and returning it. All slices must have same length.
Formula:
zᵢ = xᵢ-kMulScalar
fn MulScalar[S: ~[]T, T: numeric](mut z: S, x: S, k: T): SSets z to the product x*k and returning it. All slices must have same length.
Formula:
zᵢ = xᵢ*kDivScalar
fn DivScalar[S: ~[]T, T: numeric](mut z: S, x: S, k: T): SSets z to the division x/k and returning it. All slices must have same length.
Formula:
zᵢ = xᵢ/k