1 /* basics.c */
2
3 #include "../Chv.h"
4
5 #define MYDEBUG 0
6
7 /*--------------------------------------------------------------------*/
8 /*
9 -----------------------
10 simplest constructor
11
12 created -- 98apr30, cca
13 -----------------------
14 */
15 Chv *
Chv_new(void)16 Chv_new (
17 void
18 ) {
19 Chv *chv ;
20
21 ALLOCATE(chv, struct _Chv, 1) ;
22 Chv_setDefaultFields(chv) ;
23
24 return(chv) ; }
25
26 /*--------------------------------------------------------------------*/
27 /*
28 -----------------------
29 set the default fields
30
31 created -- 98apr30, cca
32 -----------------------
33 */
34 void
Chv_setDefaultFields(Chv * chv)35 Chv_setDefaultFields (
36 Chv *chv
37 ) {
38 if ( chv == NULL ) {
39 fprintf(stderr, "\n fatal error in Chv_setDefaultFields(%p)"
40 "\n bad input", chv) ;
41 exit(-1) ;
42 }
43 chv->id = -1 ;
44 chv->nD = 0 ;
45 chv->nL = 0 ;
46 chv->nU = 0 ;
47 chv->type = SPOOLES_REAL ;
48 chv->symflag = SPOOLES_SYMMETRIC ;
49 DV_setDefaultFields(&chv->wrkDV) ;
50 chv->rowind = NULL ;
51 chv->colind = NULL ;
52 chv->entries = NULL ;
53 chv->next = NULL ;
54
55 return ; }
56
57 /*--------------------------------------------------------------------*/
58 /*
59 --------------------------------------------------
60 clear the data fields, releasing allocated storage
61
62 created -- 98apr30, cca
63 --------------------------------------------------
64 */
65 void
Chv_clearData(Chv * chv)66 Chv_clearData (
67 Chv *chv
68 ) {
69 /*
70 ---------------
71 check the input
72 ---------------
73 */
74 if ( chv == NULL ) {
75 fprintf(stderr, "\n fatal error in Chv_clearData(%p)"
76 "\n bad input\n", chv) ;
77 exit(-1) ;
78 }
79 /*
80 ------------------------
81 free the working storage
82 ------------------------
83 */
84 DV_clearData(&chv->wrkDV) ;
85 /*
86 ----------------------
87 set the default fields
88 ----------------------
89 */
90 Chv_setDefaultFields(chv) ;
91
92 return ; }
93
94 /*--------------------------------------------------------------------*/
95 /*
96 ------------------------------------------
97 destructor, free's the object and its data
98
99 created -- 98apr30, cca
100 ------------------------------------------
101 */
102 void
Chv_free(Chv * chv)103 Chv_free (
104 Chv *chv
105 ) {
106 if ( chv == NULL ) {
107 fprintf(stderr, "\n fatal error in Chv_free(%p)"
108 "\n bad input\n", chv) ;
109 exit(-1) ;
110 }
111 Chv_clearData(chv) ;
112 FREE(chv) ;
113
114 return ; }
115
116 /*--------------------------------------------------------------------*/
117