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
37 lines (35 loc) • 1.31 kB
JavaScript
import { factory } from '../../../utils/factory.js';
var name = 'matAlgo14xDs';
var dependencies = ['typed'];
export var createMatAlgo14xDs = /* #__PURE__ */factory(name, dependencies, _ref => {
var typed = _ref.typed;
/**
* Iterates over DenseMatrix items and invokes the callback function f(Aij..z, b).
* Callback function invoked MxN times.
*
* C(i,j,...z) = f(Aij..z, b)
*
* @param {Matrix} a The DenseMatrix instance (A)
* @param {Scalar} b The Scalar value
* @param {Function} callback The f(Aij..z,b) operation to invoke
* @param {boolean} inverse A true value indicates callback should be invoked f(b,Aij..z)
*
* @return {Matrix} DenseMatrix (C)
*
* https://github.com/josdejong/mathjs/pull/346#issuecomment-97659042
*/
return function matAlgo14xDs(a, b, callback, inverse) {
// a arrays
var adt = a._datatype;
// callback signature to use
var cf = callback;
// process data types
if (typeof adt === 'string') {
// convert b to the same datatype
b = typed.convert(b, adt);
// callback
cf = typed.find(callback, [adt, adt]);
}
return inverse ? a.map(v => cf(b, v), false, true) : a.map(v => cf(v, b), false, true);
};
});