Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const matrixA = math.matrix([[0, 1], [2, 3], [4, 5]]);
const matrixB = math.matrix([[0], [1], [2]]);
console.log(`Matrix A Dimension: ${matrixA.size()[0]}x${matrixA.size()[1]}`);
console.log(`Is vector: ${matrixA.size()[1] === 1}`);
console.log(`Matrix B Dimension: ${matrixB.size()[0]}x${matrixB.size()[1]}`);
console.log(`Is vector: ${matrixB.size()[1] === 1}`);
console.log('\n');
// Matrix Addition
const matrixC = math.matrix([[0, 1], [2, 3], [4, -5]]);
const matrixD = math.matrix([[1, -1], [-2, 4], [-7, 4]]);
const matrixAdditionCD = math.add(matrixC, matrixD);
console.log('Matrix Addition:');
console.log(matrixAdditionCD.valueOf());
console.log('\n');
// Matrix Subtraction
const matrixE = math.matrix([[0, 1], [2, 3], [4, -5]]);
const matrixF = math.matrix([[1, -1], [-2, 4], [-7, 4]]);
const matrixAdditionEF = math.subtract(matrixE, matrixF);
console.log('Matrix Subtraction:');
console.log(matrixAdditionEF.valueOf());
console.log('\n');
function addVectors(v) {
var add = true;
while (add) {
if (v.length == 2) {
add = false;
return mathjs.add(v[0], v[1]);
} else {
result = mathjs.add(v[0], v[1]);
// remove the first vector in array
v.shift();
// replace the new first element in array with result
v[0] = result;
}
}
}
if(uval) {
var row = rowmask;
var col = colmask;
var counter = unusedSpace;
var countermask = getElMask(0);
var incmask = getIncMask();
var notmask = getNotMask();
var toothless = countermask;
while(counter--) {
var state = this.state[col];
if(state) {
row = toothless | rowmask;
if(uval == 1) {
newState[row] = math.add(newState[row] || ZERO, state);
} else {
newState[row] = math.add(newState[row] || ZERO, math.multiply(uval, state));
}
newStateBits |= row;
}
toothless = (toothless + incmask) & notmask;
col = toothless | colmask;
}
}
}
}
}
// replace current state with new state
this.state = newState;
this.stateBits = newStateBits;
if (undefined === accounts) {
var message = `accounts is undefined`;
currentTestResult.failureMessages.push(message);
acctestutils.addTestResult(classResults, currentTestResult, false);
return;
}
if (accounts.length !== 1) {
var message = `accounts.length of ${accounts.length} was expected to be 1`;
currentTestResult.failureMessages.push(message);
acctestutils.addTestResult(classResults, currentTestResult, false);
return;
}
let plusOne = math.add(math.bignumber(accounts[0].balance.timestamp), math.bignumber(1));
let minusOne = math.subtract(math.bignumber(accounts[0].balance.timestamp), math.bignumber(1));
let paq = `${accountsPath}?timestamp=gt:${minusOne.toString()}` + `×tamp=lt:${plusOne.toString()}&limit=1`;
url = acctestutils.getUrl(server, paq);
currentTestResult.url = url;
accounts = await getAccounts(url, currentTestResult);
if (undefined === accounts) {
var message = `accounts is undefined`;
currentTestResult.failureMessages.push(message);
acctestutils.addTestResult(classResults, currentTestResult, false);
return;
}
if (accounts.length !== 1) {
var message = `accounts.length of ${accounts.length} was expected to be 1`;
function calcResult(params) {
let result = 0;
const nextIndex = params.length + 1;
for (let i = 0; i < params.length; i++) {
result = math.add(
math.fraction(result),
math.fraction(
math.multiply(
math.fraction(params[i]),
math.fraction(
math.pow(nextIndex, params.length - i - 1)
)
)
)
);
}
return result;
}
function(totalOutputError, layerNeuron) {
return add(
totalOutputError,
square(layerNeuron.outputError)
);
},
bignumber(0)
function(
synapse,
synapseIndex,
synapses
) {
synapse.previousWeightChange = synapse.weightChange;
synapse.weightChange = add(
multiply(
bignumber(learningRate),
multiply(
layerNeuron.delta,
synapse.incomingConnection.output
)
),
multiply(
bignumber(momentumRate),
synapse.previousWeightChange
)
);
synapse.previousWeight = synapse.weight;
synapse.weight = add(
synapse.weight,
synapse.weightChange
const main = () => {
let G = null;
for (let i = 0; i < 3; i++) {
if (G === null) {
G = randomG();
} else {
G = math.add(G, randomG());
}
}
for (let i = 0; i < 3; i++) {
G = math.subtract(G, randomG());
}
const alpha = learningRate;
const sigma = samplesArea;
let w = [math.randomInt(W - sigma * 4) + sigma * 2, math.randomInt(H - sigma * 4) + sigma * 2];
const points = [];
const samplePoints = [];
let minimumFound = false;
while (!minimumFound) {
const noise = math.add(math.multiply(initRandomMatrix(sampleSize, 2), 4), -2);
const wp = math.add(math.dotMultiply(sigma, noise), math.multiply(math.ones(sampleSize, 1), [w]));