Log sig functions#

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. If true, will also save these objects in a cache directory to be re-used for future runs.

Returns:

Status code (0 = success).

sig_to_log_sig#

int 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, bool scalar_term = true, 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, 1 or 2). 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 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, bool scalar_term = true, 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 batch_size, uint64_t dimension, uint64_t degree, bool time_aug, bool lead_lag, int method, bool scalar_term = true, int n_jobs = 1) noexcept#

Backpropagates derivatives through the sig_to_log_sig_f function.

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, 1 or 2). 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 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, bool scalar_term = true, int n_jobs = 1) noexcept#

log_sig_combine#

int log_sig_combine_f(const float *log_sig1, const float *log_sig2, float *out, uint64_t batch_size, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#
int log_sig_combine_d(const double *log_sig1, const double *log_sig2, double *out, uint64_t batch_size, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#

log_sig_combine_backprop#

int log_sig_combine_backprop_f(const float *d_out, float *d_ls1, float *d_ls2, const float *ls1, const float *ls2, uint64_t batch_size, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#
int log_sig_combine_backprop_d(const double *d_out, double *d_ls1, double *d_ls2, const double *ls1, const double *ls2, uint64_t batch_size, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#

log_sig_join#

int log_sig_join_f(const float *log_sig, const float *displacement, float *out, uint64_t batch_size, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#
int log_sig_join_d(const double *log_sig, const double *displacement, double *out, uint64_t batch_size, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#

log_sig_join_backprop#

int log_sig_join_backprop_f(const float *d_out, float *d_logsig, float *d_displacement, const float *log_sig, const float *displacement, uint64_t batch_size, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#
int log_sig_join_backprop_d(const double *d_out, double *d_logsig, double *d_displacement, const double *log_sig, const double *displacement, uint64_t batch_size, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#

log_sig_from_path#

int log_sig_from_path_f(const float *path, float *out, uint64_t batch_size, uint64_t length, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#
int log_sig_from_path_d(const double *path, double *out, uint64_t batch_size, uint64_t length, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#
int log_sig_from_path_backprop_f(const float *d_out, float *d_path, const float *path, uint64_t batch_size, uint64_t length, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#
int log_sig_from_path_backprop_d(const double *d_out, double *d_path, const double *path, uint64_t batch_size, uint64_t length, uint64_t dimension, uint64_t degree, int n_jobs = 1) noexcept#

logsig_to_sig#

int logsig_to_sig_f(const float *log_sig, float *out, uint64_t batch_size, uint64_t dimension, uint64_t degree, bool time_aug = false, bool lead_lag = false, int method = 0, bool scalar_term = true, int n_jobs = 1) noexcept#
int logsig_to_sig_d(const double *log_sig, double *out, uint64_t batch_size, uint64_t dimension, uint64_t degree, bool time_aug = false, bool lead_lag = false, int method = 0, bool scalar_term = true, int n_jobs = 1) noexcept#
int logsig_to_sig_backprop_f(const float *log_sig, float *out, const float *sig_derivs, uint64_t batch_size, uint64_t dimension, uint64_t degree, bool time_aug = false, bool lead_lag = false, int method = 0, bool scalar_term = true, int n_jobs = 1) noexcept#
int logsig_to_sig_backprop_d(const double *log_sig, double *out, const double *sig_derivs, uint64_t batch_size, uint64_t dimension, uint64_t degree, bool time_aug = false, bool lead_lag = false, int method = 0, bool scalar_term = true, int n_jobs = 1) 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}
}