Geogram  Version 1.9.1
A programming library of geometric algorithms
nl.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_H
41 #define OPENNL_H
42 
43 #include "nl_linkage.h"
44 #include <stdio.h>
45 #include <stdint.h>
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 #define NL_VERSION_4_0 1
52 
53 #define NLAPI
54 
55 /*
56  * Deactivate warnings about documentation
57  * We do that, because CLANG's doxygen parser does not know
58  * some doxygen commands that we use (retval, copydoc) and
59  * generates many warnings for them...
60  */
61 
62 #if defined(__clang__)
63 #pragma clang diagnostic ignored "-Wunknown-pragmas"
64 #pragma clang diagnostic ignored "-Wdocumentation"
65 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
66 #endif
67 
215  typedef unsigned int NLenum;
216 
221  typedef unsigned char NLboolean;
222 
227  typedef unsigned int NLbitfield;
228 
233  typedef void NLvoid;
234 
238  typedef signed char NLbyte;
239 
243  typedef short NLshort;
244 
248  typedef int32_t NLint;
249 
253  typedef unsigned char NLubyte;
254 
258  typedef unsigned short NLushort;
259 
263  typedef uint32_t NLuint;
264 
268  typedef int64_t NLlong;
269 
273  typedef uint64_t NLulong;
274 
278  typedef int NLsizei;
279 
283  typedef float NLfloat;
284 
288  typedef double NLdouble;
289 
297  typedef void(*NLfunc)(void);
298 
305  typedef void* NLContext;
306 
311 #define NL_FALSE 0x0
316 #define NL_TRUE 0x1
317 
336 #define NL_SOLVER 0x100
337 
347 #define NL_NB_VARIABLES 0x101
348 
361 #define NL_LEAST_SQUARES 0x102
362 
375 #define NL_MAX_ITERATIONS 0x103
376 
388 #define NL_THRESHOLD 0x104
389 
400 #define NL_OMEGA 0x105
401 
419 #define NL_SYMMETRIC 0x106
420 
433 #define NL_USED_ITERATIONS 0x107
434 
445 #define NL_ERROR 0x108
446 
457 #define NL_INNER_ITERATIONS 0x109
458 
469 #define NL_ELAPSED_TIME 0x10a
470 
483 #define NL_PRECONDITIONER 0x10b
484 
496 #define NL_GFLOPS 0x10c
497 
509 #define NL_NNZ 0x10d
510 
511 
516 #define NL_NB_SYSTEMS 0x10e
517 
540 #define NL_SOLVER_DEFAULT 0x000
541 
553 #define NL_CG 0x200
554 
566 #define NL_BICGSTAB 0x201
567 
583 #define NL_GMRES 0x202
584 
599 #define NL_PRECOND_NONE 0x000
600 
612 #define NL_PRECOND_JACOBI 0x300
613 
627 #define NL_PRECOND_SSOR 0x301
628 
640 #define NL_PRECOND_USER 0x303
641 
674 #define NL_NORMALIZE_ROWS 0x400
675 
689 #define NL_VERBOSE 0x401
690 
691 
705 #define NL_NO_VARIABLES_INDIRECTION 0x402
706 
724  NLAPI NLContext NLAPIENTRY nlNewContext(void);
725 
731  NLAPI void NLAPIENTRY nlDeleteContext(NLContext context);
732 
739  NLAPI void NLAPIENTRY nlMakeCurrent(NLContext context);
740 
745  NLAPI NLContext NLAPIENTRY nlGetCurrent(void);
746 
757  NLAPI NLboolean NLAPIENTRY nlInitExtension(const char* extension);
758 
764  NLAPI NLboolean NLAPIENTRY nlExtensionIsInitialized(const char* extension);
765 
771  NLAPI void NLAPIENTRY nlInitialize(int argc, char** argv);
772 
792  NLAPI void NLAPIENTRY nlSolverParameterd(NLenum pname, NLdouble param);
793 
825  NLAPI void NLAPIENTRY nlSolverParameteri(NLenum pname, NLint param);
826 
832  NLAPI void NLAPIENTRY nlGetBooleanv(NLenum pname, NLboolean* params);
833 
839  NLAPI void NLAPIENTRY nlGetDoublev(NLenum pname, NLdouble* params);
840 
846  NLAPI void NLAPIENTRY nlGetIntegerv(NLenum pname, NLint* params);
847 
853  NLAPI void NLAPIENTRY nlGetIntegervL(NLenum pname, NLlong* params);
854 
855 
860  NLAPI void NLAPIENTRY nlEnable(NLenum pname);
861 
866  NLAPI void NLAPIENTRY nlDisable(NLenum pname);
867 
874 
897 #define NL_FUNC_SOLVER 0x600
898 
911 #define NL_FUNC_MATRIX 0x601
912 
926 #define NL_FUNC_PRECONDITIONER 0x602
927 
947 #define NL_FUNC_PROGRESS 0x603
948 
957  NLAPI void NLAPIENTRY nlSetFunction(NLenum pname, NLfunc param);
958 
966  NLAPI void NLAPIENTRY nlGetFunction(NLenum pname, NLfunc* param);
967 
982  NLAPI void NLAPIENTRY nlSetVariable(NLuint i, NLdouble value);
983 
984 
995  NLAPI void NLAPIENTRY nlMultiSetVariable(
996  NLuint i, NLuint k, NLdouble value
997  );
998 
1007  NLAPI NLdouble NLAPIENTRY nlGetVariable(NLuint i);
1008 
1019  NLAPI NLdouble NLAPIENTRY nlMultiGetVariable(NLuint i, NLuint k);
1020 
1033  NLAPI void NLAPIENTRY nlLockVariable(NLuint index);
1034 
1046  NLAPI void NLAPIENTRY nlUnlockVariable(NLuint index);
1047 
1059  NLAPI NLboolean NLAPIENTRY nlVariableIsLocked(NLuint index);
1060 
1073 #define NL_SYSTEM 0x0
1074 
1081 #define NL_MATRIX 0x1
1082 
1089 #define NL_ROW 0x2
1090 
1097 #define NL_MATRIX_PATTERN 0x3
1098 
1116  NLAPI void NLAPIENTRY nlBegin(NLenum primitive);
1117 
1135  NLAPI void NLAPIENTRY nlEnd(NLenum primitive);
1136 
1137 
1145  NLAPI void NLAPIENTRY nlSetRowLength(NLuint i, NLuint n);
1146 
1159  NLAPI void NLAPIENTRY nlCoefficient(NLuint i, NLdouble value);
1160 
1161 
1162 
1174  NLAPI NLulong NLAPIENTRY nlAddIJCoefficient(
1175  NLuint i, NLuint j, NLdouble value
1176  );
1177 
1191  NLAPI void NLAPIENTRY nlAddIJCoefficientAt(
1192  NLuint i, NLuint j, NLdouble value, NLulong index
1193  );
1194 
1195 
1206  NLAPI void NLAPIENTRY nlSetIJCoefficientAtRowOffset(
1207  NLuint i, NLuint j, NLdouble value, NLuint row_offset
1208  );
1209 
1220  NLAPI void NLAPIENTRY nlAddIRightHandSide(NLuint i, NLdouble value);
1221 
1233  NLAPI void NLAPIENTRY nlMultiAddIRightHandSide(
1234  NLuint i, NLuint k, NLdouble value
1235  );
1236 
1264  NLAPI void NLAPIENTRY nlRightHandSide(NLdouble value);
1265 
1266 
1274  NLAPI void NLAPIENTRY nlMultiRightHandSide(NLuint k, NLdouble value);
1275 
1305  NLAPI void NLAPIENTRY nlRowScaling(NLdouble value);
1306 
1320  NLAPI NLboolean NLAPIENTRY nlSolve(void);
1321 
1322 
1332  NLAPI void NLAPIENTRY nlUpdateRightHandSide(NLdouble* values);
1333 
1345 #define NL_VARIABLES_BUFFER 0x1000
1346 
1360  NLAPI void NLAPIENTRY nlBindBuffer(
1361  NLenum buffer, NLuint k, void* addr, NLuint stride
1362  );
1363 
1364 
1374 #define NL_STIFFNESS_MATRIX 0x3001
1375 
1379 #define NL_MASS_MATRIX 0x3002
1380 
1388  NLAPI void NLAPIENTRY nlMatrixMode(NLenum matrix);
1389 
1394 #define NL_NB_EIGENS NL_NB_SYSTEMS
1395 
1400 #define NL_EIGEN_MAX_ITERATIONS NL_MAX_ITERATIONS
1401 
1406 #define NL_EIGEN_THRESHOLD NL_THRESHOLD
1407 
1412 #define NL_EIGEN_SOLVER 0x2000
1413 
1418 #define NL_EIGEN_SHIFT 0x2001
1419 
1424 #define NL_EIGEN_SHIFT_INVERT 0x2002
1425 
1431  NLAPI void NLAPIENTRY nlEigenSolverParameterd(
1432  NLenum pname, NLdouble val
1433  );
1434 
1441  NLAPI void NLAPIENTRY nlEigenSolverParameteri(
1442  NLenum pname, NLint val
1443  );
1444 
1448  NLAPI void NLAPIENTRY nlEigenSolve(void);
1449 
1450 
1456  NLAPI double NLAPIENTRY nlGetEigenValue(NLuint i);
1457 
1467  typedef int (*NLprintfFunc)(const char* format, ...);
1468 
1472  typedef int (*NLfprintfFunc)(FILE* out, const char* format, ...);
1473 
1477  NLAPI void NLAPIENTRY nlPrintfFuncs(NLprintfFunc f1, NLfprintfFunc f2);
1478 
1491  struct NLMatrixStruct;
1492 
1496  typedef struct NLMatrixStruct* NLMatrix;
1497 
1504  NLAPI NLMatrix NLAPIENTRY nlGetCurrentMatrix(void);
1505 
1510 #ifdef __cplusplus
1511 }
1512 #endif
1513 
1514 #include "nl_ext.h"
1515 #include "nl_64.h"
1516 
1517 /*************************************************************************/
1518 
1519 #endif
std::string extension(const std::string &path)
Gets a path extension.
NLAPI void NLAPIENTRY nlMultiAddIRightHandSide(NLuint i, NLuint k, NLdouble value)
Adds a coefficient to a component of the right hand side of the equation.
NLAPI void NLAPIENTRY nlEnable(NLenum pname)
Sets a boolean parameter to NL_TRUE.
NLAPI void NLAPIENTRY nlGetIntegerv(NLenum pname, NLint *params)
Gets the value of an integer parameter.
NLAPI NLContext NLAPIENTRY nlGetCurrent(void)
Gets the current context.
NLAPI void NLAPIENTRY nlUpdateRightHandSide(NLdouble *values)
Updates the right hand side of the constructed system in one call.
NLAPI void NLAPIENTRY nlGetFunction(NLenum pname, NLfunc *param)
Gets a function pointer.
NLAPI void NLAPIENTRY nlPrintfFuncs(NLprintfFunc f1, NLfprintfFunc f2)
Specifies user functions for printing messages.
NLAPI void NLAPIENTRY nlMatrixMode(NLenum matrix)
Specifies to which matrix the subsequent calls to nlBegin(), nlEnd(), nlCoefficient(),...
void * NLContext
An OpenNL context.
Definition: nl.h:305
uint32_t NLuint
A 4-bytes unsigned integer.
Definition: nl.h:263
NLAPI void NLAPIENTRY nlEigenSolverParameterd(NLenum pname, NLdouble val)
Sets a floating-point parameter of the eigen solver.
NLAPI void NLAPIENTRY nlCoefficient(NLuint i, NLdouble value)
Appends a coefficient to the current row.
NLAPI void NLAPIENTRY nlGetIntegervL(NLenum pname, NLlong *params)
Gets the value of a 64 bits integer parameter.
NLAPI void NLAPIENTRY nlUnlockVariable(NLuint index)
Unlocks a variable.
unsigned char NLubyte
A 1-byte unsigned integer.
Definition: nl.h:253
int NLsizei
Size of an object, 4-bytes signed integer.
Definition: nl.h:278
NLAPI void NLAPIENTRY nlMultiRightHandSide(NLuint k, NLdouble value)
Sets the right-hand side of the current row when there are several systems to be solved.
short NLshort
A 2-bytes signed integer.
Definition: nl.h:243
NLAPI NLboolean NLAPIENTRY nlInitExtension(const char *extension)
Initializes an OpenNL extension.
uint64_t NLulong
A 8-bytes unsigned integer.
Definition: nl.h:273
NLAPI NLulong NLAPIENTRY nlAddIJCoefficient(NLuint i, NLuint j, NLdouble value)
Adds a coefficient to the current matrix.
NLAPI void NLAPIENTRY nlSetVariable(NLuint i, NLdouble value)
Sets the value of a variable.
int(* NLprintfFunc)(const char *format,...)
Function pointer type for user printf function.
Definition: nl.h:1467
signed char NLbyte
A 1-byte signed integer.
Definition: nl.h:238
double NLdouble
A double-precision floating-point number.
Definition: nl.h:288
NLAPI void NLAPIENTRY nlEigenSolve(void)
Calls the eigen solver.
NLAPI NLboolean nlIsEnabled(NLenum pname)
Tests a boolean parameter.
void(* NLfunc)(void)
A function pointer.
Definition: nl.h:297
NLAPI void NLAPIENTRY nlInitialize(int argc, char **argv)
Initializes OpenNL using command line arguments.
NLAPI void NLAPIENTRY nlGetDoublev(NLenum pname, NLdouble *params)
Gets the value of a double-precision floating-point parameter.
struct NLMatrixStruct * NLMatrix
Opaque handle to a matrix.
Definition: nl.h:1496
NLAPI void NLAPIENTRY nlMultiSetVariable(NLuint i, NLuint k, NLdouble value)
Sets the value of a variable when there are several systems to solve.
int32_t NLint
A 4-bytes signed integer.
Definition: nl.h:248
NLAPI NLdouble NLAPIENTRY nlMultiGetVariable(NLuint i, NLuint k)
Gets the value of a variable when there are several systems to solve.
int64_t NLlong
A 8-bytes signed integer.
Definition: nl.h:268
unsigned int NLenum
A symbolic constant.
Definition: nl.h:215
NLAPI void NLAPIENTRY nlRightHandSide(NLdouble value)
Sets the right-hand side of the current row.
NLAPI void NLAPIENTRY nlDisable(NLenum pname)
Sets a boolean parameter to NL_FALSE.
float NLfloat
A single-precision floating-point number.
Definition: nl.h:283
NLAPI void NLAPIENTRY nlSolverParameteri(NLenum pname, NLint param)
Specifies an integer solver parameter.
NLAPI void NLAPIENTRY nlBindBuffer(NLenum buffer, NLuint k, void *addr, NLuint stride)
Specifies a buffer binding to directly map user data to variables instead of using nlGetVariable() / ...
NLAPI void NLAPIENTRY nlLockVariable(NLuint index)
Locks a variable.
NLAPI void NLAPIENTRY nlGetBooleanv(NLenum pname, NLboolean *params)
Gets the value of a boolean parameter.
NLAPI void NLAPIENTRY nlSolverParameterd(NLenum pname, NLdouble param)
Specifies a floating-point solver parameter.
NLAPI NLboolean NLAPIENTRY nlSolve(void)
Solves the linear system in the current context.
NLAPI NLContext NLAPIENTRY nlNewContext(void)
Creates a new OpenNL context.
NLAPI void NLAPIENTRY nlEigenSolverParameteri(NLenum pname, NLint val)
Sets an integer parameter of the eigen solver.
int(* NLfprintfFunc)(FILE *out, const char *format,...)
Function pointer type for user fprintf function.
Definition: nl.h:1472
unsigned short NLushort
A 2-bytes unsigned integer.
Definition: nl.h:258
NLAPI void NLAPIENTRY nlMakeCurrent(NLContext context)
Sets the current OpenNL context.
unsigned char NLboolean
A truth value (NL_TRUE or NL_FALSE).
Definition: nl.h:221
NLAPI NLboolean NLAPIENTRY nlVariableIsLocked(NLuint index)
Tests whether a variable is locked.
NLAPI void NLAPIENTRY nlRowScaling(NLdouble value)
Sets the row scaling for the next row.
NLAPI NLdouble NLAPIENTRY nlGetVariable(NLuint i)
Gets the value of a variable.
NLAPI NLboolean NLAPIENTRY nlExtensionIsInitialized(const char *extension)
Tests whether an OpenNL extension is initialized.
NLAPI void NLAPIENTRY nlAddIRightHandSide(NLuint i, NLdouble value)
Adds a coefficient to a component of the right hand side of the equation.
NLAPI NLMatrix NLAPIENTRY nlGetCurrentMatrix(void)
Gets the current matrix.
NLAPI void NLAPIENTRY nlBegin(NLenum primitive)
Begins a new primitive.
NLAPI void NLAPIENTRY nlSetFunction(NLenum pname, NLfunc param)
Sets a function pointer.
NLAPI double NLAPIENTRY nlGetEigenValue(NLuint i)
Gets an eigenvalue.
void NLvoid
Return type of functions that do not return a value.
Definition: nl.h:233
unsigned int NLbitfield
A set of symbolic constants that can be combined with the bitwise or operator.
Definition: nl.h:227
NLAPI void NLAPIENTRY nlSetRowLength(NLuint i, NLuint n)
Specifies the length of a row of the matrix.
NLAPI void NLAPIENTRY nlEnd(NLenum primitive)
Begins a new primitive.
NLAPI void NLAPIENTRY nlAddIJCoefficientAt(NLuint i, NLuint j, NLdouble value, NLulong index)
Adds a coefficient to the current matrix with known index.
NLAPI void NLAPIENTRY nlDeleteContext(NLContext context)
Destroys an existing OpenNL context.
Some optional extensions of the OpenNL linear solver library.
Specify linkage for OpenNL integrated into Geogram.
The base class for abstract matrices.
Definition: nl_matrix.h:80
NLAPI void NLAPIENTRY nlSetIJCoefficientAtRowOffset(NLuint i, NLuint j, NLdouble value, NLuint row_offset)
Sets a coefficient to the current matrix at a known row offset.