function avgMatrix( A, B, weight ) {
	var propA;
	var propB;
	var nrow;
	var ncol;
	var val;
	var C;
	var i;
	var j;

	nrow = A.shape[ 0 ];
	ncol = A.shape[ 1 ];
	C = matrix( [ nrow, ncol ] );
	propA = ( weight - 1.0 ) / weight;
	propB = 1.0 / weight;

	for ( i = 0; i < nrow; i++ ) {
		for ( j = 0; j < ncol; j++ ) {
			val = (propA * A.get(i, j)) + (propB * B.get(i, j));
			C.set( i, j, val );
		}
	}
	return C;
}
Calculate weighted average of two matrices.

@private
@param {Matrix} A - first matrix
@param {Matrix} B - second matrix
@param {PositiveInteger} weight - relative weight of matrix A
@returns {Matrix} averaged matrix