\hypertarget{group__mymath}{}\doxysection{Mymath Library}
\label{group__mymath}\index{Mymath Library@{Mymath Library}}


Math and matrix utilities.  


\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \mbox{\hyperlink{group__mymath_ga227eaade4011887dce2896bb79d155bc}{transpone}} (double $\ast$arr, unsigned int Nrows, unsigned int Ncols)
\begin{DoxyCompactList}\small\item\em Transposes a matrix in-\/place. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__mymath_ga20b46b1a784a88425c75346675dd5a9f}{invert}} (double $\ast$arr, unsigned int Nrows, unsigned int Ncols)
\begin{DoxyCompactList}\small\item\em Inverts a square matrix in-\/place. \end{DoxyCompactList}\item 
double $\ast$ \mbox{\hyperlink{group__mymath_gaa416e7200d138f4658d7e0957f99b1f7}{mulmat}} (const double $\ast$matrix0, unsigned int Nrows, unsigned int Ncols, const double $\ast$matrix1, unsigned int Mrows, unsigned int Mcols)
\begin{DoxyCompactList}\small\item\em Multiplies two matrices and returns the result as a new matrix. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__mymath_gab2f9dd27878a8e05a6aba5b499b178de}{matlinreg}} (double coeffs\mbox{[}2\mbox{]}, const double $\ast$xmat, unsigned int Nrows, unsigned int Ncols, double $\ast$vec, const double $\ast$weight)
\begin{DoxyCompactList}\small\item\em Performs linear regression on a dataset with optional weighting. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__mymath_ga796beb5c24876db27ada7a5e2466330d}{fit\+Npeaks}} (double $\ast$intercept, double $\ast$slope, unsigned int cur\+Pos, const struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$maxvals, const struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$maxes, const struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$subpos, unsigned int npeaks, double SDthreshold)
\begin{DoxyCompactList}\small\item\em Fits a line to N peaks in the data, with outlier rejection. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__mymath_ga7ed6eb4d3afa19567d734e84c0e23ba4}{fastlinreg}} (double coeffs\mbox{[}2\mbox{]}, const double $\ast$xmat, unsigned int Npoints, const double $\ast$vec, const double $\ast$weight\+Arr)
\begin{DoxyCompactList}\small\item\em Performs fast weighted linear regression. \end{DoxyCompactList}\item 
size\+\_\+t \mbox{\hyperlink{group__mymath_gad6fc91777cf096e8b0b1cf14109ddbd3}{getmaxpos}} (const int $\ast$array, size\+\_\+t Array\+Length)
\begin{DoxyCompactList}\small\item\em Returns the index of the maximum value in an integer array. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__mymath_ga239201d57c9b2822f69d5ccb3005cc0f}{linreg}} (const double $\ast$xarr, const double $\ast$yarr, size\+\_\+t Array\+Length, double $\ast$intercept, double $\ast$slope, double $\ast$stdev)
\begin{DoxyCompactList}\small\item\em Performs simple linear regression on two arrays. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__mymath_ga185afbbfacdb1ebd2fb8bc9f8c7ce458}{shift\+Half}} (size\+\_\+t value, size\+\_\+t Array\+Length)
\begin{DoxyCompactList}\small\item\em Shifts a value by half the array length, wrapping around. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Math and matrix utilities. 



\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__mymath_ga7ed6eb4d3afa19567d734e84c0e23ba4}\label{group__mymath_ga7ed6eb4d3afa19567d734e84c0e23ba4}} 
\index{Mymath Library@{Mymath Library}!fastlinreg@{fastlinreg}}
\index{fastlinreg@{fastlinreg}!Mymath Library@{Mymath Library}}
\doxysubsubsection{\texorpdfstring{fastlinreg()}{fastlinreg()}}
{\footnotesize\ttfamily void fastlinreg (\begin{DoxyParamCaption}\item[{double}]{coeffs\mbox{[}2\mbox{]},  }\item[{const double $\ast$}]{xmat,  }\item[{unsigned int}]{Npoints,  }\item[{const double $\ast$}]{vec,  }\item[{const double $\ast$}]{weight\+Arr }\end{DoxyParamCaption})}



Performs fast weighted linear regression. 


