tatami
C++ API for different matrix representations
|
Flexible representations for matrix data. More...
Classes | |
class | ArrayView |
View into a pre-allocated array. More... | |
class | BlockSparsifiedWrapper |
Wrap a block dense extractor in the sparse interface. More... | |
class | CompressedSparseColumnMatrix |
Compressed sparse column matrix. More... | |
struct | CompressedSparseContents |
Compressed sparse contents. More... | |
class | CompressedSparseMatrix |
Compressed sparse matrix representation. More... | |
class | CompressedSparseRowMatrix |
Compressed sparse row matrix. More... | |
class | ConsecutiveOracle |
Predict future accesses along a consecutive sequence. More... | |
class | ConstantMatrix |
Matrix containing a constant value. More... | |
class | DelayedBinaryIsometricArithmetic |
Delayed binary isometric arithmetic. More... | |
struct | DelayedBinaryIsometricBoolean |
Delayed binary isometric boolean operations. More... | |
struct | DelayedBinaryIsometricCompare |
Delayed binary isometric comparison. More... | |
class | DelayedBinaryIsometricMockAdvanced |
Advanced mock operation for DelayedBinaryIsometricOperation . More... | |
class | DelayedBinaryIsometricMockBasic |
Basic mock operation for DelayedBinaryIsometricOperation . More... | |
class | DelayedBinaryIsometricOperation |
Delayed isometric operations on two matrices. More... | |
class | DelayedBind |
Delayed combining of a matrix. More... | |
class | DelayedCast |
Recast a Matrix to a different interface type. More... | |
class | DelayedSubset |
Delayed subsetting of a matrix with general indices. More... | |
class | DelayedSubsetBlock |
Delayed subsetting to a contiguous block. More... | |
class | DelayedSubsetSorted |
Delayed subsetting of a matrix with sorted indices. More... | |
class | DelayedSubsetSortedUnique |
Delayed subsetting of a matrix with sorted, unique indices. More... | |
class | DelayedSubsetUnique |
Delayed subsetting of a matrix with unique indices. More... | |
class | DelayedTranspose |
Delayed transposition of a matrix. More... | |
class | DelayedUnaryIsometricAbs |
Take the absolute value of a matrix entry. More... | |
class | DelayedUnaryIsometricAcos |
Take the inverse cosine of a matrix entry. More... | |
class | DelayedUnaryIsometricAcosh |
Take the inverse hyperbolic cosine of a matrix entry. More... | |
class | DelayedUnaryIsometricArithmeticScalar |
Delayed unary isometric scalar arithmetic. More... | |
class | DelayedUnaryIsometricArithmeticVector |
Delayed unary isometric vector arithmetic. More... | |
class | DelayedUnaryIsometricAsin |
Take the inverse sine of a matrix entry. More... | |
class | DelayedUnaryIsometricAsinh |
Take the inverse hyperbolic sine of a matrix entry. More... | |
class | DelayedUnaryIsometricAtan |
Take the inverse tangent of a matrix entry. More... | |
class | DelayedUnaryIsometricAtanh |
Take the inverse hyperbolic tangent of a matrix entry. More... | |
class | DelayedUnaryIsometricBooleanCast |
Delayed unary isometric boolean cast. More... | |
class | DelayedUnaryIsometricBooleanNot |
Delayed unary isometric boolean NOT operation. More... | |
class | DelayedUnaryIsometricBooleanScalar |
Delayed unary isometric scalar boolean operation. More... | |
class | DelayedUnaryIsometricBooleanVector |
Delayed unary isometric vector boolean operations. More... | |
class | DelayedUnaryIsometricCeiling |
Take the ceiling of a matrix entry. More... | |
class | DelayedUnaryIsometricCompareScalar |
Delayed scalar comparison. More... | |
class | DelayedUnaryIsometricCompareVector |
Delayed vector comparisons. More... | |
class | DelayedUnaryIsometricCos |
Take the cosine of a matrix entry. More... | |
class | DelayedUnaryIsometricCosh |
Take the hyperbolic cosine of a matrix entry. More... | |
class | DelayedUnaryIsometricExp |
Use a matrix entry as an exponent. More... | |
class | DelayedUnaryIsometricExpm1 |
Use a matrix entry as an exponent minus 1. More... | |
class | DelayedUnaryIsometricFloor |
Take the floor of a matrix entry. More... | |
class | DelayedUnaryIsometricGamma |
Apply the gamma function to a matrix entry. More... | |
class | DelayedUnaryIsometricLgamma |
Apply the log-gamma function to a matrix entry. More... | |
class | DelayedUnaryIsometricLog |
Take the logarithm of a matrix entry. More... | |
class | DelayedUnaryIsometricLog1p |
Take the logarithm of a matrix entry plus 1. More... | |
class | DelayedUnaryIsometricMockAdvanced |
Advanced mock operation for DelayedUnaryIsometricOperation . More... | |
class | DelayedUnaryIsometricMockBasic |
Basic mock operation for a DelayedUnaryIsometricOperation . More... | |
class | DelayedUnaryIsometricOperation |
Delayed isometric operation on a single matrix. More... | |
class | DelayedUnaryIsometricRound |
Round a matrix entry to the nearest integer. More... | |
class | DelayedUnaryIsometricSign |
Take the sign of a matrix entry. More... | |
class | DelayedUnaryIsometricSin |
Take the sine of a matrix entry. More... | |
class | DelayedUnaryIsometricSinh |
Take the hyperbolic sine of a matrix entry. More... | |
class | DelayedUnaryIsometricSpecialCompare |
Delayed special value comparison. More... | |
class | DelayedUnaryIsometricSpecialSubstitute |
Delayed special value substitution. More... | |
class | DelayedUnaryIsometricSqrt |
Take the square root of a matrix entry. More... | |
class | DelayedUnaryIsometricSubstituteScalar |
Delayed scalar substitution. More... | |
class | DelayedUnaryIsometricSubstituteVector |
Delayed vector comparisons. More... | |
class | DelayedUnaryIsometricTan |
Take the tangent of a matrix entry. More... | |
class | DelayedUnaryIsometricTanh |
Take the hyperbolic tangent of a matrix entry. More... | |
class | DelayedUnaryIsometricTrunc |
Integer truncation of a matrix entry. More... | |
class | DenseColumnMatrix |
Dense column-major matrix. More... | |
class | DenseMatrix |
Dense matrix representation. More... | |
class | DenseRowMatrix |
Dense row-major matrix. More... | |
class | FixedVectorOracle |
Predict future accesses from a vector containing a fixed sequence. More... | |
class | FixedViewOracle |
Predict future accesses from a view on a fixed sequence. More... | |
class | FragmentedSparseColumnMatrix |
Fragmented sparse column matrix. More... | |
struct | FragmentedSparseContents |
Fragmented sparse contents. More... | |
class | FragmentedSparseMatrix |
Fragmented sparse matrix representation. More... | |
class | FragmentedSparseRowMatrix |
Fragmented sparse row matrix. More... | |
class | FullSparsifiedWrapper |
Wrap a full dense extractor in the sparse interface. More... | |
struct | has_data |
Compile time check for the data() method. More... | |
struct | has_data< T, V, decltype((void) std::declval< V >().data(), 0)> |
Compile time check for the data() method. More... | |
class | IndexSparsifiedWrapper |
Wrap an indexed dense extractor in the sparse interface. More... | |
class | Matrix |
Virtual class for a matrix. More... | |
class | MyopicDenseExtractor |
Extract an element of the target dimension in dense form without an oracle. More... | |
class | MyopicSparseExtractor |
Extract an element of the target dimension in sparse form without an oracle. More... | |
struct | Options |
Options for accessing data from a Matrix instance. More... | |
class | Oracle |
Predict future access requests on the target dimension. More... | |
class | OracularDenseExtractor |
Extract an element of the target dimension in dense form with an oracle. More... | |
class | OracularSparseExtractor |
Extract an element of the target dimension in sparse form with an oracle. More... | |
struct | PseudoOracularDenseExtractor |
Mimic the OracularDenseExtractor interface. More... | |
struct | PseudoOracularSparseExtractor |
Mimic the OracularSparseExtractor interface. More... | |
class | SomeNumericArray |
Array of some numeric type, determined at runtime. More... | |
struct | SparseRange |
A range of a sparse vector. More... | |
Typedefs | |
template<bool oracle_, typename Value_ , typename Index_ > | |
using | DenseExtractor = typename std::conditional< oracle_, OracularDenseExtractor< Value_, Index_ >, MyopicDenseExtractor< Value_, Index_ > >::type |
template<bool oracle_, typename Value_ , typename Index_ > | |
using | SparseExtractor = typename std::conditional< oracle_, OracularSparseExtractor< Value_, Index_ >, MyopicSparseExtractor< Value_, Index_ > >::type |
template<typename Index_ > | |
using | VectorPtr = std::shared_ptr< const std::vector< Index_ > > |
using | NumericMatrix = Matrix< double, int > |
template<class Array_ > | |
using | ElementType = typename std::remove_cv< typename std::remove_reference< decltype(std::declval< Array_ >()[0])>::type >::type |
template<bool oracle_, typename Index_ > | |
using | MaybeOracle = typename std::conditional< oracle_, std::shared_ptr< const Oracle< Index_ > >, bool >::type |
Enumerations | |
enum class | DimensionSelectionType : char { FULL , BLOCK , INDEX } |
enum class | ArithmeticOperation : char { ADD , SUBTRACT , MULTIPLY , DIVIDE , POWER , MODULO , INTEGER_DIVIDE } |
enum class | BooleanOperation : char { AND , OR , XOR , EQUAL } |
enum class | CompareOperation : char { EQUAL , GREATER_THAN , LESS_THAN , GREATER_THAN_OR_EQUAL , LESS_THAN_OR_EQUAL , NOT_EQUAL } |
enum class | SpecialCompareOperation : char { ISNAN , ISINF , ISFINITE } |
enum | SomeNumericType { I8 , U8 , I16 , U16 , I32 , U32 , I64 , U64 , F32 , F64 } |
Flexible representations for matrix data.
using tatami::DenseExtractor = typedef typename std::conditional<oracle_, OracularDenseExtractor<Value_, Index_>, MyopicDenseExtractor<Value_, Index_> >::type |
oracle_ | Whether to use an oracle-aware interface. |
Value_ | Data value type, should be numeric. |
Index_ | Row/column index type, should be integer. |
Type alias that switches between OracularDenseExtractor
and MyopicDenseExtractor
depending on oracle_
. Intended for templated class definitions, where setting oracle_
can define subclasses for both interfaces.
using tatami::SparseExtractor = typedef typename std::conditional<oracle_, OracularSparseExtractor<Value_, Index_>, MyopicSparseExtractor<Value_, Index_> >::type |
oracle_ | Whether to use an oracle-aware interface. |
Value_ | Data value type, should be numeric. |
Index_ | Row/column index type, should be integer. |
Type alias that switches between OracularSparseExtractor
and MyopicSparseExtractor
depending on oracle_
. Intended for templated class definitions, where setting oracle_
can define subclasses for both interfaces.
using tatami::VectorPtr = typedef std::shared_ptr<const std::vector<Index_> > |
Index | Row/column index type, should be integer. |
Pointer to a vector, typically containing unique and sorted indices. We use a shared pointer so that we can cheaply re-use the same sequence of indices for multiple Matrix
objects.
A convenient shorthand for the most common use case of double-precision matrices.
using tatami::ElementType = typedef typename std::remove_cv<typename std::remove_reference<decltype(std::declval<Array_>()[0])>::type>::type |
Array_ | Some array of values that are accessed with [ . |
Extract the type of array elements, after stripping away references and const
-ness.
using tatami::MaybeOracle = typedef typename std::conditional<oracle_, std::shared_ptr<const Oracle<Index_> >, bool>::type |
oracle_ | Whether an oracle should be supplied. |
Index_ | Row/column index type, should be integer. |
Maybe an Oracle
, maybe a placeholder boolean, depending on oracle_
.
|
strong |
Selection of dimension elements:
FULL
: selects the full extent of the dimension, i.e., all elements.BLOCK
: selects a contiguous block of elements in the dimension.INDEX
: selects a sorted and unique array of indices of dimension elements.This corresponds to the various overloads of Matrix
methods (e.g., Matrix::dense_row()
), each of which extracts a different selection of elements from the non-target dimension.
|
strong |
Type of arithmetic operation.
The INTEGER_DIVIDE
refers to a floored division, which differs from truncation for negative quotients. This choice is based on R's %/%
, which in turn is based on a recommendation by Donald Knuth.
Similarly, x MODULO y
is defined as x - floor(x / y)
, based on the same floored division. Note that this differs from the built-in %
operator, which performs truncation.
|
strong |
Type of boolean operation.
|
strong |
Type of comparison operation.
|
strong |
Type of comparison operation for special IEEE values.
Types supported in SomeNumericArray
. The letters indicate whether it is an integer (I), unsigned integer (U) or a float, while the numbers specify the number of bits for the type. So, for example, U16
is an unsigned 16-bit integer, while F64
is a double
.
void tatami::convert_to_dense | ( | const Matrix< InputValue_, InputIndex_ > * | matrix, |
bool | row_major, | ||
StoredValue_ * | store, | ||
int | threads = 1 |
||
) |
StoredValue_ | Type of data values to be stored in the output. |
InputValue_ | Type of data values in the input. |
InputIndex_ | Integer type for the indices in the input. |
matrix | Pointer to a tatami::Matrix . | |
row_major | Whether to store the output as a row-major matrix. | |
[out] | store | Pointer to an array of length equal to the product of the dimensions of matrix . On output, this is filled with values from matrix in row- or column-major format depending on row_major . |
threads | Number of threads to use, for parallelization with parallelize() . |
|
inline |
Value_ | Type of data values in the output interface. |
Index_ | Integer type for the indices in the output interface. |
StoredValue_ | Type of data values to be stored in the output. |
InputValue_ | Type of data values in the input. |
InputIndex_ | Integer type for the indices in the input. |
matrix | Pointer to a tatami::Matrix . |
row_major | Whether to return a row-major matrix. |
threads | Number of threads to use, for parallelization with parallelize() . |
tatami::DenseMatrix
with the same dimensions and type as the matrix referenced by matrix
. If row_major = true
, the matrix is row-major, otherwise it is column-major. void tatami::transpose | ( | const Input_ * | input, |
size_t | nrow, | ||
size_t | ncol, | ||
size_t | input_stride, | ||
Output_ * | output, | ||
size_t | output_stride | ||
) |
Input_ | Input type. |
Output_ | Output type. |
[in] | input | Pointer to an array containing a row-major matrix with nrow rows and ncol columns. Elements within each row should be contiguous but consecutive rows can be separated by a constant stride, see input_stride . The array should have at least (nrow - 1) * input_stride + ncol addressable elements. |
nrow | Number of rows in the matrix stored at input . | |
ncol | Number of columns in the matrix stored at input . | |
input_stride | Distance between corresponding entries on consecutive rows of the input matrix. This should be greater than or equal to ncol . | |
[out] | output | Pointer to an array in which to store the transpose of the matrix in input . On output, this stores a row-major matrix with ncol rows and nrow columns. Elements within each row should be contiguous but consecutive rows can be separated by a constant stride, see output_stride . The array should have at least (ncol - 1) * output_stride + nrow addressable elements. It is assumed that output does not alias input . |
output_stride | Distance between corresponding entries on consecutive rows of the output matrix. This should be greater than or equal to nrow . |
This function is intended for developers of Matrix
subclasses who need to do some transposition, e.g., for dense chunks during caching. The *_stride
arguments allow input
and output
to refer to submatrices of larger arrays.
The argument descriptions refer to row-major matrices only for the sake of convenience. This function is equally applicable to column-major matrices, just replace all instances of "row" with "column" and vice versa.
Input_ | Input type. |
Output_ | Output type. |
[in] | input | Pointer to an array containing a row-major matrix with nrow rows and ncol columns. The array should have at least nrow * ncol addressable elements, and all elements should be stored contiguously in the array. |
nrow | Number of rows in the matrix stored at input . | |
ncol | Number of columns in the matrix stored at input . | |
[out] | output | Pointer to an array of length nrow * ncol . On output, this will hold the transpose of the matrix represented by input , i.e., a row-major matrix with ncol rows and nrow columns. It is assumed that output does not alias input . |
This function is intended for developers of Matrix
subclasses who need to do some transposition, e.g., for dense chunks during caching. Users should instead construct a DelayedTranspose
object to perform a memory-efficient delayed transposition, or use convert_to_dense()
to convert their dense data into the desired storage layout.
The argument descriptions refer to row-major matrices only for the sake of convenience. This function is equally applicable to column-major matrices, just replace all instances of "row" with "column" and vice versa.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
|
inline |
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
.
|
inline |
operation
in a DelayedBinaryIsometricOperation
. std::shared_ptr< Matrix< OutputValue_, Index_ > > tatami::make_DelayedBinaryIsometricOperation | ( | std::shared_ptr< const Matrix< InputValue_, Index_ > > | left, |
std::shared_ptr< const Matrix< InputValue_, Index_ > > | right, | ||
Operation_ | op | ||
) |
A make_*
helper function to enable partial template deduction of supplied types.
OutputValue_ | Type of the result of the operation. |
InputValue_ | Type of the value of the input matrices. |
Index_ | Type of index value. |
Operation_ | Helper class defining the operation. |
left | Pointer to a (possibly const ) Matrix . |
right | Pointer to a (possibly const ) Matrix . |
op | Instance of the operation helper class. |
DelayedBinaryIsometricOperation
clas. DelayedUnaryIsometricArithmeticScalar< ArithmeticOperation::ADD, true, InputValue_, Scalar_ > tatami::make_DelayedUnaryIsometricAddScalar | ( | Scalar_ | scalar | ) |
InputValue_ | Type of the matrix value to use in the operation. |
Scalar_ | Type of the scalar. |
scalar | Scalar value to be added. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticScalar< ArithmeticOperation::SUBTRACT, right_, InputValue_, Scalar_ > tatami::make_DelayedUnaryIsometricSubtractScalar | ( | Scalar_ | scalar | ) |
right_ | Whether the scalar should be on the right hand side of the subtraction. |
InputValue_ | Type of the matrix value to use in the operation. |
Scalar_ | Type of the scalar. |
scalar | Scalar value to be subtracted. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticScalar< ArithmeticOperation::MULTIPLY, true, InputValue_, Scalar_ > tatami::make_DelayedUnaryIsometricMultiplyScalar | ( | Scalar_ | scalar | ) |
InputValue_ | Type of the matrix value to use in the operation. |
Scalar_ | Type of the scalar. |
scalar | Scalar value to be multiplied. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticScalar< ArithmeticOperation::DIVIDE, right_, InputValue_, Scalar_ > tatami::make_DelayedUnaryIsometricDivideScalar | ( | Scalar_ | scalar | ) |
right_ | Whether the scalar should be on the right hand side of the division. |
InputValue_ | Type of the matrix value to use in the operation. |
Scalar_ | Type of the scalar. |
scalar | Scalar value to be divided. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticScalar< ArithmeticOperation::POWER, right_, InputValue_, Scalar_ > tatami::make_DelayedUnaryIsometricPowerScalar | ( | Scalar_ | scalar | ) |
right_ | Whether the scalar should be on the right hand side of the power transformation. |
InputValue_ | Type of the matrix value to use in the operation. |
Scalar_ | Type of the scalar. |
scalar | Scalar value to be power transformed. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticScalar< ArithmeticOperation::MODULO, right_, InputValue_, Scalar_ > tatami::make_DelayedUnaryIsometricModuloScalar | ( | Scalar_ | scalar | ) |
right_ | Whether the scalar should be on the right hand side of the modulus. |
InputValue_ | Type of the matrix value to use in the operation. |
Scalar_ | Type of the scalar. |
scalar | Scalar value to be modulo transformed. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticScalar< ArithmeticOperation::INTEGER_DIVIDE, right_, InputValue_, Scalar_ > tatami::make_DelayedUnaryIsometricIntegerDivideScalar | ( | Scalar_ | scalar | ) |
right_ | Whether the scalar should be on the right hand side of the integer division. |
InputValue_ | Type of the matrix value to use in the operation. |
Scalar_ | Type of the scalar. |
scalar | Scalar value to be integer divided. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticVector< ArithmeticOperation::ADD, true, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricAddVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector to be added to the rows/columns. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricArithmeticVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticVector< ArithmeticOperation::SUBTRACT, right_, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricSubtractVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
right_ | Whether the scalar should be on the right hand side of the subtraction. |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector to subtract from (or be subtracted by) the rows/columns. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricArithmeticVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticVector< ArithmeticOperation::MULTIPLY, true, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricMultiplyVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector to multiply the rows/columns. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricArithmeticVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticVector< ArithmeticOperation::DIVIDE, right_, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricDivideVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
right_ | Whether the scalar should be on the right hand side of the division. |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector to divide (or be divided by) the rows/columns. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricArithmeticVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticVector< ArithmeticOperation::POWER, right_, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricPowerVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
right_ | Whether the scalar should be on the right hand side of the power transformation. |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector to use in the power transformation of the rows/columns. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricArithmeticVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticVector< ArithmeticOperation::MODULO, right_, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricModuloVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
right_ | Whether the scalar should be on the right hand side of the modulus. |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector to use in the modulus of the rows/columns. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricArithmeticVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricArithmeticVector< ArithmeticOperation::INTEGER_DIVIDE, right_, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricIntegerDivideVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
right_ | Whether the scalar should be on the right hand side of the integer division. |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector to integer divide (or be integer divided by) the rows/columns. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricArithmeticVector . |
operation
in a DelayedUnaryIsometricOperation
.
|
inline |
operation
in a DelayedUnaryIsometricOperation
.
|
inline |
scalar | Scalar value to use in the operation. |
operation
in a DelayedUnaryIsometricOperation
.
|
inline |
scalar | Scalar value to use in the operation. |
operation
in a DelayedUnaryIsometricOperation
.
|
inline |
scalar | Scalar value to be used in the operation. |
operation
in a DelayedUnaryIsometricOperation
.
|
inline |
scalar | Scalar value to be used in the operation. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricBooleanVector< BooleanOperation::AND, Vector_ > tatami::make_DelayedUnaryIsometricBooleanAndVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
Vector_ | Type of the vector. |
vector | Vector of values to be used in the operation. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricBooleanVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricBooleanVector< BooleanOperation::OR, Vector_ > tatami::make_DelayedUnaryIsometricBooleanOrVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
Vector_ | Type of the vector. |
vector | Vector of values to be used in the operation. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricBooleanVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricBooleanVector< BooleanOperation::XOR, Vector_ > tatami::make_DelayedUnaryIsometricBooleanXorVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
Vector_ | Type of the vector. |
vector | Vector of values to be used in the operation. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricBooleanVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricBooleanVector< BooleanOperation::EQUAL, Vector_ > tatami::make_DelayedUnaryIsometricBooleanEqualVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
Vector_ | Type of the vector. |
vector | Vector of values to be used in the operation. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricBooleanVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareScalar< CompareOperation::EQUAL, InputValue_ > tatami::make_DelayedUnaryIsometricEqualScalar | ( | InputValue_ | scalar | ) |
InputValue_ | Type of the matrix value to use in the operation. |
scalar | Value to be compared. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareScalar< CompareOperation::GREATER_THAN, InputValue_ > tatami::make_DelayedUnaryIsometricGreaterThanScalar | ( | InputValue_ | scalar | ) |
InputValue_ | Type of the matrix value to use in the operation. |
scalar | Scalar value to be compared. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareScalar< CompareOperation::LESS_THAN, InputValue_ > tatami::make_DelayedUnaryIsometricLessThanScalar | ( | InputValue_ | scalar | ) |
InputValue_ | Type of the matrix value to use in the operation. |
scalar | Scalar value to be compared. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareScalar< CompareOperation::GREATER_THAN_OR_EQUAL, InputValue_ > tatami::make_DelayedUnaryIsometricGreaterThanOrEqualScalar | ( | InputValue_ | scalar | ) |
InputValue_ | Type of the matrix value to use in the operation. |
scalar | Scalar value to be compared. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareScalar< CompareOperation::LESS_THAN_OR_EQUAL, InputValue_ > tatami::make_DelayedUnaryIsometricLessThanOrEqualScalar | ( | InputValue_ | scalar | ) |
InputValue_ | Type of the matrix value to use in the operation. |
scalar | Scalar value to be compared. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareScalar< CompareOperation::NOT_EQUAL, InputValue_ > tatami::make_DelayedUnaryIsometricNotEqualScalar | ( | InputValue_ | scalar | ) |
InputValue_ | Type of the matrix value to use in the operation. |
scalar | Scalar value to be compared. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareVector< CompareOperation::EQUAL, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricEqualVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector of values to be compared. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricCompareVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareVector< CompareOperation::GREATER_THAN, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricGreaterThanVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector of values to be compared. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricCompareVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareVector< CompareOperation::LESS_THAN, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricLessThanVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector of values to be compared. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricCompareVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareVector< CompareOperation::GREATER_THAN_OR_EQUAL, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricGreaterThanOrEqualVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector of values to be compared. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricCompareVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareVector< CompareOperation::LESS_THAN_OR_EQUAL, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricLessThanOrEqualVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector of values to be compared. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricCompareVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricCompareVector< CompareOperation::NOT_EQUAL, InputValue_, Vector_ > tatami::make_DelayedUnaryIsometricNotEqualVector | ( | Vector_ | vector, |
bool | by_row | ||
) |
InputValue_ | Type of the matrix value to use in the operation. |
Vector_ | Type of the vector. |
vector | Vector of values to be compared. |
by_row | Whether each element of vector corresponds to a row, see DelayedUnaryIsometricCompareVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSpecialCompare< SpecialCompareOperation::ISNAN, pass_, InputValue_ > tatami::make_DelayedUnaryIsometricIsnan | ( | ) |
pass_ | Whether to return truthy if the matrix value is NaN. |
InputValue_ | Type of the matrix value to use in the operation. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSpecialCompare< SpecialCompareOperation::ISINF, pass_, InputValue_ > tatami::make_DelayedUnaryIsometricIsinf | ( | ) |
pass_ | Whether to return truthy if the matrix value is infinite. |
InputValue_ | Type of the matrix value to use in the operation. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSpecialCompare< SpecialCompareOperation::ISFINITE, pass_, InputValue_ > tatami::make_DelayedUnaryIsometricIsfinite | ( | ) |
pass_ | Whether to return truthy if the matrix value is finite. |
InputValue_ | Type of the matrix value to use in the operation. |
operation
in a DelayedUnaryIsometricOperation
. std::shared_ptr< Matrix< OutputValue_, Index_ > > tatami::make_DelayedUnaryIsometricOperation | ( | std::shared_ptr< const Matrix< InputValue_, Index_ > > | matrix, |
Operation_ | operation | ||
) |
A make_*
helper function to enable partial template deduction of supplied types.
OutputValue_ | Type of matrix value after the operation. |
InputValue_ | Type of matrix value before the operation. |
Index_ | Type of index value. |
Operation_ | Helper class implementing the operation. |
matrix | Pointer to a (possibly const ) Matrix . |
operation | Instance of the operation helper class. |
DelayedUnaryIsometricOperation
class. DelayedUnaryIsometricSubstituteScalar< CompareOperation::EQUAL, Value_ > tatami::make_DelayedUnaryIsometricSubstituteEqualScalar | ( | Value_ | compared, |
Value_ | substitute | ||
) |
Value_ | Type of the matrix value. |
compared | Scalar to be compared to the matrix values. |
substitute | Scalar to substitute into the matrix when the comparison is true. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteScalar< CompareOperation::GREATER_THAN, Value_ > tatami::make_DelayedUnaryIsometricSubstituteGreaterThanScalar | ( | Value_ | compared, |
Value_ | substitute | ||
) |
Value_ | Type of the matrix value. |
compared | Scalar to be compared to the matrix values. |
substitute | Scalar value to substitute into the matrix when the comparison is true. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteScalar< CompareOperation::LESS_THAN, Value_ > tatami::make_DelayedUnaryIsometricSubstituteLessThanScalar | ( | Value_ | compared, |
Value_ | substitute | ||
) |
Value_ | Type of the matrix value. |
compared | Scalar to be compared to the matrix values. |
substitute | Scalar value to substitute into the matrix when the comparison is true. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteScalar< CompareOperation::GREATER_THAN_OR_EQUAL, Value_ > tatami::make_DelayedUnaryIsometricSubstituteGreaterThanOrEqualScalar | ( | Value_ | compared, |
Value_ | substitute | ||
) |
Value_ | Type of the matrix value. |
compared | Scalar to be compared to the matrix values. |
substitute | Scalar value to substitute into the matrix when the comparison is true. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteScalar< CompareOperation::LESS_THAN_OR_EQUAL, Value_ > tatami::make_DelayedUnaryIsometricSubstituteLessThanOrEqualScalar | ( | Value_ | compared, |
Value_ | substitute | ||
) |
Value_ | Type of the matrix value. |
compared | Scalar to be compared to the matrix values. |
substitute | Scalar to substitute into the matrix when the comparison is true. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteScalar< CompareOperation::NOT_EQUAL, Value_ > tatami::make_DelayedUnaryIsometricSubstituteNotEqualScalar | ( | Value_ | compared, |
Value_ | substitute | ||
) |
Value_ | Type of the matrix value. |
compared | Scalar to be compared to the matrix values. |
substitute | Scalar value to substitute into the matrix when the comparison is true. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteVector< CompareOperation::EQUAL, Value_, Vector_ > tatami::make_DelayedUnaryIsometricSubstituteEqualVector | ( | Vector_ | compared, |
Vector_ | substitute, | ||
bool | by_row | ||
) |
Value_ | Type of the matrix value. |
Vector_ | Type of the vector. |
compared | Vector to be compared to the matrix values. |
substitute | Vector containing values to substitute into the matrix when the comparison is true. |
by_row | Whether each element of compared and substitute corresponds to a row, see DelayedUnaryIsometricSubstituteVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteVector< CompareOperation::GREATER_THAN, Value_, Vector_ > tatami::make_DelayedUnaryIsometricSubstituteGreaterThanVector | ( | Vector_ | compared, |
Vector_ | substitute, | ||
bool | by_row | ||
) |
Value_ | Type of the matrix value. |
Vector_ | Type of the vector. |
compared | Vector to be compared to the matrix values. |
substitute | Vector containing values to substitute into the matrix when the comparison is true. |
by_row | Whether each element of compared and substitute corresponds to a row, see DelayedUnaryIsometricSubstituteVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteVector< CompareOperation::LESS_THAN, Value_, Vector_ > tatami::make_DelayedUnaryIsometricSubstituteLessThanVector | ( | Vector_ | compared, |
Vector_ | substitute, | ||
bool | by_row | ||
) |
Value_ | Type of the matrix value. |
Vector_ | Type of the vector. |
compared | Vector to be compared to the matrix values. |
substitute | Vector containing values to substitute into the matrix when the comparison is true. |
by_row | Whether each element of compared and substitute corresponds to a row, see DelayedUnaryIsometricSubstituteVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteVector< CompareOperation::GREATER_THAN_OR_EQUAL, Value_, Vector_ > tatami::make_DelayedUnaryIsometricSubstituteGreaterThanOrEqualVector | ( | Vector_ | compared, |
Vector_ | substitute, | ||
bool | by_row | ||
) |
Value_ | Type of the matrix value. |
Vector_ | Type of the vector. |
compared | Vector to be compared to the matrix values. |
substitute | Vector containing values to substitute into the matrix when the comparison is true. |
by_row | Whether each element of compared and substitute corresponds to a row, see DelayedUnaryIsometricSubstituteVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteVector< CompareOperation::LESS_THAN_OR_EQUAL, Value_, Vector_ > tatami::make_DelayedUnaryIsometricSubstituteLessThanOrEqualVector | ( | Vector_ | compared, |
Vector_ | substitute, | ||
bool | by_row | ||
) |
Value_ | Type of the matrix value. |
Vector_ | Type of the vector. |
compared | Vector to be compared to the matrix values. |
substitute | Vector containing values to substitute into the matrix when the comparison is true. |
by_row | Whether each element of compared and substitute corresponds to a row, see DelayedUnaryIsometricSubstituteVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSubstituteVector< CompareOperation::NOT_EQUAL, Value_, Vector_ > tatami::make_DelayedUnaryIsometricSubstituteNotEqualVector | ( | Vector_ | compared, |
Vector_ | substitute, | ||
bool | by_row | ||
) |
Value_ | Type of the matrix value. |
Vector_ | Type of the vector. |
compared | Vector to be compared to the matrix values. |
substitute | Vector containing values to substitute into the matrix when the comparison is true. |
by_row | Whether each element of compared and substitute corresponds to a row, see DelayedUnaryIsometricSubstituteVector . |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSpecialSubstitute< SpecialCompareOperation::ISNAN, pass_, Value_ > tatami::make_DelayedUnaryIsometricSubstituteIsnan | ( | Value_ | substitute | ) |
pass_ | Whether to perform the substitution if the matrix value is NaN. If false, the substitution is performed if the matrix value is not NaN. |
Value_ | Type of the matrix value. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSpecialSubstitute< SpecialCompareOperation::ISINF, pass_, Value_ > tatami::make_DelayedUnaryIsometricSubstituteIsinf | ( | Value_ | substitute | ) |
pass_ | Whether to return truthy if the matrix value is infinite. If false, the substitution is performed if the matrix value is not infinite. |
Value_ | Type of the matrix value. |
operation
in a DelayedUnaryIsometricOperation
. DelayedUnaryIsometricSpecialSubstitute< SpecialCompareOperation::ISFINITE, pass_, Value_ > tatami::make_DelayedUnaryIsometricSubstituteIsfinite | ( | Value_ | substitute | ) |
pass_ | Whether to return truthy if the matrix value is finite. If false, the substitution is performed if the matrix value is not finite. |
Value_ | Type of the matrix value. |
operation
in a DelayedUnaryIsometricOperation
. std::shared_ptr< Matrix< Value_, Index_ > > tatami::make_DelayedBind | ( | std::vector< std::shared_ptr< const Matrix< Value_, Index_ > > > | matrices, |
bool | row | ||
) |
A make_*
helper function to enable partial template deduction of supplied types.
Value_ | Type of matrix value. |
Index_ | Type of index value. |
matrices | Pointers to Matrix objects. |
row | Whether to combine matrices by the rows (i.e., the output matrix has number of rows equal to the sum of the number of rows in matrices ). If false, combining is applied by the columns. |
DelayedBind
instance. std::shared_ptr< Matrix< ValueOut_, IndexOut_ > > tatami::make_DelayedCast | ( | std::shared_ptr< const Matrix< ValueIn_, IndexIn_ > > | p | ) |
Recast a Matrix
to a different interface type.
ValueOut_ | Data type to cast to. |
IndexOut_ | Index type to cast to. |
ValueIn_ | Data type to cast from. |
IndexIn_ | Index type to cast from. |
p | Pointer to the (possbly const ) Matrix instance to cast from. |
Matrix
instance of the desired interface type. std::shared_ptr< Matrix< Value_, Index_ > > tatami::make_DelayedTranspose | ( | std::shared_ptr< const Matrix< Value_, Index_ > > | matrix | ) |
A make_*
helper function to enable partial template deduction of supplied types during delayed transposition.
Value_ | Type of matrix value. |
Index_ | Type of index value. |
matrix | Pointer to a (possibly const ) Matrix instance. |
DelayedTranspose
instance. std::vector< size_t > tatami::compress_sparse_triplets | ( | size_t | nrow, |
size_t | ncol, | ||
Values_ & | values, | ||
RowIndices_ & | row_indices, | ||
ColumnIndices_ & | column_indices, | ||
bool | csr | ||
) |
Values_ | Random-access container for the values. |
RowIndices_ | Random access container for the row indices. |
ColumnIndices_ | Random access container for the column indices. |
nrow | Number of rows. |
ncol | Number of columns. |
row_indices | Row indices of the structural non-zeros. Values must be non-negative integers less than nrow . |
column_indices | Column indices of the structural non-zeros. This must be of the same length as row_indices , where corresponding entries contain data for a single structural non-zero. Values must be non-negative integers less than ncol . |
values | Values of the structural non-zeros. This must be of the same length as row_indices and column_indices , where corresponding entries contain data for a single structural non-zero. |
csr | Whether to create a compressed sparse row format. If false , the compressed sparse column format is used instead. |
row_indices
, column_indices
and values
are sorted in-place by the row and column indices (if csr = true
) or by the column and row indices (if csr = false
). A vector of index pointers is returned with length nrow + 1
(if csr = true
) or ncol + 1
(if csr = false
). void tatami::count_compressed_sparse_non_zeros | ( | const tatami::Matrix< Value_, Index_ > * | matrix, |
bool | row, | ||
Count_ * | output, | ||
int | threads | ||
) |
Value_ | Type of value in the matrix. |
Index_ | Integer type of row/column index. |
Count_ | Integer type for the non-zero count. |
matrix | Pointer to a tatami::Matrix . | |
row | Whether to count structural non-zeros by row. | |
[out] | output | Pointer to an array of length equal to the number of rows (if row = true ) or columns (otherwise) of matrix . On output, this stores the number of structural non-zeros in each row (if row = true ) or column (otherwise). |
threads | Number of threads to use, for parallelization with parallelize() . |
For sparse matrix
, all structural non-zero elements are reported, even if they have actual values of zero. In contrast, for dense matrix
, only the non-zero values are counted; these are considered to be structural non-zeros upon conversion to a sparse matrix (e.g., in fill_compressed_sparse_contents()
).
void tatami::fill_compressed_sparse_contents | ( | const tatami::Matrix< InputValue_, InputIndex_ > * | matrix, |
bool | row, | ||
const Pointer_ * | pointers, | ||
StoredValue_ * | output_value, | ||
StoredIndex_ * | output_index, | ||
int | threads | ||
) |
StoredValue_ | Type of data values to be stored in the output. |
StoredIndex_ | Integer type for storing the indices in the output. |
Pointer_ | Integer type for the row/column pointers. |
InputValue_ | Type of data values in the input interface. |
InputIndex_ | Integer type for indices in the input interface. |
matrix | Pointer to a tatami::Matrix . | |
row | Whether to fill output_value and output_index by row, i.e., the output represents a compressed sparse row matrix. | |
[in] | pointers | Pointer to an array of length greater than or equal to the number of rows (if row = true ) or columns (otherwise) of matrix . Each entry contains the position of the start of each row/column in output_value and output_index . This argument is equivalent to the array of pointers for the compressed sparse format (e.g., CompressedSparseContents::pointers ), and can be obtained by taking the cumulative sum of the per-row/column counts from count_compressed_sparse_non_zeros() . |
[out] | output_value | Pointer to an array of length equal to the total number of structural non-zero elements. On output, this is used to store the values of those elements in a compressed sparse format (e.g., CompressedSparseContents::value ). |
[out] | output_index | Pointer to an array of length equal to the total number of structural non-zero elements. On output, this is used to store the row/column indices of those elements in a compressed sparse format (e.g., CompressedSparseContents::index ). |
threads | Number of threads to use, for parallelization with parallelize() . |
CompressedSparseContents< StoredValue_, StoredIndex_, StoredPointer_ > tatami::retrieve_compressed_sparse_contents | ( | const Matrix< InputValue_, InputIndex_ > * | matrix, |
bool | row, | ||
bool | two_pass, | ||
int | threads = 1 |
||
) |
StoredValue_ | Type of data values to be stored in the output. |
StoredIndex_ | Integer type for storing the row/column indices in the output. |
Pointer_ | Integer type for the row/column pointers in the output. |
InputValue_ | Type of data values in the input interface. |
InputIndex_ | Integer type for indices in the input interface. |
matrix | Pointer to a tatami::Matrix . |
row | Whether to retrieve the contents of matrix by row, i.e., the output is a compressed sparse row matrix. |
two_pass | Whether to perform the retrieval in two passes. This requires another pass through matrix but is more memory-efficient. |
threads | Number of threads to use, for parallelization with parallelize() . |
CompressedSparseContents
.The behavior of this function can be replicated by manually calling count_compressed_sparse_non_zeros()
followed by fill_compressed_sparse_contents()
. This may be desirable for users who want to put the compressed sparse contents into pre-existing memory allocations.
std::shared_ptr< Matrix< Value_, Index_ > > tatami::convert_to_compressed_sparse | ( | const Matrix< InputValue_, InputIndex_ > * | matrix, |
bool | row, | ||
bool | two_pass = false , |
||
int | threads = 1 |
||
) |
Value_ | Type of data values in the output interface. |
Index_ | Integer type for the indices in the output interface. |
StoredValue_ | Type of data values to be stored in the output. |
StoredIndex_ | Integer type for storing the indices in the output. |
InputValue_ | Type of data values in the input interface. |
InputIndex_ | Integer type for indices in the input interface. |
matrix | Pointer to a tatami::Matrix , possibly containing delayed operations. |
row | Whether to return a compressed sparse row matrix. |
two_pass | Whether to use a two-pass strategy that reduces peak memory usage at the cost of speed. |
threads | Number of threads to use, for parallelization with parallelize() . |
tatami::CompressedSparseMatrix
, with the same dimensions and type as the matrix referenced by matrix
. If row = true
, the matrix is in compressed sparse row format, otherwise it is compressed sparse column. FragmentedSparseContents< StoredValue_, StoredIndex_ > tatami::retrieve_fragmented_sparse_contents | ( | const Matrix< InputValue_, InputIndex_ > * | matrix, |
bool | row, | ||
int | threads = 1 |
||
) |
StoredValue_ | Type of data values to be stored in the output. |
StoredIndex_ | Integer type for storing the indices in the output. |
InputValue_ | Type of data values in the input interface. |
InputIndex_ | Integer type for indices in the input interface. |
matrix | Pointer to a tatami::Matrix . |
row | Whether to retrieve the contents of matrix by row, i.e., the output is a fragmented sparse row matrix. |
threads | Number of threads to use, for parallelization with parallelize() . |
FragmentedSparseContents
. std::shared_ptr< Matrix< Value_, Index_ > > tatami::convert_to_fragmented_sparse | ( | const Matrix< InputValue_, InputIndex_ > * | matrix, |
bool | row, | ||
int | threads = 1 |
||
) |
Value_ | Type of data values in the output interface. |
Index_ | Integer type for the indices in the output interface. |
StoredValue_ | Type of data values to be stored in the output. |
StoredIndex_ | Integer type for storing the indices in the output. |
InputValue_ | Type of data values in the input interface. |
InputIndex_ | Integer type for indices in the input interface. |
matrix | Pointer to a tatami::Matrix , possibly containing delayed operations. |
row | Whether to return a fragmented sparse row matrix. |
threads | Number of threads to use, for parallelization with parallelize() . |
tatami::FragmentedSparseMatrix
, with the same dimensions and type as the matrix referenced by matrix
. If row = true
, the matrix is in fragmented sparse row format, otherwise it is fragmented sparse column. std::shared_ptr< Matrix< Value_, Index_ > > tatami::make_DelayedSubsetBlock | ( | std::shared_ptr< const Matrix< Value_, Index_ > > | matrix, |
Index_ | subset_start, | ||
Index_ | subset_length, | ||
bool | by_row | ||
) |
A make_*
helper function to enable partial template deduction of supplied types.
Value_ | Type of matrix value. |
Index_ | Integer type for the row/column indices. |
matrix | Pointer to the underlying (pre-subset) Matrix . |
subset_start | Index of the start of the block. This should be a row index if by_row = true and a column index otherwise. |
subset_length | Index of the one-past-the-end of the block. |
by_row | Whether to apply the subset to the rows. If false, the subset is applied to the columns. |
DelayedSubsetBlock
instance. std::shared_ptr< Matrix< Value_, Index_ > > tatami::make_DelayedSubset | ( | std::shared_ptr< const Matrix< Value_, Index_ > > | matrix, |
SubsetStorage_ | subset, | ||
bool | by_row | ||
) |
A make_*
helper function to enable partial template deduction of supplied types. This will automatically dispatch to DelayedSubsetSortedUnique
, DelayedSubsetUnique
, DelayedSubsetSorted
or DelayedSubset
, depending on the values in subset
.
Value_ | Type of matrix value. |
Index_ | Integer type of the row/column indices. |
SubsetStorage_ | Vector containing the subset indices, to be automatically deduced. Any class implementing [ , size() , begin() and end() can be used here. |
matrix | Pointer to a (possibly const ) Matrix . |
subset | Instance of the subset index vector. |
by_row | Whether to apply the subset to the rows. If false, the subset is applied to the columns. |
DelayedSubset
instance. auto tatami::consecutive_extractor | ( | const Matrix< Value_, Index_ > * | mat, |
bool | row, | ||
Index_ | iter_start, | ||
Index_ | iter_length, | ||
Args_ &&... | args | ||
) |
This function creates an extractor object with a ConsecutiveOracle
instance spanning a range of rows or columns. Matrix
implementations that are oracle-aware can then perform pre-fetching of future accesses for greater performance.
sparse_ | Whether to perform sparse retrieval. |
Value_ | Type of the matrix value. |
Index_ | Type of the row/column index. |
Args_ | Types of further arguments to pass to Matrix::dense_row or Matrix::dense_column . |
mat | Matrix to iterate over. |
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
iter_start | Index of the first row (if row = true ) or column (otherwise) of the iteration range. |
iter_length | Number of rows (if row = true ) or columns (otherwise) in the iteration range. |
args | Further arguments to pass to new_extractor() . |
[iter_start, iter_start + iter_length)
. This may be either an OracularDenseExtractor
or OracularSparseExtractor
depending on sparse_
. Value_ | Type of value being copied. |
Size_ | Type for the array length. |
[in] | input | Pointer to a source array of size n . |
n | Length of the array. | |
[out] | output | Pointer to a destination array of size n . |
input
to output
, and output
is returned. This is a no-op if input == output
. auto tatami::new_extractor | ( | const Matrix< Value_, Index_ > * | ptr, |
bool | row, | ||
MaybeOracle< oracle_, Index_ > | oracle, | ||
Args_ &&... | args | ||
) |
This utility makes it easier for developers to write a single templated function that works with and without oracles. A boolean placeholder should be provided as the "oracle" in the myopic extractor case.
sparse_ | Whether to perform sparse retrieval. |
oracle_ | Whether an oracle should be supplied. |
Value_ | Data value type, should be numeric. |
Index_ | Row/column index type, should be integer. |
Args_ | Further arguments. |
[in] | ptr | Pointer to a Matrix object to iterate over. |
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. | |
oracle | Pointer to an oracle if oracle_ = true , otherwise a placeholder boolean that is ignored. | |
args | Zero or more additional arguments to pass to methods like Matrix::dense_row() . |
ptr
. This may be any of MyopicDenseExtractor
, MyopicSparseExtractor
, OracularDenseExtractor
or OracularSparseExtractor
, depending on sparse_
and oracle_
. Apply a function to a set of tasks in parallel, usually for iterating over a dimension of a Matrix
. By default, this uses subpar::parallelize_range()
internally, which uses OpenMP if available and <thread>
otherwise. Advanced users can override the default parallelization mechanism by defining a TATAMI_CUSTOM_PARALLEL
function-like macro. The macro should accept the fun
, tasks
and threads
arguments as described below.
parallel_ | Whether the tasks should be run in parallel. If false , no parallelization is performed and all tasks are run on the current thread. |
Function_ | Function to be applied for a contiguous range of tasks. This should accept three arguments:
|
Index_ | Integer type for the number of tasks. |
fun | Function that executes a contiguous range of tasks. |
tasks | Number of tasks. |
threads | Number of threads. |
Process runs of consecutive indices that are used in the index-aware dense_row()
, sparse_column()
, etc. methods. This provides some opportunities for optimization when the indices contain contiguous stretches. For example, third-party libraries can be asked to process blocks of observations rather than handling them one at a time.
Index_ | Integer type for the row/column indices. |
Function_ | Function to apply to each contiguous run. |
indices | Pointer to an array of sorted and unique indices for row/column elements. |
length | Length of the array pointed to by indices . |
fun | Function to apply to each contiguous run of indices. This should take two arguments - the start index of each run, and the length of the run. Calls to fun are guaranteed to contain increasing start indices with non-overlapping runs. The return value of this function is ignored. |
std::shared_ptr< const Matrix< Value_, Index_ > > tatami::wrap_shared_ptr | ( | const Matrix< Value_, Index_ > * | ptr | ) |
Wrap a raw pointer inside a shared_ptr
, typically to enable use of a raw tatami::Matrix
pointer with delayed operation wrappers. This enables use of delayed operations inside functions that accept a raw pointer to an externally owned tatami::Matrix
.
Value_ | Numeric type for the matrix value. |
Index_ | Integer type for the row/column indices. |
ptr | A pointer to a tatami::Matrix instance. |
ptr
. The assumption is that ptr
will always outlive the returned pointer.