Commit 7e7448c2 authored by Martin Maechler's avatar Martin Maechler
Browse files

Provide NA_bigz_ & NA_bigq_

parent 6bc955dc
......@@ -43,6 +43,7 @@ export(
"mod.bigz",
"modulus", "modulus<-", # "modulus<-.bigz", "modulus.bigz",
"mul.bigq", "mul.bigz",
NA_bigz_, NA_bigq_,
"ncol.bigq", "ncol.bigz", "nrow.bigq", "nrow.bigz",
"nextprime",
"numerator", "numerator<-",
......
......@@ -11,5 +11,12 @@ gmpVersion <- function()
.onLoad <- function(libname, pkgname) {
options("gmp:warnModMismatch" = TRUE, ## see ../man/biginteger.Rd
"gmp:warnNoInv" = TRUE) ## ../man/add.biginteger.Rd | ../src/bigmod.cc
## as.big[zq]() need package dynloaded :
gmpEnv <- parent.env(environment())
gmpEnv$ NA_bigz_ <- as.bigz(NA)
gmpEnv$ NA_bigq_ <- as.bigq(NA)
invisible()
}
......@@ -8,6 +8,7 @@
\alias{as.double.bigz}
\alias{print.bigz}
\alias{is.na.bigz}
\alias{NA_bigz_}
% these two are C symbols, will be removed eventually:
\alias{biginteger_as}
\alias{biginteger_as_character}
......@@ -18,6 +19,7 @@
}
\usage{
as.bigz(a, mod = NA)
NA_bigz_
\S3method{as.character}{bigz}(x, b = 10, \dots)
% \S3method{as.double}{bigz}(x,\dots)
is.bigz(x)
......@@ -60,6 +62,8 @@ is.bigz(x)
Comparison are supported, i.e., \code{"=="}, \code{"!="},
\code{"<"}, \code{"<="}, \code{">"}, and \code{">="}.
\code{NA_bigz_} is computed on package load time as \code{as.bigz(NA)}.
Objects of class \code{"bigz"} may have a \dQuote{modulus}, accessible
via \code{\link{modulus}()}, currently as an attribute \code{mod}.
When the object has such a modulus \eqn{m}, arithmetic is performed
......@@ -121,6 +125,7 @@ two <- as.bigz(2)
p1 <- two^107 -1 ; isprime(p1); p1
p2 <- two^127 -1 ; isprime(p2); p2
stopifnot( is.na(NA_bigz_) )
## Calculate c = x^e mod n
## --------------------------------------------------------------------
......
\name{bigq}
\title{Large sized rationals}
\alias{bigq}
\alias{bigq-class}
\alias{as.bigq}
......@@ -7,18 +8,17 @@
\alias{as.double.bigq}
\alias{print.bigq}
\alias{is.na.bigq}
\alias{NA_bigq_}
\alias{as.bigz.bigq}
\alias{denominator}
\alias{denominator<-}
\alias{numerator}
\alias{numerator<-}
\title{Large sized rationals}
\description{
Class \code{"bigq"} encodes rationals encoded as ratios of arbitrary
large integers (via GMP).
A simple S3 class (internally a \code{\link{raw}} vector), it has been
registered as formal (S4) class (via \code{\link{setOldClass}}), too.
}
\usage{
as.bigq(n, d = 1)
......@@ -30,6 +30,7 @@ is.bigq(x)
\S3method{print}{bigq}(x, quote=FALSE, initLine = TRUE, ...)
denominator(x)
numerator(x)
NA_bigq_
}
\arguments{
......@@ -60,6 +61,8 @@ numerator(x)
\details{
\code{as.bigz.bigq()} returns the smallest integers not less than the
corresponding rationals bigq.
\code{NA_bigq_} is computed on package load time as \code{as.bigq(NA)}.
}
\author{Antoine Lucas}
......@@ -87,6 +90,8 @@ stopifnot(is.bigq(x), is.bigq(x + y),
as.character(x)
as.double(x)
stopifnot( is.na(NA_bigq_) )
# Depict the "S4-class" bigq, i.e., the formal (S4) methods:
if(require("Rmpfr")) # mostly interesting there
showMethods(class="bigq")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment