[Roxygen-commits] r179 - in pkg: inst/doc sandbox

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Aug 24 10:37:19 CEST 2008


Author: pcd
Date: 2008-08-24 10:37:19 +0200 (Sun, 24 Aug 2008)
New Revision: 179

Added:
   pkg/inst/doc/example-pseudoprime.R
   pkg/inst/doc/roxygen.Rnw
Modified:
   pkg/sandbox/example-pseudoprime.R
Log:
scrunch line-width for LaTeX listing; inchoate vignette


Added: pkg/inst/doc/example-pseudoprime.R
===================================================================
--- pkg/inst/doc/example-pseudoprime.R	                        (rev 0)
+++ pkg/inst/doc/example-pseudoprime.R	2008-08-24 08:37:19 UTC (rev 179)
@@ -0,0 +1 @@
+link ../../sandbox/example-pseudoprime.R
\ No newline at end of file


Property changes on: pkg/inst/doc/example-pseudoprime.R
___________________________________________________________________
Name: svn:special
   + *

Added: pkg/inst/doc/roxygen.Rnw
===================================================================
--- pkg/inst/doc/roxygen.Rnw	                        (rev 0)
+++ pkg/inst/doc/roxygen.Rnw	2008-08-24 08:37:19 UTC (rev 179)
@@ -0,0 +1,9 @@
+\documentclass{article}
+\usepackage{fancyvrb}
+\begin{document}
+\begin{figure}
+  \centering
+  \VerbatimInput[numbers=left, frame=single]{example-pseudoprime.R}
+  \caption{Roxygen example \texttt{example-pseudoprime.R}}
+\end{figure}
+\end{document}

Modified: pkg/sandbox/example-pseudoprime.R
===================================================================
--- pkg/sandbox/example-pseudoprime.R	2008-08-24 08:37:16 UTC (rev 178)
+++ pkg/sandbox/example-pseudoprime.R	2008-08-24 08:37:19 UTC (rev 179)
@@ -1,23 +1,26 @@
 #' Test an integer for primality with Fermat's Little Theorem.
 #'
-#' Fermat's Little Theorem states that if \eqn{n} is a prime number and
-#' \eqn{a} is any positive integer less than \eqn{n}, then \eqn{a} raised
-#' to the \eqn{n}th power is congruent to \eqn{a modulo n}.
+#' Fermat's Little Theorem states that if \eqn{n} is a prime
+#' number and \eqn{a} is any positive integer less than \eqn{n},
+#' then \eqn{a} raised to the \eqn{n}th power is congruent to
+#' \eqn{a modulo n}.
 #'
 #' @author Peter Danenberg \email{pcd@@roxygen.org}
 #' @param n the integer to test for primality
 #' @return Whether the integer passes the Fermat test
-#'   for a randomized 0 < a < n
+#'   for a randomized \eqn{0 < a < n}
 fermat.test <- function(n) {
   a <- floor(runif(1, min=1, max=n))
-  isTRUE(a ^ n %% n == a)
+  a ^ n %% n == a
 }
 
-#' Check an integer for pseudo-primality to an arbitrary precision.
+#' Check an integer for pseudo-primality to an arbitrary
+#' precision.
 #'
-#' A number is pseudo-prime if it is probably prime, the basis of
-#' which is the probabilistic Fermat test; if it passes two such
-#' tests, the chances are better than 3 out of 4 that \eqn{n} is prime.
+#' A number is pseudo-prime if it is probably prime, the basis
+#' of which is the probabilistic Fermat test; if it passes two
+#' such tests, the chances are better than 3 out of 4 that
+#' \eqn{n} is prime.
 #'
 #' @author Peter Danenberg \email{pcd@@roxygen.org}
 #' @param n the integer to test for pseudoprimality.
@@ -26,12 +29,11 @@
 #' @export
 #' @seealso \code{\link{fermat.test}}
 #' @references Abelson, Hal; Jerry Sussman, and Julie Sussman.
-#'   Structure and Interpretation of Computer Programs. Cambridge:
-#'   MIT Press, 1984.
+#'   Structure and Interpretation of Computer Programs.
+#'   Cambridge: MIT Press, 1984.
 #' @keywords pseudoprime fermat
 #' @examples
-#'   ## Will be true most of the time
-#'   is.pseudoprime(13, 4)
+#' is.pseudoprime(13, 4)  # TRUE most of the time
 is.pseudoprime <- function(n, times) {
   if (times == 0) TRUE
   else if (fermat.test(n)) is.fermat.prime(n, times - 1)



More information about the Roxygen-commits mailing list