import { CalendarUnit, EastFunction, RoundFunction, RoundingMode, TimeUnit } from '../functions'; import { DateTimeType, FloatType, IntegerType, NullType, Nullable, PromoteType, ValueTypeOf } from '../types'; /** * Convert `from` to the specified `type`. * * Note: the output may approximate large integers by the nearest 64-bit floating-point value. * * @param from the {@link Expression} to convert * @param type the {@link EastType} to convert to * * @category Expression * * @example * ```typescript * // ... * // convert a percentage to a ratio * Ratio: Divide(Convert(Variable('Percentage', IntegerType), FloatType), 100), * // ... * ``` */ export declare function Convert(from: EastFunction>, type: Nullable): EastFunction>; export declare function Convert(from: EastFunction, type: FloatType): EastFunction; /** * Convert `from` to the specified `type`. * * Note: the output may approximate floating-point numbers by rounding towards zero to the nearest 64-bit signed-integer value. `NaN` is converted to `0n`. * * @param from the {@link Expression} to convert * @param type the {@link EastType} to convert to * * @category Expression * * @example * ```typescript * // ... * // convert a ratio to a percentage * Percentage: Convert(Multiply(Variable('Ratio', FloatType), 100), IntegerType), * // ... * ``` */ export declare function Convert(from: EastFunction>, type: Nullable): EastFunction>; export declare function Convert(from: EastFunction, type: IntegerType): EastFunction; /** * Add `first` to `second`. These can either be integer of float expressions. Combining * float with integer will result in a float. * * @param first the first {@link Expression} to add * @param second the second {@link Expression} to add * * @category Expression * * @example * ```typescript * // ... * // return the bank balance after a sale is deposited * NewBalance: Add( * Variable('Balance', FloatType), * Variable('SaleTotal', FloatType) * ), * // return the number of stock after a quantity is purchased * NewStockLevel: Add( * Variable('StockLevel', IntegerType), * Variable('PurchaseQuantity', IntegerType) * ), * // ... * ``` */ export declare function Add>(first: U, second: EastFunction): EastFunction; export declare function Add>(first: EastFunction, second: U): EastFunction; export declare function Add(first: EastFunction, second: EastFunction): EastFunction>; /** * Subtract `second` from `first`. These can either be integer of float expressions. * Combining float with integer will result in a float. * * @param first the {@link Expression} to subtract from * @param second the {@link Expression} amount to subtract * * @category Expression * * @example * ```typescript * // ... * // return the bank balance after a purchase is made * NewBalance: Subtract( * Variable('Balance', FloatType), * Variable('PurchaseTotal', FloatType) * ), * // return the number of stock after a quantity is sold * NewStockLevel: Subtract( * Variable('StockLevel', IntegerType), * Variable('SaleQuantity', IntegerType) * ), * // ... * ``` */ export declare function Subtract>(first: U, second: EastFunction): EastFunction; export declare function Subtract>(first: EastFunction, second: U): EastFunction; export declare function Subtract(first: EastFunction, second: EastFunction): EastFunction>; /** * Multiply `first` by `second`. * * @param first the first {@link Expression} to multiply * @param second the second {@link Expression} to multiply * * @category Expression * * @example * ```typescript * // ... * // return the total price of a quantity of products with a given unit price * TotalPrice: Multiply( * Variable('UnitPrice', FloatType), * Variable('Quantity', FloatType) * ), * // return the number of calendar days in NumberOfWeeks * NumberOfDays: Multiply( * Variable('NumberOfWeeks', IntegerType), * 7n * ), * // ... * ``` */ export declare function Multiply>(first: U, second: EastFunction): EastFunction; export declare function Multiply>(first: EastFunction, second: U): EastFunction; export declare function Multiply(first: EastFunction, second: EastFunction): EastFunction>; /** * Divide `first` by `second`. * * @param first the initial {@link Expression} to divide * @param second the {@link Expression} to divide by * * @category Expression * * @example * ```typescript * // ... * // return the average revenue collected each trading day * RevenuePerDay: Divide( * Variable('TotalRevenue', FloatType), * Variable('DaysOpen', FloatType) * ), * // ... * ``` */ export declare function Divide>(first: U, second: EastFunction): EastFunction : FloatType>; export declare function Divide>(first: EastFunction, second: U): EastFunction : FloatType>; export declare function Divide(first: EastFunction, second: EastFunction): EastFunction : U extends NullType ? Nullable : FloatType>; /** * Find the remainder when deviding `first` by `second`. * * @param first the initial {@link Expression} to divide * @param second the {@link Expression} to divide by * * @category Expression * * @example * ```typescript * // ... * // return true if X is an even integer, or false if X is an odd integer * IsEven: Equal( * Modulo( * Variable('X', IntegerType), * 2n * ), * 0n * ), * // ... * ``` */ export declare function Modulo(first: number, second: EastFunction): EastFunction : FloatType>; export declare function Modulo(first: EastFunction, second: bigint): EastFunction : FloatType>; export declare function Modulo(first: EastFunction, second: EastFunction): EastFunction : U extends NullType ? Nullable : FloatType>; export declare function Modulo(first: bigint, second: EastFunction): EastFunction : IntegerType>; export declare function Modulo(first: EastFunction, second: bigint): EastFunction : IntegerType>; export declare function Modulo(first: EastFunction, second: EastFunction): EastFunction : U extends NullType ? Nullable : IntegerType>; /** * Round datetime `value` to a whole time `unit` ("year", "month", "week", "day", "hour", "minute", "second"), using `rounding_mode` of "nearest", "floor" (round down) or "ceiling" (round up). * * @param value the {@link Expression} to round * @param rounding_mode 'nearest', 'floor' (always round down) or 'ceiling' (always round up) * @param unit 'year', 'month', 'week', 'day', 'hour', 'minute' or 'second' * * @category Expression * * @example * ```typescript * // ... * // return the instant at the beginning of the week * WholeHoursWorked: Round( * Variable('Date', DateTimeType), * 'floor', * 'week' * ), * // ... * ``` */ export declare function Round(value: EastFunction, rounding_mode: RoundingMode, unit: TimeUnit | CalendarUnit): RoundFunction; /** * Round number `value` to an integer, using `rounding_mode` of "nearest" (default), "floor" (round down) or "ceiling" (round up). * * @param value the {@link Expression} to round * @param rounding_mode 'nearest', 'floor' (always round down) or 'ceiling' (always round up) * @param unit IntegerType * * @category Expression * * @example * ```typescript * // ... * // return the number of whole hours worked on a shift (rounded down) * WholeHoursWorked: Round( * Variable('HoursWorked', FloatType), * 'floor', * 'integer' * ), * // ... * ``` */ export declare function Round(value: EastFunction, rounding_mode: RoundingMode, type: 'integer'): RoundFunction : IntegerType>; /** * Round number `value` to a whole number, using `rounding_mode` of "nearest" (default), "floor" (round down) or "ceiling" (round up). * * @param value the {@link Expression} to round * @param rounding_mode 'nearest', 'floor' (always round down) or 'ceiling' (always round up) * * @category Expression * * @example * ```typescript * // ... * // return the quantity rounded to the nearest whole number * RoundedQuantity: Round( * Variable('Quantity', FloatType), * 'nearest' * ), * // ... * ``` */ export declare function Round(value: EastFunction, rounding_mode?: RoundingMode, type?: 'float'): RoundFunction; /** * Round the number to the specified number of significant digits, e.g. 1234.5 -> 1200.0. * * @param value the {@link Expression} to round * @param significant_digits number of significant digits to keep * * @category Expression */ export declare function RoundPrecision(value: EastFunction, significant_digits: number): EastFunction; /** * Round the integer to the specified number of significant digits, e.g. 1234 -> 1200. * * @param value the {@link Expression} to round * @param significant_digits number of significant digits to keep * * @category Expression * * */ export declare function RoundPrecision(value: EastFunction, significant_digits: number): EastFunction; /** * Return the square root of a number. * * @param value the {@link Expression} to find the square root of * * @category Expression * * @example * ```typescript * // ... * // return the quantity rounded to the nearest whole number * StandardDeviation: Sqrt(Variable('Variance', FloatType)), * // ... * ``` */ export declare function Sqrt(value: EastFunction): EastFunction; /** * Return the square root of an integer (returning a floating-point number). * * @param value the {@link Expression} to find the square root of * * @category Expression * */ export declare function Sqrt(value: EastFunction): EastFunction : FloatType>; /** * Return the natural logarithm of a number (base _e_). * * @param value the {@link Expression} to find the natural logarithm of * * @category Expression * * @example * ```typescript * // ... * // transform a positive variable into a logarithmic scale * XLog: Log(Variable('X', FloatType)), * // ... * ``` */ export declare function Log(value: EastFunction): EastFunction; /** * Return the (natural) exponential of a number (i.e. power with base _e_). * * @param value the {@link Expression} for the exponent * * @category Expression * * @example * ```typescript * // ... * // transform a variable from a logarithmic space to normal space * XExp: Exp(Variable('X', FloatType)), * // ... * ``` */ export declare function Exp(value: EastFunction): EastFunction; /** * Return the sine of a number. The input is specified in radians. * * @param value the {@link Expression} for the angle * * @category Expression * * @example * ```typescript * // ... * // calculate the sine of an angle * sin_x: Sin(x), * // ... * ``` */ export declare function Sin(value: EastFunction): EastFunction; /** * Return the cosine of a number. The input is specified in radians. * * @param value the {@link Expression} for the angle * * @category Expression * * @example * ```typescript * // ... * // calculate the cosine of an angle * cos_x: Cos(x), * // ... * ``` */ export declare function Cos(value: EastFunction): EastFunction; /** * Return the tangent of a number. The input is specified in radians. * * @param value the {@link Expression} for the angle * * @category Expression * * @example * ```typescript * // ... * // calculate the tangent of an angle * tan_x: Tan(x), * // ... * ``` */ export declare function Tan(value: EastFunction): EastFunction; /** * Return `first` to the power of `second`, `first ^ second`. * * @param value the {@link Expression} for the base * @param value the {@link Expression} for the exponent * * @category Expression * * @example * ```typescript * // ... * // find the cube root of X * Y: Pow(Variable('X', FloatType), 1/3), * // ... * ``` */ export declare function Pow(first: EastFunction, second: number): EastFunction; export declare function Pow(first: EastFunction, second: EastFunction): EastFunction;