ALP User Documentation  0.8.preview
Algebraic Programming User Documentation
kml_iss.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2024 Huawei Technologies Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
33 #ifndef _H_ALP_KML_ISS
34 #define _H_ALP_KML_ISS
35 
36 #include <stddef.h> // for size_t
37 
38 #include "solver.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 typedef void KmlSolverTask;
45 
46 // KML solver library error values
47 #define KMLSS_NO_ERROR 0
48 #define KMLSS_NONZERO_INDEXING 1
49 #define KMLSS_MISSING_DIAGONAL_ELEMENT 2
50 #define KMLSS_ZERO_DIAGONAL_ELEMENT 3
51 #define KMLSS_NO_MEMORY 4
52 #define KMLSS_NULL_ARGUMENT 5
53 #define KMLSS_BAD_DATA_SIZE 6
54 #define KMLSS_BAD_DATA 7
55 #define KMLSS_BAD_SELECTOR 8
56 #define KMLSS_BAD_N 9
57 #define KMLSS_BAD_NB 10
58 #define KMLSS_BAD_LDX 11
59 #define KMLSS_BAD_LDB 12
60 #define KMLSS_BAD_HANDLE 13
61 #define KMLSS_BAD_PRECONDITIONER 14
62 #define KMLSS_INVALID_CALL_ORDER 15
63 #define KMLSS_BAD_MATRIX_FORMAT 16
64 #define KMLSS_REORDERING_PROBLEM 1001
65 #define KMLSS_ZERO_PARTIAL_PIVOT 1002
66 #define KMLSS_INTERNAL_ERROR 1000001
67 #define KMLSS_NOT_IMPLEMENTED 1000002
68 
69 // error value for errors non prescribed by KML
70 #define KMLSS_OTHER_ERROR 2000002
71 
72 // KML solvers parameters value
73 #define KMLSS_FILL_IN 0
74 #define KMLSS_PERM 1
75 #define KMLSS_REFINEMENT_MAX_STEPS 2
76 #define KMLSS_THRESHOLD 3
77 #define KMLSS_MAX_ITERATION_COUNT 4
78 #define KMLSS_RESTART_PARAM 5
79 #define KMLSS_ITERATION_COUNT 6
80 #define KMLSS_TOLERANCE 7
81 #define KMLSS_INCREASE_ACCURACY 8
82 #define KMLSS_PRECONDITIONER_TYPE 9
83 #define KMLSS_ORTHOGONALIZATION_TYPE 10
84 #define KMLSS_BOOST_THRESHOLD 11
85 #define KMLSS_SCALING_TYPE 12
86 #define KMLSS_MATRIX_FORMAT 13
87 #define KMLSS_REFINEMENT_STEPS 14
88 #define KMLSS_REFINEMENT_TOLERANCE_LEVEL 15
89 #define KMLSS_REFINEMENT_RESIDUAL 16
90 #define KMLSS_PIVOTING_THRESHOLD 17
91 #define KMLSS_MATCHING_TYPE 18
92 
93 
100 #define KML_CG_PREFIXED( name ) KmlIssCg ## name
101 
102 // Initialization routines to create a solver task
103 
104 int KML_CG_PREFIXED( InitSI )( KmlSolverTask **, int, const float *, const int *, const int * );
105 int KML_CG_PREFIXED( InitDI )( KmlSolverTask **, int, const double *, const int *, const int * );
106 
107 // Setters for preconditioner
108 
109 int KML_CG_PREFIXED( SetUserPreconditionerSI )( KmlSolverTask **, void *, int (*)( void *, float * ) );
110 int KML_CG_PREFIXED( SetUserPreconditionerDI )( KmlSolverTask **, void *, int (*)( void *, double * ) );
111 
112 // Setters for solver parameters
113 
114 typedef int KML_SOLVER_PARAM;
115 int KML_CG_PREFIXED( SetSII )( KmlSolverTask **, KML_SOLVER_PARAM, const int *, int );
116 int KML_CG_PREFIXED( SetDII )( KmlSolverTask **, KML_SOLVER_PARAM, const int *, int );
117 int KML_CG_PREFIXED( SetSIS )( KmlSolverTask **, KML_SOLVER_PARAM, const float *, int );
118 int KML_CG_PREFIXED( SetDID )( KmlSolverTask **, KML_SOLVER_PARAM, const double *, int );
119 
120 // Analyze problem before solving
121 
122 int KML_CG_PREFIXED( AnalyzeSI )( KmlSolverTask ** );
123 int KML_CG_PREFIXED( AnalyzeDI )( KmlSolverTask ** );
124 
125 // Analyze a sparse matrix and change it storage mode
126 
127 int KML_CG_PREFIXED( FactorizeSI )( KmlSolverTask ** );
128 int KML_CG_PREFIXED( FactorizeDI )( KmlSolverTask ** );
129 
130 // Run the solver
131 
132 int KML_CG_PREFIXED( SolveSI )( KmlSolverTask **, int, float *, int, const float *, int );
133 int KML_CG_PREFIXED( SolveDI )( KmlSolverTask **, int, double *, int, const double *, int );
134 
135 // Get parameters after solving
136 
137 int KML_CG_PREFIXED( GetSII )( KmlSolverTask **, KML_SOLVER_PARAM, int *, int );
138 int KML_CG_PREFIXED( GetDII )( KmlSolverTask **, KML_SOLVER_PARAM, int *, int );
139 int KML_CG_PREFIXED( GetSIS )( KmlSolverTask **, KML_SOLVER_PARAM, float *, int );
140 int KML_CG_PREFIXED( GetDID )( KmlSolverTask **, KML_SOLVER_PARAM, double *, int );
141 
142 // De-allocate data and destroy the solver task
143 
144 int KML_CG_PREFIXED( CleanSI )( KmlSolverTask ** );
145 int KML_CG_PREFIXED( CleanDI )( KmlSolverTask ** );
146 
147 #ifdef __cplusplus
148 } // end extern "C"
149 #endif
150 
151 #endif // end ifdef _H_ALP_KML_ISS
152 
Defines the solver transition path API.