tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ > Class Template Referencefinal

Helper for delayed calculation of the exponential function of each matrix entry minus 1. More...

#include <math_helpers.hpp>

Inheritance diagram for tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >:
Collaboration diagram for tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >:

Public Member Functions

std::optional< Index_ > nrow () const
 
std::optional< Index_ > ncol () const
 
bool zero_depends_on_row () const
 
bool zero_depends_on_column () const
 
bool non_zero_depends_on_row () const
 
bool non_zero_depends_on_column () const
 
void dense (bool, Index_, Index_, Index_ length, const InputValue_ *input, OutputValue_ *output) const
 
void dense (bool, Index_, const std::vector< Index_ > &indices, const InputValue_ *input, OutputValue_ *output) const
 
bool is_sparse () const
 
void sparse (bool, Index_, Index_ number, const InputValue_ *input, const Index_ *, OutputValue_ *output) const
 
OutputValue_ fill (bool, Index_) const
 
- Public Member Functions inherited from tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >

Detailed Description

template<typename OutputValue_, typename InputValue_, typename Index_>
class tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >

Helper for delayed calculation of the exponential function of each matrix entry minus 1.

This class computes expm1() on each element of a Matrix. It should be used as the Operation_ in the DelayedUnaryIsometricOperation class.

Template Parameters
OutputValue_Type of the result of the operation.
InputValue_Type of the value of the input matrix.
Index_Integer type for the row/column indices.

Member Function Documentation

◆ nrow()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
std::optional< Index_ > tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::nrow ( ) const
inlinevirtual
Returns
Expected number of rows in the matrix to which this operation is to be applied (i.e., the underlying matrix in the DelayedUnaryIsometricOperation constructor). If no value is returned, the matrix may have any number of rows.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.

◆ ncol()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
std::optional< Index_ > tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::ncol ( ) const
inlinevirtual
Returns
Expected number of columns in the matrix to which this operation is to be applied (i.e., the underlying matrix in the DelayedUnaryIsometricOperation constructor). If no value is returned, the matrix may have any number of columns.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.

◆ zero_depends_on_row()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
bool tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::zero_depends_on_row ( ) const
inlinevirtual
Returns
Whether the operation will convert a structural zero to a non-zero value, in a manner that depends on the identity of the column in which the structural zero occurs.

This method is only called when is_sparse() returns false. It is not necessary to explicitly return false here for sparsity-preserving operations, as DelayedUnaryIsometricOperation will automatically recognize such operations as being row-independent.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.

◆ zero_depends_on_column()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
bool tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::zero_depends_on_column ( ) const
inlinevirtual
Returns
Whether the operation will convert a structural zero to a non-zero value, in a manner that depends on the identity of the column in which the structural zero occurs.

This method is only called when is_sparse() returns false. It is not necessary to explicitly return false here for sparsity-preserving operations, as DelayedUnaryIsometricOperation will automatically recognize such operations as being row-independent.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.

◆ non_zero_depends_on_row()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
bool tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::non_zero_depends_on_row ( ) const
inlinevirtual
Returns
Whether the result of the operation on a non-zero operand depends on the identity of the row containing the operand.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.

◆ non_zero_depends_on_column()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
bool tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::non_zero_depends_on_column ( ) const
inlinevirtual
Returns
Whether the result of the operation on a non-zero operand depends on the identity of the column containing the operand.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.

◆ dense() [1/2]

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
void tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::dense ( bool row,
Index_ i,
Index_ start,
Index_ length,
const InputValue_ * input,
OutputValue_ * output ) const
inlinevirtual

This method accepts a contiguous block of an element of the target dimension from the underlying matrix (input), applies the operation to each value, and stores the result in another array of different type (output).

