From 281a7701b5eac489e95bcbc98072dbe6cf0b69c1 Mon Sep 17 00:00:00 2001 From: stla Date: Thu, 9 Nov 2023 10:19:57 +0100 Subject: [PATCH] nome --- NAMESPACE | 1 + R/nome.R | 20 ++++++++++++++++++++ man/nome.Rd | 20 ++++++++++++++++++++ tests/testthat/test-nome.R | 5 +++++ 4 files changed, 46 insertions(+) create mode 100644 R/nome.R create mode 100644 man/nome.Rd create mode 100644 tests/testthat/test-nome.R diff --git a/NAMESPACE b/NAMESPACE index d86569c..6cdabec 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -30,6 +30,7 @@ export(ljtheta1) export(ljtheta2) export(ljtheta3) export(ljtheta4) +export(nome) export(sl) export(slh) export(sm) diff --git a/R/nome.R b/R/nome.R new file mode 100644 index 0000000..7e3a5a6 --- /dev/null +++ b/R/nome.R @@ -0,0 +1,20 @@ +#' @title Nome +#' @description The nome in function of the parameter \eqn{m}. +#' +#' @param m the parameter, square of elliptic modulus +#' +#' @return A complex number. +#' @export +#' @importFrom Carlson elliptic_F +#' +#' @examples +#' nome(-2) +nome <- function(m) { + if(m == 0) { + return(as.complex(0)) + } + if(m == 1) { + return(as.complex(1)) + } + exp(-pi * elliptic_F(pi/2, 1-m) / elliptic_F(pi/2, m)) +} \ No newline at end of file diff --git a/man/nome.Rd b/man/nome.Rd new file mode 100644 index 0000000..ec37df8 --- /dev/null +++ b/man/nome.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nome.R +\name{nome} +\alias{nome} +\title{Nome} +\usage{ +nome(m) +} +\arguments{ +\item{m}{the parameter, square of elliptic modulus} +} +\value{ +A complex number. +} +\description{ +The nome in function of the parameter \eqn{m}. +} +\examples{ +nome(-2) +} diff --git a/tests/testthat/test-nome.R b/tests/testthat/test-nome.R new file mode 100644 index 0000000..bec2b25 --- /dev/null +++ b/tests/testthat/test-nome.R @@ -0,0 +1,5 @@ +test_that("Some value of the nome", { + expect_equal(nome(-2), as.complex(-0.06823783), tolerance = 1e-6) + expect_equal(nome(0.5), as.complex(exp(-pi))) + expect_equal(nome(5/16), as.complex(0.02340125), tolerance = 1e-6) +}) \ No newline at end of file