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

Helper operation interface for DelayedBinaryIsometricOperation. More...

#include <helper_interface.hpp>

Inheritance diagram for tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >:

Public Member Functions

virtual OutputValue_ fill (bool row, Index_ i) const =0
 
virtual bool zero_depends_on_row () const =0
 
virtual bool zero_depends_on_column () const =0
 
virtual bool non_zero_depends_on_row () const =0
 
virtual bool non_zero_depends_on_column () const =0
 
virtual void dense (bool row, Index_ i, Index_ start, Index_ length, const InputValue_ *left_buffer, const InputValue_ *right_buffer, OutputValue_ *output_buffer) const =0
 
virtual void dense (bool row, Index_ i, const std::vector< Index_ > &indices, const InputValue_ *left_buffer, const InputValue_ *right_buffer, OutputValue_ *output_buffer) const =0
 
virtual Index_ sparse (bool row, Index_ i, const SparseRange< InputValue_, Index_ > &left, const SparseRange< InputValue_, Index_ > &right, OutputValue_ *output_value, Index_ *output_index, bool report_value, bool report_index) const =0
 
virtual bool is_sparse () const =0
 
virtual std::optional< Index_ > nrow () const =0
 
virtual std::optional< Index_ > ncol () const =0
 

Detailed Description

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

Helper operation interface for DelayedBinaryIsometricOperation.

This class defines the interface for an operation helper in DelayedBinaryIsometricOperation. Operations should generally inherit from this class, though it is possible for developers to define their own classes with the same signatures for compile-time polymorphism.

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

Member Function Documentation

◆ fill()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual OutputValue_ tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::fill ( bool row,
Index_ i ) const
pure virtual
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 row = true && !zero_depends_on_row() or row = false && !zero_depends_on_column().
Returns
The result of OP(lz, rz) where OP is the operation, lz is a structural zero from the i-th row/column of the left matrix, and rz is a structural zero from the i-th row/column of the left matrix.

This function will never be called by DelayedBinaryIsometricOperation 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.

Implemented in tatami::DelayedBinaryIsometricArithmeticHelper< op_, OutputValue_, InputValue_, Index_ >, tatami::DelayedBinaryIsometricBooleanHelper< op_, OutputValue_, InputValue_, Index_ >, and tatami::DelayedBinaryIsometricCompareHelper< op_, OutputValue_, InputValue_, Index_ >.

◆ zero_depends_on_row()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual bool tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::zero_depends_on_row ( ) const
pure virtual
Returns
Whether applying the operation to a pair of structural zeros (one from each matrix) yields a value that depends on the identity of the row containing those zeros.

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

Implemented in tatami::DelayedBinaryIsometricArithmeticHelper< op_, OutputValue_, InputValue_, Index_ >, tatami::DelayedBinaryIsometricBooleanHelper< op_, OutputValue_, InputValue_, Index_ >, and tatami::DelayedBinaryIsometricCompareHelper< op_, OutputValue_, InputValue_, Index_ >.

◆ zero_depends_on_column()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual bool tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::zero_depends_on_column ( ) const
pure virtual
Returns
Whether applying the operation to a pair of structural zeros (one from each matrix) yields a value that depends on the identity of the column containing those zeros.

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

Implemented in tatami::DelayedBinaryIsometricArithmeticHelper< op_, OutputValue_, InputValue_, Index_ >, tatami::DelayedBinaryIsometricBooleanHelper< op_, OutputValue_, InputValue_, Index_ >, and tatami::DelayedBinaryIsometricCompareHelper< op_, OutputValue_, InputValue_, Index_ >.

◆ non_zero_depends_on_row()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual bool tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::non_zero_depends_on_row ( ) const
pure virtual
Returns
Whether the result of the operation depends on the identity of the row containing the operands, where at least one of the operands is non-zero.

Implemented in tatami::DelayedBinaryIsometricArithmeticHelper< op_, OutputValue_, InputValue_, Index_ >, tatami::DelayedBinaryIsometricBooleanHelper< op_, OutputValue_, InputValue_, Index_ >, and tatami::DelayedBinaryIsometricCompareHelper< op_, OutputValue_, InputValue_, Index_ >.

◆ non_zero_depends_on_column()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual bool tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::non_zero_depends_on_column ( ) const
pure virtual
Returns
Whether the result of the operation depends on the identity of the column containing the operands, where at least one of the operands is non-zero.

Implemented in tatami::DelayedBinaryIsometricArithmeticHelper< op_, OutputValue_, InputValue_, Index_ >, tatami::DelayedBinaryIsometricBooleanHelper< op_, OutputValue_, InputValue_, Index_ >, and tatami::DelayedBinaryIsometricCompareHelper< op_, OutputValue_, InputValue_, Index_ >.

◆ dense() [1/2]

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual void tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::dense ( bool row,
Index_ i,
Index_ start,
Index_ length,
const InputValue_ * left_buffer,
const InputValue_ * right_buffer,
OutputValue_ * output_buffer ) const
pure virtual

This method should apply the operation to corresponding values of left_buffer and right_buffer. These buffers represent the same element of the target dimension from the left and right matrices, respectively, in dense form. Each buffer holds values from a contiguous block of the non-target dimension.

Parameters
rowWhether the rows are the target dimension. If true, left_buffer and right_buffer hold the contents of the i-th row from both matrices; otherwise, they hold the contents of the i-th column.
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,out]left_bufferPointer to an array containing the row/column extracted from the left matrix. This has length addressable elements, and the result of the operation should be stored here.
[in]right_bufferPointer to an array containing the row/column extracted from the right matrix. This has length addressable elements.
[out]output_bufferPointer to an array in which to store the result of the operation. This has length addressable elements. If InputValue_ == OutputValue_, this is guaranteed to be the same as left_buffer.

