jiangchengfeiyi-xiaochengxu/node_modules/mathjs/lib/cjs/function/arithmetic/dotMultiply.js
2025-01-02 11:13:50 +08:00

72 lines
2.1 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createDotMultiply = void 0;
var _factory = require("../../utils/factory.js");
var _matAlgo02xDS = require("../../type/matrix/utils/matAlgo02xDS0.js");
var _matAlgo09xS0Sf = require("../../type/matrix/utils/matAlgo09xS0Sf.js");
var _matAlgo11xS0s = require("../../type/matrix/utils/matAlgo11xS0s.js");
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
const name = 'dotMultiply';
const dependencies = ['typed', 'matrix', 'equalScalar', 'multiplyScalar', 'concat'];
const createDotMultiply = exports.createDotMultiply = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
let {
typed,
matrix,
equalScalar,
multiplyScalar,
concat
} = _ref;
const matAlgo02xDS0 = (0, _matAlgo02xDS.createMatAlgo02xDS0)({
typed,
equalScalar
});
const matAlgo09xS0Sf = (0, _matAlgo09xS0Sf.createMatAlgo09xS0Sf)({
typed,
equalScalar
});
const matAlgo11xS0s = (0, _matAlgo11xS0s.createMatAlgo11xS0s)({
typed,
equalScalar
});
const matrixAlgorithmSuite = (0, _matrixAlgorithmSuite.createMatrixAlgorithmSuite)({
typed,
matrix,
concat
});
/**
* Multiply two matrices element wise. The function accepts both matrices and
* scalar values.
*
* Syntax:
*
* math.dotMultiply(x, y)
*
* Examples:
*
* math.dotMultiply(2, 4) // returns 8
*
* a = [[9, 5], [6, 1]]
* b = [[3, 2], [5, 2]]
*
* math.dotMultiply(a, b) // returns [[27, 10], [30, 2]]
* math.multiply(a, b) // returns [[52, 28], [23, 14]]
*
* See also:
*
* multiply, divide, dotDivide
*
* @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Left hand value
* @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Right hand value
* @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Multiplication of `x` and `y`
*/
return typed(name, matrixAlgorithmSuite({
elop: multiplyScalar,
SS: matAlgo09xS0Sf,
DS: matAlgo02xDS0,
Ss: matAlgo11xS0s
}));
});