Skip to content

compute dot

kgryte edited this page May 12, 2015 · 1 revision

Computes the dot product between two arrays of equal length.

var val = compute.dot( [1,2,3], [4,5,6] );
// returns 32

For object arrays, provide an accessor function for accessing numeric values.

function getValue( d, i, j ) {
	if ( j === 0 ) {
		return d.x;
	}
	return d;
}

var x = [
	{'x':1},
	{'x':2},
	{'x':3}
];

var y = [ 4, 5, 6 ];

var val = compute.dot( x, y, getValue );
// returns 32

If provided empty arrays, the method returns null.

Clone this wiki locally