Home > freetb4matlab > general > idivide.m

idivide

PURPOSE ^

% Integer division with different round rules. The standard behavior of

SYNOPSIS ^

function z = idivide (x, y, op)

DESCRIPTION ^

% -*- texinfo -*-
% @deftypefn {Function File} {} idivide (@var{x}, @var{y}, @var{op})
% Integer division with different round rules.  The standard behavior of
% the an integer division such as @code{@var{a} ./ @var{b}} is to round
% the result to the nearest integer.  This is not always the desired
% behavior and @code{idivide} permits integer element-by-element
% division to be performed with different treatment for the fractional
% part of the division as determined by the @var{op} flag.  @var{op} is
% a string with one of the values: 
%
% @table @asis
% @item 'fix'
% Calculate @code{@var{a} ./ @var{b}} with the fractional part rounded
% towards zero.
% @item 'round'
% Calculate @code{@var{a} ./ @var{b}} with the fractional part rounded
% towards the nearest integer.
% @item 'floor'
% Calculate @code{@var{a} ./ @var{b}} with the fractional part rounded
% downwards.
% @item 'ceil'
% Calculate @code{@var{a} ./ @var{b}} with the fractional part rounded
% upwards.
% @end table
% 
% @noindent
% If @var{op} is not given it is assumed that it is @code{'fix'}.
% An example demonstrating these rounding rules is
%
% @example
% @group
% idivide (int8 ([-3, 3]), int8 (4), 'fix')
% @result{} int8 ([0, 0])
% idivide (int8 ([-3, 3]), int8 (4), 'round')
% @result{} int8 ([-1, 1])
% idivide (int8 ([-3, 3]), int8 (4), 'ceil')
% @result{} int8 ([0, 1])
% idivide (int8 ([-3, 3]), int8 (4), 'floor')
% @result{} int8 ([-1, 0])
% @end group
% @end example
%
% @seealso{ldivide, rdivide}
% @end deftypefn

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Fri 22-May-2009 15:13:00 by m2html © 2003