variance.transform.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createVarianceTransform = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var _errorTransform = require("./utils/errorTransform.js");
  8. var _variance = require("../../function/statistics/variance.js");
  9. var _lastDimToZeroBase = require("./utils/lastDimToZeroBase.js");
  10. var name = 'variance';
  11. var dependencies = ['typed', 'add', 'subtract', 'multiply', 'divide', 'apply', 'isNaN'];
  12. /**
  13. * Attach a transform function to math.var
  14. * Adds a property transform containing the transform function.
  15. *
  16. * This transform changed the `dim` parameter of function var
  17. * from one-based to zero based
  18. */
  19. var createVarianceTransform = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  20. var typed = _ref.typed,
  21. add = _ref.add,
  22. subtract = _ref.subtract,
  23. multiply = _ref.multiply,
  24. divide = _ref.divide,
  25. apply = _ref.apply,
  26. isNaN = _ref.isNaN;
  27. var variance = (0, _variance.createVariance)({
  28. typed: typed,
  29. add: add,
  30. subtract: subtract,
  31. multiply: multiply,
  32. divide: divide,
  33. apply: apply,
  34. isNaN: isNaN
  35. });
  36. return typed(name, {
  37. '...any': function any(args) {
  38. args = (0, _lastDimToZeroBase.lastDimToZeroBase)(args);
  39. try {
  40. return variance.apply(null, args);
  41. } catch (err) {
  42. throw (0, _errorTransform.errorTransform)(err);
  43. }
  44. }
  45. });
  46. }, {
  47. isTransformFunction: true
  48. });
  49. exports.createVarianceTransform = createVarianceTransform;