1 /*
2 ARPACK++ v1.2 2/20/2000
3 c++ interface to ARPACK code.
4
5 MODULE UMFPACKc.h.
6 Interface to UMFPACK routines.
7
8 Author of this class:
9 Martin Reuter
10 Date 2/28/2013
11
12 Arpack++ Author:
13 Francisco Gomes
14
15 ARPACK Authors
16 Richard Lehoucq
17 Danny Sorensen
18 Chao Yang
19 Dept. of Computational & Applied Mathematics
20 Rice University
21 Houston, Texas
22 */
23
24 #ifndef UMFPACKC_H
25 #define UMFPACKC_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #define UMFPACK_INFO 90
32 #define UMFPACK_CONTROL 20
33 #define UMFPACK_OK (0)
34 #define UMFPACK_A (0) /* Ax=b */
35 #define UMFPACK_PRL 0 /* print level */
36
37 void umfpack_di_defaults
38 (
39 double Control [UMFPACK_CONTROL]
40 ) ;
41
42
43 int umfpack_di_symbolic
44 (
45 int n_row,
46 int n_col,
47 const int Ap [ ],
48 const int Ai [ ],
49 const double Ax [ ],
50 void **Symbolic,
51 const double Control [UMFPACK_CONTROL],
52 double Info [UMFPACK_INFO]
53 ) ;
54
55 int umfpack_di_numeric
56 (
57 const int Ap [ ],
58 const int Ai [ ],
59 const double Ax [ ],
60 void *Symbolic,
61 void **Numeric,
62 const double Control [UMFPACK_CONTROL],
63 double Info [UMFPACK_INFO]
64 ) ;
65
66 void umfpack_di_free_symbolic
67 (
68 void **Symbolic
69 ) ;
70
71 void umfpack_di_free_numeric
72 (
73 void **Numeric
74 ) ;
75
76 int umfpack_di_triplet_to_col
77 (
78 int n_row,
79 int n_col,
80 int nz,
81 const int Ti [ ],
82 const int Tj [ ],
83 const double Tx [ ],
84 int Ap [ ],
85 int Ai [ ],
86 double Ax [ ],
87 int Map [ ]
88 ) ;
89
90 int umfpack_di_solve
91 (
92 int sys,
93 const int Ap [ ],
94 const int Ai [ ],
95 const double Ax [ ],
96 double X [ ],
97 const double B [ ],
98 void *Numeric,
99 const double Control [UMFPACK_CONTROL],
100 double Info [UMFPACK_INFO]
101 ) ;
102
103 int umfpack_di_report_matrix
104 (
105 int n_row,
106 int n_col,
107 const int Ap [ ],
108 const int Ai [ ],
109 const double Ax [ ],
110 int col_form,
111 const double Control [UMFPACK_CONTROL]
112 ) ;
113
114 #ifdef __cplusplus
115 }
116 #endif
117
118 //#include "umfpack.h"
119 #include <fstream>
120
Write_Triplet_Matrix(const std::string & fname,int * tripi,int * tripj,double * tripx,unsigned int nnz)121 inline void Write_Triplet_Matrix(const std::string & fname, int * tripi,
122 int * tripj, double* tripx, unsigned int nnz)
123 {
124 std::ofstream myfile;
125 myfile.open ( fname.c_str() );
126 myfile.precision(20);
127 for (unsigned int i=0;i<nnz;i++)
128 {
129 myfile << tripi[i]+1 << " " << tripj[i]+1 << " " << tripx[i] << std::endl;
130 }
131 myfile.close();
132 }
133
134 /*inline void Write_Cholmod_Sparse_Matrix(const std::string & fname,
135 cholmod_sparse* A, cholmod_common *c)
136 {
137 std::ofstream myfile;
138 myfile.open ( fname.c_str() );
139 cholmod_triplet * T = cholmod_sparse_to_triplet(A,c);
140 //std::cout << " [ " << std::endl;
141 myfile.precision(20);
142 for (unsigned int i=0;i<T->nnz;i++)
143 {
144 myfile << ((int*)T->i)[i]+1 << " " << ((int*)T->j)[i]+1 << " " << ((double*)T->x)[i] << std::endl;
145 }
146 //std::cout << " ] " << std::endl;
147 myfile.close();
148
149 cholmod_free_triplet(&T,c);
150
151 }
152
153 // Create_Cholmod_Sparse_Matrix
154 inline cholmod_sparse* Create_Cholmod_Sparse_Matrix(int m, int n, int nnz,
155 double* a, int* irow, int* pcol, char uplo, cholmod_common *c)
156 {
157
158 cholmod_sparse* A = new cholmod_sparse;
159 A->nrow = m;
160 A->ncol = n;
161 A->nzmax = nnz;
162 A->p = pcol;
163 A->i = irow;
164 A->nz = NULL;
165 A->x = a;
166 A->z = NULL;
167 if (uplo == 'L') A->stype = -1;
168 else A->stype = 1;
169 A->itype = CHOLMOD_INT;
170 A->xtype = CHOLMOD_REAL; // real
171 A->dtype = CHOLMOD_DOUBLE; // double
172 A->sorted = 0;
173 A->packed = 1;
174
175 return A;
176
177
178
179
180 } // Create_Cholmod_Sparse_Matrix (double).
181
182 // Create_Cholmod_Dense_Matrix (from Triplet)
183 inline cholmod_dense* Create_Cholmod_Dense_Matrix(int m, int n,
184 double* a, cholmod_common *c)
185 {
186
187
188 cholmod_dense* A = new cholmod_dense;
189 A->nrow = m;
190 A->ncol = n;
191 A->nzmax = m*n;
192 A->d = m;
193 A->x = a;
194 A->z = NULL;
195 A->xtype = CHOLMOD_REAL; // real
196 A->dtype = CHOLMOD_DOUBLE; // double
197
198 // cholmod_dense* As = cholmod_copy_dense(A,c);
199
200 return A;
201
202 } // Create_Cholmod_Dense_Matrix (double).
203
204 // Create_Cholmod_Dense_Matrix (from Triplet)
205 inline void Get_Cholmod_Dense_Data(cholmod_dense* A, int n, double* a)
206 {
207 memcpy(a,A->x,n*sizeof(double));
208
209 // for (int i = 0;i<n;i++)
210 // a[i] = ((double*)A->x)[i];
211
212 } // Create_Cholmod_Dense_Matrix (double).
213
214 */
215
216 #endif // UMFPACKC_H
217