Geogram
Version 1.9.1-rc
A programming library of geometric algorithms
|
Internal OpenNL functions to manipulate sparse matrices. More...
#include "nl_private.h"
Go to the source code of this file.
Classes | |
struct | NLMatrixStruct |
The base class for abstract matrices. More... | |
struct | NLCoeff |
Represents a coefficient in a sparse matrix. More... | |
struct | NLRowColumn |
Represents a row or a column of a sparse matrix. More... | |
struct | NLCRSMatrix |
A compact self-contained storage for sparse matrices. More... | |
struct | NLSparseMatrix |
Typedefs | |
typedef struct NLMatrixStruct * | NLMatrix |
typedef void(* | NLDestroyMatrixFunc) (NLMatrix M) |
Function pointer type for matrix destructors. | |
typedef void(* | NLMultMatrixVectorFunc) (NLMatrix M, const double *x, double *y) |
Function pointer type for matrix x vector product. | |
typedef NLuint | NLuint_big |
Type for internal indices. More... | |
typedef void(* | NLMatrixFunc) (const double *x, double *y) |
Function pointer type for matrix-vector products. | |
Functions | |
NLAPI void NLAPIENTRY | nlDeleteMatrix (NLMatrix M) |
Deletes a matrix. More... | |
NLAPI void NLAPIENTRY | nlMultMatrixVector (NLMatrix M, const double *x, double *y) |
Computes a matrix x vector product. More... | |
NLAPI void NLAPIENTRY | nlCRSMatrixPatternSetRowLength (NLCRSMatrix *M, NLuint i, NLuint n) |
Specifies the number of non-zero entries in the row of a matrix that was constructed by nlCRSMatrixConstructPattern() or nlCRSMatrixConstructPatternSymmetric(). | |
NLAPI void NLAPIENTRY | nlCRSMatrixPatternCompile (NLCRSMatrix *M) |
Intializes a NLCRSMatrix from the pattern (row lengths). More... | |
NLAPI void NLAPIENTRY | nlSparseMatrixAddMatrix (NLSparseMatrix *M, double mul, const NLMatrix N) |
Adds a matrix to another sparse matrix. More... | |
NLAPI void NLAPIENTRY | nlSparseMatrixAddRow (NLSparseMatrix *M) |
Adds a new empty row to a sparse matrix. More... | |
NLAPI void NLAPIENTRY | nlSparseMatrixAddColumn (NLSparseMatrix *M) |
Adds a new empty column to a sparse matrix. More... | |
NLAPI void NLAPIENTRY | nlSparseMatrixMAddRow (NLSparseMatrix *M, NLuint i1, double s, NLuint i2) |
Adds a row of a sparse matrix to another row. (row[i1] += s * row[i2]). More... | |
NLAPI void NLAPIENTRY | nlSparseMatrixScaleRow (NLSparseMatrix *M, NLuint i, double s) |
Scales a row of a sparse matrix. (row[i] *= s). More... | |
NLAPI void NLAPIENTRY | nlSparseMatrixZeroRow (NLSparseMatrix *M, NLuint i) |
Zeroes a row of a sparse matrix. (row[i] = 0). More... | |
NLAPI NLuint_big NLAPIENTRY | nlMatrixNNZ (NLMatrix M) |
Gets the number of non-zero entries in a matrix. More... | |
NLAPI NLMatrix NLAPIENTRY | nlMatrixFactorize (NLMatrix M, NLenum solver) |
Factorizes a matrix. More... | |
NLAPI NLMatrix NLAPIENTRY | nlMatrixNewFromFunction (NLuint m, NLuint n, NLMatrixFunc func) |
Creates a matrix implemented by a matrix-vector function. More... | |
NLAPI NLMatrixFunc NLAPIENTRY | nlMatrixGetFunction (NLMatrix M) |
Gets the function pointer that implements matrix x vector product. More... | |
NLAPI NLMatrix NLAPIENTRY | nlMatrixNewFromProduct (NLMatrix M, NLboolean product_owns_M, NLMatrix N, NLboolean product_owns_N) |
Creates a matrix that represents the product of two matrices. More... | |
Internal OpenNL functions to manipulate sparse matrices.
Definition in file nl_matrix.h.
typedef NLuint NLuint_big |
Type for internal indices.
Matrix dimension is limited to 4G x 4G. Number of non-zero entries is limited to 2^32 (4G) in standard mode, and to 2^64 in GARGANTUA mode.
Definition at line 268 of file nl_matrix.h.
NLAPI void NLAPIENTRY nlCRSMatrixPatternCompile | ( | NLCRSMatrix * | M | ) |
Intializes a NLCRSMatrix from the pattern (row lengths).
[in] | M | a pointer to the NLCRSMatrix to be compiled. |
NLAPI void NLAPIENTRY nlDeleteMatrix | ( | NLMatrix | M | ) |
Deletes a matrix.
If M
is NULL, then the function does nothing
[in] | M | the matrix to be deleted |
Factorizes a matrix.
The corresponding extension needs to be successfully initialized before calling this function.
[in] | M | the input matrix |
[in] | solver | a direct solver, i.e., one of:
|
M
, or NULL if M
is singular. When calling nlMultMatrixVector() with the result, it solves a linear system (the result may be thought of as the inverse of M
). NLAPI NLMatrixFunc NLAPIENTRY nlMatrixGetFunction | ( | NLMatrix | M | ) |
Gets the function pointer that implements matrix x vector product.
[in] | M | the matrix |
NLAPI NLMatrix NLAPIENTRY nlMatrixNewFromFunction | ( | NLuint | m, |
NLuint | n, | ||
NLMatrixFunc | func | ||
) |
Creates a matrix implemented by a matrix-vector function.
[in] | m | number of rows |
[in] | n | number of columns |
[in] | func | a function that implements the matrix x vector product, and that takes the right hand side and the left hand side as arguments. |
NLAPI NLMatrix NLAPIENTRY nlMatrixNewFromProduct | ( | NLMatrix | M, |
NLboolean | product_owns_M, | ||
NLMatrix | N, | ||
NLboolean | product_owns_N | ||
) |
Creates a matrix that represents the product of two matrices.
[in] | M | an m times k matrix. |
[in] | product_owns_M | if set to NL_TRUE, then caller is no longer responsible for the memory associated to M, and M will be destroyed when the product will be destroyed. If it is set to NL_FALSE, then the product only keeps a reference to M, and the caller remains responsible for deallocating M. |
[in] | N | a k times n matrix. |
[in] | product_owns_N | if set to NL_TRUE, then caller is no longer responsible for the memory associated to N, and N will be destroyed when the product will be destroyed. If it is set to NL_FALSE, then the product only keeps a reference to N, and the caller remains responsible for deallocating N. |
NLAPI NLuint_big NLAPIENTRY nlMatrixNNZ | ( | NLMatrix | M | ) |
Gets the number of non-zero entries in a matrix.
If the matrix is sparse, it gets the number of non-zero entries, else it returns m*n
M
NLAPI void NLAPIENTRY nlMultMatrixVector | ( | NLMatrix | M, |
const double * | x, | ||
double * | y | ||
) |
Computes a matrix x vector product.
[in] | M | the matrix |
[in] | x | the vector to be multiplied by the matrix |
[out] | y | the result |
NLAPI void NLAPIENTRY nlSparseMatrixAddColumn | ( | NLSparseMatrix * | M | ) |
Adds a new empty column to a sparse matrix.
[in,out] | M | a pointer to the sparse matrix. |
NLAPI void NLAPIENTRY nlSparseMatrixAddMatrix | ( | NLSparseMatrix * | M, |
double | mul, | ||
const NLMatrix | N | ||
) |
Adds a matrix to another sparse matrix.
Does M += mul * N. If N has symmetric storage, then M needs also to have symmetric storage.
[in,out] | M | a pointer to an NLSparseMatrix |
[in] | mul | a multiplicative factor that pre-multiply all coefficients of N |
[in] | N | a matrix. Needs to be either a NLSparseMatrix or a NLCRSMatrix. |
NLAPI void NLAPIENTRY nlSparseMatrixAddRow | ( | NLSparseMatrix * | M | ) |
Adds a new empty row to a sparse matrix.
[in,out] | M | a pointer to the sparse matrix. |
NLAPI void NLAPIENTRY nlSparseMatrixMAddRow | ( | NLSparseMatrix * | M, |
NLuint | i1, | ||
double | s, | ||
NLuint | i2 | ||
) |
Adds a row of a sparse matrix to another row. (row[i1] += s * row[i2]).
[in,out] | M | a pointer to a sparse matrix. |
[in] | i1 | index of the row. |
[in] | s | scaling factor. |
[in] | i2 | index of the other row. |
NLAPI void NLAPIENTRY nlSparseMatrixScaleRow | ( | NLSparseMatrix * | M, |
NLuint | i, | ||
double | s | ||
) |
Scales a row of a sparse matrix. (row[i] *= s).
[in,out] | M | a pointer to a sparse matrix. |
[in] | i | index of the row. |
[in] | s | scaling factor. |
NLAPI void NLAPIENTRY nlSparseMatrixZeroRow | ( | NLSparseMatrix * | M, |
NLuint | i | ||
) |
Zeroes a row of a sparse matrix. (row[i] = 0).
[in,out] | M | a pointer to a sparse matrix. |
[in] | i | index of the row. |