scalar-autograd
Version:
Scalar-based reverse-mode automatic differentiation in TypeScript.
281 lines (280 loc) • 8.19 kB
TypeScript
import { Value } from './Value';
export declare class V {
private static ensureValue;
/**
* Creates a constant Value (non-differentiable).
* @param value The numeric value
* @param label Optional label for the value
* @returns New constant Value
*/
static C(value: number, label?: string): Value;
/**
* Creates a weight Value (differentiable).
* @param value The numeric value
* @param label Optional label for the value
* @returns New differentiable Value
*/
static W(value: number, label?: string): Value;
/**
* Addition operation.
* @param a First operand
* @param b Second operand
* @returns New Value with sum
*/
static add(a: Value | number, b: Value | number): Value;
/**
* Multiplication operation.
* @param a First operand
* @param b Second operand
* @returns New Value with product
*/
static mul(a: Value | number, b: Value | number): Value;
/**
* Subtraction operation.
* @param a First operand
* @param b Second operand
* @returns New Value with difference
*/
static sub(a: Value | number, b: Value | number): Value;
/**
* Division operation.
* @param a Dividend
* @param b Divisor
* @param eps Small epsilon to prevent division by zero
* @returns New Value with quotient
*/
static div(a: Value | number, b: Value | number, eps?: number): Value;
/**
* Power operation with numeric exponent.
* @param a Base
* @param exp Exponent
* @returns New Value with result
*/
static pow(a: Value | number, exp: number): Value;
/**
* Power operation with Value exponent.
* @param a Base
* @param b Exponent
* @param eps Small epsilon for logarithm
* @returns New Value with result
*/
static powValue(a: Value | number, b: Value | number, eps?: number): Value;
/**
* Modulo operation.
* @param a Dividend
* @param b Divisor
* @returns New Value with remainder
*/
static mod(a: Value | number, b: Value | number): Value;
/**
* Absolute value operation.
* @param a Input value
* @returns New Value with absolute value
*/
static abs(a: Value | number): Value;
/**
* Exponential function.
* @param a Input value
* @returns New Value with e^a
*/
static exp(a: Value | number): Value;
/**
* Natural logarithm.
* @param a Input value
* @param eps Small epsilon for numerical stability
* @returns New Value with ln(a)
*/
static log(a: Value | number, eps?: number): Value;
/**
* Minimum of two values.
* @param a First value
* @param b Second value
* @returns New Value with minimum
*/
static min(a: Value | number, b: Value | number): Value;
/**
* Maximum of two values.
* @param a First value
* @param b Second value
* @returns New Value with maximum
*/
static max(a: Value | number, b: Value | number): Value;
/**
* Floor function.
* @param a Input value
* @returns New Value with floor
*/
static floor(a: Value | number): Value;
/**
* Ceiling function.
* @param a Input value
* @returns New Value with ceiling
*/
static ceil(a: Value | number): Value;
/**
* Round function.
* @param a Input value
* @returns New Value rounded to nearest integer
*/
static round(a: Value | number): Value;
/**
* Square function.
* @param a Input value
* @returns New Value with a B2
*/
static square(a: Value | number): Value;
/**
* Cube function.
* @param a Input value
* @returns New Value with a B3
*/
static cube(a: Value | number): Value;
/**
* Reciprocal function.
* @param a Input value
* @param eps Small epsilon to prevent division by zero
* @returns New Value with 1/a
*/
static reciprocal(a: Value | number, eps?: number): Value;
/**
* Clamp function.
* @param a Input value
* @param min Minimum bound
* @param max Maximum bound
* @returns New Value clamped between min and max
*/
static clamp(a: Value | number, min: number, max: number): Value;
/**
* Negation operation.
* @param a Input value
* @returns New Value which is negation
*/
static neg(a: Value | number): Value;
/**
* Sum of array of values.
* @param vals Array of values
* @returns New Value with sum
*/
static sum(vals: (Value | number)[]): Value;
/**
* Mean of array of values.
* @param vals Array of values
* @returns New Value with mean
*/
static mean(vals: (Value | number)[]): Value;
/**
* Sine function.
* @param x Input value
* @returns New Value with sin(x)
*/
static sin(x: Value | number): Value;
/**
* Cosine function.
* @param x Input value
* @returns New Value with cos(x)
*/
static cos(x: Value | number): Value;
/**
* Tangent function.
* @param x Input value
* @returns New Value with tan(x)
*/
static tan(x: Value | number): Value;
/**
* Arcsine function.
* @param x Input value
* @returns New Value with asin(x)
*/
static asin(x: Value | number): Value;
/**
* Arccosine function.
* @param x Input value
* @returns New Value with acos(x)
*/
static acos(x: Value | number): Value;
/**
* Arctangent function.
* @param x Input value
* @returns New Value with atan(x)
*/
static atan(x: Value | number): Value;
/**
* ReLU activation function.
* @param x Input value
* @returns New Value with max(0, x)
*/
static relu(x: Value | number): Value;
/**
* Softplus activation function.
* @param x Input value
* @returns New Value with ln(1 + e^x)
*/
static softplus(x: Value | number): Value;
/**
* Hyperbolic tangent function.
* @param x Input value
* @returns New Value with tanh(x)
*/
static tanh(x: Value | number): Value;
/**
* Sigmoid activation function.
* @param x Input value
* @returns New Value with 1/(1 + e^(-x))
*/
static sigmoid(x: Value | number): Value;
/**
* Equal comparison operation.
* @param a First operand
* @param b Second operand
* @returns New Value with 1 if equal, 0 otherwise
*/
static eq(a: Value | number, b: Value | number): Value;
/**
* Not equal comparison operation.
* @param a First operand
* @param b Second operand
* @returns New Value with 1 if not equal, 0 otherwise
*/
static neq(a: Value | number, b: Value | number): Value;
/**
* Greater than comparison operation.
* @param a First operand
* @param b Second operand
* @returns New Value with 1 if a > b, 0 otherwise
*/
static gt(a: Value | number, b: Value | number): Value;
/**
* Less than comparison operation.
* @param a First operand
* @param b Second operand
* @returns New Value with 1 if a < b, 0 otherwise
*/
static lt(a: Value | number, b: Value | number): Value;
/**
* Greater than or equal comparison operation.
* @param a First operand
* @param b Second operand
* @returns New Value with 1 if a >= b, 0 otherwise
*/
static gte(a: Value | number, b: Value | number): Value;
/**
* Less than or equal comparison operation.
* @param a First operand
* @param b Second operand
* @returns New Value with 1 if a <= b, 0 otherwise
*/
static lte(a: Value | number, b: Value | number): Value;
static ifThenElse(cond: Value | number, thenVal: Value | number, elseVal: Value | number): Value;
/**
* Square root function.
* @param a Input value
* @returns New Value with sqrt(a)
*/
static sqrt(a: Value | number): Value;
/**
* Sign function.
* @param a Input value
* @returns New Value with sign(a)
*/
static sign(a: Value | number): Value;
}