matlab/0000755000175100001440000000000014640471532011536 5ustar hornikusersmatlab/tests/0000755000175100001440000000000014245524746012707 5ustar hornikusersmatlab/tests/size.R0000644000175100001440000000204214245203403013762 0ustar hornikusers### ### $Id: size.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.size <- function(input, expected) { output <- do.call(getFromNamespace("size", "matlab"), input) identical(as.integer(output), expected) } X.vec <- 2:9 size.expected.X.vec <- c(1, length(X.vec)) test.size(list(X = X.vec), size.expected.X.vec) test.size(list(X = X.vec, 1), as.integer(1)) test.size(list(X = X.vec, 2), length(X.vec)) X.mat <- matrix(X.vec, 4, 2) size.expected.X.mat <- dim(X.mat) test.size(list(X = X.mat), size.expected.X.mat) test.size(list(X = X.mat, 1), size.expected.X.mat[1]) test.size(list(X = X.mat, 2), size.expected.X.mat[2]) test.size(list(X = X.mat, 3), as.integer(1)) # singleton dimension X.arr <- array(2:25, c(4, 3, 2)) size.expected.X.arr <- dim(X.arr) test.size(list(X = X.arr), size.expected.X.arr) test.size(list(X = X.arr, 1), size.expected.X.arr[1]) test.size(list(X = X.arr, 2), size.expected.X.arr[2]) test.size(list(X = X.arr, 3), size.expected.X.arr[3]) matlab/tests/repmat.R0000644000175100001440000000245214245203403014305 0ustar hornikusers### ### $Id: repmat.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.repmat <- function(input, expected) { output <- do.call(getFromNamespace("repmat", "matlab"), input) identical(output, expected) } X.scalar <- 1 repmat.expected.ones.3x3 <- matlab::ones(3) repmat.expected.ones.4x2 <- matlab::ones(4, 2) test.repmat(list(A = X.scalar, n = 3), repmat.expected.ones.3x3) test.repmat(list(A = X.scalar, m = c(4, 2)), repmat.expected.ones.4x2) test.repmat(list(A = X.scalar, m = 4, n = 2), repmat.expected.ones.4x2) test.repmat(list(A = X.scalar, n = matlab::size(repmat.expected.ones.4x2)), repmat.expected.ones.4x2) X.mat <- matlab::eye(2) repmat.expected.pat1 <- matrix(c(rep(c(1,0), times=3), rep(c(0,1), times=3)), nrow = 6, ncol = 6) test.repmat(list(A = X.mat, m = 3), repmat.expected.pat1) test.repmat(list(A = X.mat[, 1], c(1, 1)), X.mat[, 1]) X.vec <- as.numeric(1:8) repmat.expected.pat2 <- matrix(rep(X.vec, 5), nrow = 5, byrow = TRUE) test.repmat(list(A = as.matrix(X.vec), m = c(5, 1)), repmat.expected.pat2) X.str <- "value" repmat.expected.str <- matrix(rep(X.str, 4), nrow = 1) test.repmat(list(A = X.str, m = 1, n = 4), repmat.expected.str) matlab/tests/logspace.R0000644000175100001440000000140514245203403014607 0ustar hornikusers### ### $Id: logspace.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.logspace <- function(input, expected) { output <- do.call(getFromNamespace("logspace", "matlab"), input) identical(all.equal(output, expected, tolerance = 0.0001), TRUE) } logspace.expected.1topi <- c(10.0000, 7.4866, 5.6050, 4.1963, 3.1416) test.logspace(list(a = 1, b = pi, n = 5), logspace.expected.1topi) ## more rigorously this time test.logspace(list(a = 0, b = 1, n = 0), 10) ## HWB 2011/02/03 test.logspace(list(a = 0, b = 10, n = 1), 10^10) ## HWB 2011/02/03 test.logspace(list(a = 0, b = 1, n = 1.5), 10) ## HWB 2011/02/03 matlab/tests/zeros.R0000644000175100001440000000114314245203403014153 0ustar hornikusers### ### $Id: zeros.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.zeros <- function(input, expected) { output <- do.call(getFromNamespace("zeros", "matlab"), input) identical(output, expected) } zeros.expected.3x3 <- matrix(0, nrow = 3, ncol = 3) zeros.expected.4x2 <- matrix(0, nrow = 4, ncol = 2) test.zeros(list(n = 3), zeros.expected.3x3) test.zeros(list(n = c(4, 2)), zeros.expected.4x2) test.zeros(list(m = 4, n = 2), zeros.expected.4x2) test.zeros(list(n = matlab::size(zeros.expected.4x2)), zeros.expected.4x2) matlab/tests/padarray.R0000644000175100001440000000471114245203403014620 0ustar hornikusers### ### $Id: padarray.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.padarray <- function(input, expected) { output <- do.call(getFromNamespace("padarray", "matlab"), input) identical(output, expected) } ## Add three elements of padding to beginning of vector ## The padding elements contain mirror copies of the array padarray.expected.mat4x4 <- matrix(1:4, 4, 4, byrow = TRUE) test.padarray(list(A = 1:4, padsize = 3, padval = "symmetric", direction = "pre"), padarray.expected.mat4x4) ## Add three elements of padding to the end of the first dimension of array ## and two elements of padding to the end of the second dimension. ## Use value of the last array element as the padding value. Amat.2x2 <- matrix(as.numeric(1:4), nrow = 2, ncol = 2, byrow = TRUE) padarray.expected.mat5x4 <- matrix(c(1, 2, 2, 2, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4), nrow = 5, ncol = 4, byrow = TRUE) test.padarray(list(A = Amat.2x2, padsize = c(3, 2), padval = "replicate", direction = "post"), padarray.expected.mat5x4) ## Add three elements of padding to each dimension of a three-dimensional array. ## Each pad element contains the value zero. Bmat.2x2 <- matrix(5:8, nrow = 2, ncol = 2, byrow = TRUE) Carr.2x2x2 <- array(c(Amat.2x2, Bmat.2x2), c(2, 2, 2)) padarray.expected.arr8x8x2 <- { A <- array(0, c(8, 8, 2)) A[4:5, 4:5, 1] <- Amat.2x2 A[4:5, 4:5, 2] <- Bmat.2x2 A } test.padarray(list(A = Carr.2x2x2, padsize = c(3, 3), padval = 0, direction = "both"), padarray.expected.arr8x8x2) ## Add three elements of padding to end of vector ## The padding elements contain a mirror copy of the vector padarray.expected.vec <- c(letters[1:5], rev(letters[3:5])) test.padarray(list(A = letters[1:5], padsize = c(0, 3), padval = "symmetric", direction = "post"), padarray.expected.vec) matlab/tests/linspace.R0000644000175100001440000000142114245203403014606 0ustar hornikusers### ### $Id: linspace.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.linspace <- function(input, expected) { output <- do.call(getFromNamespace("linspace", "matlab"), input) identical(output, expected) } linspace.expected.100 <- as.numeric(1:100) linspace.expected.25x5 <- c(0, 6.25, 12.50, 18.75, 25) linspace.expected.len1 <- 25 test.linspace(list(a = 1, b = 100), linspace.expected.100) test.linspace(list(a = 0, b = 25, n = 5), linspace.expected.25x5) test.linspace(list(a = 1, b = 25, n = 1), linspace.expected.len1) ## more rigorously this time test.linspace(list(a = 0, b = 1, n = 2.5), 0:1) ## HWB 2011/02/03 test.linspace(list(a = 0, b = 1, n = 3.9), seq(0, 1, length=floor(3))) matlab/tests/numel.R0000644000175100001440000000066314245203403014137 0ustar hornikusers### ### $Id: numel.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.numel <- function(input, expected) { output <- do.call(getFromNamespace("numel", "matlab"), input) identical(output, expected) } a <- array(NA, c(4, 4, 2)) a[,,1] <- matlab::magic(4) a[,,2] <- t(a[,,1]) numel.expected.4x4x2 <- 32 test.numel(list(A = a), numel.expected.4x4x2) matlab/tests/cell.R0000644000175100001440000000131214245203403013726 0ustar hornikusers### ### $Id: cell.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.cell <- function(input, expected) { output <- do.call(getFromNamespace("cell", "matlab"), input) identical(output, expected) } cell.expected.2x2 <- list() length(cell.expected.2x2) <- prod(dims <- c(2, 2)) dim(cell.expected.2x2) <- dims cell.expected.4x2 <- list() length(cell.expected.4x2) <- prod(dims <- c(4, 2)) dim(cell.expected.4x2) <- dims test.cell(list(n = 2), cell.expected.2x2) test.cell(list(n = c(4, 2)), cell.expected.4x2) test.cell(list(n = 4, m = 2), cell.expected.4x2) test.cell(list(n = matlab::size(matlab::ones(2))), cell.expected.2x2) matlab/tests/flipud.R0000644000175100001440000000131014245203403014270 0ustar hornikusers### ### $Id: flipud.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.flipud <- function(input, expected) { output <- do.call(getFromNamespace("flipud", "matlab"), input) identical(output, expected) } X.mat <- matrix(1:6, 3, 2) flipud.expected.X.mat <- matrix(c(3:1, 6:4), 3, 2) test.flipud(list(X.mat), flipud.expected.X.mat) X.vec <- seq(1, 9, by = 2) flipud.expected.X.vec <- seq(9, 1, by = -2) test.flipud(list(X.vec), flipud.expected.X.vec) ## Since R does not really have concept of row/column vectors ## identical(test.fliplr(X.vec, flipud.expected.X.vec), ## test.flipud(X.vec, flipud.expected.X.vec)) matlab/tests/mkconstarray.R0000644000175100001440000000060414245203403015527 0ustar hornikusers### ### $Id: mkconstarray.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.mkconstarray <- function(input, expected) { output <- do.call(getFromNamespace("mkconstarray", "matlab"), input) identical(output, expected) } test.mkconstarray(list(class.type = "double", value = pi, size = 4), rep(pi, 4)) matlab/tests/tictoc.R0000644000175100001440000000056714245203403014307 0ustar hornikusers### ### $Id: tictoc.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.toc <- function(delay, expected) { Sys.sleep(delay) output <- matlab::toc(FALSE) all.equal(output, expected, tolerance = 0.10) } matlab::tic() try(test.toc(4, 4)) try(test.toc(2, 4+2)) matlab/tests/fileparts.R0000644000175100001440000001210714245203403015004 0ustar hornikusers### ### $Id: fileparts.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.fileparts <- function(input, expected) { output <- do.call(getFromNamespace("fileparts", "matlab"), input) identical(output, expected) } ext <- ".ext" gz <- ".gz" file.without.ext <- "myfile" file.with.ext <- paste(file.without.ext, ext, sep = "") file.with.ext.gz <- paste(file.with.ext, gz, sep = "") hidden.file <- ".profile" user.name <- "luser" abs.dir <- paste("", "home", user.name, sep = "/") rel.cur.dir <- "." rel.parent.dir <- ".." tilde.dir <- "~" tilde.user.dir <- paste(tilde.dir, user.name, sep = "") abs.dir.file.with.ext <- paste(abs.dir, file.with.ext, sep = "/") abs.dir.file.with.ext.gz <- paste(abs.dir, file.with.ext.gz, sep = "/") abs.dir.file.without.ext <- paste(abs.dir, file.without.ext, sep = "/") abs.dir.hidden.file <- paste(abs.dir, hidden.file, sep = "/") abs.dir.trailing.slash <- paste(abs.dir, "", sep = "/") abs.rel.cur.dir <- paste(abs.dir, rel.cur.dir, sep = "/") abs.rel.parent.dir <- paste(abs.dir, rel.parent.dir, sep = "/") rel.cur.dir.file.with.ext <- paste(rel.cur.dir, file.with.ext, sep = "/") rel.cur.dir.file.without.ext <- paste(rel.cur.dir, file.without.ext, sep = "/") rel.cur.dir.hidden.file <- paste(rel.cur.dir, hidden.file, sep = "/") rel.cur.dir.trailing.slash <- paste(rel.cur.dir, "", sep = "/") tilde.dir.trailing.slash <- paste(tilde.dir, "", sep = "/") tilde.user.dir.trailing.slash <- paste(tilde.user.dir, "", sep = "/") ## 'myfile.ext' test.fileparts(list(file.with.ext), list(pathstr = "", name = file.without.ext, ext = ext, versn = "")) ## '/home/luser/myfile.ext' test.fileparts(list(abs.dir.file.with.ext), list(pathstr = abs.dir, name = file.without.ext, ext = ext, versn = "")) ## '/home/luser/myfile.ext.gz' test.fileparts(list(abs.dir.file.with.ext.gz), list(pathstr = abs.dir, name = file.with.ext, ext = gz, versn = "")) ## '/home/luser/myfile' test.fileparts(list(abs.dir.file.without.ext), list(pathstr = abs.dir, name = file.without.ext, ext = "", versn = "")) ## '/home/luser/.profile' test.fileparts(list(abs.dir.hidden.file), list(pathstr = abs.dir, name = character(0), ext = hidden.file, versn = "")) ## '/home/luser' test.fileparts(list(abs.dir), list(pathstr = dirname(abs.dir), name = basename(abs.dir), ext = "", versn = "")) ## '/home/luser/' test.fileparts(list(abs.dir.trailing.slash), list(pathstr = abs.dir, name = character(0), ext = "", versn = "")) ## './myfile.ext' test.fileparts(list(rel.cur.dir.file.with.ext), list(pathstr = rel.cur.dir, name = file.without.ext, ext = ext, versn = "")) ## './myfile' test.fileparts(list(rel.cur.dir.file.without.ext), list(pathstr = rel.cur.dir, name = file.without.ext, ext = "", versn = "")) ## './.profile' test.fileparts(list(rel.cur.dir.hidden.file), list(pathstr = rel.cur.dir, name = character(0), ext = hidden.file, versn = "")) ## '.' test.fileparts(list(rel.cur.dir), list(pathstr = "", name = character(0), ext = ".", versn = "")) ## '..' test.fileparts(list(rel.parent.dir), list(pathstr = "", name = ".", ext = ".", versn = "")) ## './' test.fileparts(list(rel.cur.dir.trailing.slash), list(pathstr = rel.cur.dir, name = character(0), ext = "", versn = "")) ## "~" test.fileparts(list(tilde.dir), list(pathstr = "", name = tilde.dir, ext = "", versn = "")) ## "~/" test.fileparts(list(tilde.dir.trailing.slash), list(pathstr = tilde.dir, name = character(0), ext = "", versn = "")) ## "~luser" test.fileparts(list(tilde.user.dir), list(pathstr = "", name = tilde.user.dir, ext = "", versn = "")) ## "~luser/" test.fileparts(list(tilde.user.dir.trailing.slash), list(pathstr = tilde.user.dir, name = character(0), ext = "", versn = "")) matlab/tests/eye.R0000644000175100001440000000144714245203403013602 0ustar hornikusers### ### $Id: eye.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.eye <- function(input, expected) { output <- do.call(getFromNamespace("eye", "matlab"), input) identical(output, expected) } eye.expected.3x3 <- matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1), nrow = 3, ncol = 3, byrow = TRUE) eye.expected.4x2 <- matrix(c(1, 0, 0, 1, 0, 0, 0, 0), nrow = 4, ncol = 2, byrow = TRUE) test.eye(list(m = 3), eye.expected.3x3) test.eye(list(m = c(4, 2)), eye.expected.4x2) test.eye(list(m = 4, n = 2), eye.expected.4x2) test.eye(list(m = matlab::size(eye.expected.4x2)), eye.expected.4x2) matlab/tests/pow2.R0000644000175100001440000000127414245203403013705 0ustar hornikusers### ### $Id: pow2.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.pow2 <- function(input, expected) { output <- do.call(getFromNamespace("pow2", "matlab"), input) identical(output, expected) } pow2.expected.00 <- 0 pow2.expected.m1 <- -0.5 pow2.expected.f <- c(1, 2, 4, 8) pow2.expected.fe <- c(0, 0.5, -8, 24) pow2.expected.complex <- c(2^(1i), 2^(-1i)) test.pow2(list(f=0, e=0), pow2.expected.00) test.pow2(list(f=-1, e=-1), pow2.expected.m1) test.pow2(list(f=0:3), pow2.expected.f) test.pow2(list(f=c(0, 1, -2, 3), e=c(0, -1, 2, 3)), pow2.expected.fe) test.pow2(list(f=c(1i, -1i)), pow2.expected.complex) matlab/tests/fullfile.R0000644000175100001440000000077714245203403014627 0ustar hornikusers### ### $Id: fullfile.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.fullfile <- function(input, expected) { output <- do.call(getFromNamespace("fullfile", "matlab"), input) identical(output, expected) } fullfile.expected <- file.path(path.expand("~"), "somedir", "foo.txt") test.fullfile(list(dir = path.expand("~"), subdir = "somedir", file = "foo.txt"), fullfile.expected) matlab/tests/ndims.R0000644000175100001440000000062414245203403014126 0ustar hornikusers### ### $Id: ndims.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.ndims <- function(input, expected) { output <- do.call(getFromNamespace("ndims", "matlab"), input) identical(output, expected) } test.ndims(list(A = array(NA, c(4, 4, 2))), 3) test.ndims(list(A = matlab::magic(4)), 2) test.ndims(list(A = 1:5), 2) matlab/tests/ceil.R0000644000175100001440000000060114245203403013723 0ustar hornikusers### ### $Id: ceil.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.ceil <- function(input, expected) { output <- do.call(getFromNamespace("ceil", "matlab"), input) identical(output, expected) } X <- c(-1.9, -0.2, 3.4, 5.6, 7) ceil.expected <- c(-1, 0, 4, 6, 7) test.ceil(list(X), ceil.expected) matlab/tests/rot90.R0000644000175100001440000000142414245203403013770 0ustar hornikusers### ### $Id: rot90.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.rot90 <- function(input, expected) { output <- do.call(getFromNamespace("rot90", "matlab"), input) identical(output, expected) } X.mat <- matrix(1:9, nrow = 3, byrow = TRUE) rot90.expected.X.mat <- matrix(c(3:1, 6:4, 9:7), nrow = 3) rot180.expected.X.mat <- matrix(c(9:7, 6:4, 3:1), nrow = 3, byrow = TRUE) rot270.expected.X.mat <- matrix(c(7:9, 4:6, 1:3), nrow = 3) rot360.expected.X.mat <- X.mat test.rot90(list(A = X.mat, k = 1), rot90.expected.X.mat) test.rot90(list(A = X.mat, k = 2), rot180.expected.X.mat) test.rot90(list(A = X.mat, k = 3), rot270.expected.X.mat) test.rot90(list(A = X.mat, k = 4), rot360.expected.X.mat) matlab/tests/jet.colors.R0000644000175100001440000000136514245203403015101 0ustar hornikusers### ### $Id: jet.colors.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.jet.colors <- function(input, expected) { output <- do.call(getFromNamespace("jet.colors", "matlab"), input) identical(output, expected) } jet.expected.m0 <- character(0) jet.expected.m1 <- "#00FFFF" jet.expected.m8 <- c("#0000FF", "#0080FF", "#00FFFF", "#80FF80", "#FFFF00", "#FF8000", "#FF0000", "#800000") test.jet.colors(list(n = 0), jet.expected.m0) test.jet.colors(list(n = 1), jet.expected.m1) test.jet.colors(list(n = 8), jet.expected.m8) matlab/tests/hilb.R0000644000175100001440000000125714245203403013735 0ustar hornikusers### ### $Id: hilb.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.hilb <- function(input, expected) { output <- do.call(getFromNamespace("hilb", "matlab"), input) identical(output, expected) } hilb.expected.na.nodim <- matrix(NA, nrow=0, ncol=0) hilb.expected.zero.nodim <- matrix(0, nrow=0, ncol=0) hilb.expected.one <- matrix(1, nrow=1, ncol=1) hilb.expected.five <- 1 / matrix(c(1:5,2:6,3:7,4:8,5:9), nrow=5, ncol=5) test.hilb(list(n=-1), hilb.expected.na.nodim) test.hilb(list(n=0), hilb.expected.zero.nodim) test.hilb(list(n=1), hilb.expected.one) test.hilb(list(n=5), hilb.expected.five) matlab/tests/primes.R0000644000175100001440000000217414245203403014315 0ustar hornikusers### ### $Id: primes.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.primes <- function(input, expected) { output <- do.call(getFromNamespace("primes", "matlab"), input) identical(output, expected) } primes.expected.101 <- c( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101) primes.expected.n37 <- primes.expected.101[1:12] primes.expected.n13 <- primes.expected.101[1:6] primes.expected.n8 <- c(2, 3, 5, 7) primes.expected.n5 <- c(2, 3, 5) primes.expected.n3 <- c(2, 3) primes.expected.n2 <- 2 primes.expected.n1 <- NULL test.primes(list(n=1), primes.expected.n1) test.primes(list(n=2), primes.expected.n2) test.primes(list(n=3), primes.expected.n3) test.primes(list(n=5), primes.expected.n5) test.primes(list(n=8), primes.expected.n8) test.primes(list(n=13), primes.expected.n13) test.primes(list(n=37), primes.expected.n37) test.primes(list(n=101), primes.expected.101) matlab/tests/fliplr.R0000644000175100001440000000106514245203403014304 0ustar hornikusers### ### $Id: fliplr.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.fliplr <- function(input, expected) { output <- do.call(getFromNamespace("fliplr", "matlab"), input) identical(output, expected) } X.mat <- matrix(1:6, 2, 3, byrow = TRUE) fliplr.expected.X.mat <- matrix(c(3:1, 6:4), 2, 3, byrow = TRUE) test.fliplr(list(X.mat), fliplr.expected.X.mat) X.vec <- seq(1, 9, by = 2) fliplr.expected.X.vec <- seq(9, 1, by = -2) test.fliplr(list(X.vec), fliplr.expected.X.vec) matlab/tests/nextpow2.R0000644000175100001440000000170314245203403014601 0ustar hornikusers### ### $Id: nextpow2.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.nextpow2 <- function(input, expected) { output <- do.call(getFromNamespace("nextpow2", "matlab"), input) identical(output, expected) } nextpow2.expected.0 <- 0 nextpow2.expected.vector <- c(0, 1, 2, 2, 3, 3, 3, 3, 4, 4) nextpow2.expected.matrix <- matrix(c(0, 1, 1, 0), nrow=2, ncol=2) nextpow2.expected.16 <- 4 nextpow2.expected.m16 <- 4 nextpow2.expected.m6 <- -19 nextpow2.expected.mq <- -2 test.nextpow2(list(x=0), nextpow2.expected.0) test.nextpow2(list(x=1:10), nextpow2.expected.vector) test.nextpow2(list(x=matrix(c(1i, 2i, 2+0i, 0+0i), nrow=2, ncol=2)), nextpow2.expected.matrix) test.nextpow2(list(x=16), nextpow2.expected.16) test.nextpow2(list(x=-16), nextpow2.expected.m16) test.nextpow2(list(x=1e-6), nextpow2.expected.m6) test.nextpow2(list(x=-0.25), nextpow2.expected.mq) matlab/tests/ones.R0000644000175100001440000000112514245203403013755 0ustar hornikusers### ### $Id: ones.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.ones <- function(input, expected) { output <- do.call(getFromNamespace("ones", "matlab"), input) identical(output, expected) } ones.expected.3x3 <- matrix(1, nrow = 3, ncol = 3) ones.expected.4x2 <- matrix(1, nrow = 4, ncol = 2) test.ones(list(n = 3), ones.expected.3x3) test.ones(list(n = c(4, 2)), ones.expected.4x2) test.ones(list(m = 4, n = 2), ones.expected.4x2) test.ones(list(n = matlab::size(ones.expected.4x2)), ones.expected.4x2) matlab/tests/std.R0000644000175100001440000000116114245203403013603 0ustar hornikusers### ### $Id: std.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.std <- function(input, expected) { output <- do.call(getFromNamespace("std", "matlab"), input) identical(all.equal(output, expected, tolerance = 0.0001), TRUE) } X.mat <- matrix(c(1, 5, 9, 7, 15, 22), 2, 3, byrow = TRUE) std.expected.by.col <- c(4.2426, 7.0711, 9.1924) std.expected.by.row <- c(4.000, 7.5056) test.std(list(x = X.mat), std.expected.by.col) test.std(list(x = t(X.mat)), std.expected.by.row) matlab/tests/rem.R0000644000175100001440000000447314245247446013624 0ustar hornikusers### ### $Id: rem.R 30 2022-05-30 23:11:34Z proebuck $ ### ##----------------------------------------------------------------------------- test.rem <- function(input, expected) { output <- do.call(getFromNamespace("rem", "matlab"), input) identical(output, expected) } ## Remainder After Division of Scalar rem.expected.div.scalar <- 3 test.rem(list(x = 23, y = 5), rem.expected.div.scalar) ## Remainder After Division of Vector X.vec <- 1:5 rem.expected.div.vec <- c(1, 2, 0, 1, 2) test.rem(list(x = X.vec, y = 3), rem.expected.div.vec) ## Remainder After Division of Vector by Zero X.vec <- 1:5 rem.expected.div.vec.by0 <- rep(NaN, length(X.vec)) test.rem(list(x = X.vec, y = 0), rem.expected.div.vec.by0) ## Remainder After Division for Positive and Negative Values ## Note that nonzero results have the same sign as the dividend. X.posneg.vec <- c(-4, -1, 7, 9) rem.expected.div.posneg.vec <- c(-1, -1, 1, 0) test.rem(list(x = X.posneg.vec, y = 3), rem.expected.div.posneg.vec) ## Remainder After Division for Floating-Point Values X.theta <- c(0.0, 3.5, 5.9, 6.2, 9.0, 4 * pi) b <- 2 * pi; expected.div.fp.vec <- c(0, 3.5, 5.9, 6.2, 2.716815, 0) test.rem(list(x = X.theta, y = b), expected.div.fp.vec) ## Remainder After Division of Matrix X.mat <- matrix(1:9, nrow = 3, byrow = TRUE) rem.expected.X.mat <- matrix(c(3:1, 6:4, 9:7), nrow = 3, byrow = TRUE) rem.expected.X.mat.Y0 <- matrix(rep(NaN, length(X.mat)), nrow = nrow(X.mat)) rem.expected.X.mat.Y1 <- matrix(rep(1, length(X.mat)), nrow = nrow(X.mat)) rem.expected.X.mat.Y2 <- matrix(rep(c(1, 0), 5)[1:length(X.mat)], nrow = nrow(X.mat)) rem.expected.X.mat.Y3 <- matrix(rep(c(1, 2, 0), nrow(X.mat)), nrow = nrow(X.mat), byrow = TRUE) test.rem(list(x = X.mat, y = 0), rem.expected.X.mat.Y0) test.rem(list(x = X.mat, y = 1), rem.expected.X.mat.Y1) test.rem(list(x = X.mat, y = 2), rem.expected.X.mat.Y2) test.rem(list(x = X.mat, y = 3), rem.expected.X.mat) ## rem & mod give same results with X, Y having same sign test.rem(list(x = 5, y = 3), matlab::mod(5, 3)) test.rem(list(x = -5, y = -3), matlab::mod(-5, -3)) ## alternate formula used when X, Y having different signs test.rem(list(x = 5, y = -3), (matlab::mod(5, -3) - -3)) test.rem(list(x = -5, y = 3), (matlab::mod(-5, 3) - 3)) matlab/tests/factors.R0000644000175100001440000000205414245203403014454 0ustar hornikusers### ### $Id: factors.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.factors <- function(input, expected) { output <- do.call(getFromNamespace("factors", "matlab"), input) identical(output, expected) } factors.expected.n2 <- 2 factors.expected.n3 <- 3 factors.expected.prm <- 999983 factors.expected.pr2 <- c(9999889, 9999901) factors.expected.prp <- c(65003, 65003) factors.expected.nn <- c(2, 2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 7, 7, 11) factors.expected.nm <- c(99989, 99991, 100003) factors.expected.n32 <- c(3, 5, 17, 257, 65537) test.factors(list(n=2), factors.expected.n2) test.factors(list(n=3), factors.expected.n3) test.factors(list(n=999983), factors.expected.prm) #test.factors(list(n=9999889*9999901), factors.expected.pr2) test.factors(list(n=4225390009), factors.expected.prp) test.factors(list(n=2^5 * 3^4 * 5^3 * 7^2 * 11), factors.expected.nn) test.factors(list(n=99989*99991*100003), factors.expected.nm) test.factors(list(n=2^32-1), factors.expected.n32) matlab/tests/isempty.R0000644000175100001440000000112414245203403014502 0ustar hornikusers### ### $Id: isempty.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.isempty <- function(input, expected) { output <- do.call(getFromNamespace("isempty", "matlab"), input) identical(output, expected) } test.isempty(list(A = 1:3), FALSE) test.isempty(list(A = numeric(0)), TRUE) test.isempty(list(A = matrix(NA, nrow = 2, ncol = 2)), FALSE) test.isempty(list(A = matrix(NA, nrow = 0, ncol = 2)), TRUE) test.isempty(list(A = array(NA, c(2, 2, 2))), FALSE) test.isempty(list(A = array(NA, c(2, 0, 2))), TRUE) matlab/tests/sum.R0000644000175100001440000000164314245203403013622 0ustar hornikusers### ### $Id: sum.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.sum <- function(input, expected) { output <- do.call(getFromNamespace("sum", "matlab"), input) identical(all.equal(output, expected, tolerance = 0.0001), TRUE) } X.vec <- 1:9 sum.expected.vec <- 45 cat("vector test", "\n") test.sum(list(x = X.vec, na.rm = FALSE), sum.expected.vec) X.mat <- matrix(X.vec, 3, 3, byrow = TRUE) sum.expected.mat.by.col <- c(12, 15, 18) sum.expected.mat.by.row <- c(6, 15, 24) cat("matrix test", "\n") test.sum(list(x = X.mat, na.rm = FALSE), sum.expected.mat.by.col) test.sum(list(x = t(X.mat), na.rm = FALSE), sum.expected.mat.by.row) X.log <- c(TRUE, TRUE, FALSE, TRUE) sum.expected.log <- 3 cat("logical test", "\n") test.sum(list(x = X.log, na.rm = FALSE), sum.expected.log) matlab/tests/strcmp.R0000644000175100001440000000143714245203403014327 0ustar hornikusers### ### $Id: strcmp.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.strcmp <- function(input, expected) { output <- do.call(getFromNamespace("strcmp", "matlab"), input) identical(output, expected) } test.strcmp(list(S = "foo", T = "foo"), TRUE) test.strcmp(list(S = "foo", T = "bar"), FALSE) test.strcmp(list(S = c("foo", "bar"), T = c("foo", "bar")), TRUE) # Case matters... test.strcmp(list(S = c("foo", "bar"), T = c("FOO", "BAR")), FALSE) # Number of elements of each must match... test.strcmp(list(S = c("foo", "bar"), T = c("foo", "bar", "baz")), FALSE) test.strcmp(list(S = c("foo", "bar", "baz"), T = c("xxx", "bar", "xxx")), FALSE) matlab/tests/pascal.R0000644000175100001440000000166214245203403014262 0ustar hornikusers### ### $Id: pascal.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.pascal <- function(input, expected) { output <- do.call(getFromNamespace("pascal", "matlab"), input) identical(output, expected) } pascal.expected.n4 <- matrix(c(1, 1, 1, 1, 1, 2, 3, 4, 1, 3, 6, 10, 1, 4, 10, 20), 4, byrow = TRUE) test.pascal(list(n = 4), pascal.expected.n4) pascal.expected.n3k1 <- matrix(c(1, 0, 0, 1, -1, 0, 1, -2, 1), 3, byrow = TRUE) test.pascal(list(n = 3, k = 1), pascal.expected.n3k1) pascal.expected.n3k2 <- matrix(c(1, 1, 1, -2, -1, 0, 1, 0, 0), 3, byrow = TRUE) test.pascal(list(n = 3, k = 2), pascal.expected.n3k2) matlab/tests/find.R0000644000175100001440000000111414245203403013727 0ustar hornikusers### ### $Id: find.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.find <- function(input, expected) { output <- do.call(getFromNamespace("find", "matlab"), input) identical(output, expected) } X <- c(3, 2, 1, 1, 2, 3) find.expected.eq.one <- c(3, 4) test.find(list(X == 1), find.expected.eq.one) X <- c(1, 0, 4, -3, 0, 0, 0, 8, 6) find.expected.nonzero <- c(1, 3, 4, 8, 9) find.expected.gt.two <- c(3, 8, 9) test.find(list(X), find.expected.nonzero) test.find(list(X > 2), find.expected.gt.two) matlab/tests/magic.R0000644000175100001440000000405614245203403014077 0ustar hornikusers### ### $Id: magic.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.magic <- function(input, expected) { output <- do.call(getFromNamespace("magic", "matlab"), input) identical(output, expected) } magic.expected.3 <- matrix(c(8, 1, 6, 3, 5, 7, 4, 9, 2), nrow = 3, ncol = 3, byrow = TRUE) magic.expected.4 <- matrix(c(16, 2, 3, 13, 5, 11, 10, 8, 9, 7, 6, 12, 4, 14, 15, 1), nrow = 4, ncol = 4, byrow = TRUE) magic.expected.6 <- matrix(c(35, 1, 6, 26, 19, 24, 3, 32, 7, 21, 23, 25, 31, 9, 2, 22, 27, 20, 8, 28, 33, 17, 10, 15, 30, 5, 34, 12, 14, 16, 4, 36, 29, 13, 18, 11), nrow = 6, ncol = 6, byrow = TRUE) magic.expected.10 <- matrix(c(92, 99, 1, 8, 15, 67, 74, 51, 58, 40, 98, 80, 7, 14, 16, 73, 55, 57, 64, 41, 4, 81, 88, 20, 22, 54, 56, 63, 70, 47, 85, 87, 19, 21, 3, 60, 62, 69, 71, 28, 86, 93, 25, 2, 9, 61, 68, 75, 52, 34, 17, 24, 76, 83, 90, 42, 49, 26, 33, 65, 23, 5, 82, 89, 91, 48, 30, 32, 39, 66, 79, 6, 13, 95, 97, 29, 31, 38, 45, 72, 10, 12, 94, 96, 78, 35, 37, 44, 46, 53, 11, 18,100, 77, 84, 36, 43, 50, 27, 59), nrow = 10, ncol = 10, byrow = TRUE) test.magic(list(n = 3), magic.expected.3) # 'n' odd test.magic(list(n = 4), magic.expected.4) # 'n' divisible by four test.magic(list(n = 6), magic.expected.6) # 'n' even but not divisible by four test.magic(list(n = 10), magic.expected.10) matlab/tests/reshape.R0000644000175100001440000000155614245203403014450 0ustar hornikusers### ### $Id: reshape.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.reshape <- function(input, expected, drop = FALSE) { ans <- do.call(getFromNamespace("reshape", "matlab"), input) output <- if (drop) { drop(ans) } else { ans } identical(output, expected) } Xmat.4x3 <- matrix(1:12, nrow = 4, ncol = 3) reshape.expected.mat6x2 <- matrix(1:12, nrow = 6, ncol = 2) test.reshape(list(A = Xmat.4x3, m = 6, n = 2), reshape.expected.mat6x2) test.reshape(list(A = Xmat.4x3, m = 6, n = 2, p = 1), reshape.expected.mat6x2, drop = TRUE) test.reshape(list(A = Xmat.4x3, c(6, 2)), reshape.expected.mat6x2) test.reshape(list(A = Xmat.4x3, matlab::size(reshape.expected.mat6x2)), reshape.expected.mat6x2) matlab/tests/vander.R0000644000175100001440000000233414245203403014273 0ustar hornikusers### ### $Id: vander.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.vander <- function(input, expected) { output <- do.call(getFromNamespace("vander", "matlab"), input) identical(output, expected) } vander.expected.empty <- matrix(as.numeric(NA), nrow=0, ncol=0) vander.expected.scalar <- matrix(1.0, nrow=1, ncol=1) vander.expected.seq3 <- matrix(c( 1, 1, 1, 1, 1, 5.0625, 3.375, 2.25, 1.5, 1, 16, 8, 4, 2, 1, 39.0625, 15.625, 6.25, 2.5, 1, 81, 27, 9, 3, 1), nrow=5, ncol=5, byrow=TRUE) vander.expected.complex <- matrix(c(-1, 0.0 + 1i, 1.0, -4, 0.0 + 2i, 1.0, -9, 0.0 + 3i, 1.0), nrow=3, ncol=3, byrow=TRUE) test.vander(list(v=numeric()), vander.expected.empty) test.vander(list(v=1), vander.expected.scalar) test.vander(list(v=seq(from=1, to=3, by=0.5)), vander.expected.seq3) test.vander(list(v=c(1,2,3)*1i), vander.expected.complex) matlab/tests/mod.R0000644000175100001440000000211014245203403013563 0ustar hornikusers### ### $Id: mod.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.mod <- function(input, expected) { output <- do.call(getFromNamespace("mod", "matlab"), input) identical(output, expected) } mod.expected.scalar <- 3 mod.expected.vec <- c(1, 2, 0, 1, 2) test.mod(list(x = 13, y = 5), mod.expected.scalar) test.mod(list(x = 1:5, y = 3), mod.expected.vec) ## by convention any.nonzero <- 1 test.mod(list(x = any.nonzero, y = 0), any.nonzero) ## HWB 2011/03/08 test.mod(list(x = any.nonzero, y = any.nonzero), 0) ## get complicated test.mod(list(x = 5, y = c(1, 2, 0, NaN, Inf)), c(0, 1, 5, NaN, NaN)) test.mod(list(x = 1:5, y = c(1, 2, 0, NaN, Inf)), c(0, 0, 3, NaN, NaN)) ## rem & mod give same results with X, Y having same sign test.mod(list(x = 5, y = 3), matlab::rem(5, 3)) test.mod(list(x = -5, y = -3), matlab::rem(-5, -3)) ## alternate formula used when X, Y having different signs test.mod(list(x = 5, y = -3), (matlab::rem(5, -3) - -3)) test.mod(list(x = -5, y = 3), (matlab::rem(-5, 3) - 3)) matlab/tests/isprime.R0000644000175100001440000000240514245203403014463 0ustar hornikusers### ### $Id: isprime.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.isprime <- function(input, expected) { output <- do.call(getFromNamespace("isprime", "matlab"), input) identical(output, expected) } isprime.expected.n1 <- 0 isprime.expected.n2 <- 1 isprime.expected.n100 <- c(0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0) isprime.expected.10x10 <- matrix(isprime.expected.n100, nrow=10, ncol=10, byrow=TRUE) test.isprime(list(x=1), isprime.expected.n1) test.isprime(list(x=2), isprime.expected.n2) test.isprime(list(x=1:100), isprime.expected.n100) test.isprime(list(x=matrix(1:100, nrow=10, 10, byrow=TRUE)), isprime.expected.n100) matlab/tests/fix.R0000644000175100001440000000057514245203403013607 0ustar hornikusers### ### $Id: fix.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.fix <- function(input, expected) { output <- do.call(getFromNamespace("fix", "matlab"), input) identical(output, expected) } X <- c(-1.9, -0.2, 3.4, 5.6, 7.0) fix.expected <- c(-1, 0, 3, 5, 7) test.fix(list(X), fix.expected) matlab/tests/meshgrid.R0000644000175100001440000000314214245203403014614 0ustar hornikusers### ### $Id: meshgrid.R 22 2022-05-30 18:03:47Z proebuck $ ### ##----------------------------------------------------------------------------- test.meshgrid <- function(input, expected) { output <- do.call(getFromNamespace("meshgrid", "matlab"), input) identical(output, expected) } x1 <- 1:3 y1 <- 10:14 meshgrid.expected.xy <- list(x = matrix(rep(x1, length(y1)), nrow = length(y1), ncol = length(x1), byrow = TRUE), y = matrix(rep(y1, length(x1)), nrow = length(y1), ncol = length(x1))) test.meshgrid(list(x = 0), meshgrid.expected.xy) test.meshgrid(list(x = x1, y = y1), meshgrid.expected.xy) x2 <- 5:8 y2 <- 10:14 z2 <- 2:3 meshgrid.expected.xyz <- list(x = array(matrix(rep(x2, length(y2)), nrow = length(y2), ncol = length(x2), byrow = TRUE), c(length(y2), length(x2), length(z2))), y = array(rep(y2, length(x2)), c(length(y2), length(x2), length(z2))), z = array(sapply(z2, function(val, len) rep(val, len), length(y2) * length(x2)), c(length(y2), length(x2), length(z2)))) test.meshgrid(list(x = x2, y = y2, z = z2, nargout = 3), meshgrid.expected.xyz) matlab/MD50000644000175100001440000001432014640471532012046 0ustar hornikusers8cabbde38d51ca485e29a04efae3ae88 *DESCRIPTION e4a17a2ac301ccf65155d6662e0f9064 *NAMESPACE 16e34721f71cda024c1a798b30b242de *NEWS 2fd8d25e3404a83452ca49d64db0a413 *R/ceil.R 5649cf69f2f764bab407e26d942a8a51 *R/cell.R fa216cfeea1cfd9f160e8585b6a9d10c *R/colorbar.R 62f8eef85335108849e98fec11ce4e9a *R/eye.R 6543c0c9a387e3212816e5fb4c7d4b67 *R/factors.R 5ad154c56efcc89f42ac1a2fd2f4f711 *R/fileparts.R c731d40b5bdc358d90c8251265de774b *R/filesep.R 6da1d193063f9661fbd7ab0cf808e93f *R/find.R 34ccab0d2771cc4024cb59a912cec872 *R/fix.R b44f3300d8076adc43119d2d6749c862 *R/fliplr.R e3f5e891f48bacc10402c28f7ad82bf9 *R/flipud.R 12aa95a16a6541adb80210fea6ef9ed7 *R/fullfile.R 944980f51be4feb23fe4ab40b14ee986 *R/hilb.R 7724cb36581dda5e111387cb458b59f7 *R/imagesc.R 482d535c41e3cf22f593b41283ebbc43 *R/isempty.R 17c5bffa30f70c95c432f81a814a6438 *R/isprime.R c66d9f5fab71f1ef8d061fadbc8e93c7 *R/jet.colors.R bf3e7b5a1be8c9af807a5f7d809225be *R/linspace.R fa233c03d464d6e38737d60a901cd615 *R/logspace.R 958c4440f8d0558bfbcaaad5ee0f7ad2 *R/magic.R 5aa373bf259a4a624d5f8b6ce8d3d4b3 *R/meshgrid.R 70d7a1f43a1b445145141f2bc60bec26 *R/mkconstarray.R 01e8eb60eada8c0c4f55ac560d463e5a *R/mod.R 8ad77e320d868b72b0d31b4f4a3a1b1a *R/multiline.plot.colors.R 2fa307987bf43f10693ca3b5d8e65656 *R/ndims.R f359dad865cacf5ae89980610c0ebb27 *R/nextpow2.R c0fd5ed53efc158ea27f1844fb9e68e3 *R/numel.R f4c15a28df65279119014226ea0d8d8c *R/ones.R 668a0aea5dc54798e79b93b333256f2c *R/padarray.R 8aac7723e95c881a51b38c6a8043113b *R/pascal.R 4e5a3ad9f6de6981e50cab607d1f3ceb *R/pathsep.R 35c8e0ef3f4689eaac9bc0e759e5bda6 *R/pow2.R 93e1dd1c0979af2b938ba1e1699766a2 *R/primes.R c1adb702b61ed96921c1437c81adbb6e *R/rem.R e91a59797a3e151eb93694c77826ef19 *R/repmat.R 08375ded3f0d1312603bf7f380fb3ecd *R/reshape.R d5a7728a5a323303d1fe84440418e5f4 *R/rosser.R 997f8d14a97ea07cbdd2adf2c835f699 *R/rot90.R ebe89815eee6175b96cda2e7a3b847b0 *R/size.R 05362603e46e86eb3ae1d5f37832402c *R/size_t-class.R 87dcbafc317e8ecc85192ecdfd18ba0c *R/std.R bfb59d2b321f2242e489a50aa614cff2 *R/strcmp.R 3e111917d50e5e1d3e29cd5df2c8cc1a *R/sum.R bec2053409d6ac22424a2dd49e6b5b9e *R/tictoc.R 9766839904a01bc17a737a6b4d7f7f7e *R/vander.R 14de91d2fd536a951dd365e36f6ca141 *R/zeros.R eab2eb656d2eac69dadcda8519b6b1c4 *R/zzz.R 5886c2dd7900e0b5230b7896911422f9 *build/stage23.rdb 269462414077dfa7b40265b251e48743 *inst/COPYRIGHTS fa654ee774f160767ab9735a4f2bab9a *man/ceil.Rd e58b53b5fbc6dce24d93e3fab2ec676b *man/cell.Rd ac8ff1712d0030ddf6ff9d43bcaa598f *man/colorbar.Rd 22cdfccfcee92f95ae72bf1fc0d61b4d *man/eye.Rd 6ad2e4353060322e48caaa8feb03425a *man/factors.Rd 0216e8aeda4e93ab848880a2ef5c29e0 *man/fileparts.Rd 34a561cbb5119255326a47e88af9beab *man/filesep.Rd bd1a8ed5142a893da5894ae2219e2280 *man/find.Rd bc18bba5a1c8610780cdc930283c8b4a *man/fix.Rd bc5db007a171223cef5727494d734892 *man/fliplr.Rd 713104c18166ed7d9db4c3e4d5195225 *man/fullfile.Rd 145c3510557820960368e1b273628cc6 *man/hilb.Rd dc27a45e265094b0c07c7c50a5079f9c *man/imagesc.Rd 7ed7d04517b05259ef87ad74350b4b52 *man/isempty.Rd e24c66d8df3d757707f639e6c14bbbb2 *man/isprime.Rd fc314623f852c8a86df7a5d22d7fc393 *man/jet.colors.Rd 0d8bada52926effa82caed0a7ff91f67 *man/linspace.Rd cfd38673cb33c2be9c915b484f967d75 *man/logspace.Rd 61b9cce2b7121748933b6eb702e89f76 *man/magic.Rd 567b7ba528a3d697d86183ca67c774f3 *man/matlab-package.Rd dadabcad35ef9604a508e676932fdcb1 *man/meshgrid.Rd 0e7839955075b8829edfa95cbbbcc06f *man/mod.Rd da691a0d272d7d1d23206a5348aa9f41 *man/multiline.plot.colors.Rd 43dbef85e24506f583093e127210fc55 *man/ndims.Rd 64829e63e1fce8722cda00fd86621009 *man/nextpow2.Rd f82030fb36265e6e5e05845f0ed8caa8 *man/numel.Rd ae13faa0117f6cd1396ec80899c9da34 *man/ones.Rd dc30a0652794df6f48f386a284a61469 *man/padarray.Rd 27da2c95a830fe06b8dd5cba93a1665e *man/pascal.Rd a56ff461e3d572f760a4eb5f1b8b4ba3 *man/pathsep.Rd 30992235da622b7d92d1bbf2e640acf4 *man/pow2.Rd fdc24dd27ede9a44162e322bde19a9d2 *man/primes.Rd d97c305f213eae2f96c434d78a2b0752 *man/repmat.Rd 1cca95ff8317e4f74fe87d18f4767ef0 *man/reshape.Rd b2a01f69208c949e07220876ae71ec8d *man/rosser.Rd 4f7bc0a37e526a77efd3a9db009c73a0 *man/rot90.Rd 8df7380dd54c6c2eefb60b4483c805a0 *man/size.Rd 34f218a9de27dc70c64ddc479d08a9eb *man/size_t-class.Rd 802707eb45be7d52b68474fbf97800e0 *man/std.Rd 23c618192c09c274145918f7ab5203d9 *man/strcmp.Rd 7650a60b0cd224b3c3126abe0d1a5d32 *man/sum.Rd a00e94163b6d0e44c6d1bfb534bbffda *man/tictoc.Rd bb0d9ced849cb34582ac4b9f2dfea182 *man/vander.Rd 88bf46554a9c48a76a6c6a1bc5f01118 *tests/ceil.R 2a1f2ca5e65a1b2d1dd629e93ddffe5a *tests/cell.R 5163921d395e870f09018d2cfec8afb9 *tests/eye.R fc1ae417a31d34ca76e1f965094aeb13 *tests/factors.R 1c7fbd08a0bc21fa605ce91b2150190c *tests/fileparts.R c2c85417f4c6531a212b83e3a4b0ecfd *tests/find.R b768953c8ef5176696288cdc5b742f5d *tests/fix.R f9669ca5cb34e41d8d9ed1c912196f03 *tests/fliplr.R d0b6798f1a11abc6f778f729bca27a22 *tests/flipud.R 4be4504c67be9e4e676bf51afa72a550 *tests/fullfile.R 21a1bbbf4fd675ab7e0ad45286228a76 *tests/hilb.R e3a29d0f49b96264be731065289d8c04 *tests/isempty.R 88e1b54be316c83684ebf2a72a8d518c *tests/isprime.R 78706a315ba7f2443bb5445a361a8c1d *tests/jet.colors.R 117cad05c765d2421625d3b1724bab8c *tests/linspace.R 99277f872817bf7a46d7559dbdcdd3ed *tests/logspace.R ffbfece8ccbe4b90b0b89a2c8213b0b3 *tests/magic.R b45dfdabf8aec7f5fa8343e72e81dd39 *tests/meshgrid.R 185ab7ad8c46894ad8f52f19c48dc64b *tests/mkconstarray.R 65df3ba96dba23472dfe21b620c0432c *tests/mod.R 7f8c2df87abc7b5e5f7ba0981b1e5c76 *tests/ndims.R 8a104c5e5b4996e9ef36bfd44ad0919d *tests/nextpow2.R e945388f9196c60f7205647f31e8cdfd *tests/numel.R b9ff5caf409e6389bcf592b2a247cf73 *tests/ones.R 0d27a5a026afb09f943c7b7715667d18 *tests/padarray.R 5c58d4cba2d4edc3f552fb9857e83110 *tests/pascal.R 15534f64a880229906db5d4672925741 *tests/pow2.R ba96f79d41b3e40aefd8a6792606e655 *tests/primes.R a8db8cc2b5582a6cc02256bb03a92640 *tests/rem.R 735edc9c1352bd89d00eb6d6f9817970 *tests/repmat.R 0411d5add3741c26d7b96088755fdaf5 *tests/reshape.R c4594146c3bd6cb9197c38029f15ea5a *tests/rot90.R 4f7aaeeb268135847da7e3145ca45309 *tests/size.R 54f65c3d8b0192ec9609b2c91d6a2577 *tests/std.R 07b9d472dd7f9b0993c18c5c071d81c6 *tests/strcmp.R f393ae774b7627282e5783f928259fd3 *tests/sum.R 2d9cddd0195aa4479b89675df4145286 *tests/tictoc.R 76155d9731bd1ab0ed88ae83b16081ea *tests/vander.R 58b55f0453df62f2fc11f0b620767ce8 *tests/zeros.R matlab/R/0000755000175100001440000000000014245524745011745 5ustar hornikusersmatlab/R/size.R0000644000175100001440000000650614245246376013052 0ustar hornikusers### ### $Id: size.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Array dimensions. ### ##----------------------------------------------------------------------------- setGeneric("size", function(X, dimen) { #cat("generic", match.call()[[1]], "\n") standardGeneric("size") }) setMethod("size", signature(X = "vector", dimen = "missing"), function(X, dimen) { #cat(match.call()[[1]], "(vector, missing)", "\n") # return(as.size_t(length(X))) # :NOTE: Incompatible with previous implementation but consistent with MATLAB callGeneric(matrix(X, nrow = 1)) }) setMethod("size", signature(X = "matrix", dimen = "missing"), function(X, dimen) { #cat(match.call()[[1]], "(matrix, missing)", "\n") as.size_t(dim(X)) }) setMethod("size", signature(X = "array", dimen = "missing"), function(X, dimen) { #cat(match.call()[[1]], "(array, missing)", "\n") as.size_t(dim(X)) }) setMethod("size", signature(X = "vector", dimen = "numeric"), function(X, dimen) { #cat(match.call()[[1]], "(vector, numeric)", "\n") callGeneric(matrix(X, nrow = 1), dimen) }) setMethod("size", signature(X = "matrix", dimen = "numeric"), function(X, dimen) { #cat(match.call()[[1]], "(matrix, numeric)", "\n") callGeneric(X, as.integer(dimen)) }) setMethod("size", signature(X = "matrix", dimen = "integer"), function(X, dimen) { #cat(match.call()[[1]], "(matrix, integer)", "\n") getLengthOfDimension(X, dimen) }) setMethod("size", signature(X = "array", dimen = "numeric"), function(X, dimen) { #cat(match.call()[[1]], "(array, numeric)", "\n") callGeneric(X, as.integer(dimen)) }) setMethod("size", signature(X = "array", dimen = "integer"), function(X, dimen) { #cat(match.call()[[1]], # "(", data.class(X), ", ", data.class(dimen), ")", "\n") getLengthOfDimension(X, dimen) }) setMethod("size", signature(X = "missing", dimen = "ANY"), function(X, dimen) { #cat(match.call()[[1]], "(missing, ANY)", "\n") stop(sprintf("argument %s missing", sQuote("X"))) }) ##----------------------------------------------------------------------------- getLengthOfDimension <- function(X, dimen) { if (!is.array(X)) { stop(sprintf("argument %s must be matrix or array", sQuote("X"))) } if (!(length(dimen) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("dimen"))) } else if (dimen < 1) { stop(sprintf("argument %s must be a positive quantity", sQuote("dimen"))) } len <- if (dimen <= length(dim(X))) { dim(X)[dimen] } else { 1 # singleton dimension } as.integer(len) } matlab/R/repmat.R0000644000175100001440000000444614245246376013371 0ustar hornikusers### ### $Id: repmat.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Replicate and tile an array. ### ##----------------------------------------------------------------------------- repmat <- function(A, ...) { nargs <- length(dots <- list(...)) dims <- as.integer(if (nargs == 1 && is.size_t(dots[[1]])) { dots[[1]] } else { unlist(dots) }) if (length(dims) == 1) { dims[2] <- dims[1] } if (!(length(dims) > 1)) { stop("dimensions must be of length greater than 1") } else if (!(all(dims > 0))) { stop("dimensions must be a positive quantity") } B <- switch(EXPR = mode(A), logical =, complex =, numeric = { if (all(dims == 1)) { ## nothing to do in this case A } else if (dims[length(dims)] == 1) { ## avoid dropping single dimension before replication t(kronecker(array(1, rev(dims)), A)) } else { kronecker(array(1, dims), A) } }, character = { ## convert unique strings to factors fA <- factor(A, levels = unique(A)) ## recursive call using integer version of A iA.mat <- Recall(unclass(fA), dims) ## replace integers with strings according to factor values saved.dim <- dim(iA.mat) cA.mat <- sapply(seq(along = iA.mat), function(i, A, fac) { A[i] <- levels(fac)[A[i]] }, iA.mat, fA) dim(cA.mat) <- saved.dim cA.mat }, NULL) if (is.null(B)) { stop(sprintf("argument %s must be one of [%s]", sQuote("A"), paste(c("numeric", "logical", "complex", "character"), collapse = "|"))) } B } matlab/R/logspace.R0000644000175100001440000000047614245203403013655 0ustar hornikusers### ### $Id: logspace.R 22 2022-05-30 18:03:47Z proebuck $ ### ### Generate logarithmically spaced vectors. ### ##----------------------------------------------------------------------------- logspace <- function(a, b, n = 50) { if (b == pi) { b <- log10(pi) } 10 ^ matlab::linspace(a, b, n) } matlab/R/colorbar.R0000644000175100001440000000610614245203403013657 0ustar hornikusers### ### $Id: colorbar.R 22 2022-05-30 18:03:47Z proebuck $ ### ### Displays colorbar showing the color scale. ### SIDE.BELOW <- as.integer(1) SIDE.LEFT <- as.integer(2) SIDE.ABOVE <- as.integer(3) SIDE.RIGHT <- as.integer(4) LAS.PARALLEL <- as.integer(0) LAS.HORIZONTAL <- as.integer(1) LAS.PERPENDICULAR <- as.integer(2) LAS.VERTICAL <- as.integer(3) ##----------------------------------------------------------------------------- colorbar <- function(C, location = c("EastOutside", "WestOutside", "NorthOutside", "SouthOutside"), ...) { if (!is.numeric(C)) { stop(sprintf("argument %s must be numeric", sQuote("C"))) } if (!is.character(location)) { stop(sprintf("argument %s must be character", sQuote("location"))) } location <- match.arg(location) range.C <- range(C) min.lim.C <- round(range.C[1]) max.lim.C <- round(range.C[2]) seq.lim.C <- seq(min.lim.C, max.lim.C) colorbar.EO <- function(...) { ## Swap number of lines of margin on left and right sides ## to give enough room to draw the tickmark labels on right saved.par <- par(mar = c(5, 2, 4, 4) + 0.1) on.exit(par(saved.par)) graphics::image(x = 1, y = seq.lim.C, z = t(matrix(seq.lim.C, ncol = 1)), ann = FALSE, xaxt = "n", yaxp = c(min.lim.C, max.lim.C, 5), axes = FALSE, ...) axis(SIDE.RIGHT, axTicks(SIDE.RIGHT), las = LAS.HORIZONTAL) box() } colorbar.WO <- function(...) { graphics::image(x = 1, y = seq.lim.C, z = t(matrix(seq.lim.C, ncol = 1)), ann = FALSE, xaxt = "n", yaxp = c(min.lim.C, max.lim.C, 5), las = LAS.HORIZONTAL, ...) } colorbar.NO <- function(...) { graphics::image(x = seq.lim.C, y = 1, z = t(matrix(seq.lim.C, nrow = 1)), ann = FALSE, xaxp = c(min.lim.C, max.lim.C, 5), yaxt = "n", axes = FALSE, ...) axis(SIDE.ABOVE, axTicks(SIDE.ABOVE)) box() } colorbar.SO <- function(...) { graphics::image(x = seq.lim.C, y = 1, z = t(matrix(seq.lim.C, nrow = 1)), ann = FALSE, xaxp = c(min.lim.C, max.lim.C, 5), yaxt = "n", ...) } switch(EXPR = location, EastOutside = colorbar.EO(...), WestOutside = colorbar.WO(...), SouthOutside = colorbar.SO(...), NorthOutside = colorbar.NO(...)) invisible(NULL) } matlab/R/zeros.R0000644000175100001440000000131614245246376013234 0ustar hornikusers### ### $Id: zeros.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Create a matrix of all zeros. ### ##----------------------------------------------------------------------------- zeros <- function(...) { nargs <- length(dots <- list(...)) dims <- as.integer(if (nargs == 1 && is.size_t(dots[[1]])) { dots[[1]] } else { unlist(dots) }) if (length(dims) == 1) { dims[2] <- dims[1] } if (!(length(dims) > 1)) { stop("dimensions must be of length greater than 1") } else if (!(all(dims > 0))) { stop("dimensions must be a positive quantity") } array(0, dims) } matlab/R/padarray.R0000644000175100001440000002041714245246376013700 0ustar hornikusers### ### $Id: padarray.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Pad a vector. ### ##----------------------------------------------------------------------------- setGeneric("padarray", function(A, padsize, padval = 0, direction = c("both", "pre", "post")) { #cat("generic", match.call()[[1]], "\n") standardGeneric("padarray") }) setMethod("padarray", signature(A = "array", padsize = "numeric", padval = "missing", direction = "missing"), function(A, padsize, padval, direction) { #cat(match.call()[[1]], "(array, numeric, missing, missing)", "\n") callGeneric(A, padsize, padval, direction) }) setMethod("padarray", signature(A = "array", padsize = "numeric", padval = "ANY", direction = "character"), function(A, padsize, padval, direction) { #cat(match.call()[[1]], "(array, numeric, ANY, character)", "\n") method <- "constant" padarray0(A, method, padsize, padval, match.arg(direction)) }) setMethod("padarray", signature(A = "array", padsize = "numeric", padval = "character", direction = "character"), function(A, padsize, padval, direction) { #cat(match.call()[[1]], "(array, numeric, character, character)", "\n") ## third parameter is overloaded if (padval %in% c("circular", "replicate", "symmetric")) { method <- padval padval <- NA } else { method <- "constant" } padarray0(A, method, padsize, padval, match.arg(direction)) }) setMethod("padarray", signature(A = "vector", padsize = "numeric", padval = "ANY", direction = "ANY"), function(A, padsize, padval, direction) { #cat(match.call()[[1]], "(vector, numeric, ANY, ANY)", "\n") callGeneric(matrix(A, nrow = 1), padsize, padval, direction) }) ##----------------------------------------------------------------------------- padarray0 <- function(a, method = c("constant", "circular", "replicate", "symmetric"), padsize, padval, direction = c("both", "pre", "post")) { #cat(match.call()[[1]], "(array, character, numeric, ANY, character)", "\n") #cat("a =", a, "\n") #cat("method =", method, "\n") #cat("padsize =", padsize, "\n") #cat("padval =", padval, "\t", "(", data.class(padval), ")", "\n") #cat("direction =", direction, "\n") method <- match.arg(method) direction <- match.arg(direction) if (length(padsize) < matlab::ndims(a)) { padsize[matlab::ndims(a)] <- 0 } if (!(length(padval) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("padval"))) } if (method == "constant" && !(is.numeric(a) || is.logical(a))) { stop(sprintf("argument %s must be numeric or logical for constant padding", sQuote("a"))) } b <- if (matlab::isempty(a)) { sizeB <- if (direction == "both") { matlab::size(a) + 2*padsize } else { matlab::size(a) + padsize } mkconstarray(data.class(a), padval, sizeB) } else { switch(EXPR = method, constant = constantPad(a, padsize, padval, direction), circular = circularPad(a, padsize, direction), symmetric = symmetricPad(a, padsize, direction), replicate = replicatePad(a, padsize, direction)) } if (is.logical(a)) { mode(b) <- "logical" } b } ##----------------------------------------------------------------------------- constantPad <- function(a, padsize, padval, direction) { numDims <- matlab::numel(padsize) ## Form index vectors to subassign input array into output array. ## Also compute the size of the output array. idx <- matlab::cell(1, numDims) sizeB <- matlab::zeros(1, numDims) for (k in seq(1, numDims)) { M <- matlab::size(a, k) switch(EXPR = direction, pre = { idx[[k]] <- (1:M) + padsize[k] sizeB[k] <- M + padsize[k] }, post = { idx[[k]] <- 1:M sizeB[k] <- M + padsize[k] }, both = { idx[[k]] <- (1:M) + padsize[k] sizeB[k] <- M + 2*padsize[k] }) } ## Initialize output array with padding value. ## Make sure output array is same type as the input. b <- mkconstarray(mode(a), padval, sizeB) do.call("[<-", c(list(b), idx, list(a))) } ##----------------------------------------------------------------------------- circularPad <- function(a, padsize, direction) { numDims <- matlab::numel(padsize) ## Form index vectors to subassign input array into output array. ## Also compute the size of the output array. idx <- matlab::cell(1, numDims) for (k in seq(1, numDims)) { M <- matlab::size(a, k) dimNums <- 1:M p <- padsize[k] switch(EXPR = direction, pre = { idx[[k]] <- dimNums[matlab::mod(-p:(M-1), M) + 1] }, post = { idx[[k]] <- dimNums[matlab::mod(0:(M+p-1), M) + 1] }, both = { idx[[k]] <- dimNums[matlab::mod(-p:(M+p-1), M) + 1] }) } do.call("[", c(list(a), idx)) } ##----------------------------------------------------------------------------- symmetricPad <- function(a, padsize, direction) { numDims <- matlab::numel(padsize) ## Form index vectors to subassign input array into output array. ## Also compute the size of the output array. idx <- matlab::cell(1, numDims) for (k in seq(1, numDims)) { M <- matlab::size(a, k) dimNums <- c(1:M, seq(from = M, to = 1, by = -1)) p <- padsize[k] switch(EXPR = direction, pre = { idx[[k]] <- dimNums[matlab::mod(-p:(M-1), 2*M) + 1] }, post = { idx[[k]] <- dimNums[matlab::mod(0:(M+p-1), 2*M) + 1] }, both = { idx[[k]] <- dimNums[matlab::mod(-p:(M+p-1), 2*M) + 1] }) } do.call("[", c(list(a), idx)) } ##----------------------------------------------------------------------------- replicatePad <- function(a, padsize, direction) { numDims <- matlab::numel(padsize) ## Form index vectors to subassign input array into output array. ## Also compute the size of the output array. idx <- matlab::cell(1, numDims) for (k in seq(1, numDims)) { M <- matlab::size(a, k) p <- padsize[k] onesVector <- if (p > 0) { matlab::ones(1, p) } else { NULL } switch(EXPR = direction, pre = { idx[[k]] <- c(onesVector, 1:M) }, post = { idx[[k]] <- c(1:M, M*onesVector) }, both = { idx[[k]] <- c(onesVector, 1:M, M*onesVector) }) } do.call("[", c(list(a), idx)) } matlab/R/linspace.R0000644000175100001440000000171514245203403013653 0ustar hornikusers### ### $Id: linspace.R 22 2022-05-30 18:03:47Z proebuck $ ### ### Generate linearly spaced vectors. ### ##----------------------------------------------------------------------------- linspace <- function(a, b, n = 100) { if (!is.numeric(a)) { stop(sprintf("argument %s must be numeric", sQuote("a"))) } else if (!(length(a) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("a"))) } if (!is.numeric(b)) { stop(sprintf("argument %s must be numeric", sQuote("b"))) } else if (!(length(b) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("b"))) } if (!is.numeric(n)) { stop(sprintf("argument %s must be numeric", sQuote("n"))) } else if (!(length(n) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("n"))) } n <- floor(n) ## Undocumented but required if (n < 2) { b } else { seq(a, b, length = n) } } matlab/R/multiline.plot.colors.R0000644000175100001440000000155014245246376016351 0ustar hornikusers### ### $Id: multiline.plot.colors.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Create a vector of colors equivalent to MATLAB's default colors to use ### for multiline plots. ### ##----------------------------------------------------------------------------- multiline.plot.colors <- function() { get.gca.colororder <- function() { colors <- c(rgb(0.00, 0.00, 1.00), # blue rgb(0.00, 0.50, 0.00), rgb(1.00, 0.00, 0.00), # red rgb(0.00, 0.75, 0.75), rgb(0.75, 0.00, 0.75), rgb(0.75, 0.75, 0.00), rgb(0.25, 0.25, 0.25)) # grey25 i.named.colors <- c(1, 3, 7) names(colors)[i.named.colors] <- c("blue", "red", "grey25") names(colors)[-i.named.colors] <- "" colors } get.gca.colororder() } matlab/R/numel.R0000644000175100001440000000051514245246376013212 0ustar hornikusers### ### $Id: numel.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Provides number of elements. ### ##----------------------------------------------------------------------------- numel <- function(A, varargin) { if (!missing(varargin)) { stop("not implemented") # need example } prod(matlab::size(A)) } matlab/R/cell.R0000644000175100001440000000163114245246376013011 0ustar hornikusers### ### $Id: cell.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Create cell array. ### ##----------------------------------------------------------------------------- cell <- function(...) { nargs <- length(dots <- list(...)) dims <- as.integer(if (nargs == 1 && is.size_t(dots[[1]])) { dots[[1]] } else { unlist(dots) }) if (length(dims) == 1) { dims[2] <- dims[1] } if (!(length(dims) > 1)) { stop("dimensions must be of length greater than 1") } else if (!(all(dims > 0))) { stop("dimensions must be a positive quantity") } createCellArray <- function(dims) { L <- vector("list", prod(dims)) dim(L) <- dims for (i in seq(along = L)) { L[[i]] <- numeric(0) } return(L) } createCellArray(dims) } matlab/R/flipud.R0000644000175100001440000000275614245246376013366 0ustar hornikusers### ### $Id: flipud.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Flip matrices up-down. ### ##----------------------------------------------------------------------------- setGeneric("flipud", function(object) { #cat("generic", match.call()[[1]], "\n") standardGeneric("flipud") }) setMethod("flipud", signature(object = "vector"), function(object) { #cat(match.call()[[1]], "(vector)", "\n") rev(object) }) setMethod("flipud", signature(object = "matrix"), function(object) { #cat(match.call()[[1]], "(matrix)", "\n") m <- matlab::size(object)[1] object[m:1, ] }) setMethod("flipud", signature(object = "array"), function(object) { #cat(match.call()[[1]], "(array)", "\n") stop(sprintf("argument %s must be vector or matrix", sQuote("object"))) }) setMethod("flipud", signature(object = "ANY"), function(object) { #cat(match.call()[[1]], "(ANY)", "\n") stop(sprintf("method not defined for %s argument", data.class(object))) }) setMethod("flipud", signature(object = "missing"), function(object) { #cat(match.call()[[1]], "(missing)", "\n") stop(sprintf("argument %s missing", sQuote("object"))) }) matlab/R/mkconstarray.R0000644000175100001440000000117514245246376014612 0ustar hornikusers### ### $Id: mkconstarray.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Create a constant array of specified class. ### ##----------------------------------------------------------------------------- mkconstarray <- function(class.type = c("character", "complex", "double", "integer", "logical", "numeric"), value, size) { matlab::repmat(as(value, match.arg(class.type)), size) } matlab/R/tictoc.R0000644000175100001440000000132214245246376013354 0ustar hornikusers### ### $Id: tictoc.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Stopwatch timer. ### ##----------------------------------------------------------------------------- tic <- function(gcFirst = FALSE) { if (gcFirst == TRUE) { gc(verbose = FALSE) } assign("savedTime", proc.time()[3], envir = .MatlabNamespaceEnv) invisible() } ##----------------------------------------------------------------------------- toc <- function(echo = TRUE) { prevTime <- get("savedTime", envir = .MatlabNamespaceEnv) diffTimeSecs <- proc.time()[3] - prevTime if (echo) { cat(sprintf("elapsed time is %f seconds", diffTimeSecs), "\n") invisible() } else { diffTimeSecs } } matlab/R/fileparts.R0000644000175100001440000000562114245246376014066 0ustar hornikusers### ### $Id: fileparts.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Return filename parts. ### ##----------------------------------------------------------------------------- fileparts <- function(pathname) { if (!is.character(pathname)) { stop(sprintf("argument %s must be character", sQuote("pathname"))) } else if (!(length(pathname) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("pathname"))) } ## R only expands a single tilde, optionally followed by sep wouldExpandTilde <- function(pathname) { possible <- substr(pathname, 1, 2) ((nchar(possible) == 1 && possible == "~") || (nchar(possible) == 2 && substr(possible, 2, 2) == "/")) } tildeUser <- character(0) hasTilde <- substr(pathname, 1, 1) == "~" if (hasTilde && wouldExpandTilde(pathname)) { ## Augment tilde with bogus value prevent expansion by path.expand luser <- "xxxxxx" # :HACK: assumed not to exist tildeUser <- paste("~", luser, sep = "") pathname <- sub("~", tildeUser, pathname) } fname <- basename(pathname) if (fname == pathname) { pathstr <- "" } else { hasTrailingSep <- function(pathname) { nchars <- nchar(pathname) lastChar <- substr(pathname, nchars, nchars) ## :TODO: There must be a standard function for the following... if (.Platform$OS.type == "windows") { lastChar == "/" || lastChar == "\\" } else { lastChar == "/" } } pathstr <- if (hasTrailingSep(pathname)) { fname <- "" ## dirname normalizes path ending with fsep so ## append a character so trailing sep is kept dirname(paste(pathname, "x", sep = "")) } else { dirname(pathname) } } if (fname == ".") { ## Handle relative current directory name <- character(0) ext <- "." } else if (fname == "..") { ## Handle relative parent directory name <- "." ext <- "." } else { name <- { ext.re <- "\\.[^\\.]*$" # match from last period to end sub(ext.re, "", fname) } if (name == "") { ## Handle UNIX hidden files name <- character(0) ext <- fname } else { split.re <- name ext <- unlist(strsplit(fname, split.re, fixed = TRUE))[2] } } if (length(tildeUser) > 0) { switch(EXPR = charmatch("~", c(pathstr, name)), pathstr <- sub(tildeUser, "~", pathstr), name <- sub(tildeUser, "~", name)) } list(pathstr = pathstr, name = name, ext = ifelse(!is.na(ext), ext, ""), versn = "") } matlab/R/eye.R0000644000175100001440000000207614245246376012660 0ustar hornikusers### ### $Id: eye.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Create an identity matrix. ### ##----------------------------------------------------------------------------- eye <- function(m, n) { if (is.size_t(m)) { m <- as.integer(m) } if (missing(n)) { len.m <- length(m) if (len.m == 1) { n <- m } else if (len.m > 1) { n <- m[-1] m <- m[1] } } if (!is.numeric(n)) { stop(sprintf("argument %s must be numeric", sQuote("n"))) } else if (!(length(n) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("n"))) } else if (!(n > 0)) { stop(sprintf("argument %s must be a positive quantity", sQuote("n"))) } if (!is.numeric(m)) { stop(sprintf("argument %s must be numeric", sQuote("m"))) } else if (!(length(m) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("m"))) } else if (!(m > 0)) { stop(sprintf("argument %s must be a positive quantity", sQuote("m"))) } diag(1, m, n) } matlab/R/imagesc.R0000644000175100001440000000354514245203403013470 0ustar hornikusers### ### $Id: imagesc.R 22 2022-05-30 18:03:47Z proebuck $ ### ### Displays matrix C as an image with its data scaled to use the full ### color palette. ### ##----------------------------------------------------------------------------- imagesc <- function(x = seq(ncol(C)), y = seq(nrow(C)), C, col = jet.colors(12), ...) { if (missing(C)) { if (!missing(x)) { if (is.null(dim(x))) { stop(sprintf("argument %s must be matrix-like", sQuote("x"))) } C <- x x <- seq(ncol(C)) } else { stop(sprintf("argument %s not specified", sQuote("C"))) } } if (any(diff(x) <= 0) || any(diff(y) <= 0)) { stop(sprintf("increasing %s and %s values expected", sQuote("x"), sQuote("y"))) } if (!(is.numeric(C) && is.matrix(C))) { stop(sprintf("argument %s must be matrix", sQuote("C"))) } range.C <- range(C) min.lim.C <- round(range.C[1]) max.lim.C <- round(range.C[2]) graphics::image(x = x, y = y, z = t(C)[,nrow(C):1], zlim = c(min.lim.C, max.lim.C), axes = FALSE, col = col, ...) pretty.axp <- function(axp.name = c("xaxp", "yaxp"), ...) { axp.name <- match.arg(axp.name) dots <- list(...) axp <- if (axp.name %in% names(dots)) { dots[[axp.name]] } else { par(axp.name) } pretty(axp[1]:axp[2], axp[3]) } at.x <- pretty.axp("xaxp", ...) axis(SIDE.BELOW, at.x) at.y <- pretty.axp("yaxp", ...) axis(SIDE.LEFT, at.y, labels = rev(at.y), las = LAS.HORIZONTAL) box() invisible(NULL) } matlab/R/rosser.R0000644000175100001440000000137414245203403013373 0ustar hornikusers### ### $Id: rosser.R 22 2022-05-30 18:03:47Z proebuck $ ### ### Returns the Rosser matrix. ### ##----------------------------------------------------------------------------- rosser <- function() { rosser.dat <- c( 611, 196, -192, 407, -8, -52, -49, 29, 196, 899, 113, -192, -71, -43, -8, -44, -192, 113, 899, 196, 61, 49, 8, 52, 407, -192, 196, 611, 8, 44, 59, -23, -8, -71, 61, 8, 411, -599, 208, 208, -52, -43, 49, 44, -599, 411, 208, 208, -49, -8, 8, 59, 208, 208, 99, -911, 29, -44, 52, -23, 208, 208, -911, 99 ) storage.mode(rosser.dat) <- "integer" matrix(rosser.dat, nrow=8, ncol=8, byrow=TRUE) } matlab/R/pow2.R0000644000175100001440000000170214245246376012760 0ustar hornikusers### ### $Id: pow2.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Raise 2 to some power. ### ##----------------------------------------------------------------------------- pow2 <- function(f, e) { if (!(is.numeric(f) || is.complex(f))) { stop(sprintf("argument %s must be numeric or complex", sQuote("f"))) } if (missing(e)) { e <- f f <- rep(1, length(e)) } else { if (!(is.numeric(e) || is.complex(e))) { stop(sprintf("Argument %s must be numeric or complex", sQuote("e"))) } if (is.complex(f) || is.complex(e)) { f <- Re(f) e <- Re(e) warning("imaginary part of complex arguments ignored") } } if (length(f) != length(e)) { stop(sprintf("Arguments %s and %s must be of same length", sQuote("f"), sQuote("e"))) } f * 2^e } matlab/R/fullfile.R0000644000175100001440000000035314245246376013674 0ustar hornikusers### ### $Id: fullfile.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Build full filename from parts. ### ##----------------------------------------------------------------------------- fullfile <- function(...) { file.path(...) } matlab/R/ndims.R0000644000175100001440000000035714245246376013210 0ustar hornikusers### ### $Id: ndims.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Provides the number of dimensions. ### ##----------------------------------------------------------------------------- ndims <- function(A) { length(matlab::size(A)) } matlab/R/zzz.R0000644000175100001440000000331214245227073012716 0ustar hornikusers### ### $Id: zzz.R 28 2022-05-30 20:51:07Z proebuck $ ### ### Hooks called as package is loaded, attached, detatched, and unloaded. ### ## Namespace environment for this package .MatlabNamespaceEnv <- new.env() ## ## Package/Namespace Hooks ## ##----------------------------------------------------------------------------- .onAttach <- function(libname, pkgname) { verbose <- getOption("verbose") if (verbose) { local({ libraryPkgName <- function(pkgname, sep="_") { unlist(strsplit(pkgname, sep, fixed=TRUE))[1] } packageDescription <- function(pkgname) { fieldnames <- c("Title", "Version") metafile <- file.path(libname, pkgname, "DESCRIPTION") meta <- as.list(read.dcf(metafile, fieldnames)) names(meta) <- fieldnames return(meta) } meta <- packageDescription(pkgname) msg <- sprintf("%s, version %s", meta$Title, meta$Version) packageStartupMessage(msg) msg <- sprintf("Type library(help=%s) to see package documentation", libraryPkgName(pkgname)) packageStartupMessage(msg) }) } } ##----------------------------------------------------------------------------- .onLoad <- function(libname, pkgname) { ## Create environment for internal usage environment(.MatlabNamespaceEnv) <- asNamespace("matlab") ## Load internal variables assign("savedTime", 0, envir=.MatlabNamespaceEnv) ## Allow no changes or additions to environment, ## but allow its internal vars to change lockEnvironment(.MatlabNamespaceEnv) } matlab/R/ceil.R0000644000175100001440000000033414245246376013005 0ustar hornikusers### ### $Id: ceil.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Rounds to the nearest integer. ### ##----------------------------------------------------------------------------- ceil <- function(x) { ceiling(x) } matlab/R/rot90.R0000644000175100001440000000177014245246376013053 0ustar hornikusers### ### $Id: rot90.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Rotates matrix counterclockwise k*90 degrees. ### ##----------------------------------------------------------------------------- rot90 <- function(A, k = 1) { if (!is.matrix(A)) { stop(sprintf("argument %s must be matrix", sQuote("A"))) } if (!is.numeric(k)) { stop(sprintf("argument %s must be numeric", sQuote("k"))) } else if (!(length(k) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("k"))) } rot90 <- function(A) { n <- matlab::size(A)[2] A <- t(A) A[n:1, ] } rot180 <- function(A) { sz <- matlab::size(A) m <- sz[1] n <- sz[2] A[m:1, n:1] } rot270 <- function(A) { m <- matlab::size(A)[1] t(A[m:1, ]) } k <- matlab::rem(k, 4) if (k <= 0) { k <- k + 4 } switch(EXPR = k, rot90(A), rot180(A), rot270(A), A) } matlab/R/filesep.R0000644000175100001440000000033614245203403013502 0ustar hornikusers### ### $Id: filesep.R 22 2022-05-30 18:03:47Z proebuck $ ### ### Directory separator for this platform. ### ##----------------------------------------------------------------------------- filesep <- .Platform$file.sep matlab/R/jet.colors.R0000644000175100001440000000225714245246376014161 0ustar hornikusers### ### $Id: jet.colors.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Create a vector of colors beginning with dark blue, ranging through ### shades of blue, cyan, green, yellow and red, and ending with dark red. ### DEFAULT.COLORMAP.SIZE <- 64 ##----------------------------------------------------------------------------- jet <- function(m = DEFAULT.COLORMAP.SIZE) { n <- matlab::ceil(m / 4) u <- c(seq(1, n) / n, if (n > 1) { matlab::ones(1, n-1) } else { NULL }, seq(n, 1, by = -1) / n) g <- matlab::ceil(n / 2) - (matlab::mod(m, 4) == 1) + (1:length(u)) r <- g + n b <- g - n g <- g[!(g > m)] r <- r[!(r > m)] b <- b[!(b < 1)] J <- matlab::zeros(m, 3) J[r, 1] <- u[seq(along = r)] J[g, 2] <- u[seq(along = g)] J[b, 3] <- u[seq(length(u)-length(b)+1, length(u))] J } ##----------------------------------------------------------------------------- jet.colors <- function(n) { if ((n <- as.integer(n[1])) > 0) { ans <- jet(n) return(rgb(red = ans[,1], green = ans[,2], blue = ans[,3])) } else { return(character(0)) } } matlab/R/pathsep.R0000644000175100001440000000033114245203403013512 0ustar hornikusers### ### $Id: pathsep.R 22 2022-05-30 18:03:47Z proebuck $ ### ### Path separator for this platform. ### ##----------------------------------------------------------------------------- pathsep <- .Platform$path.sep matlab/R/hilb.R0000644000175100001440000000103314245246376013004 0ustar hornikusers### ### $Id: hilb.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Hilbert matrix. ### ##----------------------------------------------------------------------------- hilb <- function(n) { if (!is.numeric(n)) { stop(sprintf("argument %s must be numeric", sQuote("n"))) } else if (!(length(n) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("n"))) } n <- floor(n) if (n < 0) { return(matrix(NA, nrow=0, ncol=0)) } i <- seq_len(n) H <- 1 / outer(i-1, i, "+") H } matlab/R/primes.R0000644000175100001440000000365714245203403013363 0ustar hornikusers### ### $Id: primes.R 22 2022-05-30 18:03:47Z proebuck $ ### ### Generate list of prime numbers. ### ##----------------------------------------------------------------------------- primes <- function(n) { if (!is.numeric(n)) { stop(sprintf("argument %s must be numeric", sQuote("n"))) } else if (!(length(n) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("n"))) } n <- floor(n) if (n < 2) { return(c()) } p <- seq(1, n, by=2) p[1] <- 2 q <- length(p) if (n >= 9) { for (k in seq(3, sqrt(n), by=2)) { if (p[(k+1)/2] != 0) { p[seq((k*k+1)/2, q, by=k)] <- 0 } } } p[p > 0] } ##----------------------------------------------------------------------------- ## Alternative version... eratosthenes_sieve <- function(n) { if (!is.numeric(n)) { stop(sprintf("argument %s must be numeric", sQuote("n"))) } else if (!(length(n) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("n"))) } n <- floor(n) if (n < 2) { return(c()) ## :TBD: integer(0) instead? } ## :HACK: have issues with seq(by=) output for [2 <= n <= 5] switch(EXPR=as.character(n), "2"=return(as.integer(2)), "3"=, "4"=return(as.integer(c(2, 3))), "5"=return(as.integer(c(2, 3, 5)))) ## Create a candidate list within which non-primes will be ## marked as 0; only candidates below sqrt(n) need be checked. candidates <- seq(from=1, to=n) fin <- floor(sqrt(n)) ## Loop over the candidates, marking out each multiple for (i in seq(from=2, to=fin+1)) { if (candidates[i]) { candidates[seq(from=2*i, to=n, by=i)] <- 0 } } ## Filter out non-primes candidates[candidates > 1] } matlab/R/fliplr.R0000644000175100001440000000276614245246376013374 0ustar hornikusers### ### $Id: fliplr.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Flip matrices left-right. ### ##----------------------------------------------------------------------------- setGeneric("fliplr", function(object) { #cat("generic", match.call()[[1]], "\n") standardGeneric("fliplr") }) setMethod("fliplr", signature(object = "vector"), function(object) { #cat(match.call()[[1]], "(vector)", "\n") rev(object) }) setMethod("fliplr", signature(object = "matrix"), function(object) { #cat(match.call()[[1]], "(matrix)", "\n") n <- matlab::size(object)[2] object[, n:1] }) setMethod("fliplr", signature(object = "array"), function(object) { #cat(match.call()[[1]], "(array)", "\n") stop(sprintf("argument %s must be vector or matrix", sQuote("object"))) }) setMethod("fliplr", signature(object = "ANY"), function(object) { #cat(match.call()[[1]], "(ANY)", "\n") stop(sprintf("method not defined for %s argument", data.class(object))) }) setMethod("fliplr", signature(object = "missing"), function(object) { #cat(match.call()[[1]], "(missing)", "\n") stop(sprintf("argument %s missing", sQuote("object"))) }) matlab/R/nextpow2.R0000644000175100001440000000071514245246376013662 0ustar hornikusers### ### $Id: nextpow2.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Next higher power of 2. ### ##----------------------------------------------------------------------------- nextpow2 <- function(x) { if (!(is.numeric(x) || is.complex(x))) { stop(sprintf("argument %s must be numeric or complex", sQuote('x'))) } if (length(x) == 0) { return(numeric(0)) } x[x == 0] <- 1 ceiling(log2(abs(x))) } matlab/R/ones.R0000644000175100001440000000131314245246376013033 0ustar hornikusers### ### $Id: ones.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Create a matrix of all ones. ### ##----------------------------------------------------------------------------- ones <- function(...) { nargs <- length(dots <- list(...)) dims <- as.integer(if (nargs == 1 && is.size_t(dots[[1]])) { dots[[1]] } else { unlist(dots) }) if (length(dims) == 1) { dims[2] <- dims[1] } if (!(length(dims) > 1)) { stop("dimensions must be of length greater than 1") } else if (!(all(dims > 0))) { stop("dimensions must be a positive quantity") } array(1, dims) } matlab/R/std.R0000644000175100001440000000045214245246376012664 0ustar hornikusers### ### $Id: std.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Standard deviation. ### ##----------------------------------------------------------------------------- std <- function(x, flag = 0) { if (flag != 0) { stop("biased standard deviation not implemented") } sd(x) } matlab/R/rem.R0000644000175100001440000000114714245247726012657 0ustar hornikusers### ### $Id: rem.R 31 2022-05-30 23:14:30Z proebuck $ ### ### Remainder after division. ### ##----------------------------------------------------------------------------- rem <- function(x, y) { ## Logically, it's this code but R doesn't work like MATLAB #ans <- matlab::mod(x, y) #if (!((x > 0 && y > 0) || # (x < 0 && y < 0))) { # ans <- ans - y #} flip <- ifelse(y < 0, yes = TRUE, no = FALSE) if (flip) { x <- -x y <- -y } ans <- abs(x) %% y ans <- ifelse(x < 0, yes = -ans, no = ans) if (flip) { ans <- -ans } ans } matlab/R/factors.R0000644000175100001440000000174314245246376013537 0ustar hornikusers### ### $Id: factors.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Factorize natural number. ### ##----------------------------------------------------------------------------- factors <- function(n) { if (!is.numeric(n)) { stop(sprintf("argument %s must be numeric", sQuote("n"))) } else if (!(length(n) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("n"))) } else if (!(n >= 0)) { stop(sprintf("argument %s must be a nonnegative quantity", sQuote("n"))) } n <- floor(n) if (n < 4) { return(n) } p <- matlab::primes(sqrt(n)) # d <- matlab::find(matlab::rem(n, p) == 0) d <- which(n %% p == 0) if (length(d) == 0) { return(n) # n is prime } f <- c() for (q in p[d]) { while (n %% q == 0) { f <- c(f, q) n <- n/q } } if (n > 1) { f <- c(f, n) } f } matlab/R/isempty.R0000644000175100001440000000036014245246376013562 0ustar hornikusers### ### $Id: isempty.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Determine if object is empty. ### ##----------------------------------------------------------------------------- isempty <- function(A) { any(matlab::size(A) == 0) } matlab/R/sum.R0000644000175100001440000000565114245246376012704 0ustar hornikusers### ### $Id: sum.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Sum of elements. ### ##----------------------------------------------------------------------------- setGeneric("sum", function(x, na.rm = FALSE) { #cat("generic", match.call()[[1]], "\n") if (!is.logical(na.rm)) { stop(sprintf("argument %s must be logical", sQuote("na.rm"))) } else if (!(length(na.rm) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("na.rm"))) } standardGeneric("sum") }, useAsDefault = FALSE) setMethod("sum", signature(x = "vector", na.rm = "logical"), function(x, na.rm) { #cat(match.call()[[1]], "(vector, logical)", "\n") #cat("\tx = ", x, "\n") #cat("\tna.rm = ", na.rm, "\n") if (is.logical(x)) { mode(x) <- "integer" } base::sum(x, na.rm = na.rm) }) setMethod("sum", signature(x = "vector", na.rm = "missing"), function(x, na.rm) { #cat(match.call()[[1]], "(vector, missing)", "\n") callGeneric(x, na.rm) }) setMethod("sum", signature(x = "matrix", na.rm = "logical"), function(x, na.rm) { #cat(match.call()[[1]], "(matrix, logical)", "\n") #cat("\tx =\n"); print(x); cat("\n") #cat("\tna.rm = ", na.rm, "\n") if (is.logical(x)) { mode(x) <- "integer" } apply(x, 2, base::sum, na.rm = na.rm) }) setMethod("sum", signature(x = "matrix", na.rm = "missing"), function(x, na.rm) { #cat(match.call()[[1]], "(matrix, missing)", "\n") callGeneric(x, na.rm) }) setMethod("sum", signature(x = "array", na.rm = "logical"), function(x, na.rm) { stop(sprintf("method not implemented for %s argument", data.class(x))) }) setMethod("sum", signature(x = "array", na.rm = "missing"), function(x, na.rm) { #cat(match.call()[[1]], "(array, missing)", "\n") callGeneric(x, na.rm) }) setMethod("sum", signature(x = "ANY", na.rm = "ANY"), function(x, na.rm) { #cat(match.call()[[1]], "(ANY, ANY)", "\n") stop(sprintf("method not defined for %s argument", data.class(x))) }) setMethod("sum", signature(x = "missing", na.rm = "ANY"), function(x, na.rm) { stop(sprintf("argument %s missing", sQuote("x"))) }) matlab/R/strcmp.R0000644000175100001440000000075214245246376013405 0ustar hornikusers### ### $Id: strcmp.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Compare strings. ### ##----------------------------------------------------------------------------- strcmp <- function(S, T) { if (!is.character(S)) { stop(sprintf("argument %s must be character", sQuote("S"))) } if (!is.character(T)) { stop(sprintf("argument %s must be character", sQuote("T"))) } if (length(S) == length(T)) { all(S == T) } else { FALSE } } matlab/R/pascal.R0000644000175100001440000000212414245246376013333 0ustar hornikusers### ### $Id: pascal.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Create Pascal matrix. ### ##----------------------------------------------------------------------------- pascal <- function(n, k = 0) { if (!is.numeric(n)) { stop(sprintf("argument %s must be numeric", sQuote("n"))) } else if (!(length(n) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("n"))) } if (!is.numeric(k)) { stop(sprintf("argument %s must be numeric", sQuote("k"))) } else if (!(length(k) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("k"))) } stopifnot(k >= 0, k <= 2) P <- diag((-1) ^ seq(0, as.double(n)-1)) P[,1] <- matlab::ones(n, 1) ## Generate Pascal Cholesky factor for (j in seq(2, n-1)) { for (i in seq(j+1, n)) { P[i, j] <- P[i-1, j] - P[i-1, j-1] } } if (k == 0) { P <- P %*% t(P) } else if (k == 1) { ; } else if (k == 2) { P <- matlab::rot90(P, 3) if ((n / 2) == round(n / 2)) { P <- -P } } P } matlab/R/find.R0000644000175100001440000000051514245246376013012 0ustar hornikusers### ### $Id: find.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Find indices of nonzero elements. ### ##----------------------------------------------------------------------------- find <- function(x) { expr <- if (is.logical(x)) { x } else { x != 0 } which(expr) } matlab/R/magic.R0000644000175100001440000000372614245246376013161 0ustar hornikusers### ### $Id: magic.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Create a magic square. ### ##----------------------------------------------------------------------------- magic <- function(n) { if (!is.numeric(n)) { stop(sprintf("argument %s must be numeric", sQuote("n"))) } else if (!(length(n) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("n"))) } oddOrder <- function(n) { ans <- matlab::meshgrid(1:n) J <- ans$x I <- ans$y A <- matlab::mod(I + J - (n + 3) / 2, n) B <- matlab::mod(I + 2 * J - 2, n) M <- n * A + B + 1; M } doublyEvenOrder <- function(n) { ans <- matlab::meshgrid(1:n) J <- ans$x I <- ans$y K <- matlab::fix(matlab::mod(I, 4) / 2) == matlab::fix(matlab::mod(J, 4) / 2) M <- t(matlab::reshape(as.matrix(1:(n * n)), n, n)) M[K] = n * n + 1 - M[K] M } singlyEvenOrder <- function(n) { p <- n / 2 fun <- sys.function(sys.parent()) M <- fun(p) # same as matlab::magic(p) M <- rbind(cbind(M, M + 2 * p ^ 2), cbind(M + 3 * p ^ 2, M + p ^ 2)) if (!(n == 2)) { i <- t(1:p) k <- (n - 2) / 4 j <- c(1:k, if ((n - k + 2) <= n) (n - k + 2):n) M[cbind(i, i + p), j] <- M[cbind(i + p, i), j] i <- k + 1 j <- c(1, i) M[cbind(i, i + p), j] <- M[cbind(i + p, i), j] } M } n <- floor(n) M <- if (n <= 0) { matrix(numeric(0), 0, 0) # degenerate } else if (n == 1) { matrix(as.numeric(1), 1, 1) # degenerate } else { if (matlab::mod(n, 2) == 1) { oddOrder(n) } else if (matlab::mod(n, 4) == 0) { doublyEvenOrder(n) } else { singlyEvenOrder(n) } } M } matlab/R/reshape.R0000644000175100001440000000154514245246376013525 0ustar hornikusers### ### $Id: reshape.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Reshape matrix or array. ### ##----------------------------------------------------------------------------- reshape <- function(A, ...) { if (!is.array(A)) { stop(sprintf("argument %s must be matrix or array", sQuote("A"))) } nargs <- length(dots <- list(...)) dims <- as.integer(if (nargs == 1 && is.size_t(dots[[1]])) { dots[[1]] } else { unlist(dots) }) if (!(length(dims) > 1)) { stop("dimensions must be of length greater than 1") } else if (!(all(dims > 0))) { stop("dimensions must be a positive quantity") } else if (prod(dims) != prod(dim(A))) { stop("number of elements must not change") } array(as.vector(A), dims) } matlab/R/vander.R0000644000175100001440000000113514245246376013350 0ustar hornikusers### ### $Id: vander.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Returns the Vandermonde matrix. ### ##----------------------------------------------------------------------------- vander <- function(v) { if (!is.vector(v)) { stop(sprintf("argument %s must be vector", sQuote("v"))) } else if (!(is.numeric(v) || is.complex(v))) { stop(sprintf("argument %s must be numeric or complex", sQuote("v"))) } n <- length(v) A <- if (n == 0) { matrix(as.numeric(NA), nrow=0, ncol=0) } else { outer(v, seq(n-1, 0), "^") } A } matlab/R/mod.R0000644000175100001440000000062314245203403012631 0ustar hornikusers### ### $Id: mod.R 22 2022-05-30 18:03:47Z proebuck $ ### ### Modulus after division. ### ##----------------------------------------------------------------------------- mod <- function(x, y) { ans <- x %% y ## Substitute x[off] in answer anywhere y[off] equals zero if (length(zero.off <- which(y == 0))) { ans[zero.off] <- if (length(x) == 1) x else x[zero.off] } ans } matlab/R/isprime.R0000644000175100001440000000130714245246376013542 0ustar hornikusers### ### $Id: isprime.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Array elements that are prime numbers. ### ##----------------------------------------------------------------------------- isprime <- function(x) { if (!is.numeric(x)) { stop(sprintf("argument %s must be numeric", sQuote("x"))) } if (length(x) == 0) { return(integer(0)) } if (any(x < 0)) { stop(sprintf("each element of %s must be a nonnegative quantity", sQuote("x"))) } else if (any(x != round(x))) { stop(sprintf("each element of %s must be a non-fractional quantity", sQuote("x"))) } as.integer(x %in% matlab::primes(max(x))) } matlab/R/fix.R0000644000175100001440000000031414245246376012655 0ustar hornikusers### ### $Id: fix.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Round toward zero. ### ##----------------------------------------------------------------------------- fix <- function(A) { trunc(A) } matlab/R/meshgrid.R0000644000175100001440000000425014245246376013674 0ustar hornikusers### ### $Id: meshgrid.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Generate X and Y matrices for three-dimensional plots. ### ##----------------------------------------------------------------------------- meshgrid <- function(x, y, z, nargout = 2) { meshgrid.2d <- function(x, y) { if (missing(y)) { y <- x } if (matlab::isempty(x) || matlab::isempty(y)) { xx <- matlab::zeros(0, 0) yy <- matlab::zeros(0, 0) } else { xx <- matrix(x, ncol = length(x), byrow = TRUE) yy <- matrix(y, nrow = length(y)) nx <- ncol(xx) ny <- nrow(yy) xx <- xx[matlab::ones(ny, 1), ] yy <- yy[, matlab::ones(1, nx)] } list(x = xx, y = yy) } meshgrid.3d <- function(x, y, z) { if (missing(y) && missing(z)) { y <- x z <- x } else if (missing(z)) { stop("not enough input arguments") } if (matlab::isempty(x) || matlab::isempty(y)) { xx <- matlab::zeros(0, 0) yy <- matlab::zeros(0, 0) zz <- matlab::zeros(0, 0) } else { nx <- matlab::numel(x) ny <- matlab::numel(y) nz <- matlab::numel(z) xx <- matlab::reshape(as.matrix(x), c(1, nx, 1)) yy <- matlab::reshape(as.matrix(y), c(ny, 1, 1)) zz <- matlab::reshape(as.matrix(z), c(1, 1, nz)) xx <- xx[matlab::ones(ny, 1), , matlab::ones(nz, 1)] yy <- yy[, matlab::ones(1, nx), matlab::ones(nz, 1)] zz <- zz[matlab::ones(ny, 1), matlab::ones(nx, 1), ] } list(x = xx, y = yy, z = zz) } if (!is.numeric(nargout)) { stop(sprintf("argument %s must be numeric", sQuote("nargout"))) } else if (!(length(nargout) == 1)) { stop(sprintf("argument %s must be of length 1", sQuote("nargout"))) } switch(EXPR = as.character(nargout), "2" = meshgrid.2d(x, y), "3" = meshgrid.3d(x, y, z), stop(sprintf("argument %s must be either 2 or 3", sQuote("nargout")))) } matlab/R/size_t-class.R0000644000175100001440000000125314245246376014472 0ustar hornikusers### ### $Id: size_t-class.R 29 2022-05-30 23:02:22Z proebuck $ ### ### Size class. ### ##----------------------------------------------------------------------------- setClass("size_t", contains = "integer", prototype = as.integer(0)) ##----------------------------------------------------------------------------- size_t <- function(x) { new("size_t", as.integer(x)) } ##----------------------------------------------------------------------------- is.size_t <- function(object) { data.class(object) == "size_t" } ##----------------------------------------------------------------------------- as.size_t <- function(object) { size_t(object) } matlab/NEWS0000644000175100001440000001357414245522626012251 0ustar hornikusers ************************************************** * * * 1.0 SERIES NEWS * * * ************************************************** CHANGES IN R VERSION 1.0.4 BUG FIXES o Resubmitted since code in the R Forge-built source package did not match that of the SVN revision checked and reported on-screen, somewhat defeating its entire purpose. CHANGES IN R VERSION 1.0.3 NEW FEATURES o Modified .onLoad() method to shutup R CMD check's pedantic NOTE. o Removed extraneous return() calls. BUG FIXES o Updated to use maintainer's current email address. o Updated manpage author section ordering. o Added additional basic method imports to correct R CMD check issues. o Replaced 'rem' method to accommodate upcoming R changes. [VVH-20220524] CHANGES IN R VERSION 1.0.2 NEW FEATURES o Converted COPYRIGHT file to Debian standard, machine-readable format. CHANGES IN R VERSION 1.0.1 NEW FEATURES o Removed triple colon operators referencing internal functions which caused YA NOTE in upcoming version of R. [UW-20140205] o Changed the methods package dependency to an import which caused YA NOTE in upcoming version of R. [UW-20140205] CHANGES IN R VERSION 1.0.0 SIGNIFICANT USER-VISIBLE CHANGES o Dropped compatibility for anything less than R-2.15 as no longer able to test against previous versions of R. NEW FEATURES o After almost a decade, now has a production release number. o Added SVN revision information to many of the package files. o Added COPYRIGHTS file, and removed LICENSE file. o Removed .onAttach() anachronism for ensuring its methods package dependency was available for S4 classes. o Removed redundant 'library(methods)' calls in S4-related files. o colorbar() example code now uses dev.new() rather than X11() by request of CRAN maintainer. [KH-20140120] ************************************************** * * * 0.8 SERIES NEWS * * * ************************************************** CHANGES IN R VERSION 0.8.9 NEW FEATURES o Converted .onAttach() output to use packageStartupMessage() method. CHANGES IN R VERSION 0.8.8 NEW FEATURES o Added 'vander' method. o Added 'pow2' method. o Added 'nextpow2' method. BUG FIXES o Additional argument checking for 'isprime' method. CHANGES IN R VERSION 0.8.7 NEW FEATURES o Added 'factors' method. o Added 'hilb' method. o Added 'isprime' method. o Added 'primes' method. o Added 'rosser' method. CHANGES IN R VERSION 0.8.6 BUG FIXES o Converted NEWS file into something R can recognize. CHANGES IN R VERSION 0.8.5 BUG FIXES o Fixed 'mod' to correct for 'mod(n,0) == n' [HWB-20110308] CHANGES IN R VERSION 0.8.4 BUG FIXES o Fixed 'linspace' to correct for undocumented 'floor(n)' [HWB-20110205] o Fixed 'logspace' to correct for 'n < 2' condition. [HWB-20110205] NEW FEATURES o Reimplemented 'logspace' as '10 ^ linspace(a,b,n)' to consolidate. CHANGES IN R VERSION 0.8.3 BUG FIXES o Respecify license by request of CRAN maintainer. CHANGES IN R VERSION 0.8.2 BUG FIXES o Removed 'grdev' method from 'colorbar' test codes for R-2.8 compatibility. CHANGES IN R VERSION 0.8.1 BUG FIXES o Modified 'sum' to handle logicals. CHANGES IN R VERSION 0.8.0 NEW FEATURES o Added 'cell' method. o Added 'isempty' method. o Added 'magic' method. o Added 'meshgrid' method. o Added 'ndims' method. o Added 'numel' method. o Added 'padarray' method. o Added 'reshape' method. o Added 'strcmp' method. o Modified 'repmat' to handle character vectors. o Updated package documentation. ************************************************** * * * 0.7 SERIES NEWS * * * ************************************************** CHANGES IN R VERSION 0.7.9 NEW FEATURES o Converted error messages to use sprintf method instead of paste. o Modified 'imagesc' method argument list to allow for x,y,col arguments. Also makes use of '{xy}axp' arguments for tickmark labels. o Updated package documentation. BUG FIXES o Fixed quoting in help message. o Corrected 'ones', 'zeros', 'eye' methods for certain 'size_t' arguments. o Modified 'repmat' method to not drop single dimension before replication. o Added argument checking to 'linspace' method. CHANGES IN R VERSION 0.7.8 NEW FEATURES o Added 'colorbar' method. o Added 'fileparts' method. o Added 'filesep' and 'pathsep' objects. o Added 'fullfile' method. o Added 'imagesc' method. o Added 'jet.colors' method. o Updated package documentation. CHANGES IN R VERSION 0.7.7 NEW FEATURES o Added 'pascal' method. o Added 'linspace' method. o Added 'logspace' method. o Converted 'size' method to S4. o Added 'dimen' parameter to 'size' method. o Added 'echo' parameter to 'toc' method. CHANGES IN R VERSION 0.7.6 SIGNIFICANT USER-VISIBLE CHANGES o Initial release to CRAN. matlab/NAMESPACE0000644000175100001440000000163314245211370012751 0ustar hornikusers### ### $Id: NAMESPACE 26 2022-05-30 18:54:48Z proebuck $ ### ## Imports import(methods) importFrom(grDevices, rgb) importFrom(graphics, axTicks, axis, box, par) importFrom(stats, sd) ## Public routines export(ceil) export(cell) export(colorbar) export(eye) export(factors) export(fileparts) export(filesep) export(find) export(fix) export(fullfile) export(hilb) export(imagesc) export(isempty) export(isprime) export(jet.colors) export(linspace) export(logspace) export(magic) export(meshgrid) export(mod) export(multiline.plot.colors) export(ndims) export(nextpow2) export(numel) export(ones) export(pascal) export(pathsep) export(pow2) export(primes) export(rem) export(repmat) export(reshape) export(rosser) export(rot90) export(std) export(strcmp) export(tic,toc) export(vander) export(zeros) ## S4 Methods exportMethods(fliplr) exportMethods(flipud) exportMethods(padarray) exportMethods(size) exportMethods(sum) matlab/inst/0000755000175100001440000000000014245524746012522 5ustar hornikusersmatlab/inst/COPYRIGHTS0000644000175100001440000000054214245251233014125 0ustar hornikusers### ### $Id: COPYRIGHTS 33 2022-05-30 23:26:19Z proebuck $ ### Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: matlab Upstream-Contact: P. Roebuck Source: https://cran.r-project.org/package=matlab Files: * Copyright: 2004-2014, MD Anderson Cancer Center (MDACC) License: Artistic-2.0 matlab/build/0000755000175100001440000000000014640470516012636 5ustar hornikusersmatlab/build/stage23.rdb0000644000175100001440000000622014640470516014577 0ustar hornikusers‹Í\ërÛÆ†(R¤î_b9±»‘œ‰âX¤$ÛrJÇ­Kn•±,•V‹ÆK XP¶ªq_¤¿û}‹¶oÑIÿÇÝ%ĸ „‹©jfõ‘‹=÷ݳ @/Ç$IÊIùü”fä%úkH’†^¥ÏtþÎK£~†nmkUÔR\C©/ÛŠz¨àrMCkwÑÚÊÚÚòÊýå»+hõ«êÚZuíî+d;®·ÕCtK’ò9n¨‘šöÚU(Å3(>ÙÝÙÙz¾îLÕÁ *Õ$ûË“ð´=ìbàª"½ª¡˜’yÉûù9ÔexËTC"þ¸ÿtù«P¿6UKÓͰ¼R¨ß¨«·0q•–MÇžb_lüëïßüó= ª¡£å|÷v_l¿T]_ëΟ.¥~ ‹ÃÔ2•‰³Qq[v¥FÝîÞ7ÞVjõ¶nh«õëø«{ëë÷ï)õõŠç= f¥Ç‘!F¹7ZˆÅ—1Xx’ûÒ—Þ‡ÝõOT—SÇûÂqhÌ»l(|Y~ë%ÄPî}(j¾æë7LûåßFŒˆà#´b@²Ä™ :5J¶ï¶jßdcs@ð2З“È&äZ½¨²¼ô•Á{†±¿Ê!´ÿ ϰ9¬xèD&r‘CWHß!À«@'³I*×0öq-#×ÏðI„PÚÆg€žÉÌ'%Y³Ôýc[”0ðÃY gïÆ~ŽChyåúÎÆþ³oÐV«m(®n™èiÛTAbÊ9 ÃðS ?Í0y\Ý5DnòW† @/ ÞM¬-r-¡›†ÓŠÃ•)¡¥´ÊC„¾wÛÆjøa‚SCGŠ£+uÔ&XC®…lºª¸yW¸’a¨üL¡Àt*8RàÒT§õ$²-Btª“è-*|ã˜~踴$-Ç~î°úAf¹0!k˜¨Žn35"|Ï8ŽIi‹ŸT!èm{º-aF̤gDñZJ«äŠ)ÇxdB ”© ÍÂFÍë9ÃH —ß&»˜P®›iÝ5ý|„–Ò]“ˆþìy…H5®ç&Á[“A:¡…¤(î²ËöuBîS€³@§/GŠÈßHÆ6Åà5 ¯enŠaYu"˜Ï~ ôǃŸß~Â!´,"”U¤UFÄi ¢Ò“ÁF(Wgd¡%?_ØbpèùA…(czð ÓÇFìeìop-‹ý;„–±'ÑiËé Ñi0Æt¦!:”Äs&ßÓñßWË+å{åÕþÂ$ i&ëà.лƒiÆ~ChY„ô&Ý­$™ug Œg.$¤g Œg.6¤g Œ}Ì&¤ÇNoy| ¨f]¾|ô³ÁG5ë³Ã!´,¢ú™®b“įv¹#¯ ˆj.’/2ªg!’}Ì&ª'6W'®®.¯•W>L\ÏB1¼ÀÙš±ßãÚÀ7ÝsÀ s@ç’È‘ÏqߎkǦÒÒÕ§Fç6«Ÿ%cÝ®‚gïmCùŒmu‡AÈán‹'$ë1þ¾Wšt~d"å9„–Ò›t§ÓÄÇHq02-Ô²(ªVË6°‹‘ÛTL¤Ô‰e´]l#«˜Å9î8²K~jë.Ž« –tpèÍÔšÜBþâ1ª;Ö!6QÃrPÃÑͪ“B0‰}ˆx¤cx è[ƒOaî^¡’(¥?M\Bè)5Òõ·AgDd5ºËwØYrÜDçnŸIK@/%^µÂ§jW ½îÐ\jbÃ~´à,|!c¡ödws+BÈ à&ЉbPÌVV-Mt§„±ûp è­ôUNࢧBÌÆœ1ýà6ÐÛƒO*Æþ[¡¥cÃOª¦~Ð\6ð6i·ZlÒ¤™å6éTDgÕL:³VÔ&rð‘Î6òl‹«ÆGa 7€ÞH­F>ÁìpgÈÝNÏ(ïWØC4eÒ´Þ,‘cââV™}°´ð|ëû wÜÙîN±g&ö8`èꇟ»àC ÓßdËÅ^êÿ¯ý(3õK²†]E7D^ŒC¬ÌK)V·Ss1‘rBKÒ©ï(³#Ì"‡ÐRÆÊBÛ&R±Cdz…Ò6QÑ•¿¥Ð¢Ïri…à8˜Ø­úð[Eui‰õFw›p_mìmÇUåcpÃ- Ó/„´¤Q"V wQDº‹~lÓšæBÌÏ»7˜c'Ç' !ÃT%MÄÜ@m,š®«i2#}Ü€È÷1]äÓŠsSòîêû-ýAÍ^ÕàAÞ˜"ý œÃ0ýAMOÉë?_¼ú`eõñA‹Î£eZ³'ñ àm ogÃ#2frEðüè/ÄŒý¡e¤~QVÚnÓ•»7!t¡IÌØç8L—Ä=YÈRœ‘²²ð¿±-‚óà>YÈØÏqmÐb,€|L£Â^¹šÈþÏ"ð“’ð•}ì³nï–¢:{Á;"Œ?ƒô,¬Õî¨]›yÇã>‡¡)AŸQY³L×ÅÄå:–¢øŸöŽ…áẇ:qÏÌò}„'¤E¹¡´¾ëåPo£ÎkÖ®ó°[c6ÔÉ/bÂò„:iø'3(‰øXW&í:Áª÷xÝi÷KÝî‚KLü†.‹-ÅÔ¸K>êsIQ¶ì‡ ¡ÔM/àüNW‚cF¿¨7L-péBmYÔX¦qŒœ¾ãdx£Ä¿`\Ø©nZo'ô6?ÞÕ)_Ü£5uÓâÇ»9q+¿Ñ¬E£ºŒÑ|h·°£‚kF0X‰n±MÛ|†‡f×[…vòiXèIÔ#Åhóì¦{æÜy¥*Jè¼l ôrYĦ¦ó±±Ø3Ê‘âœ1Š®ŽeÆŠA¬3ÒsRvpT…üæ—;‘–‘Û¤SðfÁˆlh–Ë;D4Å2ÂÓA1bÄÐÓ¹‘2Rãé® k@Û1¤À,!˜ÿ©7ywŠfP®4­®üÞrLýÐ{‹|Ù®¦âàJM«x»Ñ ÜÁò÷ÅcáQ.øýsAúìÕÅQ=ÜåvOÔ"…}÷z¯¶´¸*Œ þAîw?6ÔsŸSD,ºÏ”}ü’SôZrE?ƒ]Õ‰Aw.oß°ÂêäÄãðîÝ»è¸z1¬]ÍLÇ’\×ë^½•…;s‹«Ø çžO¢Bh9°ëÀPØÎ2 Ù…¢Ûñ·.iœ,®2'ÑßõÖA¥õ ªÉ<ÔëoOòá¼Ãÿoˆì¼““·?¤Ð¿ArÏ¥º$?©m<ïìÕ³}½sPtÒt]›T+6v™NÿŽõ#ݺ–-ç â?¦@ë„tâL î¨ÈpèLBŒ–¦„J³™å®‹rè¯4sH+þ ‘étšK>µ N0ÀÂûÞö) ¯þ&~¡ÓÙ¼E—8üÍïW@¿Jk‡sHNûöÙ65½S£fa¡Çñ-¤{ü£mtìÂð ÈlìÊ[/žÔ¶÷ö·wŸgc‹e1'C´=>0”Å 'À)ßpž—… ~ßÞqb´öŸ‚Æ e åLæÃ¼¬Yz6z/Ÿ£¶¥Ì¢µ\Í>úqjÏù>ÞQt“=ãƒ3òó“ø~nŠmîAkIZË|v m£Ý‚š[4^ŸÌÿÏYÉv°M7¢Ì¨Íïoÿ#ù?='M쀄$šp~ù6ì}]Omatlab/man/0000755000175100001440000000000014245524746012320 5ustar hornikusersmatlab/man/repmat.Rd0000644000175100001440000000156014245210351014061 0ustar hornikusers% $Id: repmat.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{repmat} \alias{repmat} \title{MATLAB repmat function} \description{ Replicate and tile a matrix. } \usage{ repmat(A, \dots) } \arguments{ \item{A}{vector or matrix to be tiled. Must be numeric, logical, complex or character.} \item{\dots}{numeric dimensions for the result} } \value{ Returns matrix with value \code{A} tiled to the number of dimensions specified. Defaults to square if dimension argument resolves to a single value. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{ones}}, \code{\link{zeros}} } \examples{ repmat(1, 3) # same as ones(3) repmat(1, c(3, 3)) # same thing repmat(1, 3, 3) # same thing repmat(1, size(matrix(NA, 3, 3))) # same thing repmat(matrix(1:4, 2, 2), 3) } \keyword{array} matlab/man/mod.Rd0000644000175100001440000000107714245210351013353 0ustar hornikusers% $Id: mod.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{mod} \alias{mod} \alias{rem} \title{MATLAB mod/rem functions} \description{ Provides modulus and remainder after division. } \usage{ mod(x, y) rem(x, y) } \arguments{ \item{x, y}{numeric vectors or objects} } \value{ Returns vector containing result of the element by element operations. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ ## same results with x, y having the same sign mod(5, 3) rem(5, 3) ## same results with x, y having different signs mod(-5, 3) rem(-5, 3) } \keyword{arith} matlab/man/matlab-package.Rd0000644000175100001440000000213014245205537015426 0ustar hornikusers% $Id: matlab-package.Rd 23 2022-05-30 18:22:23Z proebuck $ \name{matlab-package} \alias{matlab-package} \docType{package} \title{MATLAB Emulation Functions} \description{ Wrapper functions and variables used to replicate MATLAB function calls as best possible to simplify porting. } \details{ \tabular{ll}{ Package: \tab matlab\cr Type: \tab Package\cr Version: \tab \Sexpr[results=text]{packageDescription("matlab")$Version}\cr Date: \tab \Sexpr[results=text]{packageDescription("matlab")$Date}\cr License: \tab \Sexpr[results=text]{packageDescription("matlab")$License}\cr } They are no more complete than absolutely necessary and are quite possibly broken for fringe cases. For a complete list of functions, use \code{library(help="matlab")}.\cr For a high-level summary of the changes for each revision, use \code{file.show(system.file("NEWS", package="matlab"))}. } \note{ In certain cases, these may not correspond exactly with MATLAB API as sometimes it just wasn't possible. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \keyword{package} matlab/man/colorbar.Rd0000644000175100001440000000536714245210351014405 0ustar hornikusers% $Id: colorbar.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{colorbar} \alias{colorbar} \title{MATLAB colorbar function} \description{ Displays colorbar showing the color scale. } \usage{ colorbar(C, location=c("EastOutside", "WestOutside", "NorthOutside", "SouthOutside"), \dots) } \arguments{ \item{C}{numeric vector or matrix representing data values} \item{location}{character scalar indicating desired orientation with respect to the axes} \item{\dots}{graphical parameters for \link[graphics]{image} may also be passed as arguments to this method} } \details{ The values of the elements of \code{C} are indices into the current \link[grDevices]{palette} that determine the color of each patch. This implementation differs a bit from its MATLAB counterpart in that the values must be passed explicitly. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{imagesc}}, \code{\link{jet.colors}}, \code{\link[graphics]{layout}}, \code{\link[graphics]{par}} } \examples{ doPlot <- function(C, cb.loc=c("EastOutside", "WestOutside", "NorthOutside", "SouthOutside"), ...) { saved.par <- par(no.readonly=TRUE) on.exit(par(saved.par)) layout.EO <- function() { ## divide the device into one row and nine columns ## allocate figure 1 the first eight columns ## allocate figure 2 the last column layout(matrix(c(1, 1, 1, 1, 1, 1, 1, 1, 2), ncol=9)) } layout.WO <- function() { ## divide the device into one row and nine columns ## allocate figure 1 the last eight columns ## allocate figure 2 the first column layout(matrix(c(2, 1, 1, 1, 1, 1, 1, 1, 1), ncol=9)) } layout.NO <- function() { ## divide the device into six rows and one column ## allocate figure 1 the last five rows ## allocate figure 2 the first row layout(matrix(c(2, 1, 1, 1, 1, 1), nrow=6)) } layout.SO <- function() { ## divide the device into six rows and one column ## allocate figure 1 the first five rows ## allocate figure 2 the last row layout(matrix(c(1, 1, 1, 1, 1, 2), nrow=6)) } location <- match.arg(cb.loc) switch(EXPR=location, EastOutside = layout.EO(), WestOutside = layout.WO(), NorthOutside = layout.NO(), SouthOutside = layout.SO()) imagesc(C, ...) colorbar(C, location, ...) } values <- matrix(c(seq(1, 5, by=1), seq(2, 10, by=2), seq(3, 15, by=3)), nrow=3, byrow=TRUE) dev.new(width=8, height=7) doPlot(values, "EastOutside", col=jet.colors(16)) } \keyword{hplot} matlab/man/imagesc.Rd0000644000175100001440000000323214245210351014177 0ustar hornikusers% $Id: imagesc.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{imagesc} \alias{imagesc} \title{MATLAB imagesc function} \description{ Scales image data to the full range of the current palette and displays the image. } \usage{ imagesc(x=seq(ncol(C)), y=seq(nrow(C)), C, col=jet.colors(12), \dots) } \arguments{ \item{x,y}{locations of grid lines at which the values in \code{C} are measured. These must be finite, non-missing and in (strictly) ascending order. By default, the dimensions of \code{C} are used.} \item{C}{numeric matrix representing data to be plotted. Note that \code{x} can be used instead of \code{C} for convenience.} \item{col}{vector of colors used to display image data} \item{\dots}{graphical parameters for \link[graphics]{image} may also be passed as arguments to this method} } \details{ Each element of \code{C} corresponds to a rectangular area in the image. The values of the elements of \code{C} are indices into the current \link[grDevices]{palette} that determine the color of each patch. The method interprets the matrix data as a table of \code{f(x[i], y[j])} values, so that the x axis corresponds to column number and the y axis to row number, with row 1 at the top, i.e., the same as the conventional printed layout of a matrix. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link[graphics]{image}}, \code{\link{jet.colors}}, \code{\link[graphics]{par}} } \examples{ values <- matrix(c(seq(1, 5, by=1), seq(2, 10, by=2), seq(3, 15, by=3)), nrow=3, byrow=TRUE) imagesc(values, xlab="cols", ylab="rows", col=jet.colors(16)) } \keyword{hplot} matlab/man/ceil.Rd0000644000175100001440000000113514245210351013503 0ustar hornikusers% $Id: ceil.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{ceil} \alias{ceil} \title{MATLAB ceil function} \description{ Rounds to the nearest integer. } \usage{ ceil(x) } \arguments{ \item{x}{numeric to be rounded} } \details{ Simply invokes \code{ceiling} for those more used to C library API name. } \value{ Returns numeric vector containing smallest integers not less than the corresponding elements of argument \code{x}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{fix}}, \code{\link[base]{Round}} } \examples{ ceil(c(0.9, 1.3, 2.4)) } \keyword{arith} matlab/man/strcmp.Rd0000644000175100001440000000131314245210351014075 0ustar hornikusers% $Id: strcmp.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{strcmp} \alias{strcmp} \title{MATLAB strcmp function} \description{ Compare strings. } \usage{ strcmp(S, T) } \arguments{ \item{S, T}{character vectors to evaluate} } \details{ Comparisons are case-sensitive and any leading and trailing blanks in either of the strings are explicitly included in the comparison. } \value{ Returns \code{TRUE} if \code{S} is identical to \code{T}; otherwise, \code{FALSE}. } \note{ Value returned is the opposite of the C language convention. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ strcmp("foo", "bar") # FALSE strcmp(c("yes", "no"), c("yes", "no")) # TRUE } \keyword{character} matlab/man/std.Rd0000644000175100001440000000132214245210351013357 0ustar hornikusers% $Id: std.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{std} \alias{std} \title{MATLAB std function} \description{ Computes the standard deviation of the values of \code{x}. } \usage{ std(x, flag=0) } \arguments{ \item{x}{numeric vector or matrix} \item{flag}{numeric scalar. If \code{0}, selects unbiased algorithm. If \code{1}, selects biased algorithm (currently unsupported).} } \details{ Simply invokes \code{\link[stats]{sd}}. } \value{ Return value depends on argument \code{x}. If vector, returns the standard deviation. If matrix, returns vector containing the standard deviation of each column. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ std(1:2) ^ 2 } \keyword{univar} matlab/man/multiline.plot.colors.Rd0000644000175100001440000000205114245210351017044 0ustar hornikusers% $Id: multiline.plot.colors.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{multiline.plot.colors} \alias{multiline.plot.colors} \title{MATLAB multiline plot colors} \description{ Creates a vector of colors equivalent to MATLAB's default colors to use for multiline plots. } \usage{ multiline.plot.colors() } \details{ This is equivalent to the MATLAB command \preformatted{ get(gca, 'ColorOrder') } } \value{ Returns vector of color names. This can be used either to create a user-defined color palette for subsequent graphics, a \code{col=} specification in graphics functions, or in \code{par}. } \note{ Method should be considered experimental and will most likely be removed and replaced with similar functionality in the near future. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link[grDevices]{palette}}, \code{\link[graphics]{par}}, \code{\link[grDevices]{rgb}} } \examples{ require(graphics) x <- matrix(1:16, nrow=2, byrow=TRUE) matplot(x, type="l", col=multiline.plot.colors()) } \keyword{color} matlab/man/meshgrid.Rd0000644000175100001440000000261014245210351014370 0ustar hornikusers% $Id: meshgrid.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{meshgrid} \alias{meshgrid} \title{MATLAB meshgrid functions} \description{ Generate X and Y matrices for three-dimensional plots. } \usage{ meshgrid(x, y, z, nargout=2) } \arguments{ \item{x, y, z}{numeric vectors of values} \item{nargout}{numeric scalar that determines number of dimensions to return} } \details{ In the first example below, the domain specified by vectors \code{x} and \code{y} are transformed into two arrays which can be used to evaluate functions of two variables and three-dimensional surface plots. The rows of the output array \code{x} are copies of the vector \code{x}; columns of the output array \code{y} are copies of the vector \code{y}.\cr The second example below is syntactic sugar for specifying \code{meshgrid(x, x)}.\cr The third example below produces three-dimensional arrays used to evaluate functions of three variables and three-dimensional volumetric plots. } \value{ Returns list containing eiher two or three matrices depending on the value of \code{nargout}. \item{x, y, z}{output matrices} } \note{ Limited to two- or three-dimensional Cartesian space. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ meshgrid(1:3, 10:14) # example 1 meshgrid(1:3) # example 2 meshgrid(5:8, 10:14, 2:3, 3) # example 3 } \keyword{array} matlab/man/reshape.Rd0000644000175100001440000000270214245210351014217 0ustar hornikusers% $Id: reshape.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{reshape} \alias{reshape} \title{MATLAB reshape function} \description{ Reshape matrix or array. } \usage{ reshape(A, \dots) } \arguments{ \item{A}{matrix or array containing the original data} \item{\dots}{numeric dimensions for the result} } \details{ In the first example below, an \code{m}-by-\code{n} matrix is created whose elements are taken column-wise from \code{A}. An error occurs if \code{A} does not have \eqn{m*n} elements.\cr In the second example below, an \code{n}-dimensional array with the same elements as \code{A} but reshaped to have the size \code{m}-by-\code{n}-by-\code{p}. The product of the specified dimensions must be the same as \code{prod(size(A))}.\cr In the third example below, an \code{n}-dimensional array with the same elements as \code{A} but reshaped to \code{siz}, a vector representing the dimensions of the reshaped array. The quantity \code{prod(siz)} must be the same as \code{prod(size(A))}. } \value{ Returns matrix (or array) of requested dimensions containing the elements of \code{A}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ Xmat.2d <- matrix(1:12, nrow=4, ncol=3) reshape(Xmat.2d, 6, 2) # example 1 reshape(Xmat.2d, c(6, 2)) # same thing Xarr.3d <- reshape(Xmat.2d, c(6, 2, 1)) # example 2 reshape(Xmat.2d, size(Xarr.3d)) # example 3 } \keyword{array} matlab/man/primes.Rd0000644000175100001440000000216014245210351014065 0ustar hornikusers% $Id: primes.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{primes} \alias{primes} \title{MATLAB primes function} \description{ Generate a list of prime numbers. } \usage{ primes(n) } \arguments{ \item{n}{scalar numeric specifying largest prime number desired.} } \details{ Generates the list of prime numbers less than or equal to \code{n} using a variant of the basic "Sieve of Eratosthenes" algorithm. This approach is reasonably fast, but requires a copious amount of memory when \code{n} is large. A prime number is one that has no other factors other than \code{1} and itself. } \value{ Returns numeric vector containing prime numbers less than or equal to argument \code{n}. } \author{ H. Borchers \email{hwborchers@googlemail.com}, P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{isprime}}, \code{\link{factors}} } \examples{ primes(1000) length(primes(1e6)) # 78498 prime numbers less than one million \dontrun{ length(primes(1e7)) # 664579 prime numbers less than ten million length(primes(1e8)) # 5761455 prime numbers less than one hundred million } } \keyword{arith} matlab/man/linspace.Rd0000644000175100001440000000167114245210351014372 0ustar hornikusers% $Id: linspace.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{linspace} \alias{linspace} \title{MATLAB linspace function} \description{ Generate linearly spaced vectors. } \usage{ linspace(a, b, n=100) } \arguments{ \item{a}{numeric scalar specifying starting point} \item{b}{numeric scalar specifying ending point} \item{n}{numeric scalar specifying number of points to be generated} } \details{ Similar to colon operator but gives direct control over the number of points. Note also that although MATLAB doesn't specifically document this, the number of points generated is actually \code{floor(n)}. } \value{ Returns vector containing containing \code{n} points linearly spaced between \code{a} and \code{b} inclusive. If \eqn{\code{n} < 2}, the result will be the ending point \code{b}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{logspace}} } \examples{ linspace(1, 10, 4) } \keyword{manip} matlab/man/rosser.Rd0000644000175100001440000000122114245210351014100 0ustar hornikusers% $Id: rosser.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{rosser} \alias{rosser} \title{MATLAB rosser function} \description{ Create the Rosser matrix, a classic symmetric eigenvalue test problem. } \usage{ rosser() } \details{ The returned matrix has the following features: \itemize{ \item{a double eigenvalue} \item{three nearly equal eigenvalues} \item{dominant eigenvalues of opposite sign} \item{a zero eigenvalue} \item{a small, nonzero eigenvalue} } } \value{ Returns an \code{8}-by-\code{8} matrix with integer elements. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ rosser() } \keyword{array} matlab/man/find.Rd0000644000175100001440000000104714245210351013511 0ustar hornikusers% $Id: find.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{find} \alias{find} \title{MATLAB find function} \description{ Finds indices of elements. } \usage{ find(x) } \arguments{ \item{x}{expression to evaluate} } \details{ If expression is not logical, finds indices of nonzero elements of argument \code{x}. } \value{ Returns indices of corresponding elements matching the expression \code{x}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ find(-3:3 >= 0) find(c(0, 1, 0, 2, 3)) } \keyword{logic} \keyword{attribute} matlab/man/eye.Rd0000644000175100001440000000077714245210351013364 0ustar hornikusers% $Id: eye.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{eye} \alias{eye} \title{MATLAB eye function} \description{ Create an identity matrix. } \usage{ eye(m, n) } \arguments{ \item{m, n}{numeric scalar specifying dimensions for the result} } \value{ Returns matrix of order 1. Defaults to square if second dimension argument \code{n} not provided. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{ones}}, \code{\link{zeros}} } \examples{ eye(3) } \keyword{array} matlab/man/nextpow2.Rd0000644000175100001440000000205414245205537014370 0ustar hornikusers% $Id: nextpow2.Rd 23 2022-05-30 18:22:23Z proebuck $ \name{nextpow2} \alias{nextpow2} \title{MATLAB nextpow2 function} \description{ Smallest power of 2 greater than or equal to its argument. } \usage{ nextpow2(x) } \arguments{ \item{x}{numeric or complex value(s).} } \details{ Computes the smallest power of two that is greater than or equal to the absolute value of \code{x}. (That is, \code{p} that satisfies \eqn{2^p \ge abs(x)}). For negative or complex values, the absolute value will be taken. } \value{ Returns numeric result containing integer \code{p} as described above. Nonscalar input returns an element-by-element result (of same size/dimensions as its input). } \author{ H. Borchers \email{hwborchers@googlemail.com}, P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{pow2}} } \examples{ nextpow2(10) # 4 nextpow2(1:10) # 0 1 2 2 3 3 3 3 4 4 nextpow2(-2^10) # 10 nextpow2(.Machine$double.eps) # -52 nextpow2(c(0.5, 0.25, 0.125)) # -1 -2 -3 } \keyword{arith} matlab/man/fileparts.Rd0000644000175100001440000000270614245210351014565 0ustar hornikusers% $Id: fileparts.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{fileparts} \alias{fileparts} \title{MATLAB fileparts function} \description{ Return filename parts. } \usage{ fileparts(pathname) } \arguments{ \item{pathname}{character string representing pathname to be parsed} } \details{ Determines the path, filename, extension, and version for the specified file. The returned \code{ext} contains a dot (.) before the file extension. The returned \code{versn} is always an empty string as the field is provided for compatibility with its namesake's results. } \value{ Returns a list with components: \item{pathstr}{character string representing directory path} \item{name}{character string representing base of file name} \item{ext}{character string representing file extension} \item{versn}{character string representing version. Unused} } \note{ Returns same insane results as does its namesake when handling relative directories, UNIX hidden files, and tilde expansion. Hidden files are returned with \code{name} containing a zero length vector and \code{ext} containing the actual name. For best results, use this routine to process files, not directories. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{fullfile}} } \examples{ ## Rename dot-txt file as dot-csv ans <- fileparts("/home/luser/foo.txt") fullfile(ans$pathstr, paste(ans$name, "csv", sep=".")) # /home/luser/foo.csv } \keyword{file} matlab/man/rot90.Rd0000644000175100001440000000127614245210351013552 0ustar hornikusers% $Id: rot90.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{rot90} \alias{rot90} \title{MATLAB rot90 function} \description{ Rotates matrix counterclockwise \code{k*90} degrees. } \usage{ rot90(A, k=1) } \arguments{ \item{A}{matrix to be rotated} \item{k}{numeric scalar specifying the number of times to rotate (1..4)} } \details{ Rotating 4 times (360 degrees) returns the original matrix unchanged. } \value{ Returns matrix corresponding to argument \code{A} having been rotated argument \code{k} number of times. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{fliplr}}, \code{\link{flipud}} } \examples{ rot90(matrix(1:4, 2, 2)) } \keyword{array} matlab/man/fullfile.Rd0000644000175100001440000000171514245210351014375 0ustar hornikusers% $Id: fullfile.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{fullfile} \alias{fullfile} \title{MATLAB fullfile function} \description{ Contructs path to a file from components in platform-independent manner } \usage{ fullfile(\dots) } \arguments{ \item{\dots}{character strings representing path components} } \details{ Builds a full filename from the directories and filename specified. This is conceptually equivalent to \preformatted{ paste(dir1, dir2, dir3, filename, sep=filesep) } with care taken to handle cases when directories begin or end with a separator. } \value{ Returns character vector of arguments concatenated term-by-term and separated by file separator if all arguments have a positive length; otherwise, an empty character vector. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{fileparts}}, \code{\link{filesep}} } \examples{ fullfile("", "etc", "profile") # /etc/profile } \keyword{file} matlab/man/isempty.Rd0000644000175100001440000000105414245210351014261 0ustar hornikusers% $Id: isempty.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{isempty} \alias{isempty} \title{MATLAB isempty function} \description{ Determine if object is empty. } \usage{ isempty(A) } \arguments{ \item{A}{object to evaluate} } \details{ An empty object has at least one dimension of size zero. } \value{ Returns \code{TRUE} if \code{x} is an empty object; otherwise, \code{FALSE}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ isempty(1:3) # FALSE isempty(array(NA, c(2, 0, 2))) # TRUE } \keyword{logic} \keyword{attribute} matlab/man/magic.Rd0000644000175100001440000000160414245210351013650 0ustar hornikusers% $Id: magic.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{magic} \alias{magic} \title{MATLAB magic function} \description{ Create a magic square. } \usage{ magic(n) } \arguments{ \item{n}{numeric scalar specifying dimensions for the result} } \details{ The value of the characteristic sum for a magic square of order \code{n} is \eqn{sum(1:n^2)/n}. The order \code{n} must be a scalar greater than or equal to 3; otherwise, the result will be either a nonmagic square, or else the degenerate magic squares 1 and []. } \value{ Returns an \code{n}-by-\code{n} matrix constructed from the integers \code{1} through \eqn{N^2} with equal row and column sums. } \note{ A magic square, scaled by its magic sum, is doubly stochastic. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{ones}}, \code{\link{zeros}} } \examples{ magic(3) } \keyword{array} matlab/man/jet.colors.Rd0000644000175100001440000000155314245210351014655 0ustar hornikusers% $Id: jet.colors.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{jet.colors} \alias{jet.colors} \title{MATLAB jet function} \description{ Creates a vector of \code{n} colors beginning with dark blue, ranging through shades of blue, cyan, green, yellow and red, and ending with dark red. } \usage{ jet.colors(n) } \arguments{ \item{n}{numeric scalar specifying number of colors to be in the palette} } \value{ Returns vector of \code{n} color names. This can be used either to create a user-defined color palette for subsequent graphics, a \code{col=} specification in graphics functions, or in \code{par}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link[grDevices]{palette}}, \code{\link[graphics]{par}}, \code{\link[grDevices]{rgb}} } \examples{ require(graphics) x <- 1:16 pie(x, col=jet.colors(length(x))) } \keyword{color} matlab/man/logspace.Rd0000644000175100001440000000153614245210351014371 0ustar hornikusers% $Id: logspace.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{logspace} \alias{logspace} \title{MATLAB logspace function} \description{ Generate logarithmically spaced vectors. } \usage{ logspace(a, b, n=50) } \arguments{ \item{a}{numeric scalar specifying exponent for starting point} \item{b}{numeric scalar specifying exponent for ending point} \item{n}{numeric scalar specifying number of points to be generated} } \details{ Useful for creating frequency vectors, it is a logarithmic equivalent of \code{linspace}. } \value{ Returns vector containing containing \code{n} points logarithmically spaced between decades \eqn{10^\code{a}} and \eqn{10^\code{b}}. For \eqn{n < 2}, \code{b} is returned. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{linspace}} } \examples{ logspace(1, pi, 36) } \keyword{manip} matlab/man/isprime.Rd0000644000175100001440000000142414245210351014240 0ustar hornikusers% $Id: isprime.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{isprime} \alias{isprime} \title{MATLAB isprime function} \description{ Array elements that are prime numbers. } \usage{ isprime(x) } \arguments{ \item{x}{numeric vector or matrix containing nonnegative integer values} } \value{ Returns an array (or vector) the same size as \code{x} containing logical 1 (\code{true}) for the elements of \code{x} which are prime, and logical 0 (\code{false}) otherwise. } \author{ H. Borchers \email{hwborchers@googlemail.com}, P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{factors}}, \code{\link{primes}} } \examples{ x <- c(2, 3, 0, 6, 10) ans <- isprime(x) ## 1, 1, 0, 0, 0 as.logical(ans) ## true, true, false, false, false } \keyword{arith} matlab/man/cell.Rd0000644000175100001440000000115314245210351013506 0ustar hornikusers% $Id: cell.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{cell} \alias{cell} \title{MATLAB cell function} \description{ Create cell array. } \usage{ cell(\dots) } \arguments{ \item{\dots}{numeric dimensions for the result} } \value{ Returns list consisting of empty matrices. Defaults to square if dimension argument resolves to a single value. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{ones}}, \code{\link{zeros}} } \examples{ cell(3) cell(c(3, 3)) # same thing cell(3, 3) # same thing cell(size(matrix(NA, 3, 3))) # same thing } \keyword{array} \keyword{list} matlab/man/pascal.Rd0000644000175100001440000000150614245210351014034 0ustar hornikusers% $Id: pascal.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{pascal} \alias{pascal} \title{MATLAB pascal function} \description{ Generate Pascal matrix. } \usage{ pascal(n, k=0) } \arguments{ \item{n}{numeric scalar specifying order} \item{k}{numeric scalar specifying desired option. Valid values are 0, 1, or 2} } \details{ Specifying \eqn{k=0} returns symmetric positive definite matrix with integer entries taken from Pascal's triangle. Specifying \eqn{k=1} returns the lower triangular Cholesky factor (up to the signs of the columns) of the Pascal matrix. Specifying \eqn{k=2} returns a cube root of the identity matrix. } \value{ Returns matrix of order \code{n} according to specified option \code{k}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ pascal(4) pascal(3, 2) } \keyword{array} matlab/man/hilb.Rd0000644000175100001440000000115514245210351013507 0ustar hornikusers% $Id: hilb.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{hilb} \alias{hilb} \title{MATLAB hilb function} \description{ Create a Hilbert matrix. } \usage{ hilb(n) } \arguments{ \item{n}{numeric scalar specifying dimensions for the result} } \details{ The Hilbert matrix is a notable example of a poorly conditioned matrix. Its elements are \preformatted{ H[i, j] = 1 / (i + j - 1)}. } \value{ Returns an \code{n}-by-\code{n} matrix constructed as described above. } \author{ H. Borchers \email{hwborchers@googlemail.com}, P. Roebuck \email{proebuck1701@gmail.com} } \examples{ hilb(3) } \keyword{array} matlab/man/padarray.Rd0000644000175100001440000000406414245210351014376 0ustar hornikusers% $Id: padarray.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{padarray} \alias{padarray} \alias{padarray,array,numeric,missing,missing-method} \alias{padarray,array,numeric,ANY,character-method} \alias{padarray,array,numeric,character,character-method} \alias{padarray,vector,numeric,ANY,ANY-method} \title{MATLAB padarray function} \description{ Pad array. } \usage{ padarray(A, padsize, padval=0, direction=c("both", "pre", "post")) } \arguments{ \item{A}{vector, matrix, or array to be padded} \item{padsize}{integer vector specifying both amount of padding and the dimension along which to add it} \item{padval}{scalar value specifying pad value, which defaults to 0. \cr Instead, it may specify the method used to determine pad values. \cr Valid values for the method are: \tabular{ll}{ \code{"circular"} \tab pad with circular repetition of elements within the dimension \cr \code{"replicate"} \tab pad by repeating border elements of array \cr \code{"symmetric"} \tab pad array with mirror reflections of itself \cr } } \item{direction}{character string specifying direction to apply padding. \cr Valid values are: \tabular{ll}{ \code{"both"} \tab pad before first element and after last array element along each dimension \cr \code{"pre"} \tab pad after last array element along each dimension \cr \code{"post"} \tab pad before first array element along each dimension \cr } } } \details{ This is an S4 generic function. } \value{ Return value is the same type as argument \code{A} with requested padding. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ padarray(1:4, c(0, 2)) # 0 0 [1 2 3 4] 0 0 padarray(1:4, c(0, 2), -1) # -1 -1 [1 2 3 4] -1 -1 padarray(1:4, c(0, 2), -1, "post") # [1 2 3 4] -1 -1 padarray(1:4, c(0, 3), "symmetric", "pre") # 3 2 1 [1 2 3 4] padarray(letters[1:5], c(0, 3), "replicate") # a a a [a b c d e] e e e padarray(letters[1:5], c(0, 3), "circular", "post") # [a b c d e] a b c } \keyword{array} matlab/man/size_t-class.Rd0000644000175100001440000000141114640470470015175 0ustar hornikusers% $Id: size_t-class.Rd 23 2022-05-30 18:22:23Z proebuck $ \name{size_t-class} \alias{size_t-class} \docType{class} \title{Class "size_t"} \description{ This class represents the dimensions of another \R object } \section{Objects from the Class}{ Objects can be created by calls of the form \code{new("size_t", \dots)}. Use of generator method is preferred. } \section{Slots}{ \describe{ \item{\code{.Data}:}{object of class \code{"integer"} containing size values} } } \section{Extends}{ Class \code{"integer"}, from data part. Class \code{"vector"}, by class \code{"integer"}. Class \code{"numeric"}, by class \code{"integer"}. } \note{ Internal class supporting \code{\link{size}}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \keyword{classes} matlab/man/pow2.Rd0000644000175100001440000000222514245205537013471 0ustar hornikusers% $Id: pow2.Rd 23 2022-05-30 18:22:23Z proebuck $ \name{pow2} \alias{pow2} \title{MATLAB pow2 function} \description{ Power with base 2. } \usage{ pow2(f, e) } \arguments{ \item{f}{numeric vector of factors} \item{e}{numeric vector of exponents for base 2} } \details{ Computes the expression \code{f * 2^e} for corresponding elements of \code{f} and \code{e}. If \code{e} is missing, it sets \code{e} to \code{f} and \code{f} to 1. Imaginary parts of complex values are ignored unless \code{e} is missing. } \value{ Returns numeric vector constructed as described above. } \author{ H. Borchers \email{hwborchers@googlemail.com}, P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{nextpow2}} } \examples{ pow2(c(0, 1, 2, 3)) # 1 2 4 8 pow2(c(0, -1, 2, 3), c(0,1,-2,3)) # 0.0 -2.0 0.5 24.0 pow2(1i) # 0.7692389+0.6389613i # For IEEE arithmetic... pow2(1/2, 1) # 1 pow2(pi/4, 2) # pi pow2(-3/4, 2) # -3 pow2(1/2, -51) # .Machine$double.eps pow2(1/2, -1021) # .Machine$double.xmin } \keyword{arith} matlab/man/vander.Rd0000644000175100001440000000132414245210351014046 0ustar hornikusers% $Id: vander.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{vander} \alias{vander} \title{MATLAB vander function} \description{ Generate Vandermonde matrix from a vector of numbers. } \usage{ vander(v) } \arguments{ \item{v}{numeric or complex vector of values} } \details{ Generates the Vandermonde matrix whose columns are powers of the vector \code{v} (of length \code{n}) using the formula \preformatted{ A[i, j] = v[i]^(n-j) } Used when fitting a polynomial to given points. } \value{ Returns an \code{n}-by-\code{n} matrix constructed as described above. } \author{ H. Borchers \email{hwborchers@googlemail.com}, P. Roebuck \email{proebuck1701@gmail.com} } \examples{ vander(1:5) } \keyword{array} matlab/man/factors.Rd0000644000175100001440000000171614245210351014235 0ustar hornikusers% $Id: factors.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{factors} \alias{factors} \title{MATLAB factor function} \description{ Performs prime factorization. } \usage{ factors(n) } \arguments{ \item{n}{numeric scalar specifying composite number to be factored} } \details{ Computes the prime factors of \code{n} in ascending order, each one as often as its multiplicity requires, such that \code{n == prod(factors(n))}. } \value{ Returns vector containing the prime factors of \code{n}. } \note{ The corresponding MATLAB function is called 'factor', but was renamed here to avoid conflict with R's compound object class. } \author{ H. Borchers \email{hwborchers@googlemail.com}, P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{isprime}}, \code{\link{primes}} } \examples{ factors(1002001) # 7 7 11 11 13 13 factors(65537) # is prime ## Euler's calculation factors(2^32 + 1) # 641 6700417 } \keyword{arith} matlab/man/ones.Rd0000644000175100001440000000127414245210351013537 0ustar hornikusers% $Id: ones.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{ones} \alias{ones} \alias{zeros} \title{MATLAB ones/zeros functions} \description{ Create a matrix consisting of all ones or zeros. } \usage{ ones(\dots) zeros(\dots) } \arguments{ \item{\dots}{numeric dimensions for the result} } \value{ Returns matrix consisting only of ones (or zeros). Defaults to square if dimension argument resolves to a single value. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{eye}} } \examples{ ones(3) ones(c(3, 3)) # same thing ones(3, 3) # same thing ones(size(matrix(NA, 3, 3))) # same thing zeros(3) } \keyword{array} matlab/man/size.Rd0000644000175100001440000000262214245210351013543 0ustar hornikusers% $Id: size.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{size} \alias{size} \alias{size,array,integer-method} \alias{size,array,missing-method} \alias{size,array,numeric-method} \alias{size,matrix,integer-method} \alias{size,matrix,missing-method} \alias{size,matrix,numeric-method} \alias{size,vector,missing-method} \alias{size,vector,numeric-method} \alias{size,missing,ANY-method} \title{MATLAB size function} \description{ Provides dimensions of \code{X}. } \usage{ size(X, dimen) } \arguments{ \item{X}{vector, matrix, or array object} \item{dimen}{numeric scalar specifies particular dimension} } \details{ This is an S4 generic function. Vector will be treated as a single row matrix. Stored value is equivalent to \code{\link[base]{dim}}. } \value{ Returns object of class \code{size_t} containing the dimensions of input argument \code{X} if invoked with a single argument. Returns integer value of specified dimension if invoked with two arguments. If \code{dimen} specifies a higher dimension than exists, returns 1 representing the singleton dimension. } \note{ Handling of vectors is different than in initial implementation. Initial implementation returned \code{\link[base]{length}}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ size(2:9) # 1 8 size(matrix(1:8, 2, 4)) # 2 4 size(matrix(1:8, 2, 4), 2) # 4 size(matrix(1:8, 2, 4), 3) # 1 } \keyword{array} matlab/man/fliplr.Rd0000644000175100001440000000172314245210351014062 0ustar hornikusers% $Id: fliplr.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{fliplr} \alias{fliplr} \alias{fliplr,ANY-method} \alias{fliplr,array-method} \alias{fliplr,matrix-method} \alias{fliplr,missing-method} \alias{fliplr,vector-method} \alias{flipud} \alias{flipud,ANY-method} \alias{flipud,array-method} \alias{flipud,matrix-method} \alias{flipud,missing-method} \alias{flipud,vector-method} \title{MATLAB matrix flip functions} \description{ Flips matrices either left-right or up-down. } \usage{ fliplr(object) flipud(object) } \arguments{ \item{object}{vector or matrix to be flipped} } \details{ These are S4 generic functions. } \value{ Return value is the same type as argument \code{object}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{rot90}} } \examples{ fliplr(1:9) flipud(1:9) # same as previous since vectors have no orientation in R fliplr(matrix(1:9, 3, 3, byrow=TRUE)) flipud(matrix(1:9, 3, 3, byrow=TRUE)) } \keyword{array} matlab/man/ndims.Rd0000644000175100001440000000133114245210351013677 0ustar hornikusers% $Id: ndims.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{ndims} \alias{ndims} \title{MATLAB ndims function} \description{ Provides number of array dimensions. } \usage{ ndims(A) } \arguments{ \item{A}{object of which to determine the number of dimensions} } \details{ Simply invokes \code{\link[base]{length}(\link{size}(A))}. } \value{ Returns the number of dimensions in the array \code{A}. } \seealso{ \code{\link{size}} } \note{ The number of dimensions is always greater than or equal to 2. Initial implementation returned \code{\link[base]{length}}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ ndims(2:9) # 2 ndims(magic(4)) # 2 ndims(array(1:8, c(2,2,2))) # 3 } \keyword{array} matlab/man/fix.Rd0000644000175100001440000000106114245210351013353 0ustar hornikusers% $Id: fix.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{fix} \alias{fix} \title{MATLAB fix function} \description{ Rounds toward zero. } \usage{ fix(A) } \arguments{ \item{A}{numeric to be rounded} } \details{ Simply invokes \code{\link[base:Round]{trunc}}. } \value{ Returns vector containing integers by truncating the corresponding values of argument \code{A} toward zero. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{ceil}}, \code{\link[base]{Round}} } \examples{ fix(c(1.3, 2.5, 3.7)) } \keyword{arith} matlab/man/tictoc.Rd0000644000175100001440000000143014245210351014052 0ustar hornikusers% $Id: tictoc.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{tictoc} \alias{tic} \alias{toc} \title{MATLAB timer functions} \description{ Provides stopwatch timer. Function \code{tic} starts the timer and \code{toc} updates the elapsed time since the timer was started. } \usage{ tic(gcFirst=FALSE) toc(echo=TRUE) } \arguments{ \item{gcFirst}{logical scalar. If \code{TRUE}, perform garbage collection prior to starting stopwatch} \item{echo}{logical scalar. If \code{TRUE}, print elapsed time to screen} } \details{ Provides analog to \code{\link[base]{system.time}}. Function \code{toc} can be invoked multiple times in a row. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ tic() for(i in 1:100) mad(runif(1000)) # kill time toc() } \keyword{utilities} matlab/man/sum.Rd0000644000175100001440000000160614245210351013376 0ustar hornikusers% $Id: sum.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{sum} \alias{sum} \alias{sum,array,logical-method} \alias{sum,array,missing-method} \alias{sum,matrix,logical-method} \alias{sum,matrix,missing-method} \alias{sum,vector,logical-method} \alias{sum,vector,missing-method} \alias{sum,ANY,ANY-method} \alias{sum,missing,ANY-method} \title{MATLAB sum function} \description{ Provides sum of elements. } \usage{ sum(x, na.rm=FALSE) } \arguments{ \item{x}{numeric or logical to be summed} \item{na.rm}{logical scalar. If \code{TRUE}, remove missing values} } \details{ This is an S4 generic function. } \value{ Return value depends on argument \code{x}. If vector, returns the same as \code{\link[base]{sum}}. If matrix, returns vector containing the sum of each column. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \examples{ sum(1:9) sum(matrix(1:9, 3, 3)) } \keyword{arith} matlab/man/numel.Rd0000644000175100001440000000107214245210351013707 0ustar hornikusers% $Id: numel.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{numel} \alias{numel} \title{MATLAB numel function} \description{ Provides number of elements in array \code{A} or subscripted array expression. } \usage{ numel(A, varargin) } \arguments{ \item{A}{object of which to determine the number of elements} \item{varargin}{unimplemented} } \value{ Returns \code{prod(size(A))}. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link[base]{prod}}, \code{\link{size}} } \examples{ numel(2:9) # 8 numel(magic(4)) # 16 } \keyword{array} matlab/man/pathsep.Rd0000644000175100001440000000120514245210351014231 0ustar hornikusers% $Id: pathsep.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{pathsep} \alias{pathsep} \title{MATLAB pathsep function} \description{ Returns the character that separates directory names in a list such as the \env{PATH} environment variable. } \usage{ pathsep } \details{ Variable that contains the value of \code{.Platform$path.sep}. } \value{ Returns character representing this platform's path separator. } \note{ Implemented as an R variable rather than a function such that it more closely resembles normal MATLAB usage. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{filesep}} } \keyword{file} matlab/man/filesep.Rd0000644000175100001440000000121714245210351014217 0ustar hornikusers% $Id: filesep.Rd 25 2022-05-30 18:46:01Z proebuck $ \name{filesep} \alias{filesep} \title{MATLAB filesep function} \description{ Returns the character that separates directory names in filenames. } \usage{ filesep } \details{ Variable that contains the value of \code{.Platform$file.sep}. } \value{ Returns character representing this platform's file separator. } \note{ Implemented as an R variable rather than a function such that it more closely resembles normal MATLAB usage. } \author{ P. Roebuck \email{proebuck1701@gmail.com} } \seealso{ \code{\link{fileparts}}, \code{\link{fullfile}}, \code{\link{pathsep}} } \keyword{file} matlab/DESCRIPTION0000644000175100001440000000111714640471532013244 0ustar hornikusersPackage: matlab Version: 1.0.4.1 Date: 2022-05-31 Title: 'MATLAB' Emulation Package Author: P. Roebuck Maintainer: P. Roebuck Description: Emulate 'MATLAB' code using 'R'. Depends: R (>= 2.15) Imports: methods URL: https://cran.r-project.org/package=matlab License: Artistic-2.0 Copyright: file COPYRIGHTS LazyLoad: true NeedsCompilation: no Repository: CRAN Date/Publication: 2024-07-01 09:14:02 UTC Repository/R-Forge/Project: estimate Repository/R-Forge/Revision: 43 Repository/R-Forge/DateTimeStamp: 2022-05-31 23:32:38 Packaged: 2024-07-01 09:05:18 UTC; hornik