DKL9 GitList
Repositories
DKL9 home
rtensor
Code
Commits
Branches
Tags
Search
Tree:
1312198
Branches
Tags
master
rtensor
types
basic.js
Import v2.3-dev from a demonic ritual
dkl9
commited
1312198
at 2023-184 18:25:57
basic.js
Blame
History
Raw
"use strict"; class BasicNumber { constructor() {} sub(z) { return this.add(z.neg()); } div(z) { return this.mul(z.recip()); } pow(z) { return this.ln().mul(z).exp(); } log(z) { return this.ln().div(z.ln()); } isNeg() { return this.lt(this.constructor.zero()); } rangeTo(b) { const al = Math.ceil(b.sub(this).mag() + 1); const ud = b.sub(this).dir(); return (new Array(al)).fill(0).map((_z, i) => this.add(ud.mul(this.constructor.ify(i)))); } dir() { return this.mag().eq(0) ? this.constructor.one() : this.div(this.constructor.ify(this.mag())); } } // because the prototype fields are nonenumerable argh BasicNumber.keys = ["sub", "div", "pow", "log", "isNeg", "rangeTo", "dir"];