Template Numerical Library version\ main:4e6e2c1
Loading...
Searching...
No Matches
Matrix Traversal Lambda Functions Reference

This page documents the lambda function signatures used in matrix traversal operations.

Traversal Function (Non-Const Matrix)

For non-const matrices sparse matrices (TNL::Matrices::SparseMatrix and TNL::Matrices::SparseMatrixView), the traversal function has full access to modify element indices and values:

auto function = [=] __cuda_callable__ ( IndexType rowIdx, IndexType localIdx, IndexType& columnIdx, RealType& value ) { ... }
#define __cuda_callable__
Definition Macros.h:49

Parameters:

  • rowIdx - The index of the matrix row to which the element belongs
  • localIdx - The rank/position of the element within the matrix row (0-based)
  • columnIdx - Reference to the column index (can be modified)
  • value - Reference to the element value (can be modified)

For other types matrices like dense (TNL::Matrices::DenseMatrix, TNL::Matrices::DenseMatrixView), tridiagonal matrices (TNL::Matrices::TridiagonalMatrix, TNL::Matrices::TridiagonalMatrixView) or multidiagonal (TNL::Matrices::MultidiagonalMatrix, TNL::Matrices::MultidiagonalMatrixView), the column index is defined implicitly and cannot be changed even for non-constant matrices. The signature then reads as:

auto function = [=] __cuda_callable__ ( IndexType rowIdx, IndexType localIdx, IndexType columnIdx, RealType& value ) { ... }

Parameters:

  • rowIdx - The index of the matrix row to which the element belongs
  • localIdx - The rank/position of the element within the matrix row (0-based)
  • columnIdx - Column index
  • value - Reference to the element value (can be modified)

Traversal Function (Const Matrix)

For const matrices, the traversal function has read-only access:

auto function = [=] __cuda_callable__ ( IndexType rowIdx, IndexType localIdx, IndexType columnIdx, const RealType& value ) {
... }

Parameters:

  • rowIdx - The index of the matrix row to which the element belongs
  • localIdx - The rank/position of the element within the matrix row (0-based)
  • columnIdx - The column index (read-only)
  • value - Const reference to the element value (read-only)

Row Traversal Function (Non-Const Matrix)

When traversing entire rows with row-level operations, the function receives the row index:

auto function = [=] __cuda_callable__ ( typename Matrix::RowView row ) { ... }

Parameters:

  • rowIdx - The index of the matrix row being processed

Row Traversal Function (Const Matrix)

Same signature for const matrices:

auto function = [=] __cuda_callable__ ( typename Matrix::ConstRowView row ) { ... }

Parameters:

  • rowIdx - The index of the matrix row being processed

Condition Lambda

For conditional traversal operations (forElementsIf, forRowsIf), a condition function determines which rows to process:

auto condition = [=] __cuda_callable__ ( IndexType rowIdx ) -> bool { ... }

Parameters:

  • rowIdx - The index of the matrix row to check

Returns:

  • true if the row should be processed, false to skip it

Related Pages