Log sig functions#
set_cache_dir#
-
int set_cache_dir(const char *dir) noexcept#
Sets the cache directory to use in
prepare_log_sigwhenuse_disk=true. If the cache directory is unset, a default directory will be used. This function is not thread safe.- Parameters:
dir – Cache directory
- Returns:
Status code (0 = success).
prepare_log_sig#
-
int prepare_log_sig(uint64_t dimension, uint64_t degree, int method, bool use_disk = false) noexcept#
Prepares for log signature calculations. This function is not thread safe.
- Parameters:
dimension – Dimension of the underlying path.
degree – Truncation degree of the log signature.
method – Method to use for log signature calculation. Please see Python documentation for details.
use_disk – If
false, will cache prepared objects in memory only. Iftrue, will also save these objects in a cache directory to be re-used for future runs.
- Returns:
Status code (0 = success).
clear_cache#
-
int clear_cache(bool use_disk = false) noexcept#
Clear the log signature cache generated by
prepare_log_sig. This function is not thread safe.- Parameters:
use_disk – If
false, will clear the cache from memory only. Iftrue, will also clear the cache directory.- Returns:
Status code (0 = success).
sig_to_log_sig#
-
int sig_to_log_sig_f(const float *sig, float *out, uint64_t dimension, uint64_t degree, bool time_aug = false, bool lead_lag = false, int method = 0) noexcept#
Converts a signature to a log signature using the specified method.
- Parameters:
sig – Pointer to signature, size =
sig_length(dimension, degree).out – Pointer to output buffer (preallocated), size =
method ? log_sig_length(dimension, degree) : sig_length(dimension, degree).dimension – Dimension of the path.
degree – Truncation degree of the (log) signature.
time_aug – Whether time augmentation was used for the signature computation (default = false).
lead_lag – Whether the lead-lag transform was used for the signature computation (default = false).
method – The method to use for the log calculation (
0,1or2). Please see the Python documentation for details.
- Returns:
Status code (0 = success).
-
int sig_to_log_sig_d(const double *sig, double *out, uint64_t dimension, uint64_t degree, bool time_aug = false, bool lead_lag = false, int method = 0) noexcept#
batch_sig_to_log_sig#
-
int batch_sig_to_log_sig_f(const float *sig, float *out, uint64_t batch_size, uint64_t dimension, uint64_t degree, bool time_aug = false, bool lead_lag = false, int method = 0, int n_jobs = 1) noexcept#
Converts a batch of signatures to log signatures using the specified method.
- Parameters:
sig – Pointer to batch of signatures (row-major), size =
batch_size * sig_length(dimension, degree).out – Pointer to output buffer (preallocated), size =
batch_size * (method ? log_sig_length(dimension, degree) : sig_length(dimension, degree)).batch_size – Batch size.
dimension – Dimension of the paths.
degree – Truncation degree of the (log) signatures.
time_aug – Whether time augmentation was used for the signature computations (default = false).
lead_lag – Whether the lead-lag transform was used for the signature computations (default = false).
method – The method to use for the log calculation (
0,1or2). Please see the Python documentation for details.n_jobs – Number of threads to run in parallel. If n_jobs = 1, the computation is run serially. If set to -1, all available threads are used. For n_jobs below -1, (max_threads + 1 + n_jobs) threads are used. For example if n_jobs = -2, all threads but one are used (default = 1).
- Returns:
Status code (0 = success).
-
int batch_sig_to_log_sig_d(const double *sig, double *out, uint64_t batch_size, uint64_t dimension, uint64_t degree, bool time_aug = false, bool lead_lag = false, int method = 0, int n_jobs = 1) noexcept#
sig_to_log_sig_backprop#
-
int sig_to_log_sig_backprop_f(const float *sig, float *out, const float *log_sig_derivs, uint64_t dimension, uint64_t degree, bool time_aug, bool lead_lag, int method) noexcept#
Backpropagates derivatives through the
sig_to_log_sig_ffunction.- Parameters:
sig – Pointer to signature, size =
sig_length(dimension, degree).out – Pointer to output buffer (preallocated), size =
sig_length(dimension, degree).log_sig_derivs – Pointer to derivatives with respect to the log signature, size =
method ? log_sig_length(dimension, degree) : sig_length(dimension, degree).dimension – Dimension of the path.
degree – Truncation degree of the (log) signature.
time_aug – Whether time augmentation was used for the signature computation (default = false).
lead_lag – Whether the lead-lag transform was used for the signature computation (default = false).
method – The method used for the log calculation (
0,1or2). Please see the Python documentation for details.
- Returns:
Status code (0 = success).
-
int sig_to_log_sig_backprop_d(const double *sig, double *out, const double *log_sig_derivs, uint64_t dimension, uint64_t degree, bool time_aug, bool lead_lag, int method) noexcept#
batch_sig_to_log_sig_backprop#
-
int batch_sig_to_log_sig_backprop_f(const float *sig, float *out, const float *log_sig_derivs, uint64_t batch_size, uint64_t dimension, uint64_t degree, bool time_aug, bool lead_lag, int method, int n_jobs) noexcept#
Backpropagates derivatives through the
batch_sig_to_log_sig_ffunction.- Parameters:
sig – Pointer to batch of signatures (row-major), size =
batch_size * sig_length(dimension, degree).out – Pointer to output buffer (preallocated), size =
batch_size * sig_length(dimension, degree).log_sig_derivs – Pointer to derivatives with respect to the log signature, size =
batch_size * (method ? log_sig_length(dimension, degree) : sig_length(dimension, degree)).batch_size – Batch size.
dimension – Dimension of the paths.
degree – Truncation degree of the (log) signatures.
time_aug – Whether time augmentation was used for the signature computations (default = false).
lead_lag – Whether the lead-lag transform was used for the signature computations (default = false).
method – The method used for the log calculation (
0,1or2). Please see the Python documentation for details.n_jobs – Number of threads to run in parallel. If n_jobs = 1, the computation is run serially. If set to -1, all available threads are used. For n_jobs below -1, (max_threads + 1 + n_jobs) threads are used. For example if n_jobs = -2, all threads but one are used (default = 1).
- Returns:
Status code (0 = success).
-
int batch_sig_to_log_sig_backprop_d(const double *sig, double *out, const double *log_sig_derivs, uint64_t batch_size, uint64_t dimension, uint64_t degree, bool time_aug, bool lead_lag, int method, int n_jobs) noexcept#
Citation#
If you found this library useful in your research, please consider citing the paper:
@article{shmelev2025pysiglib,
title={pySigLib-Fast Signature-Based Computations on CPU and GPU},
author={Shmelev, Daniil and Salvi, Cristopher},
journal={arXiv preprint arXiv:2509.10613},
year={2025}
}