|
62 | 62 | \textbf{User Guide for the SPEX Software Package} \\
|
63 | 63 | \vspace{5mm}
|
64 | 64 |
|
65 |
| - Version 3.0, July 2023 % VERSION |
| 65 | + Version 3.1, March, 2024 % VERSION |
66 | 66 | \vspace{20mm}
|
67 | 67 |
|
68 | 68 | Jinhao Chen, Timothy A. Davis, Christopher Lourenco, Lorena Mejia-Domenzain, Erick Moreno-Centeno \\
|
@@ -109,7 +109,7 @@ \chapter{SPEX Overview}\vspace{-0.75in}
|
109 | 109 | \begin{itemize}
|
110 | 110 | \item GNU GMP \cite{granlund2015gnu} and MPFR \cite{fousse2007mpfr} libraries. Distributed under the LGPL3 and GPL2 and can be acquired and installed from \url{https://gmplib.org/} and \url{http://www.mpfr.org/}, respectively.
|
111 | 111 |
|
112 |
| - \item CMake, available under a BSD 3-clause license. May be independently obtained at \url{https://cmake.org}. |
| 112 | + \item CMake \cite{hoffman2003cmake}, available under a BSD 3-clause license. May be independently obtained at \url{https://cmake.org}. |
113 | 113 |
|
114 | 114 | \item AMD \cite{amestoy1996approximate,amestoy2004algorithmamd}, available under a BSD 3-clause license and distributed along with SPEX. May be independently obtained at \url{www.suitesparse.com}
|
115 | 115 |
|
@@ -1518,6 +1518,12 @@ \section{\texttt{SPEX\_gmp}: SPEX wrapper functions for GMP/MPFR}
|
1518 | 1518 | \verb|mpfr_init2(x, size)|
|
1519 | 1519 | & \verb|SPEX_mpfr_init2(x, size)|
|
1520 | 1520 | & Initialize x with size bits \\ \hline
|
| 1521 | +\verb|mpfr_clear(x)| |
| 1522 | + & \verb|SPEX_mpfr_clear(x)| |
| 1523 | + & Safely free \verb|mpfr_t| value \\ \hline |
| 1524 | +\verb|mpfr_set_null(x)| |
| 1525 | + & \verb|SPEX_mpfr_set_null(x)| |
| 1526 | + & Initialize the (pointer) contents of a \verb|mpfr_t| value \\ \hline |
1521 | 1527 | \verb|mpfr_set(x, y, rnd)|
|
1522 | 1528 | & \verb|SPEX_mpfr_set(x, y, rnd)|
|
1523 | 1529 | & $x = y$ \\ \hline
|
@@ -1579,9 +1585,15 @@ \section{\texttt{SPEX\_gmp}: SPEX wrapper functions for GMP/MPFR}
|
1579 | 1585 | \verb|mpz_init2(x, size)|
|
1580 | 1586 | & \verb|SPEX_mpz_init2(x, size)|
|
1581 | 1587 | & Initialize x to size bits \\ \hline
|
| 1588 | +\verb|mpz_clear(x)| |
| 1589 | + & \verb|SPEX_mpz_clear(x)| |
| 1590 | + & Safely free \verb|mpz_t| value \\ \hline |
1582 | 1591 | \verb|mpz_set(x, y)|
|
1583 | 1592 | & \verb|SPEX_mpz_set(x, y)|
|
1584 | 1593 | & $x = y$ (\verb|mpz_t|) \\ \hline
|
| 1594 | +\verb|mpz_set_null(x)| |
| 1595 | + & \verb|SPEX_mpz_set_null(x)| |
| 1596 | + & Initialize the (pointer) contents of a \verb|mpz_t| value \\ \hline |
1585 | 1597 | \verb|mpz_set_ui(x, y)|
|
1586 | 1598 | & \verb|SPEX_mpz_set_ui(x, y)|
|
1587 | 1599 | & $x = y$ (\verb|uint64_t|) \\ \hline
|
@@ -1666,6 +1678,12 @@ \section{\texttt{SPEX\_gmp}: SPEX wrapper functions for GMP/MPFR}
|
1666 | 1678 | \verb|mpq_init(x)|
|
1667 | 1679 | & \verb|SPEX_mpq_init(x)|
|
1668 | 1680 | & Initialize x \\ \hline
|
| 1681 | +\verb|mpq_set_null(x)| |
| 1682 | + & \verb|SPEX_mpq_set_null(x)| |
| 1683 | + & Initialize the (pointer) contents of a \verb|mpq_t| value \\ \hline |
| 1684 | +\verb|mpq_clear(x)| |
| 1685 | + & \verb|SPEX_mpq_clear(x)| |
| 1686 | + & Safely free \verb|mpq_t| value \\ \hline |
1669 | 1687 | \verb|mpq_set(x, y)|
|
1670 | 1688 | & \verb|SPEX_mpq_set(x, y)|
|
1671 | 1689 | & $x = y$ \\ \hline
|
@@ -1807,6 +1825,67 @@ \section{\texttt{SPEX\_gmp}: SPEX wrapper functions for GMP/MPFR}
|
1807 | 1825 | \end{verbatim}
|
1808 | 1826 | } \end{mdframed}
|
1809 | 1827 |
|
| 1828 | +\section{SPEX Helper Macros} \label{ss:SPEX_helper_macros} |
| 1829 | + |
| 1830 | +In addition to the functionality described in this section; SPEX offers several helper macros to increase ease for the end user application. The first two macros are a simple try/catch mechanism which can be used to wrap functions for error handling. The next two give an easy interface to access entries $(i,j)$ in a matrix. |
| 1831 | + |
| 1832 | +\subsection{\texttt{SPEX\_TRY} and |
| 1833 | +\texttt{SPEX\_CATCH}} |
| 1834 | + |
| 1835 | +In a robust application, the return values from SPEX should be checked and properly handled in the case an error occurs. SPEX is written in C and thus it cannot rely on the try/catch mechanism of C++. Thus, \verb|SPEX_TRY| and \verb|SPEX_CHECK| aim to achieve this goal. We provide \verb|SPEX_TRY| and leave \verb|SPEX_CATCH| to the user to define. |
| 1836 | + |
| 1837 | +\begin{mdframed}[userdefinedwidth=\textwidth] |
| 1838 | +{\footnotesize |
| 1839 | +\begin{verbatim} |
| 1840 | + #define SPEX_TRY(method) \ |
| 1841 | + { \ |
| 1842 | + SPEX_info info = (method) ; \ |
| 1843 | + if (info != SPEX_OK) \ |
| 1844 | + { \ |
| 1845 | + SPEX_CATCH (info) ; \ |
| 1846 | + } \ |
| 1847 | + } |
| 1848 | +\end{verbatim} |
| 1849 | +} \end{mdframed} |
| 1850 | + |
| 1851 | +An example definition of a \verb|SPEX_CATCH| is below. This example assumes that the user needs to free a matrix and return an error code. |
| 1852 | +\begin{mdframed}[userdefinedwidth=\textwidth] |
| 1853 | +{\footnotesize |
| 1854 | +\begin{verbatim} |
| 1855 | + #define SPEX_CATCH(info) \ |
| 1856 | + { \ |
| 1857 | + SPEX_matrix_free (&A, NULL) ; \ |
| 1858 | + fprintf (stderr, "SPEX failed: info %d, \ |
| 1859 | + line %d, file %s\n", \ |
| 1860 | + info, __LINE__, __FILE__) ; \ |
| 1861 | + return (info) ; \ |
| 1862 | + } |
| 1863 | +\end{verbatim} |
| 1864 | +} \end{mdframed} |
| 1865 | + |
| 1866 | +With this mechanism, the user can safely wrap any SPEX function which returns \verb|SPEX_info| with \verb|SPEX_TRY|. For example, one can wrap. |
| 1867 | + |
| 1868 | +\subsection{\texttt{SPEX\_1D}: Access matrix entries with 1D linear indexing.} |
| 1869 | + |
| 1870 | +\begin{mdframed}[userdefinedwidth=\textwidth] |
| 1871 | +{\footnotesize |
| 1872 | +\begin{verbatim} |
| 1873 | + #define SPEX_1D(A,k,type) ((A)->x.type [k]) |
| 1874 | +\end{verbatim} |
| 1875 | +} \end{mdframed} |
| 1876 | + |
| 1877 | +This allows the $k$th entry of a matrix stored in any kind (CSC, triplet, dense) of any type (mpq, mpz, int64, double, int) to be returned. For example, to return the $n$th entry of a CSC matrix with \verb|mpz_t| data types, one would use \verb|SPEX_1D(A, n, mpz)|. |
| 1878 | + |
| 1879 | +\subsection{\texttt{SPEX\_2D}: Access dense matrix with 2D indexing.} |
| 1880 | + |
| 1881 | +\begin{mdframed}[userdefinedwidth=\textwidth] |
| 1882 | +{\footnotesize |
| 1883 | +\begin{verbatim} |
| 1884 | + #define SPEX_2D(A,i,j,type) SPEX_1D (A, (i)+(j)*((A)->m), type) |
| 1885 | +\end{verbatim} |
| 1886 | +} \end{mdframed} |
| 1887 | + |
| 1888 | +This allows the $(i,j)$ entry of a dense matrix of any type (mpq, mpz, int64, double, int). For example to return the $(m,n)$ entry of a dense matrix with \verb|mpq_t| data types, one would use \verb|SPEX_2D(A, m, n, mpq)|. |
1810 | 1889 |
|
1811 | 1890 | %-------------------------------------------------------------------------------
|
1812 | 1891 | \chapter{SPEX LU}\vspace{-0.75in} \label{ch:LeftLU}
|
@@ -2074,7 +2153,7 @@ \subsubsection{Populating data structures}
|
2074 | 2153 | corresponding to CSC form, sparse triplet form or dense form, allocate a
|
2075 | 2154 | shallow \verb|SPEX_matrix| and assign vectors accordingly, then use
|
2076 | 2155 | \verb|SPEX_matrix_copy| to get a \verb|SPEX_matrix| in the desired kind and
|
2077 |
| -type. For more details, refer to the example programs in \verb|SPEX/SPEX/Demo/*.c|. In a case when |
| 2156 | +type. For more details, refer to \verb|SPEX/SPEX/SPEX_Left_LU/Demo/example.c|. In a case when |
2078 | 2157 | \verb|A| is available in format other than CSC \verb|mpz|, and/or \verb|b| is
|
2079 | 2158 | available in format other than dense \verb|mpz|, the following code snippet
|
2080 | 2159 | shows how to get \verb|A| and \verb|b| in a required format.
|
@@ -2248,8 +2327,6 @@ \subsubsection{Converting the solution vector to the final desired form}
|
2248 | 2327 | which utilize SPEX. These files demonstrate the usage of SPEX as
|
2249 | 2328 | follows:
|
2250 | 2329 |
|
2251 |
| -{\bf FIXME: description of demos is out of date} |
2252 |
| - |
2253 | 2330 | \begin{itemize}
|
2254 | 2331 | \item \verb|example.c|: This example generates a random dense $50 \times 50$
|
2255 | 2332 | matrix and a random dense $50 \times 1$ right hand side vector $b$ and
|
|
0 commit comments