mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
248 lines (247 loc) • 11.4 kB
TypeScript
/**
* filename: `Complex.ts`
* Description: Complex number library based on a facade architecture.
*/
import * as TypeOfComplex from './ComplexInterface';
import { Decimal } from './ComplexDecimal';
import { Evaluator } from './Evaluator';
/**
* External type complex facade definitions.
*/
type RealType = number | Decimal;
type NumberObjectType = number;
type RealTypeDescriptor = 'number' | 'decimal';
type ComplexType = TypeOfComplex.ComplexHandlerType<RealType, TypeOfComplex.ComplexInterface<RealType>>;
/**
* Complex Facade internal type definitions.
*/
type ComplexInterfaceBase = TypeOfComplex.OmitComplexInterfaceDynamic<RealType, NumberObjectType, unknown>;
type InterfaceStaticHandler = TypeOfComplex.ComplexInterfaceStatic<RealType, ComplexType>;
type IsInstanceOfHandler = TypeOfComplex.IsInstanceOfComplexHandler;
type SetHandler = TypeOfComplex.SetComplexHandler;
type CreateHandler = TypeOfComplex.CreateComplexHandler<RealType, ComplexType, number>;
type PartSetHandler = TypeOfComplex.PartSetComplexHandler<RealType, TypeOfComplex.ComplexInterface<RealType>>;
type PartApplyHandler = TypeOfComplex.PartApplyComplexHandler<RealType, ComplexType>;
type PartApplyHandlerTable = TypeOfComplex.PartApplyComplexHandlerTable<RealType>;
type OneArgValueHandler = TypeOfComplex.OneArgValueComplexHandler<RealType>;
type FromHandler = TypeOfComplex.FromComplexHandler<RealType, ComplexType>;
type NoArgHandler = TypeOfComplex.NoArgComplexHandler<RealType, ComplexType>;
type OneArgHandler = TypeOfComplex.OneArgComplexHandler<RealType, ComplexType>;
type OneOptNumArgHandler = TypeOfComplex.OneOptNumArgComplexHandler<RealType, ComplexType>;
type OneArgNoReturnHandler = TypeOfComplex.OneArgNoReturnComplexHandler<RealType, ComplexType>;
type MapHandler = TypeOfComplex.MapComplexHandler<RealType, ComplexType>;
type TwoArgHandler = TypeOfComplex.TwoArgComplexHandler<RealType, ComplexType>;
type OneArgReturnBooleanHandler = TypeOfComplex.OneArgReturnBooleanComplexHandler<RealType, ComplexType>;
type OneArgReturnNumberHandler = TypeOfComplex.OneArgReturnNumberComplexHandler<RealType, ComplexType>;
type TestNumLikeHandler = TypeOfComplex.TestNumLikeComplexHandler<RealType, ComplexType>;
type ParseHandler = TypeOfComplex.ParseComplexHandler<RealType, ComplexType>;
type UnparseValueHandler = TypeOfComplex.UnparseValueComplexHandler<RealType>;
type UnparseHandler = TypeOfComplex.UnparseComplexHandler<RealType, ComplexType, number>;
type PrecedenceHandler = TypeOfComplex.PrecedenceComplexHandler<RealType, ComplexType, Evaluator, number>;
type UnparseMathMLHandler = TypeOfComplex.UnparseMathMLComplexHandler<RealType, ComplexType, Evaluator, number>;
type CompareHandler = TypeOfComplex.CompareComplexHandler<RealType, ComplexType>;
type MinMaxArrayHandler = TypeOfComplex.MinMaxArrayComplexHandler<RealType, ComplexType>;
type MinMaxArrayWithIndexHandler = TypeOfComplex.MinMaxArrayWithIndexComplexHandler<RealType, ComplexType>;
/**
* # Complex
*
* Facade Complex class.
*
* `Complex.engine = 'decimal'` switches to using the `decimal.js` package (ComplexDecimal).
*
* `Complex.engine = 'number'` switches to using the native `number` type (ComplexNumber).
*
*/
declare abstract class Complex implements ComplexInterfaceBase {
/**
* Private complex backend engine.
*/
private static _engineBackend;
/**
* Private complex backend engine descriptor.
*/
private static _engine;
/**
* Complex backend engine getter.
*/
static get engineBackend(): InterfaceStaticHandler;
/**
* Complex backend engine descriptor getter.
*/
static get engine(): RealTypeDescriptor;
/**
* Complex backend engine switcher.
*/
static set engine(engine: RealTypeDescriptor);
static readonly LOGICAL: number;
static readonly REAL: number;
static readonly COMPLEX: number;
/**
* `Complex` facade default settings.
*/
static readonly defaultSettings: TypeOfComplex.ComplexConfig<TypeOfComplex.Rounding, TypeOfComplex.Modulo>;
/**
* `Complex` facade current settings.
*/
static readonly settings: TypeOfComplex.ComplexConfig<TypeOfComplex.Rounding, TypeOfComplex.Modulo>;
static readonly isInstanceOf: IsInstanceOfHandler;
static readonly set: SetHandler;
static readonly setNumberType: OneArgNoReturnHandler;
static readonly create: CreateHandler;
static readonly realSet: PartSetHandler;
static readonly imagSet: PartSetHandler;
static readonly realApply: PartApplyHandler;
static readonly imagApply: PartApplyHandler;
static readonly from: FromHandler;
static readonly real: MapHandler;
static readonly imag: MapHandler;
static readonly realIsFinite: OneArgReturnBooleanHandler;
static readonly imagIsFinite: OneArgReturnBooleanHandler;
static readonly realIsNaN: OneArgReturnBooleanHandler;
static readonly imagIsNaN: OneArgReturnBooleanHandler;
static readonly realIsInteger: OneArgReturnBooleanHandler;
static readonly imagIsInteger: OneArgReturnBooleanHandler;
static readonly realIsNegative: OneArgReturnBooleanHandler;
static readonly imagIsNegative: OneArgReturnBooleanHandler;
static readonly realIsZero: OneArgReturnBooleanHandler;
static readonly imagIsZero: OneArgReturnBooleanHandler;
static readonly realIsPositive: OneArgReturnBooleanHandler;
static readonly imagIsPositive: OneArgReturnBooleanHandler;
static readonly realToNumber: OneArgReturnNumberHandler;
static readonly imagToNumber: OneArgReturnNumberHandler;
static readonly realLessThan: TestNumLikeHandler;
static readonly imagLessThan: TestNumLikeHandler;
static readonly realLessThanOrEqualTo: TestNumLikeHandler;
static readonly imagLessThanOrEqualTo: TestNumLikeHandler;
static readonly realEquals: TestNumLikeHandler;
static readonly imagEquals: TestNumLikeHandler;
static readonly realGreaterThanOrEqualTo: TestNumLikeHandler;
static readonly imagGreaterThanOrEqualTo: TestNumLikeHandler;
static readonly realGreaterThan: TestNumLikeHandler;
static readonly imagGreaterThan: TestNumLikeHandler;
static readonly parse: ParseHandler;
static readonly unparseValue: UnparseValueHandler;
static readonly unparse: UnparseHandler;
static readonly unparseMathMLValue: UnparseValueHandler;
static readonly precedence: PrecedenceHandler;
static readonly unparseMathML: UnparseMathMLHandler;
static readonly copy: OneArgHandler;
static readonly toMaxPrecisionValue: OneArgValueHandler;
static readonly toMaxPrecision: OneArgHandler;
static readonly epsilon: NoArgHandler;
static readonly random: OneOptNumArgHandler;
static readonly eq: TwoArgHandler;
static readonly ne: TwoArgHandler;
static readonly cmp: CompareHandler;
static readonly minMaxArrayReal: MinMaxArrayHandler;
static readonly minMaxArrayRealWithIndex: MinMaxArrayWithIndexHandler;
static readonly minMaxArrayComplex: MinMaxArrayHandler;
static readonly minMaxArrayComplexWithIndex: MinMaxArrayWithIndexHandler;
static readonly min: TwoArgHandler;
static readonly minWise: TwoArgHandler;
static readonly max: TwoArgHandler;
static readonly maxWise: TwoArgHandler;
static readonly lt: TwoArgHandler;
static readonly le: TwoArgHandler;
static readonly gt: TwoArgHandler;
static readonly ge: TwoArgHandler;
static readonly false: NoArgHandler;
static readonly true: NoArgHandler;
static readonly toLogical: OneArgHandler;
static readonly logical: MapHandler;
static readonly and: TwoArgHandler;
static readonly or: TwoArgHandler;
static readonly xor: TwoArgHandler;
static readonly not: OneArgHandler;
static readonly zero: NoArgHandler;
static readonly one: NoArgHandler;
static readonly onediv2: NoArgHandler;
static readonly minusonediv2: NoArgHandler;
static readonly minusone: NoArgHandler;
static readonly pi: NoArgHandler;
static readonly pidiv2: NoArgHandler;
static readonly onei: NoArgHandler;
static readonly onediv2i: NoArgHandler;
static readonly minusonediv2i: NoArgHandler;
static readonly minusonei: NoArgHandler;
static readonly two: NoArgHandler;
static readonly sqrt2pi: NoArgHandler;
static readonly e: NoArgHandler;
static readonly NaN_0: NoArgHandler;
static readonly inf_0: NoArgHandler;
static readonly add: TwoArgHandler;
static readonly sub: TwoArgHandler;
static readonly neg: OneArgHandler;
static readonly mul: TwoArgHandler;
static readonly rdiv: TwoArgHandler;
static readonly ldiv: TwoArgHandler;
static readonly inv: OneArgHandler;
static readonly power: TwoArgHandler;
static readonly root: TwoArgHandler;
static readonly abs: MapHandler;
static readonly hypot: TwoArgHandler;
static readonly arg: MapHandler;
static readonly conj: MapHandler;
static readonly mod: TwoArgHandler;
static readonly rem: TwoArgHandler;
static readonly fix: MapHandler;
static readonly ceil: MapHandler;
static readonly floor: MapHandler;
static readonly round: MapHandler;
static readonly sign: MapHandler;
static readonly sqrt: MapHandler;
static readonly exp: MapHandler;
static readonly log: MapHandler;
static readonly logb: TwoArgHandler;
static readonly log2: MapHandler;
static readonly log10: MapHandler;
static readonly deg2rad: MapHandler;
static readonly rad2deg: MapHandler;
static readonly sin: MapHandler;
static readonly sind: MapHandler;
static readonly cos: MapHandler;
static readonly cosd: MapHandler;
static readonly tan: MapHandler;
static readonly tand: MapHandler;
static readonly csc: MapHandler;
static readonly cscd: MapHandler;
static readonly sec: MapHandler;
static readonly secd: MapHandler;
static readonly cot: MapHandler;
static readonly cotd: MapHandler;
static readonly asin: MapHandler;
static readonly asind: MapHandler;
static readonly acos: MapHandler;
static readonly acosd: MapHandler;
static readonly atan: MapHandler;
static readonly atand: MapHandler;
static readonly acsc: MapHandler;
static readonly acscd: MapHandler;
static readonly asec: MapHandler;
static readonly asecd: MapHandler;
static readonly acot: MapHandler;
static readonly acotd: MapHandler;
static readonly sinh: MapHandler;
static readonly cosh: MapHandler;
static readonly tanh: MapHandler;
static readonly csch: MapHandler;
static readonly sech: MapHandler;
static readonly coth: MapHandler;
static readonly asinh: MapHandler;
static readonly acosh: MapHandler;
static readonly atanh: MapHandler;
static readonly acsch: MapHandler;
static readonly asech: MapHandler;
static readonly acoth: MapHandler;
static readonly gamma: MapHandler;
static readonly factorial: MapHandler;
static readonly applyFunction: PartApplyHandlerTable;
static readonly mapFunction: Record<string, MapHandler>;
static readonly twoArgFunction: Record<string, TwoArgHandler>;
}
export type { Decimal, RealType, NumberObjectType, RealTypeDescriptor, ComplexType };
export { Complex };
declare const _default: {
Complex: typeof Complex;
};
export default _default;