[Distr-commits] r754 - in branches/distr-2.4/pkg/distr: . R inst vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Nov 18 12:51:19 CET 2011
Author: ruckdeschel
Date: 2011-11-18 12:51:19 +0100 (Fri, 18 Nov 2011)
New Revision: 754
Added:
branches/distr-2.4/pkg/distr/vignettes/
branches/distr-2.4/pkg/distr/vignettes/newDistributions.Rnw
branches/distr-2.4/pkg/distr/vignettes/svn-multi.sty
branches/distr-2.4/pkg/distr/vignettes/svnkw.sty
Removed:
branches/distr-2.4/pkg/distr/inst/doc/
Modified:
branches/distr-2.4/pkg/distr/DESCRIPTION
branches/distr-2.4/pkg/distr/R/internals-qqplot.R
branches/distr-2.4/pkg/distr/R/qqbounds.R
Log:
[distr] (branches)
reaction to http://developer.r-project.org/214update.txt
+ created folder vignettes and moved content of inst/doc/ to it
+ removed lazyload tag in DESCRIPTION
+ updated affiliation info in newDistributions.Rnw
+ deleted inst/doc folder
Modified: branches/distr-2.4/pkg/distr/DESCRIPTION
===================================================================
--- branches/distr-2.4/pkg/distr/DESCRIPTION 2011-11-18 11:48:06 UTC (rev 753)
+++ branches/distr-2.4/pkg/distr/DESCRIPTION 2011-11-18 11:51:19 UTC (rev 754)
@@ -1,6 +1,6 @@
Package: distr
Version: 2.4
-Date: 2011-02-14
+Date: 2011-11-18
Title: Object oriented implementation of distributions
Description: S4 Classes and Methods for distributions
Author: Florian Camphausen, Matthias Kohl, Peter Ruckdeschel, Thomas Stabla
@@ -9,10 +9,9 @@
Suggests: distrEx, SweaveListingUtils
Imports: stats
ByteCompile: yes
-LazyLoad: yes
Encoding: latin1
License: LGPL-3
URL: http://distr.r-forge.r-project.org/
LastChangedDate: {$LastChangedDate$}
LastChangedRevision: {$LastChangedRevision$}
-SVNRevision: 699
+SVNRevision: 754
Modified: branches/distr-2.4/pkg/distr/R/internals-qqplot.R
===================================================================
--- branches/distr-2.4/pkg/distr/R/internals-qqplot.R 2011-11-18 11:48:06 UTC (rev 753)
+++ branches/distr-2.4/pkg/distr/R/internals-qqplot.R 2011-11-18 11:51:19 UTC (rev 754)
@@ -91,18 +91,18 @@
res <- uniroot(fct,lower=0,upper=1)$root*sqrt(n)
}else{
### from ks.test from package stats:
- pkstwo <- function(x, tol = 1e-06) {
- if (is.numeric(x))
- x <- as.vector(x)
- else stop("argument 'x' must be numeric")
- p <- rep(0, length(x))
- p[is.na(x)] <- NA
- IND <- which(!is.na(x) & (x > 0))
- if (length(IND)) {
- p[IND] <- .C("pkstwo", as.integer(length(x[IND])),
- p = as.double(x[IND]), as.double(tol), PACKAGE = "stats")$p
- }
- return(p)
+ pkstwo <- function(x, tol = 1e-09) {
+ #if (is.numeric(x))
+ # x <- as.vector(x)
+ #else stop("argument 'x' must be numeric")
+ #p <- rep(0, length(x))
+ #p[is.na(x)] <- NA
+ #IND <- which(!is.na(x) & (x > 0))
+ #if (length(IND)) {
+ p <- .C("pkstwo", as.integer(1),
+ p = as.double(x), as.double(tol), PACKAGE = "stats")$p
+ #}
+ # return(p)
}
### end of code from package stats
fct <- function(p0){
@@ -204,7 +204,8 @@
SI.c <- SIi>0
x.in <- x[SI.in]
x.c <- x.in[SI.c]
- x.d <- x.in[!SI.c]
+ x.d <- x.in[!SI.c]
+
qqb <- qqbounds(x,D,alpha,n,withConf.pw, withConf.sim,
exact.sCI,exact.pCI,nosym.pCI)
Modified: branches/distr-2.4/pkg/distr/R/qqbounds.R
===================================================================
--- branches/distr-2.4/pkg/distr/R/qqbounds.R 2011-11-18 11:48:06 UTC (rev 753)
+++ branches/distr-2.4/pkg/distr/R/qqbounds.R 2011-11-18 11:51:19 UTC (rev 754)
@@ -16,7 +16,8 @@
x.in <- x[SI.in]
p.r <- p(D)(x.in)
p.l <- p.l(D)(x.in)
-
+ l.x <- length(x.in)
+
if(withConf.sim)
c.crit <- try(.q2kolmogorov(alpha,n,exact.sCI), silent=TRUE)
if(withConf.pw)
@@ -27,9 +28,11 @@
te.s <- withConf.sim & !is(c.crit, "try-error")
if(te.s){
- c.crit.r <- q.r(D)(pmax(1-p.r-c.crit/sqrt(n),
+ c.crit.r <- q.r(D)(#pmax(1-p.r-c.crit/sqrt(n),
+ pmax(1-(1:l.x)/l.x-c.crit/sqrt(n),
getdistrOption("DistrResolution")),lower.tail=FALSE)
- c.crit.l <- q(D)(pmax(p.l-c.crit/sqrt(n),
+ c.crit.l <- q(D)(#pmax(p.l-c.crit/sqrt(n),
+ pmax(((1:l.x)-1)/l.x-c.crit/sqrt(n),
getdistrOption("DistrResolution")))
c.crit.l[abs(c.crit.l)==Inf] <- NA
c.crit.r[abs(c.crit.r)==Inf] <- NA
Copied: branches/distr-2.4/pkg/distr/vignettes/newDistributions.Rnw (from rev 742, branches/distr-2.4/pkg/distr/inst/doc/newDistributions.Rnw)
===================================================================
--- branches/distr-2.4/pkg/distr/vignettes/newDistributions.Rnw (rev 0)
+++ branches/distr-2.4/pkg/distr/vignettes/newDistributions.Rnw 2011-11-18 11:51:19 UTC (rev 754)
@@ -0,0 +1,412 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Vignette "How to generate new distributions in packages distr, distrEx"
+%
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%\VignetteIndexEntry{newDistributions}
+%\VignetteDepends{startupmsg}
+%\VignetteKeywords{probability distribution,estimation}
+%\VignettePackage{distr}
+%
+%
+%
+\documentclass[10pt]{article}
+%
+%use svn-multi to fill in revision information
+%
+\usepackage{svn-multi}
+% Version control information:
+\svnidlong
+{$HeadURL$}
+{$LastChangedDate$}
+{$LastChangedRevision$}
+{$LastChangedBy$}
+%\svnid{$Id: example_main.tex 146 2008-12-03 13:29:19Z martin $}
+% Don't forget to set the svn property 'svn:keywords' to
+% 'HeadURL LastChangedDate LastChangedRevision LastChangedBy' or
+% 'Id' or both depending if you use \svnidlong and/or \svnid
+%
+\newcommand{\svnfooter}{Last Changed Rev: \svnkw{LastChangedRevision}}
+\svnRegisterAuthor{ruckdeschel}{Peter Ruckdeschel}
+\svnRegisterAuthor{stamats}{Matthias Kohl}
+\svnRegisterAuthor{florian}{Florian Camphausen}
+\svnRegisterAuthor{stabla}{Thomas Stabla}
+\svnRegisterAuthor{anhuel}{Anja H{\"u}ller}
+\svnRegisterAuthor{ifrin}{Eleonara Feist}
+\svnRegisterAuthor{jdospina}{Juan David Ospina}
+\svnRegisterAuthor{kowzar}{Kouros Owzar}
+%
+\usepackage{geometry}
+%
+\usepackage{color}
+\definecolor{darkblue}{rgb}{0.0,0.0,0.75}
+\definecolor{distrCol}{rgb}{0.0,0.4,0.4}
+%
+\usepackage{ifpdf}
+%
+\usepackage{url}
+\usepackage{amssymb}
+\usepackage[%
+baseurl={r-forge.r-project.org},%
+pdftitle={How to generate new distributions in packages distr, distrEx},%
+pdfauthor={Peter Ruckdeschel, Matthias Kohl},%
+pdfsubject={distr},%
+pdfkeywords={probability distribution,simulation,estimation},%
+pagebackref,bookmarks,colorlinks,linkcolor=darkblue,citecolor=darkblue,%
+pagecolor=darkblue,raiselinks,plainpages,pdftex]{hyperref}
+%
+\markboth{\sl How to generate new distributions in packages ``{\tt distr}'', ``{\tt distrEx}''}%
+{\sl How to generate new distributions in packages ``{\tt distr}'', ``{\tt distrEx}''}
+%
+% -------------------------------------------------------------------------------
+\newcommand{\Reals}{\mathbb{R}}
+\newcommand{\R}{\mathbb{R}}
+\newcommand{\N}{\mathbb{N}}
+%
+% -------------------------------------------------------------------------------
+\RequirePackage{fancyvrb}
+\RequirePackage{listings}
+%\usepackage{Sweave} no longer needed
+% -------------------------------------------------------------------------------
+\SweaveOpts{keep.source=TRUE}
+% -------------------------------------------------------------------------------
+<<SweaveListingsPreparations, results=tex, echo=FALSE>>=
+require(SweaveListingUtils)
+SweaveListingPreparations()
+setToBeDefinedPkgs(pkgs = c("distr","distrEx"),
+ keywordstyles = "\\bf\\color{distrCol}")
+@
+% -------------------------------------------------------------------------------
+%
+% -------------------------------------------------------------------------------
+\begin{document}
+% -------------------------------------------------------------------------------
+\title{How to generate new distributions in packages \pkg{distr}, \pkg{distrEx}}
+%,version \pkgExversion}
+\author{\small Peter Ruckdeschel\thanks{Fraunhofer ITWM, Kaiserslautern}
+\\[-.5ex]
+\small Matthias Kohl\thanks{FH Furtwangen}
+\smallskip\\
+\small Fraunhofer ITWM\\[-.5ex]
+\small Fraunhofer Platz 1\\[-.5ex]
+\small 67663 Kaiserslautern\\[-.5ex]
+\small Germany\\
+\small e-Mail: {\small \tt Peter.Ruckdeschel at itwm.fraunhofer.de}\medskip\\
+\parbox[t]{5cm}{
+\footnotesize\sffamily
+ Version control information:
+\begin{tabbing}
+\footnotesize\sffamily
+ Last changes revision: \= \kill
+ Head URL: \> \parbox[t]{6cm}{\url{\svnkw{HeadURL}}}\\[1.2ex]
+ Last changed date: \> \svndate\\
+ Last changes revision: \> \svnrev\\
+ Version: \> \svnFullRevision*{\svnrev}\\
+ Last changed by: \> \svnFullAuthor*{\svnauthor}\\
+\end{tabbing}
+}}
+
+\maketitle
+% -------------------------------------------------------------------------------
+\begin{abstract}
+% -------------------------------------------------------------------------------
+In this vignette, we give short examples how to produce new
+distributions in packages \pkg{distr} and \pkg{distrEx}.
+This vignette refers to package version~\pkgversion.
+% -------------------------------------------------------------------------------
+\end{abstract}
+% -------------------------------------------------------------------------------
+Basically there are three ways to produce new
+distributions in packages \pkg{distr} and \pkg{distrEx}:
+\begin{enumerate}
+\item automatic generation of single distribution objects by arithmetics and the like
+\item using generating functions to produce single distribution objects
+\item defining new distribution classes / doing it from scratch
+\end{enumerate}
+We will give short examples of all three of them.
+% -------------------------------------------------------------------------------
+\section{Automatic generation by arithmetics and the like}
+% -------------------------------------------------------------------------------
+We have made available quite general arithmetical operations to our distribution
+objects, generating new image distribution objects automatically. As an example, try
+<<Prepa, echo=false, results=tex>>=
+## preparation: set option withSweave to true
+require(distr)
+distroptions(withSweave = TRUE)
+options(width=70)
+@
+%
+<<exam1, eval = TRUE, fig = TRUE>>=
+require(distr)
+N <- Norm(mean = 2, sd = 1.3)
+P <- Pois(lambda = 1.2)
+Z <- 2*N + 3 + P
+Z
+plot(Z, panel.first = grid(), lwd=2)
+p(Z)(0.4)
+q(Z)(0.3)
+Zs <- r(Z)(50)
+Zs
+@
+\par
+\noindent{\bf Comment:}\\
+Let \code{N} an object of class \code{"Norm"} with parameters \code{mean=2},
+\code{sd=1.3} and let \code{P} an object of class \code{"Pois"} with parameter
+\code{lambda=1.2}. Assigning to \code{Z} the expression \code{2*N+3+P}, a
+new distribution object is generated ---of class \code{"AbscontDistribution"} in
+our case--- so that identifying \code{N}, \code{P}, \code{Z} with random
+variables distributed according to {\tt N}, {\tt P}, {\tt Z},
+${\cal L}({\tt Z})={\cal L}(2*{\tt N}+3+{\tt P})$, and writing \code{p(Z)(0.4)}
+we get $P(Z\leq 0.4)$, \code{ q(Z)(0.3)} the $30\%$-quantile of {\tt Z},
+and with \code{r(Z)(50)} we generate $50$ pseudo random numbers distributed
+according to {\tt Z}, while the \code{plot} command generates the above figure.\\
+
+There a caveats to take care about; for details refer to the (larger) vignette
+{\tt distr} in package \pkg{distrDoc}.
+% -------------------------------------------------------------------------------
+\section{Using generating functions}
+% -------------------------------------------------------------------------------
+If you want to generate a single distribution object (without any particular parameter)
+generating functions are the method of choice:\\
+
+
+Objects of classes \code{LatticeDistribution} resp.\
+\code{DiscreteDistribution},
+\code{AbscontDistribution}, may be generated using the generating functions
+\code{LatticeDistribution()} resp.\ \code{DiscreteDistribution()}
+resp.\ \code{AbscontDistribution()}; see also
+the corresponding help.\\
+
+E.g., to produce a discrete distribution with
+support $(1,5,7,21)$ with corresponding probabilities $(0.1,0.1,0.6,0.2)$
+we may write
+<<DiscrDist, eval = TRUE, fig = TRUE>>=
+D <- DiscreteDistribution(supp = c(1,5,7,21), prob = c(0.1,0.1,0.6,0.2))
+D
+plot(D, panel.first = grid(), lwd = 2)
+@
+%
+\newline
+and to generate an absolutely continuos distribution with density proportional
+to $e^{-|x|^3}$, we write
+<<AbscDist, eval = TRUE, fig = TRUE>>=
+AC <- AbscontDistribution(d = function(x) exp(-abs(x)^3), withStand = TRUE)
+AC
+plot(AC, panel.first = grid(), lwd = 2)
+@
+%
+% -------------------------------------------------------------------------------
+\section{Doing it from scratch}
+% -------------------------------------------------------------------------------
+If you would like to create new parametric distributions, using already
+implemented {\tt r}, {\tt d}, {\tt p}, and {\tt q} functions
+(e.g.\ implementing additional distributions realized in another
+\href{http://cran.r-project.org}{\tt CRAN} package),
+you should probably envisage introducing new distribution {\tt S4} (sub-)classes
+and hence better look at the implementation of some discrete and
+continuous parametric distribution classes in package \pkg{distr}.
+
+\noindent{\small Hint: download the {\tt .tar.gz} file; extract it to some {\tt temp}
+folder; look at subdirectories {\tt R} and {\tt man}}\smallskip\\
+
+The general procedure is as follows
+
+\begin{enumerate}
+\item introduce a new subclass of class \code{Parameter}
+\item introduce a new subclass of \code{LatticeDistribution}/%
+\code{DiscreteDistribution} (if discrete)
+ or of class \code{AbscontDistribution} (if continuous).
+\item define accessor and replacement functions for the ``slots'' of the
+parameter (e.g.\ \code{"size"} and \code{"prob"} in the binomial case),
+possibly with new generics
+\item (possibly) define a validity function
+\item define a generating function
+\item if existing, define particular convolution methods or similar particular
+methods for this new distribution class
+\item create {\tt .Rd} files for the
+\begin{itemize}
+ \item parameter class
+ \item distribution class
+\end{itemize}
+\item if analytic expressions are available, define particular \code{E}-, \code{var}-,
+\code{skewness}-, and \code{kurtosis}-methods
+ and if so, also document\footnote{%
+%
+this is new, because so far, all \code{E}-, \code{var}-,
+\code{skewness}-, and \code{kurtosis}-methods for ``basic''
+distributions are documented in the \pkg{distrEx} documentation to
+\code{E}, \code{var}, \ldots, but this would not be operational
+any longer for new derived classes, possibly defined in other, new packages
+%
+ } the corresponding methods in
+ the distribution class {\tt .Rd} file\\
+\end{enumerate}
+
+Let's go through the steps in the example case of the Binomial implementation
+in packages \pkg{distr} and \pkg{distrEx}:
+
+\begin{enumerate}
+%
+\item in \pkg{distr}, see source in \file{R/AllClasses.R},
+%
+<<AllClass1, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distr","R","AllClasses.R","distr",
+ "## Class: BinomParameter", "#-")
+@
+%
+\item in \pkg{distr}, see source in \file{R/AllClasses.R},
+%
+<<AllClass2, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distr","R","AllClasses.R","distr",
+ from = "## Class: binomial distribution",
+ to = "contains = \"LatticeDistribution\"",
+ offset.after = 1)
+@
+%
+\item in \pkg{distr}, see source in \file{R/BinomialDistribution.R},
+%
+<<BinomDist1, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distr","R","BinomialDistribution.R","distr",
+ from = c("## Access Methods", "## wrapped access methods"),
+ to = c("setReplaceMethod\\(\"prob\", \"BinomParameter\"",
+ "size = value\\)\\)") ,
+ offset.after = c(1,1))
+@
+%
+and \file{R/AllGenerics},
+<<AllGenerics, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distr","R","AllGenerics.R","distr",
+ from = "if\\(!isGeneric\\(\"size\"",
+ to = "setGeneric\\(\"prob\"")
+@
+%
+\item in \pkg{distr}, see source in \file{R/BinomialDistribution.R},
+%
+<<BinomDist2, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distr","R","BinomialDistribution.R","distr",
+ from = "setValidity\\(\"Binom",
+ to = "else return\\(TRUE\\)",
+ offset.after = 1)
+@
+%
+\item in \pkg{distr}, see source in \file{R/BinomialDistribution.R},
+%
+<<BinomDist3, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distr","R","BinomialDistribution.R","distr",
+ from = "Binom <- function",
+ to = "Binom <- function")
+@
+%
+\item in \pkg{distr}, see source in \file{R/BinomialDistribution.R},
+%
+<<BinomDist4, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distr","R","BinomialDistribution.R","distr",
+ from = "## Convolution for",
+ to = "\\}\\)")
+@
+%
+\item in \pkg{distr}, see sources in
+%
+\begin{itemize}
+%
+\item\file{man/BinomParameter-class.Rd}
+%
+<<BinomParam, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distr","man","BinomParameter-class.Rd","distr")
+@
+%
+\item\file{man/Binom-class.Rd}
+<<Binomclass, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distr","man","Binom-class.Rd","distr")
+@
+%
+\item {\footnotesize you could have: \file{man/Binom.Rd}
+ for the generating function; in the Binomial case, documentation is in
+ \file{Binom-class.Rd}; but in case of the Gumbel distribution,
+ in package \pkg{distrEx}, there is such an extra {\tt .Rd} file}
+%
+\end{itemize}
+%
+\item in \pkg{distrEx}, see sources in
+%
+<<Prepa2, echo=false, results=tex>>=
+## preparation: set option withSweave to true
+require(distrEx)
+@
+%
+\begin{itemize}
+%
+\item\file{Expectation.R},
+<<Expect, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distrEx","R","Expectation.R","distr",
+ from = "\"E\", signature\\(object = \"Binom\"",
+ to = "\\}\\)")
+@
+%
+\item\file{Functionals.R},
+<<var, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distrEx","R","Functionals.R","distr",
+ from = "\"var\", signature\\(x = \"Binom\"",
+ to = "\\}\\)")
+@
+%
+\item\file{skewness.R},
+<<skew, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distrEx","R","Skewness.R","distr",
+ from = "\"skewness\", signature\\(x = \"Binom\"",
+ to = "\\}\\)")
+@
+%
+\item\file{kurtosis.R},
+<<kurt, results=tex, echo=FALSE>>=
+lstinputSourceFromRForge("distrEx","R","Kurtosis.R","distr",
+ from = "\"kurtosis\", signature\\(x = \"Binom\"",
+ to = "\\}\\)")
+@
+%
+\end{itemize}
+\end{enumerate}
+The procedure will be similar for \textit{any} new class of distributions.\medskip
+\begin{itemize}
+ \item[Comment] In the classes in package \pkg{distr} (historically the ``oldest''
+ in the development of this project), we still use \code{initialize} methods;
+ this is no longer needed, if you provide generating functions; for this ``more
+ recent'' approach, confer the realization of class \code{Gumbel} in package \pkg{distrEx}.
+\end{itemize}
+
+% -------------------------------------------------------------------------------
+\section{Help needed / collaboration welcome}
+% -------------------------------------------------------------------------------
+You are --- as announced on
+\href{http://distr.r-forge.r-project.org}{\tt http://distr.r-forge.r-project.org} ---
+ very welcome to collaborate in this project!
+See in particular
+\href{http://distr.r-forge.r-project.org/HOWTO-collaborate.txt}%
+{\tt http://distr.r-forge.r-project.org/HOWTO-collaborate.txt}
+
+With this you should be able to start working.
+\begin{thebibliography}{2}
+
+\bibitem{K:R:S:04}
+Kohl M., Ruckdeschel P. and Stabla T.
+\newblock {General Purpose Convolution Algorithm for Distributions in S4-Classes
+by means of FFT}.
+\newblock unpublished manual
+
+
+\bibitem{R:K:S:C:04}
+Ruckdeschel P., Kohl M., Stabla T., and Camphausen F.
+\newblock {S4 Classes for Distributions.}
+\newblock {\em R-News\/}, {\bf 6}(2): 10--13.
+\newblock http://CRAN.R-project.org/doc/Rnews/Rnews\_2006-2.pdf
+%\newblock See also {http://www.uni-bayreuth.de/departments/math/org/mathe7/RUCKDESCHEL/pubs/distr.pdf}
+
+\end{thebibliography}
+<<cleanup, echo=FALSE>>=
+#unloadNamespace("SweaveListingUtils")
+@
+% -------------------------------------------------------------------------------
+\end{document}
+% -------------------------------------------------------------------------------
Copied: branches/distr-2.4/pkg/distr/vignettes/svn-multi.sty (from rev 742, branches/distr-2.4/pkg/distr/inst/doc/svn-multi.sty)
===================================================================
--- branches/distr-2.4/pkg/distr/vignettes/svn-multi.sty (rev 0)
+++ branches/distr-2.4/pkg/distr/vignettes/svn-multi.sty 2011-11-18 11:51:19 UTC (rev 754)
@@ -0,0 +1,1752 @@
+%%
+%% This is file `svn-multi.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% svn-multi.dtx (with options: `package')
+%%
+%% This is a generated file.
+%%
+%% Copyright (C) 2006-2009 by Martin Scharrer <martin at scharrer-online.de>
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Martin Scharrer.
+%%
+%% This work consists of the files svn-multi.dtx, svn-multi-pl.dtx, svn-multi.ins
+%% and the derived files svn-multi.sty, svnkw.sty and svn-multi.pl.
+%%
+\makeatletter
+\def\svnmulti at version {v2.1}
+\def\svnmulti at rev $#1: #2 ${\def\svnmulti at rev{#2}}
+\def\svnmulti at date $#1: #2-#3-#4 #5 ${\def\svnmulti at date{#2/#3/#4}}
+\svnmulti at rev $Rev: 691 $\relax
+\svnmulti at date $Date: 2009-03-27 21:37:56 +0000 (Fri, 27 Mar 2009) $\relax
+
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+\ProvidesPackage{svn-multi}
+ [\svnmulti at date\space\svnmulti at version\space SVN Keywords for multi-file LaTeX documents]
+
+\RequirePackage{kvoptions}
+
+\SetupKeyvalOptions{%
+ family = svn-multi,
+ prefix = @svnmulti@
+}
+\newif\if at svnmulti@anygraphic
+\newif\if at svnmulti@autoload
+\newif\if at svnmulti@autokw
+\newif\if at svnmulti@autokwall
+
+\DeclareVoidOption{old}{%
+ \@svnmulti at verbatimtrue
+ \@svnmulti at groupsfalse
+ \@svnmulti at externalfalse
+ \@svnmulti at graphicsfalse
+ \@svnmulti at pgfimagesfalse
+ \@svnmulti at autoloadfalse
+ \@svnmulti at tablefalse
+ \@svnmulti at filehooksfalse
+ \@svnmulti at subgroupsfalse
+}
+\DeclareVoidOption{all}{%
+ \@svnmulti at verbatimtrue
+ \@svnmulti at groupstrue
+ \@svnmulti at externaltrue
+ \@svnmulti at graphicstrue
+ \@svnmulti at pgfimagestrue
+ \@svnmulti at autoloadtrue
+ \@svnmulti at tabletrue
+ \@svnmulti at filehookstrue
+ \@svnmulti at subgroupstrue
+}
+\DeclareBoolOption[true]{verbatim}
+\DeclareBoolOption[false]{groups}
+\DeclareBoolOption[false]{external}
+\DeclareBoolOption[false]{subgroups}
+\DeclareBoolOption[false]{graphics}
+\DeclareBoolOption[false]{pgfimages}
+\DeclareStringOption{autoload}[true]
+\DeclareBoolOption[false]{table}
+\DeclareBoolOption[false]{filehooks}
+\DeclareStringOption[false]{autokw}[all]
+
+\ExecuteOptions{old}
+\ProcessKeyvalOptions{svn-multi}
+\def\svn at depoption#1{%
+ \csname if at svnmulti@#1\endcsname\else
+ \message{svn-multi: Required option '#1' enabled.}%
+ \csname @svnmulti@#1true\endcsname
+ \fi
+}
+
+\if at svnmulti@groups
+ \svn at depoption{filehooks}
+\fi
+\if at svnmulti@external
+ \svn at depoption{filehooks}
+\fi
+\if at svnmulti@subgroups
+ \svn at depoption{groups}
+ \svn at depoption{filehooks}
+\fi
+\if at svnmulti@graphics
+ \svn at depoption{external}
+ \svn at depoption{autoload}
+ \svn at depoption{filehooks}
+\fi
+\if at svnmulti@pgfimages
+ \svn at depoption{external}
+ \svn at depoption{autoload}
+ \svn at depoption{filehooks}
+\fi
+\if at svnmulti@autoload
+ \svn at depoption{external}
+ \svn at depoption{filehooks}
+\fi
+\if at svnmulti@table
+ \svn at depoption{groups}
+ \svn at depoption{filehooks}
+\fi
+\ifx\@svnmulti at autoload\@undefined
+\else
+\ifx\@svnmulti at autoload\empty
+\else
+\def\svn at temp{true}
+\ifx\@svnmulti at autoload\svn at temp
+ \@svnmulti at autoloadtrue
+ \svn at depoption{external}
+ \svn at depoption{filehooks}
+\else
+\def\svn at temp{false}
+\ifx\@svnmulti at autoload\svn at temp
+ \if at svnmulti@autoload
+ \PackageWarning{svn-multi}{Option 'autoload' disabled.}
+ \fi
+ \@svnmulti at autoloadfalse
+\else
+ \PackageError{svn-multi}%
+ {Invalid value for 'autoload' option: '\@svnmulti at autoload'^^J%
+ ! Only 'true','false' or empty (='true') are allowed!}
+\fi\fi\fi\fi
+
+\def\svn at temp{true}
+\ifx\@svnmulti at autokw\svn at temp
+ \@svnmulti at autokwtrue
+ \@svnmulti at autokwalltrue
+ \svn at depoption{filehooks}
+\fi
+\def\svn at temp{all}
+\ifx\@svnmulti at autokw\svn at temp
+ \@svnmulti at autokwtrue
+ \@svnmulti at autokwalltrue
+ \svn at depoption{filehooks}
+\fi
+\def\svn at temp{ext}
+\ifx\@svnmulti at autokw\svn at temp
+ \@svnmulti at autokwtrue
+ \@svnmulti at autokwallfalse
+\fi
+\def\svn at temp{false}
+\ifx\@svnmulti at autokw\svn at temp
+ \@svnmulti at autokwfalse
+ \@svnmulti at autokwallfalse
+\fi
+
+\if at svnmulti@graphics
+ \@svnmulti at anygraphictrue
+\fi
+\if at svnmulti@pgfimages
+ \@svnmulti at anygraphictrue
+\fi
+
+\def\svn at ifempty#1{%
+ \begingroup
+ \edef\svn at temp{#1}%
+ \ifx\svn at temp\empty
+ \endgroup
+ \expandafter
+ \@firstoftwo
+ \else
+ \endgroup
+ \expandafter
+ \@secondoftwo
+ \fi
+}
+
+\def\svn at ifequal#1#2{%
+ \begingroup
+ \edef\svn at stringa{#1}%
+ \edef\svn at stringb{#2}%
+ \ifx\svn at stringa\svn at stringb
+ \endgroup
+ \expandafter
+ \@firstoftwo
+ \else
+ \endgroup
+ \expandafter
+ \@secondoftwo
+ \fi
+}
+
+\def\svn at ifvalidrev#1{%
+ \begingroup
+ \@ifundefined{#1}%
+ {\def\svn at temp{-1}}%
+ {\expandafter\edef
+ \expandafter\svn at temp\expandafter{\csname #1\endcsname}}%
+ \ifnum\svn at temp>-1\relax
+ \endgroup
+ \expandafter
+ \@firstoftwo
+ \else
+ \endgroup
+ \expandafter
+ \@secondoftwo
+ \fi
+}
+
+\def\svn at ifeof#1{%
+ \ifeof#1%
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+}
+
+\def\svn at ifonlyone#1{%
+ \expandafter\expandafter\expandafter
+ \svn@@ifonlyone\csname @svng@#1 at files\endcsname,\relax
+}
+
+\def\svn@@ifonlyone#1,#2\relax{%
+ \svn at ifempty{#2}
+}
+
+\def\svn at input#1{%
+ \begingroup
+ \let\svn at rg\svn at g
+ \IfFileExists{#1}{\@@input #1\relax}{}%
+ \global\let\svn at g\svn at rg
+ \endgroup
+}
+
+\def\svn at inputsvx#1{%
+ \svn at pushfilestack
+ \svn at input{#1.svx}%
+ \svn at popfilestack
+}
+
+\def\svnrev{-1} \def\@svn at rev{-1}
+\def\svndate{} \def\@svn at date{}
+\def\svnauthor{} \def\@svn at author{}
+\def\svnyear{0000} \def\@svn at year{0000}
+\def\svnmonth{00} \def\@svn at month{00}
+\def\svnday{00} \def\@svn at day{00}
+\def\svnhour{00} \def\@svn at hour{00}
+\def\svnminute{00} \def\@svn at minute{00}
+\def\svnsecond{00} \def\@svn at second{00}
+\def\svntimezonehour{+00} \def\@svn at timezonehour{+00}
+\def\svntimezoneminute{00} \def\@svn at timezoneminute{00}
+\def\svnmainurl{NOT SET} \def\svnmainfilename{NOT SET}
+\def\svnurl{} \def\svnfname{}
+\def\svn at temp{}
+
+\def\svn at pg{} \def\svn at g{} \def\svn at cg{\svn at g} \def\svn at rg{\svn at pg}
+\let\@svng@@files\relax
+
+\def\svn at initfile{%
+ \gdef\svnfilerev{-1}%
+ \gdef\svnfiledate{}%
+ \gdef\svnfileauthor{}%
+ \gdef\svnfileyear{0000}%
+ \gdef\svnfilemonth{00}%
+ \gdef\svnfileday{00}%
+ \gdef\svnfilehour{00}%
+ \gdef\svnfileminute{00}%
+ \gdef\svnfilesecond{00}%
+ \gdef\svnfiletimezonehour{+00}%
+ \gdef\svnfiletimezoneminute{00}%
+ \gdef\svnfileurl{}%
+ \gdef\svnfilefname{}%
+ \gdef\svnfiledir{}%
+}
+\svn at initfile
+
+
+\begingroup
+\@makeother\^^L
+\if at svnmulti@autokw
+\gdef\svne at ff{^^L}
+\fi
+\endgroup
+
+\if at svnmulti@autokw
+\newread\svne at read
+
+\newcommand*{\svne at catcodes}{%
+ \let\do\@makeother
+ \endlinechar=-1
+ \dospecials
+ \do\- \do\: \do\. \do\^^L
+}
+
+\def\svne at readline#1{%
+ \ifeof\svne at read
+ \def#1{}%
+ \else
+ \read\svne at read to #1\relax
+ \fi
+}
+
+\def\svne at gobblerest{%
+ \ifeof\svne at read
+ \let\next\relax
+ \else
+ \read\svne at read to \svn at temp
+ \ifx\svn at temp\svne at ff
+ \let\next\relax
+ \else
+ \let\next\svne at gobblerest
+ \fi
+ \fi
+ \next
+}
+
+\def\svne at endread{%
+ \closein\svne at read
+}
+
+\newcommand*{\svne at parseentriesfile}[1]{%
+ \begingroup
+ \let\next\relax
+ \openin\svne at read=#1format\relax
+ \ifeof\svne at read\else
+ \svne at readline\svne at version
+ \closein\svne at read
+ \ifnum\svne at version>7\relax
+ \openin\svne at read=#1entries\relax
+ \ifeof\svne at read\else
+ \svne at catcodes
+ \svne at readline\svne at version
+ \ifnum\svne at version>7\relax
+ \def\next{\svne at parsedirentry%
+ \svne at parseentries}
+ \else
+ \closein\svne at read
+ \fi
+ \fi
+ \fi
+ \fi
+ \next
+ \endgroup
+}
+
+\newcommand*{\svne at parsedirentry}{%
+ \svne at readline\svne at name
+ \svne at readline\svne at kind
+ \svn at ifempty{\svne at name}%
+ {\svn at ifequal{\svne at kind}{dir}%
+ {%
+ {\svne at readline\svn at temp}%
+ \svne at readline\svne at baseurl
+ \svne at gobblerest
+ }{}%
+ }{}%
+}
+
+\begingroup
+
+\@makeother\-
+\@makeother\:
+\@makeother\.
+
+\gdef\svne at scandate#1{%
+ \expandafter\svne at scandate@#1\relax
+ 0000-00-00T00:00:00.00000Z\relax\relax
+}
+
+\gdef\svne at scandate@#1-#2-#3T#4:#5:#6.#7\relax#8\relax{%
+ \gdef\svnfileyear{#1}%
+ \gdef\svnfilemonth{#2}%
+ \gdef\svnfileday{#3}%
+ \gdef\svnfilehour{#4}%
+ \gdef\svnfileminute{#5}%
+ \gdef\svnfilesecond{#6}%
+ \gdef\svnfiletimezonehour{+00}%
+ \gdef\svnfiletimezoneminute{00}%
+ \gdef\svnfiledate{#1-#2-#3 #4:#5:#6Z}%
+ \def\svne at date{#1-#2-#3 #4:#5:#6Z}%
+}
+
+\endgroup
+
+\newcommand*{\svne at parseentries}{%
+ \svn at ifeof{\svne at read}%
+ {}%
+ {%
+ \svne at readline\svne at name
+ \@onelevel at sanitize\svne at name
+ \svn at ifeof{\svne at read}%
+ {}%
+ {%
+ \svne at readline\svne at kind
+ \svn at ifequal{\svne at kind}{file}%
+ {%
+ \svne at readline\svn at temp
+ \svne at readline\svn at temp
+ \svne at readline\svn at temp
+ \svne at readline\svn at temp
+ \svne at readline\svn at temp
+ \svne at readline\svn at temp
+ \svne at readline\svne at date
+ \svne at readline\svne at rev
+ \svne at readline\svne at author
+ %\@onelevel at sanitize\svne at date
+ \svne at scandate{\svne at date}%
+ \edef\svne at url{\svne at baseurl/\svne at name}%
+ \svne at handleentry
+ }{}%
+ \svne at gobblerest
+ \svne at parseentries
+ }%
+ }%
+}
+
+\def\svne at handleentry{%
+ \svn at ifequal{\svne at name}{\svnfilefname}%
+ {%
+ \svnkwdef{Filename}{\svne at name}%
+ \svnkwdef{Date}{\svne at date}%
+ \svnkwdef{Revision}{\svne at rev}%
+ \svnkwdef{Author}{\svne at author}%
+ \svnkwdef{HeadURL}{\svne at url}%
+ \@svn at updateid{\svne at rev}{\svne at date}{\svne at author}{\svne at url}%
+ \svne at endread
+ }{}%
+}%
+
+\def\svnegetfile#1{%
+ \begingroup
+ \svn at getfilename{#1}%
+ \edef\svnfilefname{\svnfilefname}%
+ \@onelevel at sanitize\svnfilefname
+ \svne at parseentriesfile{\svnfiledir .svn/}%
+ \svne at parseentriesfile{\svnfiledir _svn/}%
+ \endgroup
+}
+
+\if at svnmulti@autokwall
+\AtBeginDocument{%
+ \svnegetfile{\jobname.\svn at mainext}%
+}
+\fi
+
+\fi
+
+\def\svntimezone{\svntimezonehour\svntimezoneminute\svn at gobblezeros}
+\def\svnfiletimezone{\svnfiletimezonehour\svnfiletimezoneminute\svn at gobblezeros}
+\def\svncgtimezone{\svncgtimezonehour\svncgtimezoneminute}
+
+\def\svn at gobblezeros{%
+ \futurelet\svn at nextchar\svn at gobblezeros@
+}
+\def\svn at gobblezeros@{%
+ \let\@tempa=\relax
+ \def\@tempb{0}%
+ \ifx0\svn at nextchar
+ \let\@tempa=\@gobbletwo
+ \fi
+ \@tempa
+}
+
+\def\svntime{\svnhour:\svnminute:\svnsecond}
+\def\svnfiletime{\svnfilehour:\svnfileminute:\svnfilesecond}
+\def\svncgtime{\svncghour:\svncgminute:\svncgsecond}
+
+\newcommand*{\svntoday}{%
+ \begingroup
+ \year\svnyear \month\svnmonth \day\svnday
+ \relax \today
+ \endgroup
+}
+\newcommand*{\svnfiletoday}{%
+ \begingroup
+ \year\svnfileyear \month\svnfilemonth \day\svnfileday
+ \relax \today
+ \endgroup
+}
+\newcommand*{\svncgtoday}{%
+ \@ifundefined{svng@\svn at cg @year}{??}{%
+ \begingroup
+ \year\svncgyear \month\svncgmonth \day\svncgday
+ \relax \today
+ \endgroup
+ }%
+}%
+
+\newcommand*{\svnid}{%
+ \@svnidswtrue
+ \svnkwsave
+}
+\newif\if at svnidsw
+\@svnidswfalse
+
+\def\svn at scanId#1 #2 #3 #4 #5\relax{%
+ \@svn at scandate{#3 #4}%
+ \@svn at updateid{#2}{#3 #4}{#5}{#1}%
+ \svnkwdef{Filename}{#1}%
+ \svnkwdef{Date}{#3 #4}%
+ \svnkwdef{Revision}{#2}%
+ \svnkwdef{Author}{#5}%
+}
+
+\def\@svn at updateid#1#2#3#4{%
+ \xdef\svnfilerev{#1}%
+ \xdef\svnfiledate{#2}%
+ \xdef\svnfileauthor{#3}%
+ \xdef\svnfileurl{#4}%
+ \svn at getfilename\svnfileurl%
+ \ifx\svnfilerev\empty\else
+ \ifnum\@svn at rev<\svnfilerev
+ \xdef\@svn at rev{\svnfilerev}%
+ \xdef\@svn at date{\svnfiledate}%
+ \xdef\@svn at author{\svnfileauthor}%
+ \xdef\@svn at year{\svnfileyear}%
+ \xdef\@svn at month{\svnfilemonth}%
+ \xdef\@svn at day{\svnfileday}%
+ \xdef\@svn at hour{\svnfilehour}%
+ \xdef\@svn at minute{\svnfileminute}%
+ \xdef\@svn at second{\svnfilesecond}%
+ \xdef\@svn at timezonehour{\svnfiletimezonehour}%
+ \xdef\@svn at timezoneminute{\svnfiletimezoneminute}%
+ \xdef\@svn at url{\svnfileurl}%
+ \xdef\@svn at fname{\svnfilefname}%
+ \fi
+
+ \if at svnmulti@groups
+ \ifx\svn at g\empty\else
+ \svn at updategroup{\svn at g}%
+ \fi
+ \if at svnmulti@subgroups
+ \ifsvnsubgroups
+ \svn at updategroup{\svn at filedir\svn at filebase}%
+ \fi
+ \fi
+ \fi
+ \fi
+}
+
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/distr -r 754
More information about the Distr-commits
mailing list