Skip to content

Commit

Permalink
version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdunipace authored and cran-robot committed Jan 17, 2024
1 parent 06f860e commit 2a00ec3
Show file tree
Hide file tree
Showing 35 changed files with 1,363 additions and 228 deletions.
51 changes: 41 additions & 10 deletions DESCRIPTION
@@ -1,25 +1,56 @@
Package: approxOT
Type: Package
Title: Approximate and Exact Optimal Transport Methods
Version: 1.0.2
Date: 2022-03-16
Version: 1.1
Date: 2024-01-15
Authors@R:
person("Eric", "Dunipace",
c(person("Eric", "Dunipace",
role = c("aut", "cre"),
email = "edunipace@mail.harvard.edu",
comment = c(ORCID = "0000-0001-8909-213X"))
Author: Eric Dunipace [aut, cre] (<https://orcid.org/0000-0001-8909-213X>)
comment = c(ORCID = "0000-0001-8909-213X")),
person(given = "Espen",
family = "Bernton",
role = c("ctb"),
comment = "'Hilbert Sort' adapted from their code"),
person(given = "Mathieu",
family = "Gerber",
role = c("ctb"),
comment = "'Hilbert Sort' adapted from their code"),
person(given = "Pierre",
family = "Jacob",
role = c("ctb"),
comment = "'Hilbert Sort' adapted from their code"),
person(given = "Dominic",
family = "Schuhmacher",
email = "dominic.schuhmacher@mathematik.uni-goettingen.de",
role = c("ctb"),
comment = "'Shortsimplex' optimal transport method adapted from their code"),
person(given = "Nicolas",
family = "Bonneel",
role = "ctb",
comment = "'network simplex' algorithm adapted from their code")
)
Maintainer: Eric Dunipace <edunipace@mail.harvard.edu>
Description: R and C++ functions to perform exact and
approximate optimal transport. All C++ methods are linkable
approximate optimal transport. All C++ methods can be linked
to other R packages via their header files.
License: GPL (>= 3.0)
License: GPL (== 3.0)
Imports: Rcpp (>= 1.0.3), stats
LinkingTo: Rcpp, RcppEigen, RcppCGAL, BH
BugReports: https://github.com/ericdunipace/approxOT/issues
Suggests: testthat (>= 2.1.0), transport
RoxygenNote: 7.1.1
Encoding: UTF-8
RoxygenNote: 7.2.3
URL: https://github.com/ericdunipace/approxOT
NeedsCompilation: yes
Packaged: 2022-03-17 02:43:34 UTC; eifer
Packaged: 2024-01-16 06:40:21 UTC; eifer
Author: Eric Dunipace [aut, cre] (<https://orcid.org/0000-0001-8909-213X>),
Espen Bernton [ctb] ('Hilbert Sort' adapted from their code),
Mathieu Gerber [ctb] ('Hilbert Sort' adapted from their code),
Pierre Jacob [ctb] ('Hilbert Sort' adapted from their code),
Dominic Schuhmacher [ctb] ('Shortsimplex' optimal transport method
adapted from their code),
Nicolas Bonneel [ctb] ('network simplex' algorithm adapted from their
code)
Repository: CRAN
Date/Publication: 2022-03-17 11:40:12 UTC
Date/Publication: 2024-01-16 11:50:02 UTC
60 changes: 33 additions & 27 deletions MD5
@@ -1,17 +1,17 @@
17dd4988b1c0c0176885aa3113f1ab4f *DESCRIPTION
9fbdc692ea6fbaca50a7af68505b86fa *NAMESPACE
6f99890dc04a2890d5e681cf2c38bebc *R/RcppExports.R
38f63ac108c704c098adb38f4dc1bf1c *R/approxOT-package.R
97191d086628e918c2de61c40f9652d5 *DESCRIPTION
12e7897acc7ea6d9ed0ecb167edcb3d0 *NAMESPACE
7eea561ad2d6968f615110f5eeb0fb1b *NEWS.md
a631a11dd152daa2ae50f5e14ecb73f0 *R/RcppExports.R
06b0d69c8982094376f62f1f0d4107aa *R/approxOT-package.R
e89a14923f71ebdcf13fe33720903d14 *R/cost_calculation.R
f6e038fc2a5c9d9c92ed343875268bfd *R/hilbert.projection.R
b4c05a951e57184a971f2acc6440c3f9 *R/sinkhorn.R
ad36cef7a9aecde7345b10a8fd3869cf *R/transport_options.R
36958fd303db2cb31128755e69856c3e *R/transport_plan.R
311b0d3ad8f09ecc724c1592b5100036 *R/unload.R
7f8b1cde45986aa4fe02f40495ce2d9a *R/wasserstein_distance.R
480ed25f463cf153da446d369cc30030 *README.md
4c468a3dda16ec70573948ba2307bcf4 *inst/CITATION
212874d8f2d98598293a57753726e73f *inst/include/approxOT_types.h
92c7ebfc0dbdcfcf44f334f1f4fb7960 *R/sinkhorn.R
fc3c58383a1360195ef5832a20c3bf62 *R/transport_options.R
ea0a55e237bcb86b4405df9b0bd2b075 *R/transport_plan.R
a8ad5414518cf2c47a2979e47a59a8e1 *R/wasserstein_distance.R
fa52ca3b61c3ad65d450f62c73cf2e5e *README.md
2e98e4b4ccf8580887430f6745c58223 *inst/CITATION
96298fbfc62f47b51228b0a49b2b434f *inst/include/approxOT_types.h
eb436d6657691aa863a72656186276b0 *inst/include/cost.h
4597916ea7a841fd78a11dfaec20db9b *inst/include/full_bipartitegraph.h
0d603a0b2f7eaba69ef299c2b20bd8f3 *inst/include/hilbert_cgal.h
Expand All @@ -28,55 +28,61 @@ e23e89153b9ecf7dd49d2b55f4e12422 *inst/include/trans_gandkhorn.h
2b2395e6f5ad3a08b417bd9f31f70b00 *inst/include/trans_randkhorn.h
c64aea71a0f6f6f4f0bcae065484fd5c *inst/include/trans_rank.h
ad10d58988825a440cee1feb6dc5ef69 *inst/include/trans_shortsimplex.h
bef5c93b23d7d2ead6ecd3f60014002b *inst/include/trans_sinkhorn.h
44269637b1f1dbd3c24fd477bd80749f *inst/include/trans_sinkhorn.h
a280ae57738632ce2dbe4865d88fc912 *inst/include/trans_swap.h
c74777fa68b59bcd78c5c551dd07c210 *inst/include/trans_univariate.h
90d10ef4657954b575ee7e7cc58aa3b1 *inst/include/trans_univariate_approx_pwr.h
059decd76013ef6b6c0bdda77713c035 *inst/include/transport.h
dabbf34aee9a5abae8ea3c997faded2e *inst/include/utils.h
a02025eeb3bba22eef8e3e9872d654e1 *inst/include/wasserstein.h
02c0fde86acfe291d7741cc91dc0bc4d *man/approxOT-package.Rd
b3c5e1e00a4db197d6a274bd92d67401 *man/approxOT-package.Rd
67e4a47a79f15f8cae3e97848dae7bba *man/as.matrix.transport.plan.Rd
ffa5208ece87198e95c780de36f89fdf *man/as.transport.plan.Rd
7e600afb27119941489f7728ea749f27 *man/cost_calc.Rd
1cc9fca3f58a5d34057f445cee64f97b *man/dist_2d_to_1d.Rd
cc30319d1ac5ceeae61d670ac895f4e2 *man/general_1d_transport.Rd
da8c8bcb69470af52e7a5b2fc25570e7 *man/hilbert.projection.Rd
80a97f51ec324464ed2976f8489bbab8 *man/hilbert_proj_.Rd
7f0576c37be8e66666726f0bfdde01db *man/is.transport.plan.Rd
f38af1feaf1d94330643e1baf60426c3 *man/round_transport_matrix.Rd
41208402d74440e69edad0112d6d376b *man/sinkhorn_distance.Rd
3dc9063765331f08febb48cd1ee51472 *man/sinkhorn_pot.Rd
bea865ba22e12bde0219b869e7237b29 *man/sinkhorn_pot.Rd
e9d43312b66ed6b7906d33b7d382338c *man/sinkhorn_transport.Rd
c249f2f549f9c49860c8824539a298ad *man/transport_options.Rd
9989e719a3f4bf5b9782c95b1f9cc6ac *man/transport_plan.Rd
ef90bdbb031a55d8864f447e227a00a1 *man/transport_plan_given_C.Rd
e73ad6f4b2bd99c763cf8bf4d0187575 *man/transport_options.Rd
8302fe391459ff8118c91d37fa71d24c *man/transport_plan.Rd
fdb116056216b216ff4bc85b67f58580 *man/transport_plan_given_C.Rd
452ecf171a57c89063c2cd32434dc458 *man/transport_plan_multimarg.Rd
a6f646d3ecd74f526caa073b0dff2d4b *man/wasserstein.Rd
e71d734798a150ce32a82ddb11cd08bf *man/wasserstein.Rd
36808b5a1ae1985d1b39c7082ea3787e *src/Makevars
f85e1e7a2701c8a8158d5cbd7e0338e5 *src/Makevars.win
7b60fb130fd2b35435a96bc34c3e82eb *src/RcppExports.cpp
e92fa1b866ab0174456188f39d88ad42 *src/RcppExports.cpp
49021e38b3c7bbdf5b8054f6abdf2ffb *src/cost.cpp
babb4706ef54cd811d58a0e2eacb2d0c *src/hilbert_cgal.cpp
6f2638b646746faf1cb8570d24e46d41 *src/hilbert_projection.cpp
8284b7b9df1c0e15dc9c8e277b08340c *src/networkflow.cpp
f943a99f31dbe84692c121a3484a4698 *src/round_feasible.cpp
ba6543970298f2f272042744d7bf387d *src/round_feasible.cpp
f02a6d33280c2b3a0f959b270f5af6d5 *src/shortsimplex.c
41ba408ab047211fb91406d088f74d4f *src/sinkhorn_test.cpp
68beead4ce2a14a7fa754492c54a0c64 *src/sort.cpp
e12e3fcddfa14e85518c851484a3e3d2 *src/systematic_sample.cpp
cdd858e511fbb7fbb41f768dabc5cd01 *src/trans_approxOT.cpp
5b8c8ca21d77540bd2127bace3ff3b84 *src/trans_approxOT.cpp
ea5a7d5665da9ae50a50e494202751b2 *src/trans_gandkhorn.cpp
5cdbd68a93789760913dfd3c456d10df *src/trans_greenkhorn.cpp
87c99b4b0090269538cb4c3a5b7fa75a *src/trans_hilbert.cpp
b679a0824ac45bdc49bf90daed8c8510 *src/trans_randkhorn.cpp
73f6aba1bedf54bb50ad57adb4b8e3fa *src/trans_rank.cpp
81f0800b9c07c573abb41d012c32ca5c *src/trans_shortsimplex.cpp
061884405b51201b1bf60726b902d35b *src/trans_sinkhorn.cpp
277bd700efb6ce296c39d0e16a6a6916 *src/trans_sinkhorn.cpp
1d47e723a68bdaa7c8fbf2a4dde1b420 *src/trans_swap.cpp
e4758bc972ae748200814c028b551124 *src/trans_univariate.cpp
b4474ba7a38371a72a188fee5b0727c9 *src/trans_univariate_approx_pwr.cpp
3d404f4b5a8eadb3b4869e4ca30de75e *src/transport.cpp
6ea5b2133bab675b93b3b6477af507da *src/utils.cpp
a4f0cdd5035573edf41c6ded86e8714e *src/transport.cpp
0d668fd53c7cb943ab024aeb8e73a923 *src/utils.cpp
6473d081693854b3ed38e877e1015295 *src/wasserstein.cpp
f42704eb6cd1acfd149d06a89c47640e *tests/testthat.R
1a4516e061efac67730d2a9634504c05 *tests/testthat/test-general_hilbert_transport.R
644760a1befa1c0fefd491c368ba6763 *tests/testthat/test-hilbert.R
dd67d96328b4b3142862ee72a117d2c3 *tests/testthat/test-transport_plan.R
96a47a50effd36dd405ba2c3f87add5c *tests/testthat/test-sinkhorn_pot_.R
d3b304772762841d77d6fca0141bea03 *tests/testthat/test-transport_plan.R
d5ad857c16b7aae050f35c514ffe61ec *tests/testthat/test-transport_plan_multimarg.R
452cccd2ab98505eb0e18c433ccf5ff8 *tests/testthat/test-wasserstein.R
00171adaf7f46d2c23dd87e7f080e8a5 *tests/testthat/test-wasserstein.R
5 changes: 4 additions & 1 deletion NAMESPACE
@@ -1,8 +1,11 @@
# Generated by roxygen2: do not edit by hand

S3method(base::as.matrix,transport.plan)
export(as.transport.plan)
export(cost_calc)
export(general_1d_transport)
export(hilbert.projection)
export(is.transport.plan)
export(sinkhorn_pot)
export(transport_options)
export(transport_plan)
Expand All @@ -11,4 +14,4 @@ export(transport_plan_multimarg)
export(wasserstein)
importFrom(Rcpp,evalCpp)
importFrom(Rcpp,sourceCpp)
useDynLib(approxOT)
useDynLib(approxOT, .registration = TRUE)
11 changes: 11 additions & 0 deletions NEWS.md
@@ -0,0 +1,11 @@
# approxOT

## Version 1.1

* Added a `NEWS.md` file to track changes to the package.
* Added a `as.matrix` function to convert transportation plans to matrices.
* Added a `as.transport.plan` to convert from transportation matrix to transportation plan.
* Added classes to support these two functions.
* Added support for log domain calculations for the sinkhorn method. This can be accessed with "sinkhorn_log" as the method.
* Fixed typo in C files incorrectly referencing Rcpp::stop
* updated DLL registrations in Namespace
60 changes: 48 additions & 12 deletions R/RcppExports.R
Expand Up @@ -2,15 +2,15 @@
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

cost_calculation_ <- function(A_, B_, p) {
.Call('_approxOT_cost_calculation_', PACKAGE = 'approxOT', A_, B_, p)
.Call(`_approxOT_cost_calculation_`, A_, B_, p)
}

multi_marg_final_cost_ <- function(idx_, data_, mass_, M, D, p, ground_p) {
.Call('_approxOT_multi_marg_final_cost_', PACKAGE = 'approxOT', idx_, data_, mass_, M, D, p, ground_p)
.Call(`_approxOT_multi_marg_final_cost_`, idx_, data_, mass_, M, D, p, ground_p)
}

multi_marg_given_dist_ <- function(idx_, mass_, cost_, M, N_cost, p) {
.Call('_approxOT_multi_marg_given_dist_', PACKAGE = 'approxOT', idx_, mass_, cost_, M, N_cost, p)
.Call(`_approxOT_multi_marg_given_dist_`, idx_, mass_, cost_, M, N_cost, p)
}

#' Returns orders along the Hilbert space-filling Curve
Expand All @@ -19,38 +19,74 @@ multi_marg_given_dist_ <- function(idx_, mass_, cost_, M, N_cost, p) {
#' @return An integer vector of orders
#' @keywords internal
hilbert_proj_ <- function(A) {
.Call('_approxOT_hilbert_proj_', PACKAGE = 'approxOT', A)
.Call(`_approxOT_hilbert_proj_`, A)
}

round_2_feasible_ <- function(F, mass_a, mass_b) {
.Call(`_approxOT_round_2_feasible_`, F, mass_a, mass_b)
}

sinkhorn_ <- function(p_, q_, cost_matrix_, epsilon, niterations) {
.Call('_approxOT_sinkhorn_', PACKAGE = 'approxOT', p_, q_, cost_matrix_, epsilon, niterations)
.Call(`_approxOT_sinkhorn_`, p_, q_, cost_matrix_, epsilon, niterations)
}

generate_S <- function(cost, f, g, eta) {
.Call(`_approxOT_generate_S`, cost, f, g, eta)
}

rowLogSumExp <- function(Mat) {
.Call(`_approxOT_rowLogSumExp`, Mat)
}

colLogSumExp <- function(Mat) {
.Call(`_approxOT_colLogSumExp`, Mat)
}

rowMin_eps <- function(cost, f, g, eta) {
.Call(`_approxOT_rowMin_eps`, cost, f, g, eta)
}

colMin_eps <- function(cost, f, g, eta) {
.Call(`_approxOT_colMin_eps`, cost, f, g, eta)
}

rowMin_eps_KL <- function(cost, f, g, eta, log_a, log_b) {
.Call(`_approxOT_rowMin_eps_KL`, cost, f, g, eta, log_a, log_b)
}

colMin_eps_KL <- function(cost, f, g, eta, log_a, log_b) {
.Call(`_approxOT_colMin_eps_KL`, cost, f, g, eta, log_a, log_b)
}

sinkhorn_pot_ <- function(mass_a, mass_b, cost_matrix, epsilon, niterations, unbiased, cost_matrix_A, cost_matrix_B) {
.Call('_approxOT_sinkhorn_pot_', PACKAGE = 'approxOT', mass_a, mass_b, cost_matrix, epsilon, niterations, unbiased, cost_matrix_A, cost_matrix_B)
.Call(`_approxOT_sinkhorn_pot_`, mass_a, mass_b, cost_matrix, epsilon, niterations, unbiased, cost_matrix_A, cost_matrix_B)
}

sinkhorn_pot_log_ <- function(mass_a, mass_b, cost_matrix, epsilon, niterations, unbiased, cost_matrix_A, cost_matrix_B) {
.Call(`_approxOT_sinkhorn_pot_log_`, mass_a, mass_b, cost_matrix, epsilon, niterations, unbiased, cost_matrix_A, cost_matrix_B)
}

transport_C_ <- function(mass_a_, mass_b_, cost_matrix_, method_, epsilon_, niter_, unbiased_, threads_, cost_matrix_A_, cost_matrix_B_) {
.Call('_approxOT_transport_C_', PACKAGE = 'approxOT', mass_a_, mass_b_, cost_matrix_, method_, epsilon_, niter_, unbiased_, threads_, cost_matrix_A_, cost_matrix_B_)
.Call(`_approxOT_transport_C_`, mass_a_, mass_b_, cost_matrix_, method_, epsilon_, niter_, unbiased_, threads_, cost_matrix_A_, cost_matrix_B_)
}

transport_ <- function(A_, B_, p, ground_p, method_, a_sort, epsilon_ = 0.0, niter_ = 0L, unbiased_ = FALSE, threads_ = 1L) {
.Call('_approxOT_transport_', PACKAGE = 'approxOT', A_, B_, p, ground_p, method_, a_sort, epsilon_, niter_, unbiased_, threads_)
.Call(`_approxOT_transport_`, A_, B_, p, ground_p, method_, a_sort, epsilon_, niter_, unbiased_, threads_)
}

transport_swap_ <- function(A_, B_, idx_, mass_, p, ground_p, tolerance_, niter_ = 0L) {
.Call('_approxOT_transport_swap_', PACKAGE = 'approxOT', A_, B_, idx_, mass_, p, ground_p, tolerance_, niter_)
.Call(`_approxOT_transport_swap_`, A_, B_, idx_, mass_, p, ground_p, tolerance_, niter_)
}

wasserstein_ <- function(mass_, cost_, p, from_, to_) {
.Call('_approxOT_wasserstein_', PACKAGE = 'approxOT', mass_, cost_, p, from_, to_)
.Call(`_approxOT_wasserstein_`, mass_, cost_, p, from_, to_)
}

wasserstein_p_iid_ <- function(X_, Y_, p) {
.Call('_approxOT_wasserstein_p_iid_', PACKAGE = 'approxOT', X_, Y_, p)
.Call(`_approxOT_wasserstein_p_iid_`, X_, Y_, p)
}

wasserstein_p_iid_p_ <- function(X_, Y_, p) {
.Call('_approxOT_wasserstein_p_iid_p_', PACKAGE = 'approxOT', X_, Y_, p)
.Call(`_approxOT_wasserstein_p_iid_p_`, X_, Y_, p)
}

2 changes: 1 addition & 1 deletion R/approxOT-package.R
Expand Up @@ -4,7 +4,7 @@
#' @author Eric Dunipace
#' @docType package
#' @name approxOT
#' @useDynLib approxOT
#' @useDynLib approxOT, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#' @importFrom Rcpp evalCpp
#' @rdname approxOT-package
Expand Down

0 comments on commit 2a00ec3

Please sign in to comment.