How to use the dotMultiply function from mathjs
Find comprehensive JavaScript mathjs.dotMultiply code examples handpicked from public code repositorys.
GitHub: kengz/Risk-game
43 44 45 46 47 48 49 50 51
return _.compose(fn.mean, fn.sumrow)(a); }, // for each partition of AM, reduce to mean-sum-row, then dotMultiply with degree of partition scalPartByDeg: function(AMpart, partdeg) { return m.dotMultiply(_.map(AMpart, fn.msr), partdeg); },
7
16
0
+ 3 other calls in file
GitHub: stur86/crystcif-parse
63 64 65 66 67 68 69 70 71 72
// Define rotated X,Y,Z-system, with Z along ab_normal and X along // the projection of a_direction onto the normal plane of Z. var ad = utils.unit(a_direction); var Z = utils.unit(ab_normal); var X = utils.unit(mjs.subtract(ad, mjs.dotMultiply(mjs.dot(ad, Z), Z))); var Y = utils.cross(Z, X); // Express va, vb and vc in the X,Y,Z-system var l = cellpar[0];
2
6
3
GitHub: muntashir/3net.js
68 69 70 71 72 73 74 75 76 77
function sigmoid(x) { return math.dotDivide(1, math.add(1, math.exp(math.multiply(-1, x)))); } function dSigmoid(x) { return math.dotMultiply(sigmoid(x), math.subtract(1, sigmoid(x))); } //Multiplies a column vector with a row vector because MathJS doesn't support tranposing 1 dimensional matrices function outerProduct(x, y) {
0
4
2
5 6 7 8 9 10 11 12 13 14
W = [1, 1, 0, 1/20, 0, 1, 1, 1, 1, 1, 1/140]; function weightedMse(x_song, x_target) { //console.log(x_song); //Normalize song and target vector values x_song_norm = math.dotMultiply(x_song, W); //console.log(x_song_norm) x_target_norm = math.dotMultiply(x_target, W); //console.log(x_target_norm) //Calculate MSE between song and target
0
4
3
+ 3 other calls in file
30 31 32 33 34 35 36 37 38 39
let nu = maths.chain([...Array(1002).keys()]) .dotMultiply(2) .add(1) .done(); let x1 = maths.dotMultiply(q, this.r1), x2 = maths.dotMultiply(q, this.r2); var jx = []; var _jx_1 = []; var _jx_2 = [];
2
3
0
+ 3 other calls in file
126 127 128 129 130 131 132 133 134 135
//B = math.evaluate("[" + B.toString() + "] cm"); //C = math.evaluate("[" + C.toString() + "] s"); var mathjsDoMath = performance.timerify(() => { return math.subtract( math.add( math.dotMultiply(4, math.dotDivide(math.dotMultiply(A, math.dotPow(B, 2)), math.dotPow(C, 2))), math.dotMultiply(2, math.dotDivide(math.dotMultiply(A, math.dotPow(B, 2)), math.dotPow(C, 2))), ), math.dotMultiply(3, math.dotDivide(math.dotMultiply(A, math.dotPow(B, 2)), math.dotPow(C, 2))) );
0
2
0
+ 5 other calls in file
GitHub: cytoai/autotuner
31 32 33 34 35 36 37 38 39 40
var gamma = math.dotDivide(math.subtract(mean, bestObjective), std); var pdf = math.dotDivide(math.exp(math.dotDivide(math.square(gamma), -2)), math.sqrt(2 * 3.14159)); var cdf = math.dotDivide(math.add(math.erf(math.dotDivide(gamma, math.sqrt(2))), 1), 2); return math.dotMultiply(std, math.add(math.dotMultiply(gamma, cdf), pdf)); } module.exports = { argmax: argmax,
0
2
2
+ 3 other calls in file
21 22 23 24 25 26 27 28 29 30 31 32
} // DL = (AL - Y) o sigprime(Z) function BP1(AL, Y, ZL) { const sigprimedZ = ZL.map(sigprime); return dotMultiply(subtract(AL, Y), sigprimedZ); } // Dl = (W^T * D) o sigprime(Z) function BP2(W, D, Z) {
0
0
0
17 18 19 20 21 22 23 24 25 26
if (this.trial <= config.abc.max_trials) { let component = mathjs.pickRandom(this.position); let phi = mathjs.random([1, dimensions], -1, 1)[0]; let sub = mathjs.subtract(this.position, component); let mul = mathjs.dotMultiply(sub, phi); let new_position = mathjs.add(this.position, mul); new_position = this.checkBoundaries(new_position); let new_fitness = this.evaluate(new_position);
0
0
0
60 61 62 63 64 65 66 67 68 69
*/ individual_movement(school, step, boundaries) { school.forEach((fish) => { let rand = mathjs.random([1, dimensions], -1, 1)[0]; let factor = mathjs.dotMultiply(rand, step); let nextPosition = mathjs.add(fish.position, factor); nextPosition = this.checkBoundaries(fish, nextPosition, boundaries);
0
0
0
+ 19 other calls in file
GitHub: Kirigaya-Kazuton/IA
47 48 49 50 51 52 53 54 55 56
// desvio sem tendência: é a raíz quadrada da variância sem tendência console.log('desvio sem tendência:', math.std([2, 4], 'unbiased')); // raíz quadrada console.log('raíz quadrada:', math.sqrt([9, 81])); // multiplicação convencional (1*4) e (2*3) console.log('multiplicação convencional:', math.dotMultiply([1, 2], [4, 3])); // multiplicação matricial: (1*2)+(2*3)=8 console.log('multiplicação matricial:', math.multiply([1, 2], [2, 3])); // subtração 5 - 2 e 3 -1 console.log('subtração:', math.subtract([5, 3], [2, 1]));
0
0
0
+ 2 other calls in file
GitHub: mljs/optimization
157 158 159 160 161 162 163 164 165 166
var tmp = math.multiply(math.ones(Npnt,1),weight[0]); weight_sq = math.dotMultiply(tmp,tmp); } else{ //weight_sq = (weight(:)).^2; weight_sq = math.dotMultiply(weight,weight); } // initialize Jacobian with finite difference calculation
0
0
0
+ 5 other calls in file
160 161 162 163 164 165 166 167 168 169
targets = math.resize(targets, [this.no, 1]); // calculate error terms for output var outputError = math.subtract(targets, this.ao); var dAo = math.map(this.ao, dsigmoid); var outputDelta = math.dotMultiply(dAo, outputError); // calculate error terms for hidden var hiddenError = math.multiply(math.transpose(this.wo), outputDelta); var dWo = math.map(this.ah, dsigmoid);
0
0
0
mathjs.evaluate is the most popular function in mathjs (87200 examples)