Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
nl_context.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2022 Inria
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of the ALICE Project-Team nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Contact: Bruno Levy
30  *
31  * https://www.inria.fr/fr/bruno-levy
32  *
33  * Inria,
34  * Domaine de Voluceau,
35  * 78150 Le Chesnay - Rocquencourt
36  * FRANCE
37  *
38  */
39 
40 #ifndef OPENNL_CONTEXT_H
41 #define OPENNL_CONTEXT_H
42 
43 #include "nl_private.h"
44 #include "nl_matrix.h"
45 
51 /******************************************************************************/
52 /* NLContext data structure */
53 
54 
59 typedef NLboolean(*NLSolverFunc)(void);
60 
65 typedef void(*NLProgressFunc)(
66  NLuint cur_iter, NLuint max_iter, double cur_err, double max_err
67 );
68 
69 #define NL_STATE_INITIAL 0
70 #define NL_STATE_SYSTEM 1
71 #define NL_STATE_MATRIX 2
72 #define NL_STATE_ROW 3
73 #define NL_STATE_MATRIX_CONSTRUCTED 4
74 #define NL_STATE_SYSTEM_CONSTRUCTED 5
75 #define NL_STATE_SOLVED 6
76 #define NL_STATE_MATRIX_PATTERN 7
77 
82 typedef struct {
86  void* base_address;
93 
100 #define NL_BUFFER_ITEM(B,i) \
101  *(double*)((void*)((char*)((B).base_address)+((i)*(B).stride)))
102 
103 
104 typedef struct {
111 
117 
122 
127 
132 
138 
143 
144 
150 
155 
160 
167 
175 
183 
189 
194 
201 
208 
213 
218 
223 
228 
233 
238 
243 
249 
254 
259 
260 
265 
271 
278 
283 
289 
294 
299 
304 
305 
311 
316 
321 
326 
332 
338 
343 
349 
355 
360 
368 
373 
380 
382 
387 
395 void nlCheckState(NLenum state);
396 
405 void nlTransition(NLenum from_state, NLenum to_state);
406 
415 
416 #endif
uint32_t NLuint
A 4-bytes unsigned integer.
Definition: nl.h:263
uint64_t NLulong
A 8-bytes unsigned integer.
Definition: nl.h:273
double NLdouble
A double-precision floating-point number.
Definition: nl.h:288
unsigned int NLenum
A symbolic constant.
Definition: nl.h:215
unsigned char NLboolean
A truth value (NL_TRUE or NL_FALSE).
Definition: nl.h:221
void nlCheckState(NLenum state)
Makes sure that the finite state automaton is in the expected state.
NLboolean nlDefaultSolver(void)
Implements the default solver.
NLboolean(* NLSolverFunc)(void)
The callback type for solver routines.
Definition: nl_context.h:59
NLContextStruct * nlCurrentContext
Pointer to the current context.
void(* NLProgressFunc)(NLuint cur_iter, NLuint max_iter, double cur_err, double max_err)
The callback type for displaying progress.
Definition: nl_context.h:65
void nlTransition(NLenum from_state, NLenum to_state)
Implements a transition of the finite state automaton.
Internal OpenNL functions to manipulate sparse matrices.
Some macros and functions used internally by OpenNL.
Stores the information relevant to access variables stored in buffers.
Definition: nl_context.h:82
NLuint stride
Number of bytes between the addresses of two consecutive elements in the buffer.
Definition: nl_context.h:91
void * base_address
Address of the first element in the buffer.
Definition: nl_context.h:86
NLRowColumn af
The coefficients that correspond to the free variables in the row being built.
Definition: nl_context.h:174
NLuint nb_variables
The number of variables.
Definition: nl_context.h:227
NLboolean has_matrix_pattern
true if nlBegin(NL_MATRIX_PATTERN) was called.
Definition: nl_context.h:372
NLuint nb_systems
The number of linear systems to solve.
Definition: nl_context.h:232
NLenum matrix_mode
The current matrix mode.
Definition: nl_context.h:149
NLenum solver
The used solver, as a symbolic constant.
Definition: nl_context.h:212
NLdouble * temp_eigen_value
temporary array for eigen values, used for sorting.
Definition: nl_context.h:367
NLenum state
State of the finite-state automaton.
Definition: nl_context.h:110
NLSolverFunc solver_func
the function pointer for the solver.
Definition: nl_context.h:320
NLdouble * x
The vector of free variables, solution of the system.
Definition: nl_context.h:188
NLdouble elapsed_time
elapsed time for latest solve.
Definition: nl_context.h:315
NLRowColumn al
The coefficients that correspond to the locked variables in the row being built.
Definition: nl_context.h:182
NLuint current_row
The index of the current row.
Definition: nl_context.h:242
NLboolean normalize_rows
If true, all the rows are normalized.
Definition: nl_context.h:293
NLboolean no_variables_indirection
if no_variables_indirection is set, then there is no locked variable, and the linear system directly ...
Definition: nl_context.h:379
NLProgressFunc progress_func
the function pointer for logging progress.
Definition: nl_context.h:325
NLdouble * eigen_value
the array of eigen values. Dimension = nb_systems.
Definition: nl_context.h:359
NLboolean * variable_is_locked
Locked flags of the variables, dimension = nb_variables.
Definition: nl_context.h:131
NLdouble error
error obtained after latest solve.
Definition: nl_context.h:303
NLBufferBinding * variable_buffer
Buffer bindings for the variables, dimension = nb_systems.
Definition: nl_context.h:121
NLdouble row_scaling
The scaling coefficient for the row being build.
Definition: nl_context.h:207
NLboolean ij_coefficient_called
True if NLIJCoefficient() was called.
Definition: nl_context.h:237
NLboolean preconditioner_defined
True if preconditioner was defined by client.
Definition: nl_context.h:222
NLuint n
The number of not locked variables.
Definition: nl_context.h:142
NLMatrix B
The right-hand side matrix.
Definition: nl_context.h:166
NLMatrix P
The preconditioner.
Definition: nl_context.h:159
NLuint max_iterations
Maximum number of iterations.
Definition: nl_context.h:258
NLuint * variable_index
Index of the variable in the actual linear system, dimension = nb_variables.
Definition: nl_context.h:137
NLboolean symmetric
Indicates whether the matrix is symmetric.
Definition: nl_context.h:253
NLboolean max_iterations_defined
True if max_iterations was defined by client.
Definition: nl_context.h:264
NLuint used_iterations
used number of iterations during latest solve.
Definition: nl_context.h:298
NLenum eigen_solver
The eigen solver. Should be NL_ARPACK_EXT.
Definition: nl_context.h:342
NLdouble omega
Relaxation parameter for the SSOR preconditioner.
Definition: nl_context.h:288
NLdouble threshold
Convergence threshold.
Definition: nl_context.h:277
NLboolean threshold_defined
True if threshold was defined by client.
Definition: nl_context.h:282
NLdouble * variable_value
Values of the variables, dimension = nb_systems * nb_variables.
Definition: nl_context.h:126
NLdouble * right_hand_side
The right hand sides of the row being built. An array of nb_systems doubles.
Definition: nl_context.h:200
NLdouble eigen_shift
The shift parameter of the spectral shift-invert transform.
Definition: nl_context.h:348
NLboolean least_squares
Indicates whether a least squares system is constructed.
Definition: nl_context.h:248
NLboolean user_variable_buffers
NL_TRUE if variables are allocated by the user, NL_FALSE if they are managed by OpenNL.
Definition: nl_context.h:116
NLdouble start_time
start time marking the beginning of latest solve.
Definition: nl_context.h:310
NLdouble * b
The vector of right hand sides, of size nb_systems * n.
Definition: nl_context.h:193
NLMatrix M
The matrix of the system.
Definition: nl_context.h:154
NLboolean verbose
if true, some logging information is displayed during solve.
Definition: nl_context.h:331
NLenum preconditioner
The used preconditioner, as a symbolic constant.
Definition: nl_context.h:217
NLboolean eigen_shift_invert
NL_TRUE if spectral shift-invert transform is used, NL_FALSE otherwise;.
Definition: nl_context.h:354
NLulong flops
Total number of floating point operations used during latest solve.
Definition: nl_context.h:337
NLuint inner_iterations
Maximum number of inner iterations.
Definition: nl_context.h:270
The base class for abstract matrices.
Definition: nl_matrix.h:80
Represents a row or a column of a sparse matrix.
Definition: nl_matrix.h:151