UNPKG

3.94 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.createDotPow = void 0;
7
8var _factory = require("../../utils/factory");
9
10var _algorithm = require("../../type/matrix/utils/algorithm03");
11
12var _algorithm2 = require("../../type/matrix/utils/algorithm07");
13
14var _algorithm3 = require("../../type/matrix/utils/algorithm11");
15
16var _algorithm4 = require("../../type/matrix/utils/algorithm12");
17
18var _algorithm5 = require("../../type/matrix/utils/algorithm13");
19
20var _algorithm6 = require("../../type/matrix/utils/algorithm14");
21
22var name = 'dotPow';
23var dependencies = ['typed', 'equalScalar', 'matrix', 'pow', 'DenseMatrix'];
24var 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 var dotPow = 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 dotPow(matrix(x), matrix(y)).valueOf();
92 },
93 'Array, Matrix': function ArrayMatrix(x, y) {
94 // use matrix implementation
95 return dotPow(matrix(x), y);
96 },
97 'Matrix, Array': function MatrixArray(x, y) {
98 // use matrix implementation
99 return dotPow(x, matrix(y));
100 },
101 'SparseMatrix, any': function SparseMatrixAny(x, y) {
102 return algorithm11(x, y, dotPow, false);
103 },
104 'DenseMatrix, any': function DenseMatrixAny(x, y) {
105 return algorithm14(x, y, dotPow, false);
106 },
107 'any, SparseMatrix': function anySparseMatrix(x, y) {
108 return algorithm12(y, x, dotPow, true);
109 },
110 'any, DenseMatrix': function anyDenseMatrix(x, y) {
111 return algorithm14(y, x, dotPow, true);
112 },
113 'Array, any': function ArrayAny(x, y) {
114 // use matrix implementation
115 return algorithm14(matrix(x), y, dotPow, false).valueOf();
116 },
117 'any, Array': function anyArray(x, y) {
118 // use matrix implementation
119 return algorithm14(matrix(y), x, dotPow, true).valueOf();
120 }
121 });
122 return dotPow;
123});
124exports.createDotPow = createDotPow;
\No newline at end of file