\section{REM Remainder After Division}

\subsection{Usage}

Computes the remainder after division of an array.  The syntax for its use is
\begin{verbatim}
   y = rem(x,n)
\end{verbatim}
where \verb|x| is matrix, and \verb|n| is the base of the modulus.  The
effect of the \verb|rem| operator is to add or subtract multiples of \verb|n|
to the vector \verb|x| so that each element \verb|x_i| is between \verb|0| and \verb|n|
(strictly).  Note that \verb|n| does not have to be an integer.  Also,
\verb|n| can either be a scalar (same base for all elements of \verb|x|), or a
vector (different base for each element of \verb|x|).

Note that the following are defined behaviors:
\begin{enumerate}
\item  \verb|rem(x,0) = nan|@

\item  \verb|rem(x,x) = 0|@ for nonzero \verb|x|

\item  \verb|rem(x,n)|@ has the same sign as \verb|x| for all other cases.

\end{enumerate}
Note that \verb|rem| and \verb|mod| return the same value if \verb|x| and \verb|n|
are of the same sign.  But differ by \verb|n| if \verb|x| and \verb|y| have 
different signs.
\subsection{Example}

The following examples show some uses of \verb|rem|
arrays.
\begin{verbatim}
--> rem(18,12)
ans = 
  <double>  - size: [1 1]
 6  
--> rem(6,5)
ans = 
  <double>  - size: [1 1]
 1  
--> rem(2*pi,pi)
ans = 
  <double>  - size: [1 1]
 0  

\end{verbatim}
Here is an example of using \verb|rem| to determine if integers are even
 or odd:
\begin{verbatim}
--> rem([1,3,5,2],2)
ans = 
  <double>  - size: [1 4]
 
Columns 1 to 4
 1  1  1  0  

\end{verbatim}
Here we use the second form of \verb|rem|, with each element using a 
separate base.
\begin{verbatim}
--> rem([9 3 2 0],[1 0 2 2])
ans = 
  <double>  - size: [1 4]
 
Columns 1 to 4
   0  nan    0    0  

\end{verbatim}
