UNPKG

mathjslab

Version:

MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.

271 lines (270 loc) 5.79 kB
/** * Filename: `MathOperation.ts` * Description: Definitions of mathematical operations on elements of various * basic types. */ import { type ElementType } from './MultiArray'; /** * Generic mathematical object. */ type MathObject = ElementType; /** * Unary mathematical operations. */ type UnaryMathOperation = (expression: MathObject) => MathObject; /** * Binary mathematical operations. */ type BinaryMathOperation = (left: MathObject, right: MathObject) => MathObject; /** * Unary mathematical operations. */ type MathOperationType = UnaryMathOperation | BinaryMathOperation; /** * Key of type of `MathOperation`. The keys of `MathOperation` class. */ type KeyOfTypeOfMathOperation = keyof typeof MathOperation; /** * # `MathOperation` * * Mathematical operations on generic elements. * */ declare abstract class MathOperation { /** * Creates a copy of `MathObject` object. * @param right * @returns */ static readonly copy: UnaryMathOperation; /** * Element-Wise operations. * @param op * @param left * @param right * @returns */ private static readonly elementWiseOperation; /** * Left associative operations. * @param op * @param right * @returns */ private static readonly leftOperation; /** * Plus operation (`+`). * @param left * @param right * @returns */ static readonly plus: BinaryMathOperation; /** * Minus operation (`-`). * @param left * @param right * @returns */ static readonly minus: BinaryMathOperation; /** * Mod operation. * @param left * @param right * @returns */ static readonly mod: BinaryMathOperation; /** * Rem operation. * @param left * @param right * @returns */ static readonly rem: BinaryMathOperation; /** * Times operation (`.*`). * @param left * @param right * @returns */ static readonly times: BinaryMathOperation; /** * Matrix multiplication operator (`*`). * @param left * @param right * @returns */ static readonly mtimes: BinaryMathOperation; /** * Right division operator (`./`). * @param left * @param right * @returns */ static readonly rdivide: BinaryMathOperation; /** * Matrix right division operator (`/`). * @param left * @param right * @returns */ static readonly mrdivide: BinaryMathOperation; /** * Left division operator (`.\`). * @param left * @param right * @returns */ static readonly ldivide: BinaryMathOperation; /** * Matrix left division operator (`\`). * @param left * @param right * @returns */ static readonly mldivide: BinaryMathOperation; /** * Power operator (`.^`). * @param left * @param right * @returns */ static readonly power: BinaryMathOperation; /** * Matrix power operator (`^`). * @param left * @param right * @returns */ static readonly mpower: BinaryMathOperation; /** * * @param right * @returns */ static readonly uplus: UnaryMathOperation; /** * * @param right * @returns */ static readonly uminus: UnaryMathOperation; /** * * @param left * @returns */ static readonly transpose: UnaryMathOperation; /** * * @param left * @returns */ static readonly ctranspose: UnaryMathOperation; /** * * @param left * @param right * @returns */ static readonly lt: BinaryMathOperation; /** * * @param left * @param right * @returns */ static readonly le: BinaryMathOperation; /** * * @param left * @param right * @returns */ static readonly eq: BinaryMathOperation; /** * * @param left * @param right * @returns */ static readonly ge: BinaryMathOperation; /** * * @param left * @param right * @returns */ static readonly gt: BinaryMathOperation; /** * * @param left * @param right * @returns */ static readonly ne: BinaryMathOperation; /** * * @param left * @param right * @returns */ static readonly mand: BinaryMathOperation; /** * * @param left * @param right * @returns */ static readonly mor: BinaryMathOperation; /** * * @param right * @returns */ static readonly not: UnaryMathOperation; /** * * @param left * @param right * @returns */ static readonly and: BinaryMathOperation; /** * * @param left * @param right * @returns */ static readonly or: BinaryMathOperation; /** * * @param left * @param right * @returns */ static readonly xor: BinaryMathOperation; /** * Unary operations. */ static readonly unaryOperations: { [OP in KeyOfTypeOfMathOperation]?: UnaryMathOperation; }; /** * Binary operations */ static readonly binaryOperations: { [OP in KeyOfTypeOfMathOperation]?: BinaryMathOperation; }; /** * Left associative multiple arguments operations. */ static readonly leftAssociativeMultipleOperations: { [OP in KeyOfTypeOfMathOperation]?: BinaryMathOperation; }; } export type { MathObject, UnaryMathOperation, BinaryMathOperation, MathOperationType, KeyOfTypeOfMathOperation }; export { MathOperation }; declare const _default: { MathOperation: typeof MathOperation; }; export default _default;