transport_costmat {gridOT} | R Documentation |
Calculate the cost matrix for the optimal transport between two-dimensional grids with respect to the cost function
c(x, y) = | x_1 - y_1 |^{p_1} + | x_2 - y_2 |^{p_2}.
transport_costmat(x, ...)
## S3 method for class 'otgrid'
transport_costmat(x, y, p.1 = 2, p.2 = p.1, ...)
## S3 method for class 'otgridtransport'
transport_costmat(x, ...)
x |
an object of class |
... |
further arguments (currently unused). |
y |
an object of class |
p.1 |
the first power |
p.2 |
the second power |
a matrix giving the pairwise costs in column-mayor format.
x <- otgrid(cbind(0:1, 1:0))
y <- otgrid(cbind(1:0, 0:1))
transport_costmat(x, y, p.1 = 1, p.2 = 3)