~ubuntu-branches/ubuntu/raring/python-scipy/raring-proposed

« back to all changes in this revision

Viewing changes to Lib/sandbox/pysparse/umfpack/umfpack_save_symbolic.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-07 14:12:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070107141212-mm0ebkh5b37hcpzn
* Remove build dependency on python-numpy-dev.
* python-scipy: Depend on python-numpy instead of python-numpy-dev.
* Package builds on other archs than i386. Closes: #402783.

Show diffs side-by-side

added added

removed removed

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