lib/ops.js
/**
 * Compute dot product of A and B, where both of them are 1D vectors of
 * same length
 */
Compute dot product of A and B, where both of them are 1D vectors of
same length
Compute dot product of A and B where both of them are 1D vectors of same length
function dot(A, B) {
    if (A.shape.length !== 1) {
        throw new Error('A is not a 1D array');
    }
    if (B.shape.length !== 1) {
        throw new Error('B is not a 1D array');
    }
    if (A.data.length !== B.data.length) {
        throw new Error("A and B are of different length");
    }
    var dot = 0.0;
    for (var i = 0; i < A.data.length; i++) {
        dot += A.data[i] * B.data[i];
    }
    return dot;
}
function dot ( A , B ) { if ( A . shape . length !== 1 ) { throw new Error ( 'A is not a 1D array' ) ; } if ( B . shape . length !== 1 ) { throw new Error ( 'B is not a 1D array' ) ; } if ( A . data . length !== B . data . length ) { throw new Error ( "A and B are of different length" ) ; } var dot = 0.0 ; for ( var i = 0 ; i < A . data . length ; i ++ ) { dot += A . data [ i ] * B . data [ i ] ; } return dot ; }
Compute dot product of A and B, where both of them are 1D vectors of
 same length
Compute dot product of A and B where both of them are 1D vectors of same length