simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

dotPow.js (3921B)


      1 "use strict";
      2 
      3 Object.defineProperty(exports, "__esModule", {
      4   value: true
      5 });
      6 exports.createDotPow = void 0;
      7 
      8 var _factory = require("../../utils/factory.js");
      9 
     10 var _algorithm = require("../../type/matrix/utils/algorithm03.js");
     11 
     12 var _algorithm2 = require("../../type/matrix/utils/algorithm07.js");
     13 
     14 var _algorithm3 = require("../../type/matrix/utils/algorithm11.js");
     15 
     16 var _algorithm4 = require("../../type/matrix/utils/algorithm12.js");
     17 
     18 var _algorithm5 = require("../../type/matrix/utils/algorithm13.js");
     19 
     20 var _algorithm6 = require("../../type/matrix/utils/algorithm14.js");
     21 
     22 var name = 'dotPow';
     23 var dependencies = ['typed', 'equalScalar', 'matrix', 'pow', 'DenseMatrix'];
     24 var createDotPow = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
     25   var typed = _ref.typed,
     26       equalScalar = _ref.equalScalar,
     27       matrix = _ref.matrix,
     28       pow = _ref.pow,
     29       DenseMatrix = _ref.DenseMatrix;
     30   var algorithm03 = (0, _algorithm.createAlgorithm03)({
     31     typed: typed
     32   });
     33   var algorithm07 = (0, _algorithm2.createAlgorithm07)({
     34     typed: typed,
     35     DenseMatrix: DenseMatrix
     36   });
     37   var algorithm11 = (0, _algorithm3.createAlgorithm11)({
     38     typed: typed,
     39     equalScalar: equalScalar
     40   });
     41   var algorithm12 = (0, _algorithm4.createAlgorithm12)({
     42     typed: typed,
     43     DenseMatrix: DenseMatrix
     44   });
     45   var algorithm13 = (0, _algorithm5.createAlgorithm13)({
     46     typed: typed
     47   });
     48   var algorithm14 = (0, _algorithm6.createAlgorithm14)({
     49     typed: typed
     50   });
     51   /**
     52    * Calculates the power of x to y element wise.
     53    *
     54    * Syntax:
     55    *
     56    *    math.dotPow(x, y)
     57    *
     58    * Examples:
     59    *
     60    *    math.dotPow(2, 3)            // returns number 8
     61    *
     62    *    const a = [[1, 2], [4, 3]]
     63    *    math.dotPow(a, 2)            // returns Array [[1, 4], [16, 9]]
     64    *    math.pow(a, 2)               // returns Array [[9, 8], [16, 17]]
     65    *
     66    * See also:
     67    *
     68    *    pow, sqrt, multiply
     69    *
     70    * @param  {number | BigNumber | Complex | Unit | Array | Matrix} x  The base
     71    * @param  {number | BigNumber | Complex | Unit | Array | Matrix} y  The exponent
     72    * @return {number | BigNumber | Complex | Unit | Array | Matrix}                     The value of `x` to the power `y`
     73    */
     74 
     75   return typed(name, {
     76     'any, any': pow,
     77     'SparseMatrix, SparseMatrix': function SparseMatrixSparseMatrix(x, y) {
     78       return algorithm07(x, y, pow, false);
     79     },
     80     'SparseMatrix, DenseMatrix': function SparseMatrixDenseMatrix(x, y) {
     81       return algorithm03(y, x, pow, true);
     82     },
     83     'DenseMatrix, SparseMatrix': function DenseMatrixSparseMatrix(x, y) {
     84       return algorithm03(x, y, pow, false);
     85     },
     86     'DenseMatrix, DenseMatrix': function DenseMatrixDenseMatrix(x, y) {
     87       return algorithm13(x, y, pow);
     88     },
     89     'Array, Array': function ArrayArray(x, y) {
     90       // use matrix implementation
     91       return this(matrix(x), matrix(y)).valueOf();
     92     },
     93     'Array, Matrix': function ArrayMatrix(x, y) {
     94       // use matrix implementation
     95       return this(matrix(x), y);
     96     },
     97     'Matrix, Array': function MatrixArray(x, y) {
     98       // use matrix implementation
     99       return this(x, matrix(y));
    100     },
    101     'SparseMatrix, any': function SparseMatrixAny(x, y) {
    102       return algorithm11(x, y, this, false);
    103     },
    104     'DenseMatrix, any': function DenseMatrixAny(x, y) {
    105       return algorithm14(x, y, this, false);
    106     },
    107     'any, SparseMatrix': function anySparseMatrix(x, y) {
    108       return algorithm12(y, x, this, true);
    109     },
    110     'any, DenseMatrix': function anyDenseMatrix(x, y) {
    111       return algorithm14(y, x, this, true);
    112     },
    113     'Array, any': function ArrayAny(x, y) {
    114       // use matrix implementation
    115       return algorithm14(matrix(x), y, this, false).valueOf();
    116     },
    117     'any, Array': function anyArray(x, y) {
    118       // use matrix implementation
    119       return algorithm14(matrix(y), x, this, true).valueOf();
    120     }
    121   });
    122 });
    123 exports.createDotPow = createDotPow;