QGIS API Documentation 4.3.0-Master (90cb4ecf9ef)
Loading...
Searching...
No Matches
QgsMatrixSolver Class Reference

Contains utility functions for solving matrix operations. More...

#include <qgsmatrixsolver.h>

Classes

struct  GslData

Public Member Functions

 QgsMatrixSolver (const QgsMatrixSolver &)=delete
 QgsMatrixSolver (int maximumDimension)
 Constructor for QgsMatrixSolver, pre-allocated to solve matrices with the specified maximumDimension.
 ~QgsMatrixSolver ()
int maximumDimension () const
 Returns the maximum dimension supported by this solver.
QgsMatrixSolveroperator= (const QgsMatrixSolver &)=delete
void setRightHandSide (int row, double value)
 Sets a value in the preallocated right-hand-side vector b.
void setValue (int row, int column, double value)
 Sets the value for row, column in the preallocated matrix A.
bool solve (int dimension, QVector< double > &result, Qgis::LinearMatrixMethod method=Qgis::LinearMatrixMethod::Lu)
 Solves the system Ax = b for a specific active dimension.

Static Public Member Functions

static bool isAvailable ()
 Returns true if the matrix solver functionality is available on the current system.

Detailed Description

Contains utility functions for solving matrix operations.

This utility class is designed to solve systems of linear equations in the form Ax = b using LU decomposition.

Note
In situations where many linear systems need to be solved sequentially this class supports a preallocation strategy. By constructing the solver initially with a maximumDimension (where maximumDimension is N for the largest N × N matrix to solve), all backend memory is allocated upfront. Subsequent calls to solve() using a specified dimension create zero-allocation views into this memory block. This guarantees that no heap allocations occur during calculations.
Warning
This class requires a QGIS build with the GSL library enabled. See isAvailable() to determine if the current system supports its functionality.
Since
QGIS 4.4

Definition at line 44 of file qgsmatrixsolver.h.

Constructor & Destructor Documentation

◆ QgsMatrixSolver() [1/2]

QgsMatrixSolver::QgsMatrixSolver ( int maximumDimension)
explicit

Constructor for QgsMatrixSolver, pre-allocated to solve matrices with the specified maximumDimension.

Parameters
maximumDimensionThe dimension N for the largest N × N matrix A to solve with this object. (E.g. 4 if a 4 × 4 matrix is the largest A to solve.)

Definition at line 65 of file qgsmatrixsolver.cpp.

◆ ~QgsMatrixSolver()

QgsMatrixSolver::~QgsMatrixSolver ( )

Definition at line 97 of file qgsmatrixsolver.cpp.

◆ QgsMatrixSolver() [2/2]

QgsMatrixSolver::QgsMatrixSolver ( const QgsMatrixSolver & )
delete

Member Function Documentation

◆ isAvailable()

bool QgsMatrixSolver::isAvailable ( )
static

Returns true if the matrix solver functionality is available on the current system.

Definition at line 56 of file qgsmatrixsolver.cpp.

◆ maximumDimension()

int QgsMatrixSolver::maximumDimension ( ) const

Returns the maximum dimension supported by this solver.

Definition at line 139 of file qgsmatrixsolver.cpp.

◆ operator=()

QgsMatrixSolver & QgsMatrixSolver::operator= ( const QgsMatrixSolver & )
delete

◆ setRightHandSide()

void QgsMatrixSolver::setRightHandSide ( int row,
double value )

Sets a value in the preallocated right-hand-side vector b.

Parameters
rowThe row index (0-based)
valueThe value to insert
Warning
The c++ version of this method performs no bounds checking on row, this is the caller's responsibility.
Exceptions
QgsNotSupportedExceptionfor QGIS builds without GSL support.

Definition at line 156 of file qgsmatrixsolver.cpp.

◆ setValue()

void QgsMatrixSolver::setValue ( int row,
int column,
double value )

Sets the value for row, column in the preallocated matrix A.

Parameters
rowThe row index (0-based)
columnThe column index (0-based)
valueThe value to insert
Warning
The c++ version of this method performs no bounds checking on row or column, this is the caller's responsibility.
Exceptions
QgsNotSupportedExceptionfor QGIS builds without GSL support.

Definition at line 144 of file qgsmatrixsolver.cpp.

◆ solve()

bool QgsMatrixSolver::solve ( int dimension,
QVector< double > & result,
Qgis::LinearMatrixMethod method = Qgis::LinearMatrixMethod::Lu )

Solves the system Ax = b for a specific active dimension.

Parameters
dimensionThe dimension N for the N × N sub-matrix to solve.
resultSolution vector x
methodSolving strategy to use
Returns
true on success, false if the matrix is singular and could not be solved.
Exceptions
QgsNotSupportedExceptionfor QGIS builds without GSL support.
QgsInvalidArgumentExceptionfor invalid dimension values

Definition at line 167 of file qgsmatrixsolver.cpp.


The documentation for this class was generated from the following files: