function rowmajor( ndims, shape, idx, dim, out ) {
	var i;
	var j;

	// Set dimension indices which are skipped...
	for ( i = ndims-1; i > dim; i-- ) {
		out[ i ] = idx[ i ];
	}
	// Search for the first dimension in which we don't have to "carry the one"...
	for ( i = dim; i >= 0; i-- ) {
		j = ( idx[ i ] + 1 ) % shape[ i ];
		out[ i ] = j;

		// If the current index value is greater than zero, we can continue iterating within the current sub-array...
		if ( j > 0 ) {
			break;
		}
	}
	// Set dimension indices which did not get updated...
	for ( i -= 1; i >= 0; i-- ) {
		out[ i ] = idx[ i ];
	}
	return out;
}
Returns the next Cartesian index (row-major).

@private
@param {NonNegativeInteger} ndims - number of dimensions
@param {NonNegativeIntegerArray} shape - array shape
@param {NonNegativeIntegerArray} idx - current dimension indices
@param {NonNegativeInteger} dim - index of the dimension from which to start incrementing (inclusive)
@param {(Array|TypedArray|Object)} out - output array
@returns {(Array|TypedArray|Object)} output array