\hypertarget{structadpcg}{}\doxysection{adpcg Struct Reference}
\label{structadpcg}\index{adpcg@{adpcg}}


Working struct for the adaptive CG solver.  




{\ttfamily \#include $<$adpcg.\+h$>$}

\doxysubsection*{Data Fields}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{structadpcg_a68d798c85a09fca84d53752f3002d81f}\label{structadpcg_a68d798c85a09fca84d53752f3002d81f}} 
void $\ast$ {\bfseries A}
\begin{DoxyCompactList}\small\item\em LHS data. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a6890dff38b9f6172053da05e3aab78e9}\label{structadpcg_a6890dff38b9f6172053da05e3aab78e9}} 
void $\ast$ {\bfseries r}
\begin{DoxyCompactList}\small\item\em Residual. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a1fc468e191ab79f005eb16576a8ca86f}\label{structadpcg_a1fc468e191ab79f005eb16576a8ca86f}} 
void $\ast$ {\bfseries rnew}
\begin{DoxyCompactList}\small\item\em Workspace array. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ac948f13dbf1ed6a8ad17f9b44a1343d1}\label{structadpcg_ac948f13dbf1ed6a8ad17f9b44a1343d1}} 
void $\ast$ {\bfseries d}
\begin{DoxyCompactList}\small\item\em Workspace array. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a2a9458e35ce08a2464f09f1efc5d5456}\label{structadpcg_a2a9458e35ce08a2464f09f1efc5d5456}} 
void $\ast$ {\bfseries pinvr}
\begin{DoxyCompactList}\small\item\em Workspace array. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a781323ff19ed29a6c1d3c6a1d0a048d4}\label{structadpcg_a781323ff19ed29a6c1d3c6a1d0a048d4}} 
void $\ast$ {\bfseries Ad}
\begin{DoxyCompactList}\small\item\em Workspace array. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a2d1cc6c268f3d858d557c2f0c01f430d}\label{structadpcg_a2d1cc6c268f3d858d557c2f0c01f430d}} 
void $\ast$ {\bfseries x}
\begin{DoxyCompactList}\small\item\em CG solution vector. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a3257c30f37ea1ae6085f5752f327a3c1}\label{structadpcg_a3257c30f37ea1ae6085f5752f327a3c1}} 
void $\ast$ {\bfseries aux}
\begin{DoxyCompactList}\small\item\em CG auxiliary array. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_af71cf3fb8f01f2a35bad47d3a6865796}\label{structadpcg_af71cf3fb8f01f2a35bad47d3a6865796}} 
void $\ast$ {\bfseries btmp}
\begin{DoxyCompactList}\small\item\em CG temporary RHS array. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ac02cda33bccbc276880c14c29e21d05f}\label{structadpcg_ac02cda33bccbc276880c14c29e21d05f}} 
cgint {\bfseries ptype}
\begin{DoxyCompactList}\small\item\em Pre-\/conditioner type. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ab1bdc30a55736107379808e1d179c2fb}\label{structadpcg_ab1bdc30a55736107379808e1d179c2fb}} 
void $\ast$ {\bfseries chol}
\begin{DoxyCompactList}\small\item\em Cholesky pre-\/conditioner. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a3255e9fb604df7c644af244b077d42ad}\label{structadpcg_a3255e9fb604df7c644af244b077d42ad}} 
void $\ast$ {\bfseries diag}
\begin{DoxyCompactList}\small\item\em Diagonal pre-\/conditioner. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a2687e4b3cb5da7dbd00e565343f66c6c}\label{structadpcg_a2687e4b3cb5da7dbd00e565343f66c6c}} 
double {\bfseries tol}
\begin{DoxyCompactList}\small\item\em Relative tolerance of CG. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a1ca83805524f8dd1ef51b86a4cb6cd63}\label{structadpcg_a1ca83805524f8dd1ef51b86a4cb6cd63}} 
double {\bfseries rnrm}
\begin{DoxyCompactList}\small\item\em Residual norm. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ad3c5af494f8751d0f94c81a5681ea684}\label{structadpcg_ad3c5af494f8751d0f94c81a5681ea684}} 
double {\bfseries avgsvtime}
\begin{DoxyCompactList}\small\item\em Averate solution time of previous CG solves. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a2cb9b5942923973c2f6f294bdd7aa51b}\label{structadpcg_a2cb9b5942923973c2f6f294bdd7aa51b}} 
double {\bfseries avgfctime}
\begin{DoxyCompactList}\small\item\em Average factorization time of previous CG solves. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a2f0be973124dc96a30d46d16bd727955}\label{structadpcg_a2f0be973124dc96a30d46d16bd727955}} 
double {\bfseries currenttime}
\begin{DoxyCompactList}\small\item\em Buffer of solution time in the current round. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ae4a1a68ba84ae151863ea5ca98a8471d}\label{structadpcg_ae4a1a68ba84ae151863ea5ca98a8471d}} 
double {\bfseries latesttime}
\begin{DoxyCompactList}\small\item\em Time for the latest solve. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a4bca38f3dfae9caea99bc8b2950d45fb}\label{structadpcg_a4bca38f3dfae9caea99bc8b2950d45fb}} 
cgint {\bfseries n}
\begin{DoxyCompactList}\small\item\em Dimension of linear system. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a8a5b8c768e6226bd4d37d0fdf8c879aa}\label{structadpcg_a8a5b8c768e6226bd4d37d0fdf8c879aa}} 
cgint {\bfseries niter}
\begin{DoxyCompactList}\small\item\em Number of iterations in most recent solve. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a33d14b5e68cc3e9bf715e488d081b7c5}\label{structadpcg_a33d14b5e68cc3e9bf715e488d081b7c5}} 
cgint {\bfseries maxiter}
\begin{DoxyCompactList}\small\item\em Maximum number of iterations. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ae0ff253278dce9e6391c400ce3c9f3f0}\label{structadpcg_ae0ff253278dce9e6391c400ce3c9f3f0}} 
cgint {\bfseries status}
\begin{DoxyCompactList}\small\item\em Solution status. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_af9ecdd5ed4c4d3ea3e46979a189bb39b}\label{structadpcg_af9ecdd5ed4c4d3ea3e46979a189bb39b}} 
cgint {\bfseries reuse}
\begin{DoxyCompactList}\small\item\em Reuse Cholesky pre-\/conditioner. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ac66983383f2baa0113e3a2c0f2de7d89}\label{structadpcg_ac66983383f2baa0113e3a2c0f2de7d89}} 
cgint {\bfseries nused}
\begin{DoxyCompactList}\small\item\em Number of rounds current Cholesky pre-\/conditioner is already used. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ab2a253b4fcf76740654c0979d2587017}\label{structadpcg_ab2a253b4fcf76740654c0979d2587017}} 
cgint {\bfseries nmaxiter}
\begin{DoxyCompactList}\small\item\em Number of non-\/successfull solves. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a783a672a4ef0d86410d99ef7276747cf}\label{structadpcg_a783a672a4ef0d86410d99ef7276747cf}} 
cgint {\bfseries restart}
\begin{DoxyCompactList}\small\item\em Restart frequency. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a80a8e50934e3a6f6243d068b831397e4}\label{structadpcg_a80a8e50934e3a6f6243d068b831397e4}} 
cgint {\bfseries nfactors}
\begin{DoxyCompactList}\small\item\em Number of factorizes performed so far. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a3c1573a436a8f184b1b66729e41f81bb}\label{structadpcg_a3c1573a436a8f184b1b66729e41f81bb}} 
cgint {\bfseries nrounds}
\begin{DoxyCompactList}\small\item\em Number of rounds of solves. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a94e83c500047bc7342e6be4b22c08c8a}\label{structadpcg_a94e83c500047bc7342e6be4b22c08c8a}} 
cgint {\bfseries nsolverd}
\begin{DoxyCompactList}\small\item\em Number of solves in a round. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a4526e6a11201c332064f258d470a545a}\label{structadpcg_a4526e6a11201c332064f258d470a545a}} 
cgint {\bfseries nsolves}
\begin{DoxyCompactList}\small\item\em Number of linear systems solved. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ac81303e4b6c8f1782c13af03d074cc90}\label{structadpcg_ac81303e4b6c8f1782c13af03d074cc90}} 
void($\ast$ {\bfseries v\+\_\+init} )(void $\ast$v)
\begin{DoxyCompactList}\small\item\em Initialize vector. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_acf6c19b4c91e41e3083bdb0699e00968}\label{structadpcg_acf6c19b4c91e41e3083bdb0699e00968}} 
cgint($\ast$ {\bfseries v\+\_\+alloc} )(void $\ast$v, cgint \mbox{\hyperlink{structadpcg_a4bca38f3dfae9caea99bc8b2950d45fb}{n}})
\begin{DoxyCompactList}\small\item\em Allocate memory for v. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a2aa9789618bcce938aa7986e216c1dcf}\label{structadpcg_a2aa9789618bcce938aa7986e216c1dcf}} 
void($\ast$ {\bfseries v\+\_\+free} )(void $\ast$v)
\begin{DoxyCompactList}\small\item\em Free the internal memory of vector. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a491bba38109d637049ce6c5a62658a3d}\label{structadpcg_a491bba38109d637049ce6c5a62658a3d}} 
void($\ast$ {\bfseries v\+\_\+copy} )(void $\ast$s, void $\ast$t)
\begin{DoxyCompactList}\small\item\em Copy s to t. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_aa5b62ff4c2842e8dca233976aa2e7ac4}\label{structadpcg_aa5b62ff4c2842e8dca233976aa2e7ac4}} 
void($\ast$ {\bfseries v\+\_\+reset} )(void $\ast$v)
\begin{DoxyCompactList}\small\item\em Reset vector to 0. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a3aaac9631e08e9e97c5bec740def7d8a}\label{structadpcg_a3aaac9631e08e9e97c5bec740def7d8a}} 
void($\ast$ {\bfseries v\+\_\+norm} )(void $\ast$v, double $\ast$nrm)
\begin{DoxyCompactList}\small\item\em nrm = norm(v) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ac22a6258c280f5870824175eeff3c60d}\label{structadpcg_ac22a6258c280f5870824175eeff3c60d}} 
void($\ast$ {\bfseries v\+\_\+axpy} )(double a, void $\ast$\mbox{\hyperlink{structadpcg_a2d1cc6c268f3d858d557c2f0c01f430d}{x}}, void $\ast$y)
\begin{DoxyCompactList}\small\item\em y = y + a $\ast$ x \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a472b11d7d504331724ba741d55b047d8}\label{structadpcg_a472b11d7d504331724ba741d55b047d8}} 
void($\ast$ {\bfseries v\+\_\+axpby} )(double a, void $\ast$\mbox{\hyperlink{structadpcg_a2d1cc6c268f3d858d557c2f0c01f430d}{x}}, double b, void $\ast$y)
\begin{DoxyCompactList}\small\item\em y = a $\ast$ x + b $\ast$ y \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a00eac37ac375ec76ede60477b6a6dbc7}\label{structadpcg_a00eac37ac375ec76ede60477b6a6dbc7}} 
void($\ast$ {\bfseries v\+\_\+zaxpby} )(void $\ast$z, double a, void $\ast$\mbox{\hyperlink{structadpcg_a2d1cc6c268f3d858d557c2f0c01f430d}{x}}, double b, void $\ast$y)
\begin{DoxyCompactList}\small\item\em z = a $\ast$ x + b $\ast$ y \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ac47bf7c3c78affdf894f730534dbcadc}\label{structadpcg_ac47bf7c3c78affdf894f730534dbcadc}} 
void($\ast$ {\bfseries v\+\_\+dot} )(void $\ast$\mbox{\hyperlink{structadpcg_a2d1cc6c268f3d858d557c2f0c01f430d}{x}}, void $\ast$y, double $\ast$x\+Ty)
\begin{DoxyCompactList}\small\item\em x\+Ty = x\textquotesingle{} $\ast$ y \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ae247c7b29298315d20439893b0df7efd}\label{structadpcg_ae247c7b29298315d20439893b0df7efd}} 
cgint($\ast$ {\bfseries A\+\_\+chol} )(void $\ast$\mbox{\hyperlink{structadpcg_a68d798c85a09fca84d53752f3002d81f}{A}})
\begin{DoxyCompactList}\small\item\em Compute Cholesky of A. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a74b41b9ddb7afe8855ad54d326703ddc}\label{structadpcg_a74b41b9ddb7afe8855ad54d326703ddc}} 
cgint($\ast$ {\bfseries A\+\_\+cond} )(void $\ast$\mbox{\hyperlink{structadpcg_a68d798c85a09fca84d53752f3002d81f}{A}})
\begin{DoxyCompactList}\small\item\em Evaluate conditioning of A. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_add314da04a81eb38cd95192b85c17747}\label{structadpcg_add314da04a81eb38cd95192b85c17747}} 
void($\ast$ {\bfseries A\+\_\+getdiag} )(void $\ast$\mbox{\hyperlink{structadpcg_a68d798c85a09fca84d53752f3002d81f}{A}}, void $\ast$\mbox{\hyperlink{structadpcg_a3255e9fb604df7c644af244b077d42ad}{diag}})
\begin{DoxyCompactList}\small\item\em Compute diagonal pre-\/conditioner diag = diag(\+A) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a90ee4c9ff4c6372702c101dda4857d80}\label{structadpcg_a90ee4c9ff4c6372702c101dda4857d80}} 
cgint($\ast$ {\bfseries diagpcd} )(void $\ast$\mbox{\hyperlink{structadpcg_a3255e9fb604df7c644af244b077d42ad}{diag}}, void $\ast$v)
\begin{DoxyCompactList}\small\item\em Diagonal Preconditioning operation v = P \textbackslash{} v. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_a96831c949a830e0d16cf182d622ba3d9}\label{structadpcg_a96831c949a830e0d16cf182d622ba3d9}} 
cgint($\ast$ {\bfseries cholpcd} )(void $\ast$\mbox{\hyperlink{structadpcg_ab1bdc30a55736107379808e1d179c2fb}{chol}}, void $\ast$v, void $\ast$\mbox{\hyperlink{structadpcg_a3257c30f37ea1ae6085f5752f327a3c1}{aux}})
\begin{DoxyCompactList}\small\item\em Cholesky Preconditioning operation v = P \textbackslash{} v. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_ab2d28e0dc41b9b86521a6c9f7ea56119}\label{structadpcg_ab2d28e0dc41b9b86521a6c9f7ea56119}} 
void($\ast$ {\bfseries Av} )(void $\ast$\mbox{\hyperlink{structadpcg_a68d798c85a09fca84d53752f3002d81f}{A}}, void $\ast$v, void $\ast$Av)
\begin{DoxyCompactList}\small\item\em Compute Av = A $\ast$ v. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{structadpcg_aab444b0446d757e430f61132ba62d1e5}\label{structadpcg_aab444b0446d757e430f61132ba62d1e5}} 
cgint($\ast$ {\bfseries Ainv} )(void $\ast$\mbox{\hyperlink{structadpcg_a68d798c85a09fca84d53752f3002d81f}{A}}, void $\ast$v, void $\ast$\mbox{\hyperlink{structadpcg_a3257c30f37ea1ae6085f5752f327a3c1}{aux}})
\begin{DoxyCompactList}\small\item\em Solve Ainvv = A \textbackslash{} v. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Working struct for the adaptive CG solver. 