\begin{DoxyParams}{Parameters}
{\em coeffs} & Array to store the resulting coefficients (intercept and slope). \\
\hline
{\em xmat} & The array of x values. \\
\hline
{\em Npoints} & The number of points. \\
\hline
{\em vec} & The array of y values. \\
\hline
{\em weight\+Arr} & The array of weights. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__mymath_ga796beb5c24876db27ada7a5e2466330d}\label{group__mymath_ga796beb5c24876db27ada7a5e2466330d}} 
\index{Mymath Library@{Mymath Library}!fitNpeaks@{fitNpeaks}}
\index{fitNpeaks@{fitNpeaks}!Mymath Library@{Mymath Library}}
\doxysubsubsection{\texorpdfstring{fitNpeaks()}{fitNpeaks()}}
{\footnotesize\ttfamily void fit\+Npeaks (\begin{DoxyParamCaption}\item[{double $\ast$}]{intercept,  }\item[{double $\ast$}]{slope,  }\item[{unsigned int}]{cur\+Pos,  }\item[{const struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$}]{maxvals,  }\item[{const struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$}]{maxes,  }\item[{const struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$}]{subpos,  }\item[{unsigned int}]{npeaks,  }\item[{double}]{SDthreshold }\end{DoxyParamCaption})}



Fits a line to N peaks in the data, with outlier rejection. 


\begin{DoxyParams}{Parameters}
{\em intercept} & Pointer to store the intercept. \\
\hline
{\em slope} & Pointer to store the slope. \\
\hline
{\em cur\+Pos} & The current position in the data. \\
\hline
{\em maxvals} & Array of weights. \\
\hline
{\em maxes} & Array of y values. \\
\hline
{\em subpos} & Array of sub-\/positions. \\
\hline
{\em npeaks} & Number of peaks to fit. \\
\hline
{\em SDthreshold} & Standard deviation threshold for outlier rejection. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__mymath_gad6fc91777cf096e8b0b1cf14109ddbd3}\label{group__mymath_gad6fc91777cf096e8b0b1cf14109ddbd3}} 
\index{Mymath Library@{Mymath Library}!getmaxpos@{getmaxpos}}
\index{getmaxpos@{getmaxpos}!Mymath Library@{Mymath Library}}
\doxysubsubsection{\texorpdfstring{getmaxpos()}{getmaxpos()}}
{\footnotesize\ttfamily size\+\_\+t getmaxpos (\begin{DoxyParamCaption}\item[{const int $\ast$}]{array,  }\item[{size\+\_\+t}]{Array\+Length }\end{DoxyParamCaption})}



Returns the index of the maximum value in an integer array. 


\begin{DoxyParams}{Parameters}
{\em array} & The array to search. \\
\hline
{\em Array\+Length} & The number of elements in the array. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The index of the maximum value. 
\end{DoxyReturn}
\mbox{\Hypertarget{group__mymath_ga20b46b1a784a88425c75346675dd5a9f}\label{group__mymath_ga20b46b1a784a88425c75346675dd5a9f}} 
\index{Mymath Library@{Mymath Library}!invert@{invert}}
\index{invert@{invert}!Mymath Library@{Mymath Library}}
\doxysubsubsection{\texorpdfstring{invert()}{invert()}}
{\footnotesize\ttfamily void invert (\begin{DoxyParamCaption}\item[{double $\ast$}]{arr,  }\item[{unsigned int}]{Nrows,  }\item[{unsigned int}]{Ncols }\end{DoxyParamCaption})}



Inverts a square matrix in-\/place. 


\begin{DoxyParams}{Parameters}
{\em arr} & The square matrix to invert, stored as a 1D array in row-\/major order. The result will overwrite the original matrix. \\
\hline
{\em Nrows} & The number of rows (and columns) in the square matrix. \\
\hline
{\em Ncols} & The number of columns (and rows) in the square matrix. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__mymath_ga239201d57c9b2822f69d5ccb3005cc0f}\label{group__mymath_ga239201d57c9b2822f69d5ccb3005cc0f}} 
\index{Mymath Library@{Mymath Library}!linreg@{linreg}}
\index{linreg@{linreg}!Mymath Library@{Mymath Library}}
\doxysubsubsection{\texorpdfstring{linreg()}{linreg()}}
{\footnotesize\ttfamily void linreg (\begin{DoxyParamCaption}\item[{const double $\ast$}]{xarr,  }\item[{const double $\ast$}]{yarr,  }\item[{size\+\_\+t}]{Array\+Length,  }\item[{double $\ast$}]{intercept,  }\item[{double $\ast$}]{slope,  }\item[{double $\ast$}]{stdev }\end{DoxyParamCaption})}



Performs simple linear regression on two arrays. 


