DKL9 GitList
Repositories
DKL9 home
rtensor
Code
Commits
Branches
Tags
Search
Tree:
1312198
Branches
Tags
master
rtensor
types
real.js
Import v2.3-dev from a demonic ritual
dkl9
commited
1312198
at 2023-184 18:25:57
real.js
Blame
History
Raw
"use strict"; BasicNumber.keys.forEach(k => (Number.prototype[k] = BasicNumber.prototype[k])); Number.ify = function(x) { if (typeof x == "object" && x.constructor == Complex) { return x.im ? null : new Number(x.re); } else if (typeof x == "boolean") { return 1*x; } else { return x; } }; Number.prototype.invalid = function() { return isNaN(this); }; Number.zero = () => 0; Number.one = () => 1; Number.prototype.add = function(x) { return this + x; }; Number.prototype.neg = function() { return -this; }; Number.prototype.mul = function(x) { return this * x; }; Number.prototype.recip = function() { return 1 / this; }; Number.prototype.div = function(x) { return this / x; }; Number.prototype.exp = function() { return Math.exp(this); }; Number.prototype.ln = function() { return Math.log(this); }; Number.prototype.pow = function(x) { return this ** x; }; Number.prototype.sqrt = function() { return Math.sqrt(this); }; Number.prototype.sin = function() { return Math.sin(this); }; Number.prototype.cos = function() { return Math.cos(this); }; Number.prototype.asin = function() { return Math.asin(this); }; Number.prototype.acos = function() { return Math.acos(this); }; Number.prototype.atan = function(x) { if (x) { return Math.atan2(x, this); } else { return Math.atan(this); } }; Number.prototype.eq = function(x) { return this == x; }; Number.prototype.lt = function(x) { return this < x; }; Number.prototype.mag = function() { return Math.abs(this); }; Number.prototype.floor = function() { return Math.floor(this); };