@rwk/physics-math
Version:
Math for physics homework problems
110 lines • 4.37 kB
TypeScript
/**
* @packageDocumentation
* @module Functionals
*/
import { BaseValue, BaseValueRelative, TYPE } from "./math-types";
import { ArgCount, IndefiniteIntegral, IPCompiled, IPCompileResult, IPFunction, IPFunctionBase, IPFunctionCalculus, PFunctionOpts, Variable } from "./base";
import { ViewOf } from "./utils";
import { Units } from './unit-defs';
import { Unit, Divide, Multiply } from "./units";
import { StyleContext } from "./latex";
/**
* Default integration timestep. This can be adjusted per-function.
*/
export declare let TIMESTEP: number;
export declare abstract class PFunction<R extends BaseValue = BaseValue, C extends Unit = Unit, N extends ArgCount = 1> implements IPFunctionBase<R, C, N> {
/**
* The time step to be used for numerical integration. Ignored for functions with a defined analytic integral.
*/
timestep: number;
/**
* Cached LaTeX string
*/
tex_?: string;
/**
* Name of this PFunction, for disambiguation and well-known functions (such as constants).
*/
readonly name: string;
readonly nargs: N;
abstract get returnType(): TYPE;
readonly unit: C;
protected constructor({ name, vars, unit, nargs }: PFunctionOpts<C, N>);
protected abstract compileFn(): IPCompileResult<R, N>;
f_?: IPCompiled<R, C, N>;
/**
* The implementing function
*/
get f(): IPCompiled<R, C, N>;
compile(): IPCompiled<R, C, N>;
/**
* Compute the LaTeX representation of this function.
* @param varName?? The parameter name (or expression)
* @param ctx??
*/
toTex(varName?: Variable, ctx?: StyleContext): string;
toTexWithUnits(varName?: Variable, ctx?: StyleContext): string;
/**
* Get the LaTeX representation of this function. The value is cached.
*/
get tex(): string;
/**
* Produce HTML from the LaTeX representation. Produces a new HTML element on each call
* @param varName?? The variable name to be used; ordinarily t (time).
* @param block??
* @param ctx??
*/
toHtml(varName?: Variable, block?: boolean, ctx?: StyleContext): ViewOf<this> & Element;
/**
* Produce HTML from the LaTeX representation. Produces a new HTML element on each reference,
* equivalent to:
* ```
* pFun.toHtml();
* ```
*/
get html(): ViewOf<this> & Element;
/**
*
* Set a name of the function
* @param name
* @private
*/
setName_(name: string): this;
equiv<T>(f: T): null | this | T;
simplify(options?: any): IPFunctionBase<R, C, N>;
}
/**
* Base class for our object representation, which is bidirectionally paired with implementing functions.
*/
export declare abstract class PCalculus<R extends BaseValueRelative = BaseValueRelative, C extends Unit = Unit, D extends Unit = Divide<C, Units.time>, I extends Unit = Multiply<C, Units.time>> extends PFunction<R, C> implements IPFunctionCalculus<R, C, 1, D, I> {
/**
* Cached derivative
*/
private derivative_?;
/**
* Cached integral
*/
private integral_?;
/**
* Construct a PFFunction, and extend the supplied function with our IPFunction interface.
* @param opts
*/
protected constructor(opts: any);
derivative(): IPFunctionCalculus<R, D, 1, Divide<D, Units.time>, C>;
/**
* Compute the derivative of this function. The default is to perform numeric differentiation.
*/
abstract differentiate(): IPFunctionCalculus<R, D, 1, Divide<D, Units.time>, C>;
/**
* Return the indefinite integral of this function.
*/
integral(): IndefiniteIntegral<R, I, C>;
/**
* Compute the integral of this function. We fall back to numeric integration if necessary.
*/
abstract integrate(): IndefiniteIntegral<R, I, C>;
}
export declare function isPFunction<U extends Unit, N extends ArgCount>(a: any, u: U, n: N): a is IPFunction<BaseValue, U, N>;
export declare function isPFunction(a: any): a is IPFunction;
export declare function isPCompiled<U extends Unit, N extends ArgCount>(a: any, u: U, n: N): a is IPCompiled<BaseValue, U, N>;
export declare function isPCompiled(a: any): a is IPCompiled<BaseValue, Unit, ArgCount>;
//# sourceMappingURL=pfunction.d.ts.map