1 // =============================================================================
2 // === spqr_freefac ============================================================
3 // =============================================================================
4
5 // Frees the contents of the QR factor object.
6
7 #include "spqr.hpp"
8
spqr_freefac(SuiteSparseQR_factorization<Entry> ** QR_handle,cholmod_common * cc)9 template <typename Entry> void spqr_freefac
10 (
11 SuiteSparseQR_factorization <Entry> **QR_handle,
12
13 // workspace and parameters
14 cholmod_common *cc
15 )
16
17 {
18 SuiteSparseQR_factorization <Entry> *QR ;
19 Long n, m, bncols, n1rows, r1nz ;
20
21 if (QR_handle == NULL || *QR_handle == NULL)
22 {
23 // nothing to do; caller probably ran out of memory
24 return ;
25 }
26 QR = *QR_handle ;
27
28 n = QR->nacols ;
29 m = QR->narows ;
30 bncols = QR->bncols ;
31 n1rows = QR->n1rows ;
32 r1nz = QR->r1nz ;
33
34 spqr_freenum (& (QR->QRnum), cc) ;
35 spqr_freesym (& (QR->QRsym), cc) ;
36
37 cholmod_l_free (n+bncols, sizeof (Long), QR->Q1fill, cc) ;
38 cholmod_l_free (m, sizeof (Long), QR->P1inv, cc) ;
39 cholmod_l_free (m, sizeof (Long), QR->HP1inv, cc) ;
40 cholmod_l_free (n1rows+1, sizeof (Long), QR->R1p, cc) ;
41 cholmod_l_free (r1nz, sizeof (Long), QR->R1j, cc) ;
42 cholmod_l_free (r1nz, sizeof (Entry), QR->R1x, cc) ;
43 cholmod_l_free (n, sizeof (Long), QR->Rmap, cc) ;
44 cholmod_l_free (n, sizeof (Long), QR->RmapInv, cc) ;
45
46 cholmod_l_free (1, sizeof (SuiteSparseQR_factorization <Entry>), QR, cc) ;
47 *QR_handle = NULL ;
48 }
49
50 // =============================================================================
51
52 template void spqr_freefac <double>
53 (
54 SuiteSparseQR_factorization <double> **QR_handle,
55
56 // workspace and parameters
57 cholmod_common *cc
58 ) ;
59
60 // =============================================================================
61
62 template void spqr_freefac <Complex>
63 (
64 SuiteSparseQR_factorization <Complex> **QR_handle,
65
66 // workspace and parameters
67 cholmod_common *cc
68 ) ;
69