R Under development (unstable) (2025-02-26 r87830 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(flexclust) > > ## Canberra is really only defined for >= 0 matrices, and changed > ## in dist in 2018 > > ## create a random matrix > x <- abs(matrix(rnorm(1000), ncol=4)) > rownames(x) <- 1:nrow(x) > > ## test canberra at margin > x[1:10,1] <- 0 > x[1:20,2] <- 0 > x[1:30,3] <- 0 > > stopifnot(all.equal(dist2(x,x,"eucl"), as.matrix(dist(x, "eucl")))) > stopifnot(all.equal(dist2(x,x,"man"), as.matrix(dist(x, "man")))) > stopifnot(all.equal(dist2(x,x,"max"), as.matrix(dist(x, "max")))) > stopifnot(all.equal(dist2(x,x,"bin"), as.matrix(dist(x, "bin")))) > stopifnot(all.equal(dist2(x,x,"can"), as.matrix(dist(x, "can")))) > > stopifnot(all.equal(dist2(x,x,"eucl"), dist2(x,x,"mink",p=2))) > stopifnot(all.equal(dist2(x,x,"man"), dist2(x,x,"mink",p=1))) > > proc.time() user system elapsed 0.59 0.07 0.67