|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1006 bytes
|
| Line | |
|---|
| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.default = symlog;
|
|---|
| 7 | exports.symlogish = symlogish;
|
|---|
| 8 | var _linear = require("./linear.js");
|
|---|
| 9 | var _continuous = require("./continuous.js");
|
|---|
| 10 | var _init = require("./init.js");
|
|---|
| 11 | function transformSymlog(c) {
|
|---|
| 12 | return function (x) {
|
|---|
| 13 | return Math.sign(x) * Math.log1p(Math.abs(x / c));
|
|---|
| 14 | };
|
|---|
| 15 | }
|
|---|
| 16 | function transformSymexp(c) {
|
|---|
| 17 | return function (x) {
|
|---|
| 18 | return Math.sign(x) * Math.expm1(Math.abs(x)) * c;
|
|---|
| 19 | };
|
|---|
| 20 | }
|
|---|
| 21 | function symlogish(transform) {
|
|---|
| 22 | var c = 1,
|
|---|
| 23 | scale = transform(transformSymlog(c), transformSymexp(c));
|
|---|
| 24 | scale.constant = function (_) {
|
|---|
| 25 | return arguments.length ? transform(transformSymlog(c = +_), transformSymexp(c)) : c;
|
|---|
| 26 | };
|
|---|
| 27 | return (0, _linear.linearish)(scale);
|
|---|
| 28 | }
|
|---|
| 29 | function symlog() {
|
|---|
| 30 | var scale = symlogish((0, _continuous.transformer)());
|
|---|
| 31 | scale.copy = function () {
|
|---|
| 32 | return (0, _continuous.copy)(scale, symlog()).constant(scale.constant());
|
|---|
| 33 | };
|
|---|
| 34 | return _init.initRange.apply(scale, arguments);
|
|---|
| 35 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.