UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif

75 lines (74 loc) • 2.42 kB
import { factory } from '../../utils/factory.js'; import { createMatAlgo03xDSf } from '../../type/matrix/utils/matAlgo03xDSf.js'; import { createMatAlgo07xSSf } from '../../type/matrix/utils/matAlgo07xSSf.js'; import { createMatAlgo12xSfs } from '../../type/matrix/utils/matAlgo12xSfs.js'; import { createMatrixAlgorithmSuite } from '../../type/matrix/utils/matrixAlgorithmSuite.js'; var name = 'dotPow'; var dependencies = ['typed', 'matrix', 'pow', 'DenseMatrix', 'SparseMatrix']; export var createDotPow = /* #__PURE__ */factory(name, dependencies, _ref => { var typed = _ref.typed, matrix = _ref.matrix, pow = _ref.pow, DenseMatrix = _ref.DenseMatrix, SparseMatrix = _ref.SparseMatrix; var matAlgo03xDSf = createMatAlgo03xDSf({ typed }); var matAlgo07xSSf = createMatAlgo07xSSf({ typed, SparseMatrix }); var matAlgo12xSfs = createMatAlgo12xSfs({ typed, DenseMatrix }); var matrixAlgorithmSuite = createMatrixAlgorithmSuite({ typed, matrix }); var powScalarSignatures = {}; for (var signature in pow.signatures) { if (Object.prototype.hasOwnProperty.call(pow.signatures, signature)) { if (!signature.includes('Matrix') && !signature.includes('Array')) { powScalarSignatures[signature] = pow.signatures[signature]; } } } var powScalar = typed(powScalarSignatures); /** * Calculates the power of x to y element wise. * * Syntax: * * math.dotPow(x, y) * * Examples: * * math.dotPow(2, 3) // returns number 8 * * const a = [[1, 2], [4, 3]] * math.dotPow(a, 2) // returns Array [[1, 4], [16, 9]] * math.pow(a, 2) // returns Array [[9, 8], [16, 17]] * * See also: * * pow, sqrt, multiply * * History: * * v14.0.0 Return a sparse matrix for sparse inputs * v11.6 Support matrix broadcasting * v0.23 Renamed from `epow` * * @param {number | BigNumber | Complex | Unit | Array | Matrix} x The base * @param {number | BigNumber | Complex | Unit | Array | Matrix} y The exponent * @return {number | BigNumber | Complex | Unit | Array | Matrix} The value of `x` to the power `y` */ return typed(name, matrixAlgorithmSuite({ elop: powScalar, SS: matAlgo07xSSf, DS: matAlgo03xDSf, Ss: matAlgo12xSfs, sS: matAlgo12xSfs })); });