1 /*
2  * COPYRIGHT (c) 2011, 2013 The Science and Technology Facilities Council (STFC)
3  * All Rights Reserved.
4  * This code is published under the Eclipse Public License.
5  *
6  * Authors:  Jonathan Hogg    STFC     2011-05-18
7  */
8 
9 #ifndef HSL_MA77D_H
10 #define HSL_MA77D_H
11 
12 #ifndef ma77_default_control
13 #define ma77_control ma77_control_d
14 #define ma77_info ma77_info_d
15 #define ma77_default_control ma77_default_control_d
16 #define ma77_open_nelt ma77_open_nelt_d
17 #define ma77_open ma77_open_d
18 #define ma77_input_vars ma77_input_vars_d
19 #define ma77_input_reals ma77_input_reals_d
20 #define ma77_analyse ma77_analyse_d
21 #define ma77_factor ma77_factor_d
22 #define ma77_factor_solve ma77_factor_solve_d
23 #define ma77_solve ma77_solve_d
24 #define ma77_resid ma77_resid_d
25 #define ma77_scale ma77_scale_d
26 #define ma77_enquire_posdef ma77_enquire_posdef_d
27 #define ma77_enquire_indef ma77_enquire_indef_d
28 #define ma77_alter ma77_alter_d
29 #define ma77_restart ma77_restart_d
30 #define ma77_finalise ma77_finalise_d
31 #define ma77_solve_fredholm ma77_solve_fredholm_d
32 #define ma77_lmultiply ma77_lmultiply_d
33 #endif
34 
35 typedef double ma77pkgtype_d_;
36 
37 /* Data type for user controls */
38 struct ma77_control_d {
39    /* Note: 0 is false, non-zero is true */
40 
41    /* C/Fortran interface related controls */
42    int f_arrays; /* Treat arrays as 1-based (Fortran) if true or 0-based (C) if
43                     false. */
44 
45    /* Printing controls */
46    int print_level;
47    int unit_diagnostics;   /* unit for diagnostic messages
48                               Printing is suppressed if unit_diagnostics < 0. */
49    int unit_error;         /* unit for error messages
50                               Printing is suppressed if unit_error  <  0.     */
51    int unit_warning;       /* unit for warning messages
52                               Printing is suppressed if unit_warning  <  0.   */
53 
54    /* Controls used by MA77_open */
55    int bits;
56    int buffer_lpage[2];
57    int buffer_npage[2];
58    long int file_size;
59    long int maxstore;
60    long int storage[3];
61 
62    /* Controls used by MA77_analyse */
63    int nemin;  /* Node amalgamation parameter. A child node is merged with its
64                   parent if they both involve fewer than nemin eliminations.*/
65 
66    /* Controls used by MA77_scale */
67    int maxit;
68    int infnorm;
69    ma77pkgtype_d_ thresh;
70 
71    /* Controls used by MA77_factor with posdef true */
72    int nb54;
73 
74    /* Controls used by MA77_factor with posdef false */
75    int action;    /* Keep going even if matrix is singular if true, or abort
76                      if false */
77    ma77pkgtype_d_ multiplier;
78    int nb64;
79    int nbi;
80    ma77pkgtype_d_ small;
81    ma77pkgtype_d_ static_;
82    long int storage_indef;
83    ma77pkgtype_d_ u;       /* Pivot tolerance*/
84    ma77pkgtype_d_ umin;    /* Minimum pivot tolerance*/
85 
86 #if defined(COINHSL_HSL2013) || !defined(COINHSL_HAS_MA77)
87    /* Controls used by ma77_solve_fredholm */
88    ma77pkgtype_d_ consist_tol;   /* Tolerance for consistent singular system */
89 
90    /* Pad data structure to allow for future growth */
91    int ispare[5]; long int lspare[5]; ma77pkgtype_d_ rspare[5];
92 #endif
93 };
94 
95 /***************************************************/
96 
97 /* data type for returning information to user.*/
98 struct ma77_info_d {
99    ma77pkgtype_d_ detlog;
100    int detsign;
101    int flag;
102    int iostat;
103    int matrix_dup;
104    int matrix_rank;
105    int matrix_outrange;
106    int maxdepth;
107    int maxfront;
108    long int minstore;
109    int ndelay;
110    long int nfactor;
111    long int nflops;
112    int niter;
113    int nsup;
114    int num_neg;
115    int num_nothresh;
116    int num_perturbed;
117    int ntwo;
118    int stat;
119    int index[4];
120    long int nio_read[2];
121    long int nio_write[2];
122    long int nwd_read[2];
123    long int nwd_write[2];
124    int num_file[4];
125    long int storage[4];
126    int tree_nodes;
127    int unit_restart;
128    int unused;
129    ma77pkgtype_d_ usmall;
130 
131    /* if we do not have MA77, we assume its is loaded via the linear solver loader, for which we assume HSL 2013 */
132 #if defined(COINHSL_HSL2013) || !defined(COINHSL_HAS_MA77)
133    /* Pad data structure to allow for future growth */
134    int ispare[5]; long int lspare[5]; ma77pkgtype_d_ rspare[5];
135 #endif
136 };
137 
138 /* Initialise control with default values */
139 void ma77_default_control_d(struct ma77_control_d *control);
140 void ma77_open_nelt(const int n, const char* fname1, const char* fname2,
141    const char *fname3, const char *fname4, void **keep,
142    const struct ma77_control_d *control, struct ma77_info_d *info,
143    const int nelt);
144 void ma77_open_d(const int n, const char* fname1, const char* fname2,
145    const char *fname3, const char *fname4, void **keep,
146    const struct ma77_control_d *control, struct ma77_info_d *info);
147 void ma77_input_vars(const int idx, const int nvar, const int list[],
148    void **keep, const struct ma77_control_d *control, struct ma77_info_d *info);
149 void ma77_input_reals_d(const int idx, const int length,
150    const ma77pkgtype_d_ reals[], void **keep, const struct ma77_control_d *control,
151    struct ma77_info_d *info);
152 /* Analyse the sparsity pattern and prepare for factorization */
153 void ma77_analyse(const int order[], void **keep,
154    const struct ma77_control_d *control, struct ma77_info_d *info);
155 /* To factorize the matrix */
156 void ma77_factor_d(const int posdef, void **keep,
157    const struct ma77_control_d *control, struct ma77_info_d *info,
158    const ma77pkgtype_d_ *scale);
159 /* To factorize the matrix AND solve AX = B */
160 void ma77_factor_solve_d(const int posdef, void **keep,
161    const struct ma77_control_d *control, struct ma77_info_d *info,
162    const ma77pkgtype_d_ *scale, const int nrhs, const int lx,
163    ma77pkgtype_d_ rhs[]);
164 /* To solve AX = B using the computed factors */
165 void ma77_solve_d(const int job, const int nrhs, const int lx, ma77pkgtype_d_ x[],
166    void **keep, const struct ma77_control_d *control, struct ma77_info_d *info,
167    const ma77pkgtype_d_ *scale);
168 void ma77_resid_d(const int nrhs, const int lx, const ma77pkgtype_d_ x[],
169    const int lresid, ma77pkgtype_d_ resid[], void **keep,
170    const struct ma77_control_d *control, struct ma77_info_d *info,
171    ma77pkgtype_d_ *anorm_bnd);
172 void ma77_scale_d(ma77pkgtype_d_ scale[], void **keep,
173    const struct ma77_control_d *control, struct ma77_info_d *info,
174    ma77pkgtype_d_ *anorm);
175 void ma77_enquire_posdef_d(ma77pkgtype_d_ d[], void **keep,
176    const struct ma77_control_d *control, struct ma77_info_d *info);
177 void ma77_enquire_indef_d(int piv_order[], ma77pkgtype_d_ d[], void **keep,
178    const struct ma77_control_d *control, struct ma77_info_d *info);
179 void ma77_alter_d(const ma77pkgtype_d_ d[], void **keep,
180    const struct ma77_control_d *control, struct ma77_info_d *info);
181 void ma77_restart_d(const char *restart_file, const char *fname1,
182    const char *fname2, const char *fname3, const char *fname4, void **keep,
183    const struct ma77_control_d *control, struct ma77_info_d *info);
184 /* exists only for HSL 2013 */
185 void ma77_solve_fredholm_d(int nrhs, int flag_out[], int lx, ma77pkgtype_d_ x[],
186    void **keep, const struct ma77_control_d *control,
187    struct ma77_info_d *info, const ma77pkgtype_d_ *scale);
188 /* exists only for HSL 2013 */
189 void ma77_lmultiply_d(int trans, int k, int lx, ma77pkgtype_d_ x[], int ly,
190    ma77pkgtype_d_ y[], void **keep, const struct ma77_control_d *control,
191    struct ma77_info_d *info, const ma77pkgtype_d_ *scale);
192 /* To clean up memory in keep */
193 void ma77_finalise_d(void **keep, const struct ma77_control_d *control,
194    struct ma77_info_d *info);
195 
196 #endif
197