tatami bindings for arbitrary Python matrices.
More...
|
| template<class Function_ , class Index_ > |
| void | parallelize (const Function_ fun, const Index_ tasks, int threads) |
| |
| template<typename Function_ > |
| void | lock (Function_ fun) |
| |
| template<typename Value_ , typename Index_ , class Function_ > |
| void | parse_Sparse2darray (const pybind11::object &matrix, Value_ *const vbuffer, Index_ *const ibuffer, Function_ fun) |
| |
tatami bindings for arbitrary Python matrices.
◆ lock()
template<typename Function_ >
| void tatami_python::lock |
( |
Function_ | fun | ) |
|
This function is only available if TATAMI_PYTHON_PARALLELIZE_UNKNOWN is defined. Applications can override this by defining a TATAMI_PYTHON_SERIALIZE function-like macro, which should accept a function object and execute it in some serial context.
- Template Parameters
-
| Function_ | Function that accepts no arguments. |
- Parameters
-
| fun | Function to be evaluated after the GIL is acquired. This typically involves calls to the Python interpreter or API. |
◆ parallelize()
template<class Function_ , class Index_ >
| void tatami_python::parallelize |
( |
const Function_ | fun, |
|
|
const Index_ | tasks, |
|
|
int | threads ) |
Replacement for tatami::parallelize() that applies a function to a set of tasks in parallel, usually for iterating over a dimension of a Matrix. This releases the Python GIL so that it can be re-acquired by UnknownMatrix extractors in each individual thread.
- Template Parameters
-
| Function_ | Function to be applied to a contiguous range of tasks. This should accept three arguments:
thread, the thread number executing this task range. This will be passed as an int.
task_start, the start index of the task range. This will be passed as an Index_.
task_length, the number of tasks in the task range. This will be passed as an Index_.
|
| Index_ | Integer type for the number of tasks. |
- Parameters
-
| fun | Function that executes a contiguous range of tasks. |
| tasks | Number of tasks. |
| threads | Number of threads. |
◆ parse_Sparse2darray()
template<typename Value_ , typename Index_ , class Function_ >
| void tatami_python::parse_Sparse2darray |
( |
const pybind11::object & | matrix, |
|
|
Value_ *const | vbuffer, |
|
|
Index_ *const | ibuffer, |
|
|
Function_ | fun ) |
Parse the contents of a 2-dimensional SparseNdArray from the delayedarray package.
- Template Parameters
-
| Value_ | Numeric type of the matrix value. |
| Index_ | Integer type of the matrix indices. |
| Function_ | Function to be applied at each leaf node. |
- Parameters
-
| matrix | The SparseNdarray object. |
| vbuffer | Pointer to an array of length greater than or equal to the number of rows of matrix, in which to store the values of the structural non-zero elements. This may also be NULL in which case no values are extracted. On input, the contents of the array are ignored by this function. |
| ibuffer | Pointer to an array of length greater than or equal to the number of rows of matrix, in which to store the indices of the structural non-zero elements. This may also be NULL in which case no values are extracted. On input, the contents of the array are ignored by this function. |
| fun | Function to apply to each leaf node, accepting two arguments:
c, an Index_ specifying the index of the leaf node, i.e., the column index.
n, an Index_ specifying the number of structural non-zero elements for c. The first n entries of vbuffer and ibuffer will be filled with the values and indices of these non-zero elements, respectively, if they are not NULL.
The return value of this function is ignored. Note that fun may not be called for all c - if leaf nodes do not contain any data, they will be skipped. |