\hypertarget{matrixArrayCalcs_8h}{\section{matrix\-Array\-Calcs.\-h File Reference}
\label{matrixArrayCalcs_8h}\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}}
}


matrix\-Array\-Calcs defines various utility functions for use with Matrix objects and array objects.  


{\ttfamily \#include \char`\"{}my\-Output.\-h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}math.\-h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}string.\-h\char`\"{}}\\*
{\ttfamily \#include $<$fstream$>$}\\*
{\ttfamily \#include $<$newmatap.\-h$>$}\\*
{\ttfamily \#include $<$newmatio.\-h$>$}\\*
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \hyperlink{matrixArrayCalcs_8h_a5197b278b9dd88d5c7509db1a9f76a56}{isnan}(a)~((fabs(a) $>$= 90000) $\vert$$\vert$ (a != a))
\item 
\#define \hyperlink{matrixArrayCalcs_8h_a1e471b644e7fd684cd5dbb144e00ee81}{sign}(a)~((a $>$ 0) -\/ (a $<$ 0))
\item 
\#define \hyperlink{matrixArrayCalcs_8h_a598a3330b3c21701223ee0ca14316eca}{P\-I}~3.\-14159265358979
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{matrixArrayCalcs_8h_a8574a23272c4ff2f4619aa7f5ecd582f}{min\-Val} (const int $\ast$values, const int num\-Values)
\item 
int \hyperlink{matrixArrayCalcs_8h_a398283d9d4503959638b98170fbb371d}{max\-Val} (const int $\ast$values, const int num\-Values)
\item 
Matrix \hyperlink{matrixArrayCalcs_8h_ae03a1ac8b31ccbc99fafdcab5c9456f1}{conv2} (const Matrix \&A, const Matrix \&H)
\item 
void \hyperlink{matrixArrayCalcs_8h_ad4b82b260bf9214941923697373e8ef6}{interp2} (double $\ast$xpts, double $\ast$ypts, const Matrix Z, double $\ast$xi, double $\ast$yi, double $\ast$zi, int num\-Pts)
\item 
void \hyperlink{matrixArrayCalcs_8h_a079805b2e947b76cc45193b5dd5912eb}{interp2mat} (double $\ast$xpts, double $\ast$ypts, const Matrix Z, double $\ast$xi, double $\ast$yi, Matrix \&zi)
\item 
void \hyperlink{matrixArrayCalcs_8h_a00e8a566ce6dc2f965abd44fa60ea1ff}{nearest\-Interp} (double $\ast$xpts, double $\ast$ypts, const Matrix \&zvals, double xi, double yi, double \&zi, int $\ast$x\-Indices, int $\ast$y\-Indices, Column\-Vector \&Weights)
\item 
bool \hyperlink{matrixArrayCalcs_8h_a0ab17298e31e8f2bd7d0afdf6dae026d}{find\-Nearest\-Valid} (const Matrix \&zvals, int \&x\-Index, int \&y\-Index)
\item 
void \hyperlink{matrixArrayCalcs_8h_a93519b5f002077f800b29c4364d97a22}{bilinear\-Interp} (double $\ast$xpts, double $\ast$ypts, const Matrix \&zvals, double xi, double yi, double \&zi, int $\ast$x\-Indices, int $\ast$y\-Indices, Column\-Vector \&Weights)
\item 
void \hyperlink{matrixArrayCalcs_8h_a10df3430b4f63339c501bc163da20ba0}{bicubic\-Interp} (double $\ast$xpts, double $\ast$ypts, const Matrix \&zvals, double xi, double yi, double \&zi, int $\ast$x\-Indices, int $\ast$y\-Indices, Column\-Vector \&Weights)
\item 
void \hyperlink{matrixArrayCalcs_8h_a9314989341219da17fe3d49b13bbe6af}{spline\-Interp} (double $\ast$xpts, double $\ast$ypts, const Matrix \&zvals, double xi, double yi, double \&zi, int $\ast$x\-Indices, int $\ast$y\-Indices, Column\-Vector \&Weights)
\item 
void \hyperlink{matrixArrayCalcs_8h_a97cd453dffc0b8c2c20878662f0f13f8}{nearest\-Interp\-\_\-mat} (double $\ast$xpts, double $\ast$ypts, const Matrix \&zvals, double $\ast$xi, double $\ast$yi, Matrix \&zi, Matrix \&var)
\item 
void \hyperlink{matrixArrayCalcs_8h_ab94d2c887fa02b160734b5d772ba8a29}{bilinear\-Interp\-\_\-mat} (double $\ast$xpts, double $\ast$ypts, const Matrix \&zvals, double $\ast$xi, double $\ast$yi, Matrix \&zi, Matrix \&var)
\item 
void \hyperlink{matrixArrayCalcs_8h_acd46a4cb72130c0a787036f930d64926}{bicubic\-Interp\-\_\-mat} (double $\ast$xpts, double $\ast$ypts, const Matrix \&zvals, double $\ast$xi, double $\ast$yi, Matrix \&zi, Matrix \&var)
\item 
void \hyperlink{matrixArrayCalcs_8h_ab14df0425ee1096bd119de1bd7bcdd82}{spline\-Interp\-\_\-mat} (double $\ast$xpts, double $\ast$ypts, const Matrix \&zvals, double $\ast$xi, double $\ast$yi, Matrix \&zi, Matrix \&var)
\item 
int \hyperlink{matrixArrayCalcs_8h_a54acc9e2e8c3d0cb9a9927928a5a6e26}{closest\-Pt} (double key, const double $\ast$base, size\-\_\-t nmemb)
\item 
int \hyperlink{matrixArrayCalcs_8h_a6d42c62b3df99a391e41fa37f367e751}{closest\-Pt\-Uniform\-Array} (double key, double first\-Val, double last\-Val, size\-\_\-t nmemb)
\item 
int \hyperlink{matrixArrayCalcs_8h_a41c1ad23610100bab0a5df6ebe695a61}{lower\-Bound} (double val, const double $\ast$vec, int num\-Vals)
\item 
double \hyperlink{matrixArrayCalcs_8h_a86e57067e17768f39748329b159070e1}{unif} (double mean, double half\-Interval)
\item 
double \hyperlink{matrixArrayCalcs_8h_a40723dd7c6418f724583d1fb3516031a}{unif\-\_\-zero\-Mean} (const double \&half\-Interval)
\item 
double \hyperlink{matrixArrayCalcs_8h_adb07ab3adf633b839df571ee2a25408c}{unif\-\_\-zero\-One} ()
\item 
double \hyperlink{matrixArrayCalcs_8h_a8aa203e5ca4b0f35a929b1f7505ded4d}{randn} (double mean, double stddev)
\item 
double \hyperlink{matrixArrayCalcs_8h_a1b1560e674db897f52aabcccc99e1662}{randn\-\_\-zero\-Mean} (const double \&stddev)
\item 
char $\ast$ \hyperlink{matrixArrayCalcs_8h_a3fe6dafb2bfc452e6ea3c53cf339e1f4}{char\-Cat} (char $\ast$dest, const char $\ast$front, const char $\ast$back)
\item 
double \hyperlink{matrixArrayCalcs_8h_a28973f8157ce3c558bce24300c267c8b}{compute\-K\-Ldiv\-\_\-gaussian\-\_\-mat} (double $\ast$xpts, double $\ast$ypts, const Matrix \&ref\-P\-D\-F, double $\ast$mu, const Matrix \&Cov)
\item 
Symmetric\-Matrix \hyperlink{matrixArrayCalcs_8h_a93aa722740ea7234a661a9deb5580cca}{compute\-Matrix\-Sqrt} (const Symmetric\-Matrix \&A)
\item 
void \hyperlink{matrixArrayCalcs_8h_aa9c8bcc94a53393c64261e2b2dae423b}{compute\-Array\-Cross\-Prod} (double $\ast$a, double $\ast$b, double $\ast$result)
\end{DoxyCompactItemize}


\subsection{Detailed Description}
matrix\-Array\-Calcs defines various utility functions for use with Matrix objects and array objects. \begin{DoxyAuthor}{Author}
Debbie Meduna 
\end{DoxyAuthor}
\begin{DoxyDate}{Date}
01/01/08 
\end{DoxyDate}


\subsection{Macro Definition Documentation}
\hypertarget{matrixArrayCalcs_8h_a5197b278b9dd88d5c7509db1a9f76a56}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!isnan@{isnan}}
\index{isnan@{isnan}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{isnan}]{\setlength{\rightskip}{0pt plus 5cm}\#define isnan(
\begin{DoxyParamCaption}
\item[{}]{a}
\end{DoxyParamCaption}
)~((fabs(a) $>$= 90000) $\vert$$\vert$ (a != a))}}\label{matrixArrayCalcs_8h_a5197b278b9dd88d5c7509db1a9f76a56}
\hypertarget{matrixArrayCalcs_8h_a598a3330b3c21701223ee0ca14316eca}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!P\-I@{P\-I}}
\index{P\-I@{P\-I}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{P\-I}]{\setlength{\rightskip}{0pt plus 5cm}\#define P\-I~3.\-14159265358979}}\label{matrixArrayCalcs_8h_a598a3330b3c21701223ee0ca14316eca}
\hypertarget{matrixArrayCalcs_8h_a1e471b644e7fd684cd5dbb144e00ee81}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!sign@{sign}}
\index{sign@{sign}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{sign}]{\setlength{\rightskip}{0pt plus 5cm}\#define sign(
\begin{DoxyParamCaption}
\item[{}]{a}
\end{DoxyParamCaption}
)~((a $>$ 0) -\/ (a $<$ 0))}}\label{matrixArrayCalcs_8h_a1e471b644e7fd684cd5dbb144e00ee81}