To make the CG solver more general, the operations on
\begin{DoxyEnumerate}
\item vector 2. matrix 3. matrix-\/vector are presented in abstract function pointers and users can define their own implementations for various purposes
\end{DoxyEnumerate}

More details\+: the following operations are expected Vector\+:
\begin{DoxyEnumerate}
\item v\+\_\+init(v) Initialize a vector struct
\item v\+\_\+alloc(v) Allocate internal memory for a vector struct
\item v\+\_\+free(v) Free the internal memory for a vector struct
\item v\+\_\+copy(s, t) Copy content from vector s to vector t
\item v\+\_\+reset(v) Set the content of vector 0
\item v\+\_\+norm(v, \&nrm) Compute norm of v
\item v\+\_\+axpy(a, x, y) Compute y = y + a $\ast$ x
\item v\+\_\+zaxpby(z, a, x, b, y) Compute z = a $\ast$ x + b $\ast$ y
\item v\+\_\+dot(x, y, \&dot) Compute x\textquotesingle{} $\ast$ y
\end{DoxyEnumerate}

Matrix\+:
\begin{DoxyEnumerate}
\item A\+\_\+chol(\+A) Perform Cholesky decomposition
\item is\+\_\+illcond = A\+\_\+cond(\+A) Get a boolean variable reflecting the conditioning of A
\end{DoxyEnumerate}

Matrix-\/vector\+:
\begin{DoxyEnumerate}
\item diagpcd(diag, v) Perform diagonal pre-\/conditioning
\item cholpcf(chol, v) Perform Cholesky pre-\/conditioning 
\end{DoxyEnumerate}

The documentation for this struct was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
src/\mbox{\hyperlink{adpcg_8h}{adpcg.\+h}}\end{DoxyCompactItemize}
