lib/ops.js
function outer(A, B) {
    if (A.shape.length === 1) {
        A.reshape([A.shape[0], 1]);
    }
    else if (A.shape.length === 2) {
        if (A.shape[1] !== 1) {
            throw new Error('A is not a column vector');
        }
    }
    else {
        throw new Error('A has invalid dimensions');
    }
    if (B.shape.length === 1) {
        B.reshape([1, B.shape[0]]);
    }
    else if (B.shape.length === 2) {
        if (B.shape[0] !== 1) {
            throw new Error('B is not a row vector');
        }
    }
    else {
        throw new Error('B has invalid dimensions');
    }
    if (A.shape[0] !== B.shape[1]) {
        throw new Error('Sizes of A and B are not compatible');
    }
    return matmul(A, B);
}
function outer(A, B) {
    if (A.shape.length === 1) {
        A.reshape([A.shape[0], 1]);
    }
    else if (A.shape.length === 2) {
        if (A.shape[1] !== 1) {
            throw new Error('A is not a column vector');
        }
    }
    else {
        throw new Error('A has invalid dimensions');
    }
    if (B.shape.length === 1) {
        B.reshape([1, B.shape[0]]);
    }
    else if (B.shape.length === 2) {
        if (B.shape[0] !== 1) {
            throw new Error('B is not a row vector');
        }
    }
    else {
        throw new Error('B has invalid dimensions');
    }
    if (A.shape[0] !== B.shape[1]) {
        throw new Error('Sizes of A and B are not compatible');
    }
    return matmul(A, B);
}
function outer ( A , B ) { if ( A . shape . length === 1 ) { A . reshape ( [ A . shape [ 0 ] , 1 ] ) ; } else if ( A . shape . length === 2 ) { if ( A . shape [ 1 ] !== 1 ) { throw new Error ( 'A is not a column vector' ) ; } } else { throw new Error ( 'A has invalid dimensions' ) ; } if ( B . shape . length === 1 ) { B . reshape ( [ 1 , B . shape [ 0 ] ] ) ; } else if ( B . shape . length === 2 ) { if ( B . shape [ 0 ] !== 1 ) { throw new Error ( 'B is not a row vector' ) ; } } else { throw new Error ( 'B has invalid dimensions' ) ; } if ( A . shape [ 0 ] !== B . shape [ 1 ] ) { throw new Error ( 'Sizes of A and B are not compatible' ) ; } return matmul ( A , B ) ; }
Compute outer product of two vectors
@param A Vector of shape [m] or [m,1]
@param B Vector of shape [n] or [1,n]
@returns NDArray Matrix of dimension [m,n]
Compute outer product of two vectors