Parameters
rowWhether the rows are the target dimension. If true, buffer contains row i, otherwise it contains column i.
iIndex of the extracted row (if row = true) or column (otherwise). This argument should be ignored if the operation does not depend on the row/column (i.e., when all of zero_depends_on_row() and friends return false), in which case an arbitrary placeholder may be supplied.
startStart of the contiguous block of columns (if row = true) or rows (otherwise) extracted from i.
lengthLength of the contiguous block.
[in]inputPointer to an array containing a contiguous block of a row/column extracted from the matrix. This has length addressable elements.
[out]outputPointer to an array to store the results of the operation applied to elements of input. This has length addressable elements. If InputValue_ == OutputValue_, this is guaranteed to be the same as input.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.

◆ dense() [2/2]

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
void tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::dense ( bool row,
Index_ i,
const std::vector< Index_ > & indices,
const InputValue_ * input,
OutputValue_ * output ) const
inlinevirtual

This method accepts an indexed subset of an element of the target dimension from the underlying matrix (input), applies the operation to each value, and stores the result in another array of different type (output).

Parameters
rowWhether the rows are the target dimension. If true, buffer contains row i, otherwise it contains column i.
iIndex of the extracted row (if row = true) or column (otherwise). This argument should be ignored if the operation does not depend on the row/column (i.e., when all of zero_depends_on_row() and friends return false), in which case an arbitrary placeholder may be supplied.
indicesSorted and unique indices of columns (if row = true) or rows (otherwise) extracted from i.
[in]inputPointer to an array containing an indexed subset of a row/column extracted from the matrix. This has length addressable elements.
[out]outputPointer to an array to store the results of the operation applied to elements of input. This has length addressable elements. If InputValue_ == OutputValue_, this is guaranteed to be the same as input.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.

◆ is_sparse()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
bool tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::is_sparse ( ) const
inlinevirtual
Returns
Does this operation preserve sparsity? This may return false.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.

◆ sparse()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
void tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::sparse ( bool row,
Index_ i,
Index_ num,
const InputValue_ * input_value,
const Index_ * index,
OutputValue_ * output_value ) const
inlinevirtual

This method is expected to iterate over input_value, apply the operation to each value, and store the result in output_value. We assume that the operation only needs to be applied to the structural non-zeros; structural zeros are either ignored for sparsity-preserving operations, or the result of the operation on zeros will be populated by fill().

If non_zero_depends_on_row() && !row or non_zero_depends_on_column() && row, index is guaranteed to be non-NULL. Otherwise, it may be NULL and should be ignored. Even if non-NULL, indices are not guaranteed to be sorted.

Implementations of this method do not necessarily need to have the same template arguments as shown here. It will be called without any explicit template arguments so anything can be used as long as type deduction works.

Parameters
rowWhether the rows are the target dimension. If true, buffer contains row i, otherwise it contains column i.
iIndex of the extracted row (if row = true) or column (otherwise). This argument should be ignored if the operation does not depend on the row/column (i.e., when all of zero_depends_on_row() and friends return false), in which case an arbitrary placeholder may be supplied.
numNumber of non-zero elements for row/column i.
[in]input_valuePointer to an array of values of the structural non-zero elements from the row/column of the matrix. This is guaranteed to have num addressable elements.
[in]indexPointer to an array of column (if row = true) or row indices (otherwise) of the non-zero elements. Alternatively NULL.
[out]output_valuePointer to an array in which to store the result of the operation on each element of input_value. This is guaranteed to have num addressable elements. If InputValue_ == OutputValue_, this is guaranteed to be the same as input.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.

◆ fill()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
OutputValue_ tatami::DelayedUnaryIsometricExpm1Helper< OutputValue_, InputValue_, Index_ >::fill ( bool row,
Index_ i ) const
inlinevirtual
Parameters
rowWhether i refers to the row or column index.
iThe index of the row (if row = true) or column (otherwise) containing the zeros. This argument should be ignored if the operation does not depend on the row/column, i.e., when all of zero_depends_on_row() and friends return false.
Returns
The result of the operation being applied on zeros from the i-th row/column of the matrix.

This function will never be called by DelayedUnaryIsometricOperation if the operation depends on the dimension that is not specified by row, i.e., when row = true && zero_depends_on_column() or row = false && zero_depends_on_row(). In such cases, no single fill value would exist.

Implements tatami::DelayedUnaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >.


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