mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
var collection = require('../../type/collection');
|
|
var size = require('../../util/array').size;
|
|
|
|
function factory (type, config, load, typed) {
|
|
var multiply = load(require('./multiply'));
|
|
|
|
/**
|
|
* 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 | Boolean | Complex | Unit | Array | Matrix | null} x Left hand value
|
|
* @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Right hand value
|
|
* @return {Number | BigNumber | Complex | Unit | Array | Matrix} Multiplication of `x` and `y`
|
|
*/
|
|
return typed('dotMultiply', {
|
|
'any, any': function (x, y) {
|
|
return collection.deepMap2(x, y, multiply);
|
|
}
|
|
});
|
|
}
|
|
|
|
exports.name = 'dotMultiply';
|
|
exports.factory = factory;
|