---
title: "Computation of the Gradients"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Computation of the Gradients}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(rwig) |> suppressPackageStartupMessages()
```

To set up the computation for the `sinkhorn()` and `barycenter()` algorithms,
you will need to set `with_grad = TRUE` for 
`sinkhorn_control` and `barycenter_control`.

The exact formulae of gradients were given by Xie (2025),
and have been checked by the Automatic Differentiation library 
`ForwardDiff` in Julia.

## See Also

See also `vignette("sinkhorn")`, `vignette("barycenter")`.

## References

Xie, F. (2025). 
Deriving the Gradients of Some Popular Optimal Transport Algorithms (No. arXiv:2504.08722). *arXiv*. 
https://doi.org/10.48550/arXiv.2504.08722