Implemented in tatami::DelayedBinaryIsometricArithmeticHelper< op_, OutputValue_, InputValue_, Index_ >, tatami::DelayedBinaryIsometricBooleanHelper< op_, OutputValue_, InputValue_, Index_ >, and tatami::DelayedBinaryIsometricCompareHelper< op_, OutputValue_, InputValue_, Index_ >.

◆ dense() [2/2]

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual void tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::dense ( bool row,
Index_ i,
const std::vector< Index_ > & indices,
const InputValue_ * left_buffer,
const InputValue_ * right_buffer,
OutputValue_ * output_buffer ) const
pure virtual

This method should apply the operation to corresponding values of left_buffer and right_buffer, These buffers represent the same element of the target dimension from the left and right matrices, respectively, in dense form. Each buffer holds values from an indexed subset of the non-target dimension.

Parameters
rowWhether the rows are the target dimension. If true, left_buffer and right_buffer hold the contents of the i-th row from both matrices; otherwise, they hold the contents of the i-th column.
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,out]left_bufferPointer to an array containing the row/column extracted from the left matrix. This has length addressable elements, and the result of the operation should be stored here.
[in]right_bufferPointer to an array containing the row/column extracted from the right matrix. This has length addressable elements.
[out]output_bufferPointer to an array in which to store the result of the operation. This has length addressable elements. If InputValue_ == OutputValue_, this is guaranteed to be the same as left_buffer.

Implemented in tatami::DelayedBinaryIsometricArithmeticHelper< op_, OutputValue_, InputValue_, Index_ >, tatami::DelayedBinaryIsometricBooleanHelper< op_, OutputValue_, InputValue_, Index_ >, and tatami::DelayedBinaryIsometricCompareHelper< op_, OutputValue_, InputValue_, Index_ >.

◆ sparse()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual Index_ tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::sparse ( bool row,
Index_ i,
const SparseRange< InputValue_, Index_ > & left,
const SparseRange< InputValue_, Index_ > & right,
OutputValue_ * output_value,
Index_ * output_index,
bool report_value,
bool report_index ) const
pure virtual

This method applies the operation to the sparse ranges in left and right, containing values from the same element of the target dimension from the left and right matrices, respectively. Specifically, the operation only needs to be applied to the structural non-zeros, and results of the operation should be stored in the output_* buffers. Structural zeros are either ignored for sparsity-preserving operations, or the result of the operation on zeros will be populated by fill().

Parameters
rowWhether the rows are the target dimension. If true, left_buffer and right_buffer hold the contents of the i-th row from both matrices; otherwise, they hold the contents of the i-th column.
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.
leftContents of row/column i extracted from the left matrix.
rightContents of row/column i extracted from the right matrix.
[out]output_valuePointer to an array for storing output values of the operation. This is guaranteed to have enough space for the union of indices in left and right.
[out]output_indexPointer to an array for storing output indices. This is guaranteed to have enough space for the union of indices in left and right.
report_valueWhether to return the values in output_value.
report_indexWhether to return the indices in output_index.
Returns
Number of structural non-zero elements in the output_* buffers.

If report_value = true, left.value and right.value and output_value are all guaranteed to be non-NULL. Otherwise, any of these pointers may be NULL and should be ignored.

If report_index = true, output_index is guaranteed to be non-NULL; otherwise, output_index should be ignored. left.index and right.index will always return be non-NULL regardless of report_index. Indices in left.index and right.index are also guaranteed to be in ascending order.

It is expected that the results of the operation are sorted in ascending order, i.e., indices in output_index should be increasing.

The settings of report_index and report_value should not change the number or ordering of the results. That is, output_index should have the same indices regardless of report_value, and output_value should have the same values regardless of report_index. This implies that implementations should not omit structural non-zeros even if the actual value is zero, as the computation of the actual value requires report_value = true.

Implemented in tatami::DelayedBinaryIsometricArithmeticHelper< op_, OutputValue_, InputValue_, Index_ >, tatami::DelayedBinaryIsometricBooleanHelper< op_, OutputValue_, InputValue_, Index_ >, and tatami::DelayedBinaryIsometricCompareHelper< op_, OutputValue_, InputValue_, Index_ >.

◆ is_sparse()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual bool tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::is_sparse ( ) const
pure virtual

◆ nrow()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual std::optional< Index_ > tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::nrow ( ) const
pure virtual
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.

Implemented in tatami::DelayedBinaryIsometricArithmeticHelper< op_, OutputValue_, InputValue_, Index_ >, tatami::DelayedBinaryIsometricBooleanHelper< op_, OutputValue_, InputValue_, Index_ >, and tatami::DelayedBinaryIsometricCompareHelper< op_, OutputValue_, InputValue_, Index_ >.

◆ ncol()

template<typename OutputValue_ , typename InputValue_ , typename Index_ >
virtual std::optional< Index_ > tatami::DelayedBinaryIsometricOperationHelper< OutputValue_, InputValue_, Index_ >::ncol ( ) const
pure virtual
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.

Implemented in tatami::DelayedBinaryIsometricArithmeticHelper< op_, OutputValue_, InputValue_, Index_ >, tatami::DelayedBinaryIsometricBooleanHelper< op_, OutputValue_, InputValue_, Index_ >, and tatami::DelayedBinaryIsometricCompareHelper< op_, OutputValue_, InputValue_, Index_ >.


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