umfpack_save_symbolic.c
3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* ========================================================================== */
/* === UMFPACK_save_symbolic ================================================ */
/* ========================================================================== */
/* -------------------------------------------------------------------------- */
/* UMFPACK Copyright (c) Timothy A. Davis, CISE, */
/* Univ. of Florida. All Rights Reserved. See ../Doc/License for License. */
/* web: http://www.cise.ufl.edu/research/sparse/umfpack */
/* -------------------------------------------------------------------------- */
/*
User-callable. Saves a Symbolic object to a file. It can later be read
back in via a call to umfpack_*_load_symbolic.
*/
#include "umf_internal.h"
#include "umf_valid_symbolic.h"
#define WRITE(object,type,n) \
{ \
ASSERT (object != (type *) NULL) ; \
if (fwrite (object, sizeof (type), n, f) != n) \
{ \
fclose (f) ; \
return (UMFPACK_ERROR_file_IO) ; \
} \
}
/* ========================================================================== */
/* === UMFPACK_save_symbolic ================================================ */
/* ========================================================================== */
GLOBAL Int UMFPACK_save_symbolic
(
void *SymbolicHandle,
char *user_filename
)
{
SymbolicType *Symbolic ;
char *filename ;
FILE *f ;
/* get the Symbolic object */
Symbolic = (SymbolicType *) SymbolicHandle ;
/* make sure the Symbolic object is valid */
if (!UMF_valid_symbolic (Symbolic))
{
return (UMFPACK_ERROR_invalid_Symbolic_object) ;
}
/* get the filename, or use the default name if filename is NULL */
if (user_filename == (char *) NULL)
{
filename = "symbolic.umf" ;
}
else
{
filename = user_filename ;
}
f = fopen (filename, "wb") ;
if (!f)
{
return (UMFPACK_ERROR_file_IO) ;
}
/* write the Symbolic object to the file, in binary */
WRITE (Symbolic, SymbolicType, 1) ;
WRITE (Symbolic->Cperm_init, Int, Symbolic->n_col+1) ;
WRITE (Symbolic->Rperm_init, Int, Symbolic->n_row+1) ;
WRITE (Symbolic->Front_npivcol, Int, Symbolic->nfr+1) ;
WRITE (Symbolic->Front_parent, Int, Symbolic->nfr+1) ;
WRITE (Symbolic->Front_1strow, Int, Symbolic->nfr+1) ;
WRITE (Symbolic->Front_leftmostdesc, Int, Symbolic->nfr+1) ;
WRITE (Symbolic->Chain_start, Int, Symbolic->nchains+1) ;
WRITE (Symbolic->Chain_maxrows, Int, Symbolic->nchains+1) ;
WRITE (Symbolic->Chain_maxcols, Int, Symbolic->nchains+1) ;
WRITE (Symbolic->Cdeg, Int, Symbolic->n_col+1) ;
WRITE (Symbolic->Rdeg, Int, Symbolic->n_row+1) ;
if (Symbolic->esize > 0)
{
/* only when dense rows are present */
WRITE (Symbolic->Esize, Int, Symbolic->esize) ;
}
if (Symbolic->prefer_diagonal)
{
/* only when diagonal pivoting is prefered */
WRITE (Symbolic->Diagonal_map, Int, Symbolic->n_col+1) ;
}
/* close the file */
fclose (f) ;
return (UMFPACK_OK) ;
}