kumulant

Switch

@Serializable
@SerialName(value = "Switch")
data class Switch(val on: ScalarExpr, val cases: List<SwitchCase>, val otherwise: ScalarExpr) : ScalarExpr(source)

Multi-way branch on a scalar key. Replaces nested IfExpr cascades. The first case whose SwitchCase.value equals on.eval(...) exactly wins; if none match, otherwise is returned.

Constructors

Link copied to clipboard
constructor(on: ScalarExpr, cases: List<SwitchCase>, otherwise: ScalarExpr)

Properties

Link copied to clipboard

Cases checked in order.

Link copied to clipboard

Scalar expression whose value selects the case. Typically VIndex.

Link copied to clipboard

Returned when no case matches.

Functions

Link copied to clipboard
operator fun ScalarExpr.div(rhs: ScalarExpr): ScalarExpr

Build Div of two expressions.

operator fun ScalarExpr.div(rhs: Double): ScalarExpr

Divide this expression by a literal rhs.

Link copied to clipboard
infix fun ScalarExpr.eq(rhs: ScalarExpr): BoolExpr

Exact equality (no tolerance).

infix fun ScalarExpr.eq(rhs: Double): BoolExpr

Exact equality against a literal (no tolerance).

Link copied to clipboard
open override fun eval(x: Double, y: Double = 0.0, v: DoubleArray = EMPTY_VECTOR, primary: Result? = null): Double

Evaluate this expression against the per-update inputs. See the class KDoc for the input-environment convention.

Link copied to clipboard
infix fun ScalarExpr.ge(rhs: ScalarExpr): BoolExpr

Greater-or-equal comparison.

infix fun ScalarExpr.ge(rhs: Double): BoolExpr

Greater-or-equal against a literal.

Link copied to clipboard
infix fun ScalarExpr.gt(rhs: ScalarExpr): BoolExpr

Strictly-greater-than comparison.

infix fun ScalarExpr.gt(rhs: Double): BoolExpr

Strictly-greater-than against a literal.

Link copied to clipboard
infix fun ScalarExpr.le(rhs: ScalarExpr): BoolExpr

Less-or-equal comparison.

infix fun ScalarExpr.le(rhs: Double): BoolExpr

Less-or-equal against a literal.

Link copied to clipboard
infix fun ScalarExpr.lt(rhs: ScalarExpr): BoolExpr

Strictly-less-than comparison.

infix fun ScalarExpr.lt(rhs: Double): BoolExpr

Strictly-less-than against a literal.

Link copied to clipboard

Build Sub of two expressions.

operator fun ScalarExpr.minus(rhs: Double): ScalarExpr

Subtract a literal rhs from this expression.

Link copied to clipboard
operator fun ScalarExpr.plus(rhs: ScalarExpr): ScalarExpr

Build Add of two expressions.

operator fun ScalarExpr.plus(rhs: Double): ScalarExpr

Add a literal rhs to this expression.

Link copied to clipboard

Build Mul of two expressions.

operator fun ScalarExpr.times(rhs: Double): ScalarExpr

Multiply this expression by a literal rhs.

Link copied to clipboard

Unary minus: wraps in Neg.

Switch

constructor(on: ScalarExpr, cases: List<SwitchCase>, otherwise: ScalarExpr)(source)

cases

Cases checked in order.

eval

open override fun eval(x: Double, y: Double = 0.0, v: DoubleArray = EMPTY_VECTOR, primary: Result? = null): Double(source)

Evaluate this expression against the per-update inputs. See the class KDoc for the input-environment convention.

on

Scalar expression whose value selects the case. Typically VIndex.

otherwise

Returned when no case matches.