[upd] plankton

This commit is contained in:
Fenris Wolf 2024-09-09 21:00:52 +02:00
parent 2b7ee926c1
commit ffb4304b0f
3 changed files with 2609 additions and 0 deletions

View file

@ -1516,3 +1516,892 @@ declare var printf: typeof lib_plankton.string.printf;
declare var eml_log: any;
declare var track_exports: any;
declare var make_logger: (prefix: any, current_loglevel: any) => (obj: any, lvl: any) => void;
declare namespace lib_plankton.complex {
/**
* @author fenris
*/
type type_complex = {
rea: float;
ima: float;
};
/**
* erstellt eine komplexe Zahl anhand ihrer kartesianischen Koordinaten
*
* @author fenris
*/
function make_cartesian(rea_: float, ima_: float): type_complex;
/**
* erstellt eine komplexe Zahl anhand ihrer Polar-Koordinaten
*
* @author fenris
*/
function make_polar(abs: float, arg: float): type_complex;
/**
* alias zu "make_cartesian"
*
* @author fenris
*/
function make(rea_: float, ima_: float): type_complex;
/**
* erstellt die komplexe Null
*
* @author fenris
*/
function nul(): type_complex;
/**
* erstellt die komplexe Eins
*
* @author fenris
*/
function one(): type_complex;
/**
* gibt den Real-Teil einer komplexen Zahl zurück
*
* @author fenris
*/
function rea(x: type_complex): float;
/**
* gibt den Imaginär-Teil einer komplexen Zahl zurück
*
* @author fenris
*/
function ima(x: type_complex): float;
/**
* gibt die konjugierte komplexe Zahl zurück
*
* @author fenris
*/
function con(x: type_complex): type_complex;
/**
* gibt den Betrag einer komplexen Zahl zurück
*
* @author fenris
*/
function abs(x: type_complex): float;
/**
* gibt das Argument einer komplexen Zahl zurück (auf dem Hauptzweig des komplexen Logarithmus)
*
* @author fenris
*/
function arg(x: type_complex): float;
/**
* gibt eine skalierte komplexe Zahl zurück (das Produkt mit einer reellen Zahl)
*
* @author fenris
*/
function scl(x: type_complex, s: float): type_complex;
/**
* errechnet die Summe zweier komplexer Zahl
*
* @author fenris
*/
function add(x: type_complex, y: type_complex): type_complex;
/**
* gibt die additiv inverse, also negierte komplexe Zahl zurück
*
* @author fenris
*/
function neg(x: type_complex): type_complex;
/**
* ermittelt die Differenz zweier komplexer Zahlen
*
* @author fenris
*/
function sub(x: type_complex, y: type_complex): type_complex;
/**
* ermittelt das Produkt zweier komplexer Zahlen
*
* @author fenris
*/
function mul(x: type_complex, y: type_complex): type_complex;
/**
* ermittelt die multiplikativ inverse komplexe Zahl, also den Kehrwert
*
* @author fenris
*/
function inv(x: type_complex): type_complex;
/**
* ermittelt den Quotienten zweier komplexer Zahlen
*
* @author fenris
*/
function div(x: type_complex, y: type_complex): type_complex;
/**
* ermittelt die natürliche Potenz einer komplexen Zahl
*
* @author fenris
*/
function npow(x: type_complex, n: int): type_complex;
/**
* ermittelt die natürliche Potenz einer komplexen Zahl
*
* @author fenris
* @deprecated use "npow" instead
* @todo remove
*/
function exp(x: type_complex, n: int): type_complex;
/**
* ermittelt die Potenz zweier komplexer Zahlen
*
* @author fenris
* @todo Probleme der komplexen Exponentiation berücksichtigen
*/
function pow(x: type_complex, y: type_complex): type_complex;
/**
* gibt die n-ten komplexen Einheits-Wurzeln zurück ({x C | x^n = 1})
*
* @author fenris
*/
function unitroots(n: int): Array<type_complex>;
/**
* {x C | x^n = y}
*
* @author fenris
*/
function normroots(n: int, y: type_complex): Array<type_complex>;
/**
* ermittelt ob zwei komplexe Zahlen gleich sind
*
* @author fenris
*/
function equ(x: type_complex, y: type_complex, threshold?: float): boolean;
/**
* gibt eine textuelle Repräsentation einer komplexen Zahl zurück
*
* @author fenris
*/
function str(x: type_complex): string;
}
declare namespace lib_plankton.complex {
/**
* @author fenris
*/
class class_complex {
/**
* @author fenris
*/
private subject;
/**
* @author fenris
*/
private constructor();
/**
* @author fenris
*/
private static _cram;
/**
* @author fenris
*/
private static _tear;
/**
* @author fenris
*/
static make_cartesian(rea: float, ima: float): class_complex;
/**
* @author fenris
*/
static make_polar(abs: float, arg: float): class_complex;
/**
* @author fenris
*/
static make(rea: float, ima: float): class_complex;
/**
* @author fenris
*/
static nul(): class_complex;
/**
* @author fenris
*/
static one(): class_complex;
/**
* @author fenris
*/
con(): class_complex;
/**
* @author fenris
*/
abs(): float;
/**
* @author fenris
*/
arg(): float;
/**
* @author fenris
*/
scl(s: float): class_complex;
/**
* @author fenris
*/
add(other: class_complex): class_complex;
/**
* @author fenris
*/
neg(): class_complex;
/**
* @author fenris
*/
sub(other: class_complex): class_complex;
/**
* @author fenris
*/
mul(other: class_complex): class_complex;
/**
* @author fenris
*/
inv(): class_complex;
/**
* @author fenris
*/
div(other: class_complex): class_complex;
/**
* @author fenris
*/
exp(n: int): class_complex;
/**
* @author fenris
*/
pow(other: class_complex): class_complex;
/**
* @author fenris
*/
equ(other: class_complex): boolean;
/**
* @author fenris
*/
str(): string;
/**
* @author fenris
*/
toString(): string;
}
}
declare namespace lib_plankton.math {
/**
* @desc golden ratio (e.g. for generating colors)
* @author fenris
*/
const phi: float;
/**
* @author fenris
*/
const e: float;
/**
* @author fenris
*/
const pi: float;
/**
* @author fenris
*/
const tau: float;
}
declare namespace lib_plankton.math {
/**
* @author fenris
*/
function clamp(x: number, a?: number, b?: number): number;
/**
* @desc the mathematical sign-function
* @return {int} an element of {-1,0,+1}
* @author fenris
*/
function sgn(x: number): int;
/**
* @desc integer division
* @author fenris
*/
function div(x: float, y: float): float;
/**
* @desc real modulo operator
* @author fenris
*/
function mod(x: float, y: float): float;
/**
* @desc computes "x^y mod z" via square-and-multiply
* @param {int} base ("x")
* @param {int} exponent ("y")
* @param {int} modulus ("z")
* @return {int}
* @author fenris
* @todo handle invalid cases (e.g. "z < 1")
* @todo implement iteratively
*/
function modpow(base: int, exponent: int, modulus: int): int;
/**
* @desc determines if two integers are coprime, i.e. that they don't have a common divisor greater than 1
* @author fenris
* @todo write function "gcdx" and base on it
*/
function coprime(x: int, y: int): boolean;
/**
* @desc extended euclidean algorithm for computing multiplicative inverse elements
* @param {int} modulus
* @param {int} element
* @author fenris
* @todo write function "gcdx" and base on it
* @todo handle more invalid cases
*/
function inv(modulus: int, element: int, positive?: boolean): int;
/**
* @author fenris
*/
function interpolate_linear(x: number, y: number, t?: number): number;
/**
* @desc kind of the inverse of linear interpolation; i.e. to find the coefficient "t" for given values x, y and
* their presumed interpolation v
* @author fenris
*/
function appoint_linear(x: number, y: number, v: number): number;
/**
* continued fraction decomposition
*/
function cfd(x: float, n?: int): Array<int>;
}
declare namespace lib_plankton.math {
/**
* @author fenris
*/
type type_relationparameters<type_value> = {
symbol?: string;
name?: string;
predicate?: (value: type_value, reference: type_value) => boolean;
};
/**
* @author fenris
*/
class class_relation<type_value> implements interface_showable, interface_hashable, interface_collatable<class_relation<type_value>> {
/**
* @author fenris
*/
protected id: string;
/**
* @author fenris
*/
protected symbol: string;
/**
* @author fenris
*/
protected name: string;
/**
* @author fenris
*/
protected predicate: (value: type_value, reference: type_value) => boolean;
/**
* @author fenris
*/
check(value: type_value, reference: type_value): boolean;
/**
* @author fenris
*/
constructor(id: string, { "symbol": symbol, "name": name, "predicate": predicate, }: type_relationparameters<type_value>);
/**
* @author fenris
*/
id_get(): string;
/**
* @author fenris
*/
symbol_get(): string;
/**
* @author fenris
*/
name_get(): string;
/**
* @desc [accessor] [implementation]
* @author fenris
*/
_show(): string;
/**
* @desc [accessor] [implementation]
* @author fenris
*/
_hash(): string;
/**
* @desc [accessor] [implementation]
* @author fenris
*/
_collate(relation: class_relation<type_value>): boolean;
/**
* @author fenris
*/
toString(): string;
/**
* @author fenris
*/
protected static pool<type_value>(): {
[id: string]: type_relationparameters<type_value>;
};
/**
* @author fenris
*/
static get<type_value>(id: string): class_relation<type_value>;
/**
* @author fenris
*/
static available(): Array<string>;
}
/**
* @author fenris
*/
class class_filtrationitem<type_value> implements interface_showable {
/**
* @author fenris
*/
protected extract: (dataset: Object) => type_value;
/**
* @author fenris
*/
protected relation: class_relation<type_value>;
/**
* @author fenris
*/
protected reference: type_value;
/**
* @author fenris
*/
constructor({ "extract": extract, "relation": relation, "reference": reference, }: {
extract: (dataset: Object) => type_value;
relation: class_relation<type_value>;
reference: type_value;
});
/**
* @author fenris
*/
check(dataset: Object): boolean;
/**
* @desc [implementation]
* @author fenris
*/
_show(): string;
/**
* @author fenris
*/
toString(): string;
}
/**
* @desc disjunctive normal form
* @author fenris
*/
class class_filtration implements interface_showable {
/**
* @author fenris
*/
protected clauses: Array<Array<class_filtrationitem<any>>>;
/**
* @author fenris
*/
constructor(clauses: Array<Array<class_filtrationitem<any>>>);
/**
* @author fenris
*/
check(dataset: Object): boolean;
/**
* @author fenris
*/
use(datasets: Array<Object>): Array<Object>;
/**
* @desc [implementation]
* @author fenris
*/
_show(): string;
/**
* @author fenris
*/
toString(): string;
}
/**
* @author fenris
* @deprecated
*/
function comparator_to_relation<type_value>(comparator: (x: type_value, y: type_value) => int): (x: type_value, y: type_value) => boolean;
/**
* @author fenris
* @deprecated
*/
function relation_to_comparator<type_value>(relation: (x: type_value, y: type_value) => boolean): (x: type_value, y: type_value) => int;
}
declare module lib_calculus {
/**
* @class Calculus
* @desc Ensure precision of mathematical operations
*/
class Calculus {
/** @desc only for typescript
*/
private NORM;
/**
* @constructor
* @þaram {number} norm
*/
constructor(norm?: number);
/**
* normalize
* @param {number} value
* @return {number}
*/
normalize(value: number): number;
/**
* denormalize
* @param {number} value
* @return {number}
*/
denormalize(value: number): number;
}
}
declare namespace lib_plankton.math {
/**
* {x C | 0 = ax³ + bx² + cx + d}
*
* @author fenris
*/
function cubic_solve(a: lib_plankton.complex.type_complex, b: lib_plankton.complex.type_complex, c: lib_plankton.complex.type_complex, d: lib_plankton.complex.type_complex): Array<lib_plankton.complex.type_complex>;
/**
* {x C | 0 = ax³ + bx² + cx + d}
*
* @author fenris
*/
function cubic_solve_real(a: float, b: float, c: float, d: float): Array<lib_plankton.complex.type_complex>;
}
declare namespace lib_plankton.color {
/**
* @author fenris
*/
type type_model_hsv = {
hue: float;
saturation: float;
value: float;
};
/**
* @author fenris
*/
type type_model_hsl = {
hue: float;
saturation: float;
lightness: float;
};
/**
* @author fenris
*/
type type_model_rgb = {
red: float;
green: float;
blue: float;
};
/**
* @author fenris
*/
type type_color = {
model: type_model_rgb;
};
/**
* @author fenris
*/
function make_hsv({ "hue": hue, "saturation": saturation, "value": value }: {
hue?: float;
saturation?: float;
value?: float;
}): type_color;
/**
* @author fenris
*/
function make_hsl(model_hsl: type_model_hsl): type_color;
/**
* @author fenris
*/
function make_rgb(model_rgb: type_model_rgb): type_color;
/**
* @author fenris
*/
function to_hsv(color: type_color): type_model_hsv;
/**
* @author fenris
*/
function to_hsl(color: type_color): type_model_hsl;
/**
* @author fenris
*/
function to_rgb(color: type_color): type_model_rgb;
/**
* @author fenris
*/
function to_cmyk(color: type_color): type_model_rgb;
/**
* @author fenris
*/
function add(color1: type_color, color2: type_color): type_color;
/**
* @author fenris
*/
function multiply(color1: type_color, color2: type_color): type_color;
/**
* @author fenris
* @todo blend through other model?
*/
function blend(color1: type_color, color2: type_color, strength?: float): type_color;
/**
* @author fenris
*/
function mix(color1: type_color, color2: type_color, strength1?: float, strength2?: float): type_color;
/**
* @author fenris
*/
function output_rgb(color: type_color): string;
/**
* @author fenris
*/
function output_hex(color: type_color): string;
/**
* @author fenris
*/
function output_dot(color: type_color): string;
/**
* @author fenris
*/
function give_generic({ "n": n, "offset": offset, "saturation": saturation, "value": value, }: {
n: int;
offset?: float;
saturation?: float;
value?: float;
}): type_color;
/**
* @author fenris
*/
function give_gray(value?: float): type_color;
/**
* @author fenris
*/
function give_black(): type_color;
/**
* @author fenris
*/
function give_white(): type_color;
/**
* @author fenris
*/
function give_red({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): type_color;
/**
* @author fenris
*/
function give_green({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): type_color;
/**
* @author fenris
*/
function give_blue({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): type_color;
/**
* @author fenris
*/
function give_yellow({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): type_color;
/**
* @author fenris
*/
function give_cyan({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): type_color;
/**
* @author fenris
*/
function give_magenta({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): type_color;
}
declare namespace lib_plankton.color {
/**
* @author fenris
*/
class class_color {
/**
* @author fenris
*/
private subject;
/**
* @author fenris
*/
protected constructor(subject: type_color);
/**
* @author fenris
*/
private static _cram;
/**
* @author fenris
*/
private static _tear;
/**
* @author fenris
*/
static make_hsv({ "hue": hue, "saturation": saturation, "value": value }: {
hue?: float;
saturation?: float;
value?: float;
}): class_color;
/**
* @author fenris
*/
blend(color: class_color, strength?: float): class_color;
/**
* @author fenris
*/
output_rgb(): string;
/**
* @author fenris
*/
output_hex(): string;
/**
* @author fenris
*/
output_dot(): string;
/**
* @author fenris
*/
static give_generic({ "n": n, "offset": offset, "saturation": saturation, "value": value, }: {
n: int;
offset?: float;
saturation?: float;
value?: float;
}): class_color;
static generic(x: any): class_color;
/**
* @author fenris
*/
static give_gray(value?: float): class_color;
/**
* @author fenris
*/
static give_black(): class_color;
/**
* @author fenris
*/
static give_white(): class_color;
/**
* @author fenris
*/
static give_red({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): class_color;
/**
* @author fenris
*/
static give_green({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): class_color;
/**
* @author fenris
*/
static give_blue({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): class_color;
/**
* @author fenris
*/
static give_yellow({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): class_color;
/**
* @author fenris
*/
static give_cyan({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): class_color;
/**
* @author fenris
*/
static give_magenta({ "saturation": saturation, "value": value, }?: {
saturation?: float;
value?: float;
}): class_color;
}
}
/**
* @author fenris
*/
declare namespace lib_plankton.xml {
/**
* @author fenris
*/
abstract class class_node {
/**
* @author fenris
*/
abstract compile(depth?: int): string;
}
/**
* @author fenris
*/
class class_node_text extends class_node {
/**
* @author fenris
*/
protected content: string;
/**
* @author fenris
*/
constructor(content: string);
/**
* @author fenris
*/
compile(depth?: int): string;
}
/**
* @author fenris
*/
class class_node_comment extends class_node {
/**
* @author fenris
*/
protected content: string;
/**
* @author fenris
*/
constructor(content: string);
/**
* @author fenris
*/
compile(depth?: int): string;
}
/**
* @author fenris
*/
class class_node_complex extends class_node {
/**
* @author fenris
*/
protected name: string;
/**
* @author fenris
*/
protected attributes: {
[key: string]: string;
};
/**
* @author fenris
*/
protected children: Array<class_node>;
/**
* @author fenris
*/
constructor(name: string, attributes?: {
[key: string]: string;
}, children?: any[]);
/**
* @author fenris
*/
compile(depth?: int): string;
}
}

File diff suppressed because it is too large Load diff

View file

@ -11,6 +11,8 @@ modules="${modules} file"
modules="${modules} json"
modules="${modules} args"
modules="${modules} string"
modules="${modules} color"
modules="${modules} xml"
## exec