\subsection{Function Documentation}
\hypertarget{matrixArrayCalcs_8h_a10df3430b4f63339c501bc163da20ba0}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!bicubic\-Interp@{bicubic\-Interp}}
\index{bicubic\-Interp@{bicubic\-Interp}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{bicubic\-Interp}]{\setlength{\rightskip}{0pt plus 5cm}void bicubic\-Interp (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix \&}]{zvals, }
\item[{double}]{xi, }
\item[{double}]{yi, }
\item[{double \&}]{zi, }
\item[{int $\ast$}]{x\-Indices, }
\item[{int $\ast$}]{y\-Indices, }
\item[{Column\-Vector \&}]{Weights}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a10df3430b4f63339c501bc163da20ba0}
Uses bicubic interpolation to determine zi at the point (xi,yi) from the set of data xpts, ypts, and zvals. If zvals is size m x n, xpts is size m x 1 and ypts is size n x 1. The function modifies the the entries in x\-Indices, y\-Indices and W. x\-Indices and y\-Indices are px1 arrays containing the indices of xpts and ypts used to generate zi. The method used for bicubic interpolation is very similar to that described in Numerical Recipes in C++. If a 4x4 bounding box does not exist for the current (xi,yi) data point, O\-R the interpolated point is Na\-N, \hyperlink{matrixArrayCalcs_8h_a93519b5f002077f800b29c4364d97a22}{bilinear\-Interp()} is used. \hypertarget{matrixArrayCalcs_8h_acd46a4cb72130c0a787036f930d64926}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!bicubic\-Interp\-\_\-mat@{bicubic\-Interp\-\_\-mat}}
\index{bicubic\-Interp\-\_\-mat@{bicubic\-Interp\-\_\-mat}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{bicubic\-Interp\-\_\-mat}]{\setlength{\rightskip}{0pt plus 5cm}void bicubic\-Interp\-\_\-mat (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix \&}]{zvals, }
\item[{double $\ast$}]{xi, }
\item[{double $\ast$}]{yi, }
\item[{Matrix \&}]{zi, }
\item[{Matrix \&}]{var}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_acd46a4cb72130c0a787036f930d64926}
Interpolates all points in the vectors xi, yi to fill the matrix zi using the data in xpts, ypts and Z. Calls \hyperlink{matrixArrayCalcs_8h_a10df3430b4f63339c501bc163da20ba0}{bicubic\-Interp()} for each point in the xi and yi arrays to perform this interpolation. \hypertarget{matrixArrayCalcs_8h_a93519b5f002077f800b29c4364d97a22}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!bilinear\-Interp@{bilinear\-Interp}}
\index{bilinear\-Interp@{bilinear\-Interp}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{bilinear\-Interp}]{\setlength{\rightskip}{0pt plus 5cm}void bilinear\-Interp (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix \&}]{zvals, }
\item[{double}]{xi, }
\item[{double}]{yi, }
\item[{double \&}]{zi, }
\item[{int $\ast$}]{x\-Indices, }
\item[{int $\ast$}]{y\-Indices, }
\item[{Column\-Vector \&}]{Weights}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a93519b5f002077f800b29c4364d97a22}
Uses bilinear interpolation to determine zi at the point (xi,yi) from the set of data xpts, ypts, and zvals. If zvals is size m x n, xpts is size m x 1 and ypts is size n x 1. The function modifies the the entries in x\-Indices, y\-Indices and W. x\-Indices and y\-Indices are 4x1 arrays containing the indices of xpts and ypts used to generate zi. W is a 4x1 column vector of corresponding weights where\-: zi = sum\-\_\-i W(i,1)$\ast$zvals(x\-Indices\mbox{[}i\mbox{]}+1,y\-Indices\mbox{[}i\mbox{]}+1). If a 2x2 bounding box does not exist for the current (xi,yi) data point (i.\-e., it is out of the bounds of Z), O\-R the interpolated point is Na\-N, \hyperlink{matrixArrayCalcs_8h_a00e8a566ce6dc2f965abd44fa60ea1ff}{nearest\-Interp()} is used. \hypertarget{matrixArrayCalcs_8h_ab94d2c887fa02b160734b5d772ba8a29}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!bilinear\-Interp\-\_\-mat@{bilinear\-Interp\-\_\-mat}}
\index{bilinear\-Interp\-\_\-mat@{bilinear\-Interp\-\_\-mat}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{bilinear\-Interp\-\_\-mat}]{\setlength{\rightskip}{0pt plus 5cm}void bilinear\-Interp\-\_\-mat (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix \&}]{zvals, }
\item[{double $\ast$}]{xi, }
\item[{double $\ast$}]{yi, }
\item[{Matrix \&}]{zi, }
\item[{Matrix \&}]{var}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_ab94d2c887fa02b160734b5d772ba8a29}
Interpolates all points in the vectors xi, yi to fill the matrix zi using the data in xpts, ypts and Z. Calls \hyperlink{matrixArrayCalcs_8h_a93519b5f002077f800b29c4364d97a22}{bilinear\-Interp()} for each point in the xi and yi arrays to perform this interpolation. \hypertarget{matrixArrayCalcs_8h_a3fe6dafb2bfc452e6ea3c53cf339e1f4}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!char\-Cat@{char\-Cat}}
\index{char\-Cat@{char\-Cat}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{char\-Cat}]{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ char\-Cat (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{dest, }
\item[{const char $\ast$}]{front, }
\item[{const char $\ast$}]{back}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a3fe6dafb2bfc452e6ea3c53cf339e1f4}
This function is used to concatenate two character arrays (front and back) into a new character array, dest. This differs from the C standard function strcat() in that the returned character array is an entirely new location in memory, separate from the front and back arrays. The length of the dest char array must be greater than or equal to the sum of the lengths of the front and back arrays. \hypertarget{matrixArrayCalcs_8h_a54acc9e2e8c3d0cb9a9927928a5a6e26}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!closest\-Pt@{closest\-Pt}}
\index{closest\-Pt@{closest\-Pt}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{closest\-Pt}]{\setlength{\rightskip}{0pt plus 5cm}int closest\-Pt (
\begin{DoxyParamCaption}
\item[{double}]{key, }
\item[{const double $\ast$}]{base, }
\item[{size\-\_\-t}]{nmemb}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a54acc9e2e8c3d0cb9a9927928a5a6e26}
Finds the index into the array \char`\"{}pts\char`\"{} which is closest to \char`\"{}value\char`\"{}. This function is copied from the function \hyperlink{mapio_8cpp_aaacac2d74bfa7f23515981dc04287568}{nearest()} in \hyperlink{mapio_8cpp}{mapio.\-cpp}. \hypertarget{matrixArrayCalcs_8h_a6d42c62b3df99a391e41fa37f367e751}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!closest\-Pt\-Uniform\-Array@{closest\-Pt\-Uniform\-Array}}
\index{closest\-Pt\-Uniform\-Array@{closest\-Pt\-Uniform\-Array}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{closest\-Pt\-Uniform\-Array}]{\setlength{\rightskip}{0pt plus 5cm}int closest\-Pt\-Uniform\-Array (
\begin{DoxyParamCaption}
\item[{double}]{key, }
\item[{double}]{first\-Val, }
\item[{double}]{last\-Val, }
\item[{size\-\_\-t}]{nmemb}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{matrixArrayCalcs_8h_a6d42c62b3df99a391e41fa37f367e751}
Finds the index closest to \char`\"{}value\char`\"{} for the array whose first element is \char`\"{}first\-Val\char`\"{}, last element is \char`\"{}last\-Val\char`\"{}, and has size \char`\"{}nmemb\char`\"{}. This function assumes that the array specified is uniformly spaced and takes advantage of this to perform a faster search than \hyperlink{matrixArrayCalcs_8h_a54acc9e2e8c3d0cb9a9927928a5a6e26}{closest\-Pt()}. \hypertarget{matrixArrayCalcs_8h_aa9c8bcc94a53393c64261e2b2dae423b}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!compute\-Array\-Cross\-Prod@{compute\-Array\-Cross\-Prod}}
\index{compute\-Array\-Cross\-Prod@{compute\-Array\-Cross\-Prod}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{compute\-Array\-Cross\-Prod}]{\setlength{\rightskip}{0pt plus 5cm}void compute\-Array\-Cross\-Prod (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{a, }
\item[{double $\ast$}]{b, }
\item[{double $\ast$}]{result}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{matrixArrayCalcs_8h_aa9c8bcc94a53393c64261e2b2dae423b}
This function computes the cross product\-: array1 x array2, and returns the result in result. The arrays are assumed to have 3 elements. \hypertarget{matrixArrayCalcs_8h_a28973f8157ce3c558bce24300c267c8b}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!compute\-K\-Ldiv\-\_\-gaussian\-\_\-mat@{compute\-K\-Ldiv\-\_\-gaussian\-\_\-mat}}
\index{compute\-K\-Ldiv\-\_\-gaussian\-\_\-mat@{compute\-K\-Ldiv\-\_\-gaussian\-\_\-mat}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{compute\-K\-Ldiv\-\_\-gaussian\-\_\-mat}]{\setlength{\rightskip}{0pt plus 5cm}double compute\-K\-Ldiv\-\_\-gaussian\-\_\-mat (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix \&}]{ref\-P\-D\-F, }
\item[{double $\ast$}]{mu, }
\item[{const Matrix \&}]{Cov}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a28973f8157ce3c558bce24300c267c8b}
This function computes the K\-L divergence between a proposal distribution and a Gaussian distribution with mean vector mu and covariance C. The proposal distribution is described by the matrix P, with corresponding (x,y) values given in the vectors xpts and ypts. \hypertarget{matrixArrayCalcs_8h_a93aa722740ea7234a661a9deb5580cca}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!compute\-Matrix\-Sqrt@{compute\-Matrix\-Sqrt}}
\index{compute\-Matrix\-Sqrt@{compute\-Matrix\-Sqrt}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{compute\-Matrix\-Sqrt}]{\setlength{\rightskip}{0pt plus 5cm}Symmetric\-Matrix compute\-Matrix\-Sqrt (
\begin{DoxyParamCaption}
\item[{const Symmetric\-Matrix \&}]{A}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a93aa722740ea7234a661a9deb5580cca}
This function computes the matrix square root of the given matrix, A. The given matrix and the returned matrix are both symmetric matrices. The sqrt is computed by first performing the eigenvalue decomposition of the matrix A, square rooting the resulting eigenvalues, and reconstructing the matrix to get Asqrt. \hypertarget{matrixArrayCalcs_8h_ae03a1ac8b31ccbc99fafdcab5c9456f1}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!conv2@{conv2}}
\index{conv2@{conv2}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{conv2}]{\setlength{\rightskip}{0pt plus 5cm}Matrix conv2 (
\begin{DoxyParamCaption}
\item[{const Matrix \&}]{A, }
\item[{const Matrix \&}]{H}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_ae03a1ac8b31ccbc99fafdcab5c9456f1}
Computes the 2\-D convolution of A with filter matrix H. The returned matrix B is the same size as A. H is assumed to be smaller than A. \hypertarget{matrixArrayCalcs_8h_a0ab17298e31e8f2bd7d0afdf6dae026d}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!find\-Nearest\-Valid@{find\-Nearest\-Valid}}
\index{find\-Nearest\-Valid@{find\-Nearest\-Valid}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{find\-Nearest\-Valid}]{\setlength{\rightskip}{0pt plus 5cm}bool find\-Nearest\-Valid (
\begin{DoxyParamCaption}
\item[{const Matrix \&}]{zvals, }
\item[{int \&}]{x\-Index, }
\item[{int \&}]{y\-Index}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a0ab17298e31e8f2bd7d0afdf6dae026d}
Finds the nearest valid (non-\/\-Na\-N) point in the grid zvals to the point (x\-Index, y\-Index). Replaces x\-Index and y\-Index with the indices corresponding to this found location. Returns a boolean indicating if a non-\/\-Na\-N point was successfully found. \hypertarget{matrixArrayCalcs_8h_ad4b82b260bf9214941923697373e8ef6}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!interp2@{interp2}}
\index{interp2@{interp2}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{interp2}]{\setlength{\rightskip}{0pt plus 5cm}void interp2 (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix}]{Z, }
\item[{double $\ast$}]{xi, }
\item[{double $\ast$}]{yi, }
\item[{double $\ast$}]{zi, }
\item[{int}]{num\-Pts}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_ad4b82b260bf9214941923697373e8ef6}
Interpolates the matrix Z to the (x,y) point pairs in arrays xi and yi. N indicates the number of point pairs to be interpolated. The arrays xpts and ypts contain the (x,y) values corresponding to entries in matrix Z. If Z is size m x n, xpts is size m x 1 and ypts is size n x 1. Bilinear interpolation is used for this function. \hypertarget{matrixArrayCalcs_8h_a079805b2e947b76cc45193b5dd5912eb}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!interp2mat@{interp2mat}}
\index{interp2mat@{interp2mat}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{interp2mat}]{\setlength{\rightskip}{0pt plus 5cm}void interp2mat (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix}]{Z, }
\item[{double $\ast$}]{xi, }
\item[{double $\ast$}]{yi, }
\item[{Matrix \&}]{zi}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a079805b2e947b76cc45193b5dd5912eb}
Interpolates the matrix Z to a new matrix zi over the (x,y) points in the arrays xi and yi. Nx and Ny indicates the length of these arrays. The arrays xpts and ypts contain the (x,y) values corresponding to entries in matrix Z. If Z is size m x n, xpts is size m x 1 and ypts is size n x 1. This function calls \hyperlink{matrixArrayCalcs_8h_ad4b82b260bf9214941923697373e8ef6}{interp2()} for performing interpolations. \hypertarget{matrixArrayCalcs_8h_a41c1ad23610100bab0a5df6ebe695a61}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!lower\-Bound@{lower\-Bound}}
\index{lower\-Bound@{lower\-Bound}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{lower\-Bound}]{\setlength{\rightskip}{0pt plus 5cm}int lower\-Bound (
\begin{DoxyParamCaption}
\item[{double}]{val, }
\item[{const double $\ast$}]{vec, }
\item[{int}]{num\-Vals}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a41c1ad23610100bab0a5df6ebe695a61}
Finds the lowest index into the array \char`\"{}vec\char`\"{} which bounds the value \char`\"{}val\char`\"{}. This function does N\-O\-T check that the returned index is a valid index into the array. \hypertarget{matrixArrayCalcs_8h_a398283d9d4503959638b98170fbb371d}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!max\-Val@{max\-Val}}
\index{max\-Val@{max\-Val}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{max\-Val}]{\setlength{\rightskip}{0pt plus 5cm}int max\-Val (
\begin{DoxyParamCaption}
\item[{const int $\ast$}]{values, }
\item[{const int}]{num\-Values}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a398283d9d4503959638b98170fbb371d}
Finds and returns the maximum number in the integer array values. \hypertarget{matrixArrayCalcs_8h_a8574a23272c4ff2f4619aa7f5ecd582f}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!min\-Val@{min\-Val}}
\index{min\-Val@{min\-Val}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{min\-Val}]{\setlength{\rightskip}{0pt plus 5cm}int min\-Val (
\begin{DoxyParamCaption}
\item[{const int $\ast$}]{values, }
\item[{const int}]{num\-Values}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a8574a23272c4ff2f4619aa7f5ecd582f}
Rounds the number given to the nearest integer and returns the integer.

Finds and returns the minimum number in the integer array values. \hypertarget{matrixArrayCalcs_8h_a00e8a566ce6dc2f965abd44fa60ea1ff}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!nearest\-Interp@{nearest\-Interp}}
\index{nearest\-Interp@{nearest\-Interp}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{nearest\-Interp}]{\setlength{\rightskip}{0pt plus 5cm}void nearest\-Interp (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix \&}]{zvals, }
\item[{double}]{xi, }
\item[{double}]{yi, }
\item[{double \&}]{zi, }
\item[{int $\ast$}]{x\-Indices, }
\item[{int $\ast$}]{y\-Indices, }
\item[{Column\-Vector \&}]{Weights}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a00e8a566ce6dc2f965abd44fa60ea1ff}
Uses nearest-\/neighbor interpolation to determine zi at the point (xi,yi) from the set of data xpts, ypts, and zvals. If zvals is size m x n, xpts is size m x 1 and ypts is size n x 1. The function modifies the the entries in x\-Indices, y\-Indices and W. x\-Indices and y\-Indices are px1 arrays containing the indices of xpts and ypts used to generate zi. W is a px1 matrix of corresponding weights where\-: zi = sum\-\_\-i W(i,1)$\ast$zvals(x\-Indices\mbox{[}i\mbox{]}+1,y\-Indices\mbox{[}i\mbox{]}+1). If the nearest point is Na\-N, the closest non-\/\-Na\-N point is found. \hypertarget{matrixArrayCalcs_8h_a97cd453dffc0b8c2c20878662f0f13f8}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!nearest\-Interp\-\_\-mat@{nearest\-Interp\-\_\-mat}}
\index{nearest\-Interp\-\_\-mat@{nearest\-Interp\-\_\-mat}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{nearest\-Interp\-\_\-mat}]{\setlength{\rightskip}{0pt plus 5cm}void nearest\-Interp\-\_\-mat (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix \&}]{zvals, }
\item[{double $\ast$}]{xi, }
\item[{double $\ast$}]{yi, }
\item[{Matrix \&}]{zi, }
\item[{Matrix \&}]{var}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a97cd453dffc0b8c2c20878662f0f13f8}
Interpolates all points in the vectors xi, yi to fill the matrix zi using the data in xpts, ypts and Z. Calls \hyperlink{matrixArrayCalcs_8h_a00e8a566ce6dc2f965abd44fa60ea1ff}{nearest\-Interp()} for each point in the xi and yi arrays to perform this interpolation. \hypertarget{matrixArrayCalcs_8h_a8aa203e5ca4b0f35a929b1f7505ded4d}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!randn@{randn}}
\index{randn@{randn}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{randn}]{\setlength{\rightskip}{0pt plus 5cm}double randn (
\begin{DoxyParamCaption}
\item[{double}]{mean, }
\item[{double}]{stddev}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a8aa203e5ca4b0f35a929b1f7505ded4d}
Uses a polar form Box-\/\-Muller Transform to generate a pseudorandom number from a gaussian distribution with specificied mean and standard deviation. Generates two random numbers for each call and stores the unused number for the next call to this function. \hypertarget{matrixArrayCalcs_8h_a1b1560e674db897f52aabcccc99e1662}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!randn\-\_\-zero\-Mean@{randn\-\_\-zero\-Mean}}
\index{randn\-\_\-zero\-Mean@{randn\-\_\-zero\-Mean}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{randn\-\_\-zero\-Mean}]{\setlength{\rightskip}{0pt plus 5cm}double randn\-\_\-zero\-Mean (
\begin{DoxyParamCaption}
\item[{const double \&}]{stddev}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{matrixArrayCalcs_8h_a1b1560e674db897f52aabcccc99e1662}
Uses a polar form Box-\/\-Muller Transform to generate a pseudorandom number from a gaussian distribution with zero mean and specified standard deviation. Generates two random numbers for each call and stores the unused number for the next call to this function. \hypertarget{matrixArrayCalcs_8h_a9314989341219da17fe3d49b13bbe6af}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!spline\-Interp@{spline\-Interp}}
\index{spline\-Interp@{spline\-Interp}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{spline\-Interp}]{\setlength{\rightskip}{0pt plus 5cm}void spline\-Interp (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix \&}]{zvals, }
\item[{double}]{xi, }
\item[{double}]{yi, }
\item[{double \&}]{zi, }
\item[{int $\ast$}]{x\-Indices, }
\item[{int $\ast$}]{y\-Indices, }
\item[{Column\-Vector \&}]{Weights}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_a9314989341219da17fe3d49b13bbe6af}
Uses spline interpolation to determine zi at the point (xi,yi) from the set of data xpts, ypts, and zvals. If zvals is size m x n, xvals is size m x 1 and ypts is size n x 1. The function modifies the the entries in x\-Indices, y\-Indices and W. x\-Indices and y\-Indices are px1 arrays containing the indices of xpts and ypts used to generate zi. Currently, this function is only implemented if a Matlab engine is running. Otherwise, this function calls \hyperlink{matrixArrayCalcs_8h_a00e8a566ce6dc2f965abd44fa60ea1ff}{nearest\-Interp()}. \hypertarget{matrixArrayCalcs_8h_ab14df0425ee1096bd119de1bd7bcdd82}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!spline\-Interp\-\_\-mat@{spline\-Interp\-\_\-mat}}
\index{spline\-Interp\-\_\-mat@{spline\-Interp\-\_\-mat}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{spline\-Interp\-\_\-mat}]{\setlength{\rightskip}{0pt plus 5cm}void spline\-Interp\-\_\-mat (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{xpts, }
\item[{double $\ast$}]{ypts, }
\item[{const Matrix \&}]{zvals, }
\item[{double $\ast$}]{xi, }
\item[{double $\ast$}]{yi, }
\item[{Matrix \&}]{zi, }
\item[{Matrix \&}]{var}
\end{DoxyParamCaption}
)}}\label{matrixArrayCalcs_8h_ab14df0425ee1096bd119de1bd7bcdd82}
Interpolates all points in the vectors xi, yi to fill the matrix zi using the data in xpts, ypts and Z. Currently, this function is only implemented if a Matlab engine is running. Otherwise, this function calls \hyperlink{matrixArrayCalcs_8h_a97cd453dffc0b8c2c20878662f0f13f8}{nearest\-Interp\-\_\-mat()}. \hypertarget{matrixArrayCalcs_8h_a86e57067e17768f39748329b159070e1}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!unif@{unif}}
\index{unif@{unif}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{unif}]{\setlength{\rightskip}{0pt plus 5cm}double unif (
\begin{DoxyParamCaption}
\item[{double}]{mean, }
\item[{double}]{half\-Interval}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{matrixArrayCalcs_8h_a86e57067e17768f39748329b159070e1}
Generates a pseudorandom number from a uniform distribution with given mean and half\-Interval width. \hypertarget{matrixArrayCalcs_8h_a40723dd7c6418f724583d1fb3516031a}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!unif\-\_\-zero\-Mean@{unif\-\_\-zero\-Mean}}
\index{unif\-\_\-zero\-Mean@{unif\-\_\-zero\-Mean}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{unif\-\_\-zero\-Mean}]{\setlength{\rightskip}{0pt plus 5cm}double unif\-\_\-zero\-Mean (
\begin{DoxyParamCaption}
\item[{const double \&}]{half\-Interval}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{matrixArrayCalcs_8h_a40723dd7c6418f724583d1fb3516031a}
Generates a pseudorandom number from a uniform distribution with zero mean and given half\-Interval width. \hypertarget{matrixArrayCalcs_8h_adb07ab3adf633b839df571ee2a25408c}{\index{matrix\-Array\-Calcs.\-h@{matrix\-Array\-Calcs.\-h}!unif\-\_\-zero\-One@{unif\-\_\-zero\-One}}
\index{unif\-\_\-zero\-One@{unif\-\_\-zero\-One}!matrixArrayCalcs.h@{matrix\-Array\-Calcs.\-h}}
\subsubsection[{unif\-\_\-zero\-One}]{\setlength{\rightskip}{0pt plus 5cm}double unif\-\_\-zero\-One (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{matrixArrayCalcs_8h_adb07ab3adf633b839df571ee2a25408c}
Generates a pseudorandom number from a uniform distribution with zero mean and half\-Interval width of 1. 