\begin{DoxyParams}{Parameters}
{\em xarr} & The array of x values. \\
\hline
{\em yarr} & The array of y values. \\
\hline
{\em Array\+Length} & The number of elements in the arrays. \\
\hline
{\em intercept} & Pointer to store the intercept. \\
\hline
{\em slope} & Pointer to store the slope. \\
\hline
{\em stdev} & Pointer to store the standard deviation of the fit. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__mymath_gab2f9dd27878a8e05a6aba5b499b178de}\label{group__mymath_gab2f9dd27878a8e05a6aba5b499b178de}} 
\index{Mymath Library@{Mymath Library}!matlinreg@{matlinreg}}
\index{matlinreg@{matlinreg}!Mymath Library@{Mymath Library}}
\doxysubsubsection{\texorpdfstring{matlinreg()}{matlinreg()}}
{\footnotesize\ttfamily void matlinreg (\begin{DoxyParamCaption}\item[{double}]{coeffs\mbox{[}2\mbox{]},  }\item[{const double $\ast$}]{xmat,  }\item[{unsigned int}]{Nrows,  }\item[{unsigned int}]{Ncols,  }\item[{double $\ast$}]{vec,  }\item[{const double $\ast$}]{weight }\end{DoxyParamCaption})}



Performs linear regression on a dataset with optional weighting. 


\begin{DoxyParams}{Parameters}
{\em coeffs} & An array of size 2 where the resulting coefficients (intercept and slope) will be stored. \\
\hline
{\em xmat} & The design matrix, stored as a 1D array in row-\/major order. \\
\hline
{\em Nrows} & The number of rows in the design matrix. \\
\hline
{\em Ncols} & The number of columns in the design matrix. \\
\hline
{\em vec} & The response vector, stored as a 1D array. \\
\hline
{\em weight} & An optional array of weights for each data point, stored as a 1D array. If NULL, unweighted regression is performed. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__mymath_gaa416e7200d138f4658d7e0957f99b1f7}\label{group__mymath_gaa416e7200d138f4658d7e0957f99b1f7}} 
\index{Mymath Library@{Mymath Library}!mulmat@{mulmat}}
\index{mulmat@{mulmat}!Mymath Library@{Mymath Library}}
\doxysubsubsection{\texorpdfstring{mulmat()}{mulmat()}}
{\footnotesize\ttfamily double $\ast$ mulmat (\begin{DoxyParamCaption}\item[{const double $\ast$}]{matrix0,  }\item[{unsigned int}]{Nrows,  }\item[{unsigned int}]{Ncols,  }\item[{const double $\ast$}]{matrix1,  }\item[{unsigned int}]{Mrows,  }\item[{unsigned int}]{Mcols }\end{DoxyParamCaption})}



Multiplies two matrices and returns the result as a new matrix. 


\begin{DoxyParams}{Parameters}
{\em matrix0} & The first matrix, stored as a 1D array in row-\/major order. \\
\hline
{\em Nrows} & The number of rows in the first matrix. \\
\hline
{\em Ncols} & The number of columns in the first matrix. \\
\hline
{\em matrix1} & The second matrix, stored as a 1D array in row-\/major order. \\
\hline
{\em Mrows} & The number of rows in the second matrix. \\
\hline
{\em Mcols} & The number of columns in the second matrix. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A pointer to the resulting matrix, stored as a 1D array in row-\/major order. The caller is responsible for freeing this memory. 
\end{DoxyReturn}
\mbox{\Hypertarget{group__mymath_ga185afbbfacdb1ebd2fb8bc9f8c7ce458}\label{group__mymath_ga185afbbfacdb1ebd2fb8bc9f8c7ce458}} 
\index{Mymath Library@{Mymath Library}!shiftHalf@{shiftHalf}}
\index{shiftHalf@{shiftHalf}!Mymath Library@{Mymath Library}}
\doxysubsubsection{\texorpdfstring{shiftHalf()}{shiftHalf()}}
{\footnotesize\ttfamily int shift\+Half (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{value,  }\item[{size\+\_\+t}]{Array\+Length }\end{DoxyParamCaption})}



Shifts a value by half the array length, wrapping around. 


\begin{DoxyParams}{Parameters}
{\em value} & The value to shift. \\
\hline
{\em Array\+Length} & The length of the array. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The shifted value, wrapped around the array length. 
\end{DoxyReturn}
\mbox{\Hypertarget{group__mymath_ga227eaade4011887dce2896bb79d155bc}\label{group__mymath_ga227eaade4011887dce2896bb79d155bc}} 
\index{Mymath Library@{Mymath Library}!transpone@{transpone}}
\index{transpone@{transpone}!Mymath Library@{Mymath Library}}
\doxysubsubsection{\texorpdfstring{transpone()}{transpone()}}
{\footnotesize\ttfamily void transpone (\begin{DoxyParamCaption}\item[{double $\ast$}]{arr,  }\item[{unsigned int}]{Nrows,  }\item[{unsigned int}]{Ncols }\end{DoxyParamCaption})}



Transposes a matrix in-\/place. 


\begin{DoxyParams}{Parameters}
{\em arr} & The matrix to transpose, stored as a 1D array in row-\/major order. \\
\hline
{\em Nrows} & The number of rows in the original matrix. \\
\hline
{\em Ncols} & The number of columns in the original matrix. \\
\hline
\end{DoxyParams}
