1 /* ========================================================================== */
2 /* === UMFPACK_get_symbolic ================================================= */
3 /* ========================================================================== */
4 
5 /* -------------------------------------------------------------------------- */
6 /* Copyright (c) 2005-2012 by Timothy A. Davis, http://www.suitesparse.com.   */
7 /* All Rights Reserved.  See ../Doc/License.txt for License.                  */
8 /* -------------------------------------------------------------------------- */
9 
10 /*
11     User-callable.  Gets the symbolic information held in the Symbolic object.
12     See umfpack_get_symbolic.h for a more detailed description.
13 */
14 
15 #include "umf_internal.h"
16 #include "umf_valid_symbolic.h"
17 
UMFPACK_get_symbolic(Int * p_n_row,Int * p_n_col,Int * p_n1,Int * p_nz,Int * p_nfr,Int * p_nchains,Int P[],Int Q[],Int Front_npivcol[],Int Front_parent[],Int Front_1strow[],Int Front_leftmostdesc[],Int Chain_start[],Int Chain_maxrows[],Int Chain_maxcols[],void * SymbolicHandle)18 GLOBAL Int UMFPACK_get_symbolic
19 (
20     Int *p_n_row,
21     Int *p_n_col,
22     Int *p_n1,			/* number of singletons */
23     Int *p_nz,
24     Int *p_nfr,
25     Int *p_nchains,
26     Int P [ ],
27     Int Q [ ],
28     Int Front_npivcol [ ],
29     Int Front_parent [ ],
30     Int Front_1strow [ ],
31     Int Front_leftmostdesc [ ],
32     Int Chain_start [ ],
33     Int Chain_maxrows [ ],
34     Int Chain_maxcols [ ],
35     void *SymbolicHandle
36 )
37 {
38     SymbolicType *Symbolic ;
39     Int k, n_row, n_col, n1, nfr, nchains, *p ;
40 
41     /* ---------------------------------------------------------------------- */
42     /* check inputs */
43     /* ---------------------------------------------------------------------- */
44 
45     Symbolic = (SymbolicType *) SymbolicHandle ;
46     if (!UMF_valid_symbolic (Symbolic))
47     {
48 	return (UMFPACK_ERROR_invalid_Symbolic_object) ;
49     }
50 
51     /* ---------------------------------------------------------------------- */
52     /* get contents of Symbolic */
53     /* ---------------------------------------------------------------------- */
54 
55     n_row = Symbolic->n_row ;
56     n_col = Symbolic->n_col ;
57     n1 = Symbolic->n1 ;
58     nfr = Symbolic->nfr ;
59     nchains = Symbolic->nchains ;
60 
61     if (p_n_row)
62     {
63 	*p_n_row = n_row ;
64     }
65 
66     if (p_n_col)
67     {
68 	*p_n_col = n_col ;
69     }
70 
71     if (p_n1)
72     {
73 	*p_n1 = n1 ;
74     }
75 
76     if (p_nz)
77     {
78 	*p_nz = Symbolic->nz ;
79     }
80 
81     if (p_nfr)
82     {
83 	*p_nfr = nfr ;
84     }
85 
86     if (p_nchains)
87     {
88 	*p_nchains = nchains ;
89     }
90 
91     if (P != (Int *) NULL)
92     {
93 	Int *Rperm_init, *Diagonal_map ;
94 	Rperm_init = Symbolic->Rperm_init ;
95 	Diagonal_map = Symbolic->Diagonal_map ;
96 	if (Diagonal_map != (Int *) NULL)
97 	{
98 	    ASSERT (n_row == n_col) ;
99 	    /* next pivot rows are found in the diagonal map */
100 	    for (k = 0 ; k < n_row ; k++)
101 	    {
102 		P [k] = Rperm_init [Diagonal_map [k]] ;
103 	    }
104 	}
105 	else
106 	{
107 	    /* there is no diagonal map.  */
108 	    for (k = 0 ; k < n_row ; k++)
109 	    {
110 		P [k] = Rperm_init [k] ;
111 	    }
112 	}
113     }
114 
115     if (Q != (Int *) NULL)
116     {
117 	p = Symbolic->Cperm_init ;
118 	for (k = 0 ; k < n_col ; k++)
119 	{
120 	    Q [k] = p [k] ;
121 	}
122     }
123 
124     if (Front_npivcol != (Int *) NULL)
125     {
126 	p = Symbolic->Front_npivcol ;
127 	for (k = 0 ; k <= nfr ; k++)
128 	{
129 	    Front_npivcol [k] = p [k] ;
130 	}
131     }
132 
133     if (Front_parent != (Int *) NULL)
134     {
135 	p = Symbolic->Front_parent ;
136 	for (k = 0 ; k <= nfr ; k++)
137 	{
138 	    Front_parent [k] = p [k] ;
139 	}
140     }
141 
142     if (Front_1strow != (Int *) NULL)
143     {
144 	p = Symbolic->Front_1strow ;
145 	for (k = 0 ; k <= nfr ; k++)
146 	{
147 	    Front_1strow [k] = p [k] ;
148 	}
149     }
150 
151     if (Front_leftmostdesc != (Int *) NULL)
152     {
153 	p = Symbolic->Front_leftmostdesc ;
154 	for (k = 0 ; k <= nfr ; k++)
155 	{
156 	    Front_leftmostdesc [k] = p [k] ;
157 	}
158     }
159 
160     if (Chain_start != (Int *) NULL)
161     {
162 	p = Symbolic->Chain_start ;
163 	for (k = 0 ; k <= nchains ; k++)
164 	{
165 	    Chain_start [k] = p [k] ;
166 	}
167     }
168 
169     if (Chain_maxrows != (Int *) NULL)
170     {
171 	p = Symbolic->Chain_maxrows ;
172 	for (k = 0 ; k < nchains ; k++)
173 	{
174 	    Chain_maxrows [k] = p [k] ;
175 	}
176 	Chain_maxrows [nchains] = 0 ;
177     }
178 
179     if (Chain_maxcols != (Int *) NULL)
180     {
181 	p = Symbolic->Chain_maxcols ;
182 	for (k = 0 ; k < nchains ; k++)
183 	{
184 	    Chain_maxcols [k] = p [k] ;
185 	}
186 	Chain_maxcols [nchains] = 0 ;
187     }
188 
189     return (UMFPACK_OK) ;
190 }
191