\newcommand{\NWtarget}[2]{\hypertarget{#1}{#2}}
\newcommand{\NWlink}[2]{\hyperlink{#1}{#2}}
\newcommand{\NWtxtMacroDefBy}{Fragment defined by}
\newcommand{\NWtxtMacroRefIn}{Fragment referenced in}
\newcommand{\NWtxtMacroNoRef}{Fragment never referenced}
\newcommand{\NWtxtDefBy}{Defined by}
\newcommand{\NWtxtRefIn}{Referenced in}
\newcommand{\NWtxtNoRef}{Not referenced}
\newcommand{\NWtxtFileDefBy}{File defined by}
\newcommand{\NWtxtIdentsUsed}{Uses:}
\newcommand{\NWtxtIdentsNotUsed}{Never used}
\newcommand{\NWtxtIdentsDefed}{Defines:}
\newcommand{\NWsep}{${\diamond}$}
\newcommand{\NWnotglobal}{(not defined globally)}
\newcommand{\NWuseHyperlinks}{}
\documentclass[a4paper]{report}

%\VignetteIndexEntry{Implementing Permutation Tests}
%\VignetteDepends{libcoin}
%\VignetteKeywords{conditional inference, conditional Monte Carlo}}
%\VignettePackage{libcoin}

%% packages
\usepackage{amsfonts,amstext,amsmath,amssymb,amsthm}

\usepackage[utf8]{inputenc}

\newif\ifshowcode
\showcodetrue

\usepackage{latexsym}
%\usepackage{html}

\usepackage{listings}

\usepackage{color}
\definecolor{linkcolor}{rgb}{0, 0, 0.7}

\usepackage[%
backref,%
raiselinks,%
pdfhighlight=/O,%
pagebackref,%
hyperfigures,%
breaklinks,%
colorlinks,%
pdfpagemode=UseNone,%
pdfstartview=FitBH,%
linkcolor={linkcolor},%
anchorcolor={linkcolor},%
citecolor={linkcolor},%
filecolor={linkcolor},%
menucolor={linkcolor},%
urlcolor={linkcolor}%
]{hyperref}

\usepackage[round]{natbib}

\usepackage{underscore}

\usepackage[top=25mm,bottom=25mm,left=25mm,right=25mm]{geometry}

\usepackage{lmodern}

\newcommand{\pkg}[1]{\textbf{#1}}
\newcommand{\proglang}[1]{\textsf{#1}}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\file}[1]{\texttt{#1}}

\newcommand{\R}{\mathbb{R} }
\newcommand{\Prob}{\mathbb{P} }
\newcommand{\N}{\mathbb{N} }
%\newcommand{\C}{\mathbb{C} }
\newcommand{\V}{\mathbb{V}} %% cal{\mbox{\textnormal{Var}}} }
\newcommand{\E}{\mathbb{E}} %%mathcal{\mbox{\textnormal{E}}} }
\newcommand{\Var}{\mathbb{V}} %%mathcal{\mbox{\textnormal{Var}}} }
\newcommand{\argmin}{\operatorname{argmin}\displaylimits}
\newcommand{\argmax}{\operatorname{argmax}\displaylimits}
\newcommand{\LS}{\mathcal{L}_n}
\newcommand{\TS}{\mathcal{T}_n}
\newcommand{\LSc}{\mathcal{L}_{\text{comb},n}}
\newcommand{\LSbc}{\mathcal{L}^*_{\text{comb},n}}
\newcommand{\F}{\mathcal{F}}
\newcommand{\A}{\mathcal{A}}
\newcommand{\yn}{y_{\text{new}}}
\newcommand{\z}{\mathbf{z}}
\newcommand{\X}{\mathbf{X}}
\newcommand{\Y}{\mathbf{Y}}
\newcommand{\sX}{\mathcal{X}}
\newcommand{\sY}{\mathcal{Y}}
\newcommand{\T}{\mathbf{T}}
\newcommand{\x}{\mathbf{x}}
\renewcommand{\a}{\mathbf{a}}
\newcommand{\xn}{\mathbf{x}_{\text{new}}}
\newcommand{\y}{\mathbf{y}}
\newcommand{\w}{\mathbf{w}}
\newcommand{\sbullet}{\mathbin{\vcenter{\hbox{\scalebox{0.5}{$\bullet$}}}}}
\newcommand{\wdot}{\mathbf{w}_{\sbullet}}
\renewcommand{\t}{\mathbf{t}}
\newcommand{\M}{\mathbf{M}}
\renewcommand{\vec}{\text{vec}}
\newcommand{\B}{\mathbf{B}}
\newcommand{\K}{\mathbf{K}}
\newcommand{\W}{\mathbf{W}}
\newcommand{\D}{\mathbf{D}}
\newcommand{\I}{\mathbf{I}}
\newcommand{\bS}{\mathbf{S}}
\newcommand{\cellx}{\pi_n[\x]}
\newcommand{\partn}{\pi_n(\mathcal{L}_n)}
\newcommand{\err}{\text{Err}}
\newcommand{\ea}{\widehat{\text{Err}}^{(a)}}
\newcommand{\ecv}{\widehat{\text{Err}}^{(cv1)}}
\newcommand{\ecvten}{\widehat{\text{Err}}^{(cv10)}}
\newcommand{\eone}{\widehat{\text{Err}}^{(1)}}
\newcommand{\eplus}{\widehat{\text{Err}}^{(.632+)}}
\newcommand{\eoob}{\widehat{\text{Err}}^{(oob)}}
\newcommand{\mub}{\boldsymbol{\mu}}
\newcommand{\Sigmab}{\boldsymbol{\Sigma}}


\author{Torsten Hothorn \\ Universit\"at Z\"urich}

\title{The \pkg{libcoin} Package}

\begin{document}

\pagenumbering{roman}
\maketitle
\tableofcontents

\chapter*{Licence}

{\setlength{\parindent}{0cm}
Copyright (C) 2016-2026 Torsten Hothorn \\

This file is part of the \pkg{libcoin} \proglang{R} add-on package. \\

\pkg{libcoin} is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 2. \\

\pkg{libcoin} is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details. \\

You should have received a copy of the GNU General Public License
along with \pkg{libcoin}.  If not, see <http://www.gnu.org/licenses/>.
}

\chapter{Introduction}
\pagenumbering{arabic}

The \pkg{libcoin} package implements a generic framework for permutation
tests. We assume that we are provided with $n$ observations
\begin{eqnarray*}
(\Y_i, \X_i, w_i, \text{block}_i), \quad i = 1, \dots, N.
\end{eqnarray*}
The variables $\Y$ and $\X$ from sample spaces $\mathcal{Y}$ and
$\mathcal{X}$ may
be measured at arbitrary scales and may be multivariate as well. In addition
to those measurements, case weights $w_i \in \N$ and a factor $\text{block}_i \in \{1, \dots, B\}$
coding for $B$ independent blocks may
be available.
We are interested in testing the null hypothesis of independence of $\Y$ and
$\X$
\begin{eqnarray*}
H_0: D(\Y \mid \X) = D(\Y)
\end{eqnarray*}
against arbitrary alternatives. \cite{Strasser+Weber:1999} suggest to derive
scalar test statistics for testing $H_0$ from multivariate linear statistics
of a specific linear form. Let $\A \subseteq \{1, \dots, N\}$ denote some subset of the
observation numbers and consider the linear statistic
\begin{eqnarray} \label{linstat}
\T(\A) = \vec\left(\sum_{i \in \A} w_i g(\X_i) h(\Y_i, \{\Y_i \mid i \in \A\})^\top\right)
\in \R^{PQ}.
\end{eqnarray}
Here, $g: \mathcal{X} \rightarrow \R^P$ is a transformation of
$\X$ known as the \emph{regression function} and $h: \mathcal{Y} \times
\mathcal{Y}^n \rightarrow \R^Q$ is a transformation of $\Y$ known as the
\emph{influence function}, where the latter may depend on $\Y_i$ for $i \in \A$
in a permutation symmetric way.  We will give specific examples on how to choose
$g$ and $h$ later on.

With $\x_i = g(\X_i) \in \R^P$ and $\y_i = h(\Y_i, \{\Y_i, i \in \A\}) \in \R^Q$ we write
\begin{eqnarray} \label{linstatsimple}
\T(\A) = \vec\left(\sum_{i \in \A} w_i \x_i \y_i^\top\right)
\in \R^{PQ}.
\end{eqnarray}
The \pkg{libcoin} package doesn't handle neither $g$ nor $h$, this is the job
of \pkg{coin} and we therefore continue with $\x_i$ and $\y_i$.

The distribution of $\T$  depends on the joint
distribution of $\Y$ and $\X$, which is unknown under almost all practical
circumstances. At least under the null hypothesis one can dispose of this
dependency by fixing $\X_i, i \in \A$ and conditioning on all possible
permutations $S(\A)$ of the responses $\Y_i, i \in \A$.
This principle leads to test procedures known
as \textit{permutation tests}.
The conditional expectation $\mub(\A) \in \R^{PQ}$ and covariance
$\Sigmab(\A) \in \R^{PQ \times PQ}$
of $\T$ under $H_0$ given
all permutations $\sigma \in S(\A)$ of the responses are derived by
\cite{Strasser+Weber:1999}:
\begin{eqnarray}
\mub(\A) & = & \E(\T(\A) \mid S(\A)) = \vec \left( \left( \sum_{i \in \A} w_i \x_i \right) \E(h \mid S(\A))^\top
\right), \nonumber \\
\Sigmab(\A) & = & \V(\T(\A) \mid S(\A)) \nonumber \\
& = &
    \frac{\wdot}{\wdot(\A) - 1}  \V(h \mid S(\A)) \otimes
        \left(\sum_{i \in \A} w_i  \x_i \otimes w_i \x_i^\top \right)
\label{expectcovar}
\\
& - & \frac{1}{\wdot(\A) - 1}  \V(h \mid S(\A))  \otimes \left(
        \sum_{i \in \A} w_i \x_i \right)
\otimes \left( \sum_{i \in \A} w_i \x_i\right)^\top
\nonumber
\end{eqnarray}
where $\wdot(\A) = \sum_{i \in \A} w_i$ denotes the sum of the case weights,
and $\otimes$ is the Kronecker product. The conditional expectation of the
influence function is
\begin{eqnarray*}
\E(h \mid S(\A)) = \wdot(\A)^{-1} \sum_{i \in \A} w_i \y_i \in
\R^Q
\end{eqnarray*}
with corresponding $Q \times Q$ covariance matrix
\begin{eqnarray*}
\V(h \mid S(\A)) = \wdot(\A)^{-1} \sum_{i \in \A} w_i \left(\y_i - \E(h \mid S(\A)) \right) \left(\y_i  - \E(h \mid S(\A))\right)^\top.
\end{eqnarray*}

With $A_b = \{i \mid \text{block}_i = b\}$ we get $\T = \sum_{b = 1}^B T(\A_b)$,
$\mub = \sum_{b = 1}^B \mub(\A_b)$ and $\Sigmab = \sum_{b = 1}^B \Sigmab(\A_b)$.

Having the conditional expectation and covariance at hand we are able to
standardize a linear statistic $\T \in \R^{PQ}$ of the form
(\ref{linstatsimple}). Univariate test statistics~$c$ mapping an observed linear
statistic $\t \in
\R^{PQ}$ into the real line can be of arbitrary form.  An obvious choice is
the maximum of the absolute values of the standardized linear statistic
\begin{eqnarray*}
c_\text{max}(\t, \mub, \Sigmab)  = \max \left| \frac{\t -
\mub}{\text{diag}(\Sigmab)^{1/2}} \right|
\end{eqnarray*}
utilizing the conditional expectation $\mub$ and covariance matrix
$\Sigmab$. The application of a quadratic form $c_\text{quad}(\t, \mub,
\Sigmab)  =
(\t - \mub) \Sigmab^+ (\t - \mub)^\top$ is one alternative, although
computationally more expensive because the Moore-Penrose
inverse $\Sigmab^+$ of $\Sigmab$ is involved.

The definition of one- and two-sided $p$-values used for the computations in
the \pkg{libcoin} package is
\begin{eqnarray*}
P(c(\T, \mub, \Sigmab) &\le& c(\t, \mub, \Sigmab)) \quad \text{(less)} \\
P(c(\T, \mub, \Sigmab) &\ge& c(\t, \mub, \Sigmab)) \quad \text{(greater)}\\
P(|c(\T, \mub, \Sigmab)| &\le& |c(\t, \mub, \Sigmab)|) \quad \text{(two-sided).}
\end{eqnarray*}
Note that for quadratic forms only two-sided $p$-values are available
and that in the one-sided case maximum type test statistics are replaced by
\begin{eqnarray*}
\min \left( \frac{\t - \mub}{\text{diag}(\Sigmab)^{1/2}} \right)
    \quad \text{(less) and }
\max \left( \frac{\t - \mub}{\text{diag}(\Sigmab)^{1/2}} \right)
    \quad \text{(greater).}
\end{eqnarray*}

This single source file implements and documents the \pkg{libcoin} package
following the literate programming paradigm. The keynote lecture on literate
programming by Donald E.~Knuth given at useR! 2016 in Stanford very much
motivated this little experiment.

\chapter{\proglang{R} Code}

\section{\proglang{R} User Interface}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap1}\raggedright\small
\NWtarget{nuweb3a}{} \verb@"libcoin.R"@\nobreak\ {\footnotesize {3a}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R Header}\nobreak\ {\footnotesize \NWlink{nuweb155a}{155a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape LinStatExpCov}\nobreak\ {\footnotesize \NWlink{nuweb4}{4}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape LinStatExpCov1d}\nobreak\ {\footnotesize \NWlink{nuweb6}{6}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape LinStatExpCov2d}\nobreak\ {\footnotesize \NWlink{nuweb8}{8}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape vcov LinStatExpCov}\nobreak\ {\footnotesize \NWlink{nuweb10}{10}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape doTest}\nobreak\ {\footnotesize \NWlink{nuweb12}{12}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Contrasts}\nobreak\ {\footnotesize \NWlink{nuweb14}{14}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The \pkg{libcoin} package implements two \proglang{R} functions, \code{LinStatExpCov()} and
\code{doTest()} for the computation of linear statistics, their expectation
and covariance as well as for the computation of test statistics and
$p$-values. There are two interfaces: One (labelled ``1d'') when the data is
available as matrices \code{X} and \code{Y}, both with the same number of
rows $N$. The second interface (labelled ``2d'') handles the case when the
data is available in aggregated form; details will be explained later.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap2}\raggedright\small
\NWtarget{nuweb3b}{} $\langle\,${\itshape LinStatExpCov Prototype}\nobreak\ {\footnotesize {3b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@(X, Y, ix = NULL, iy = NULL, weights = integer(0),@\\
\mbox{}\verb@ subset = integer(0), block = integer(0), checkNAs = TRUE,@\\
\mbox{}\verb@ varonly = FALSE, nresample = 0, standardise = FALSE,@\\
\mbox{}\verb@ tol = sqrt(.Machine$double.eps))@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb4}{4}\NWlink{nuweb17}{, 17}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap3}\raggedright\small
\NWtarget{nuweb4}{} $\langle\,${\itshape LinStatExpCov}\nobreak\ {\footnotesize {4}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@LinStatExpCov <-@\\
\mbox{}\verb@function@\hbox{$\langle\,${\itshape LinStatExpCov Prototype}\nobreak\ {\footnotesize \NWlink{nuweb3b}{3b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (missing(X) && !is.null(ix) && is.null(iy)) {@\\
\mbox{}\verb@        X <- ix@\\
\mbox{}\verb@        ix <- NULL@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (missing(X)) X <- integer(0)@\\
\mbox{}\verb@@\\
\mbox{}\verb@    ## <FIXME> for the time being only!!! </FIXME>@\\
\mbox{}\verb@##    if (length(subset) > 0) subset <- sort(subset)@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (is.null(ix) && is.null(iy))@\\
\mbox{}\verb@        .LinStatExpCov1d(X = X, Y = Y,@\\
\mbox{}\verb@                         weights = weights, subset = subset,@\\
\mbox{}\verb@                         block = block, checkNAs = checkNAs,@\\
\mbox{}\verb@                         varonly = varonly, nresample = nresample,@\\
\mbox{}\verb@                         standardise = standardise, tol = tol)@\\
\mbox{}\verb@    else if (!is.null(ix) && !is.null(iy))@\\
\mbox{}\verb@        .LinStatExpCov2d(X = X, Y = Y, ix = ix, iy = iy,@\\
\mbox{}\verb@                         weights = weights, subset = subset,@\\
\mbox{}\verb@                         block = block, checkNAs = checkNAs,@\\
\mbox{}\verb@                         varonly = varonly, nresample = nresample,@\\
\mbox{}\verb@                         standardise = standardise, tol = tol)@\\
\mbox{}\verb@    else@\\
\mbox{}\verb@        stop("incorrect call to ", sQuote("LinStatExpCov()"))@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb3a}{3a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{One-Dimensional Case (``1d'')}

We assume that $\x_i$ and $\y_i$ for $i = 1, \dots, N$ are available as
numeric matrices \code{X} and \code{Y} with $N$ rows as well as $P$ and $Q$
columns, respectively. The special case of a dummy matrix
\code{X} with $P$ columns can also be represented by a factor at $P$ levels.
The vector of case weights \code{weights} can be stored as \code{integer}
or \code{double} (possibly resulting from an aggregation of $N > $
\code{INT_MAX} observations). The subset vector \code{subset} may contain
the elements $1, \dots, N$ as \code{integer} or \code{double} (for $N > $
\code{INT_MAX}) and can be longer than $N$. The \code{subset} vector MUST be
sorted. \code{block} is a factor at $B$ levels of length $N$.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap4}\raggedright\small
\NWtarget{nuweb5a}{} $\langle\,${\itshape Check weights, subset, block}\nobreak\ {\footnotesize {5a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (is.null(weights)) weights <- integer(0)@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (length(weights) > 0) {@\\
\mbox{}\verb@    if (!((N == length(weights)) && all(weights >= 0)))@\\
\mbox{}\verb@        stop("incorrect weights")@\\
\mbox{}\verb@    if (checkNAs) stopifnot(!anyNA(weights))@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (is.null(subset)) subset <- integer(0)@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (length(subset) > 0 && checkNAs) {@\\
\mbox{}\verb@    rs <- range(subset)@\\
\mbox{}\verb@    if (anyNA(rs)) stop("no missing values allowed in subset")@\\
\mbox{}\verb@    if (!((rs[2] <= N) && (rs[1] >= 1L)))@\\
\mbox{}\verb@        stop("incorrect subset")@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (is.null(block)) block <- integer(0)@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (length(block) > 0) {@\\
\mbox{}\verb@    if (!((N == length(block)) && is.factor(block)))@\\
\mbox{}\verb@        stop("incorrect block")@\\
\mbox{}\verb@    if (checkNAs) stopifnot(!anyNA(block))@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb6}{6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15b}{, 15b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Missing values are only allowed in \code{X} and
\code{Y}, all other vectors must not contain \code{NA}s. Missing values are
dealt with by excluding the corresponding observations from the subset
vector.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap5}\raggedright\small
\NWtarget{nuweb5b}{} $\langle\,${\itshape Handle Missing Values}\nobreak\ {\footnotesize {5b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@ms <- !complete.cases(X, Y)@\\
\mbox{}\verb@if (all(ms))@\\
\mbox{}\verb@    stop("all observations are missing")@\\
\mbox{}\verb@if (any(ms)) {@\\
\mbox{}\verb@    if (length(subset) > 0) {@\\
\mbox{}\verb@        if (all(subset %in% which(ms)))@\\
\mbox{}\verb@            stop("all observations are missing")@\\
\mbox{}\verb@        subset <- subset[!(subset %in% which(ms))]@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        subset <- seq_len(N)[-which(ms)]@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb6}{6}.
\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The logical argument \code{varonly} triggers the computation of the diagonal
elements of the covariance matrix $\Sigmab$ only. \code{nresample} permuted linear statistics
under the null hypothesis $H_0$ are returned on the original and
standardised scale (the latter only when \code{standardise} is \code{TRUE}).
Variances smaller than \code{tol} are treated as being zero.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap6}\raggedright\small
\NWtarget{nuweb6}{} $\langle\,${\itshape LinStatExpCov1d}\nobreak\ {\footnotesize {6}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@.LinStatExpCov1d <-@\\
\mbox{}\verb@function(X, Y, weights = integer(0), subset = integer(0), block = integer(0),@\\
\mbox{}\verb@         checkNAs = TRUE, varonly = FALSE, nresample = 0, standardise = FALSE,@\\
\mbox{}\verb@         tol = sqrt(.Machine$double.eps))@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (NROW(X) != NROW(Y))@\\
\mbox{}\verb@        stop("dimensions of X and Y don't match")@\\
\mbox{}\verb@    N <- NROW(X)@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (is.integer(X)) {@\\
\mbox{}\verb@        if (is.null(attr(X, "levels")) || checkNAs) {@\\
\mbox{}\verb@            rg <- range(X)@\\
\mbox{}\verb@            if (anyNA(rg))@\\
\mbox{}\verb@                stop("no missing values allowed in X")@\\
\mbox{}\verb@            stopifnot(rg[1] > 0) # no missing values allowed here!@\\
\mbox{}\verb@            if (is.null(attr(X, "levels")))@\\
\mbox{}\verb@                attr(X, "levels") <- seq_len(rg[2])@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (is.factor(X) && checkNAs)@\\
\mbox{}\verb@        stopifnot(!anyNA(X))@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Check weights, subset, block}\nobreak\ {\footnotesize \NWlink{nuweb5a}{5a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (checkNAs) {@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape Handle Missing Values}\nobreak\ {\footnotesize \NWlink{nuweb5b}{5b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    ret <- .Call(R_ExpectationCovarianceStatistic, X, Y, weights, subset,@\\
\mbox{}\verb@                 block, as.integer(varonly), as.double(tol))@\\
\mbox{}\verb@    ret$varonly <- as.logical(ret$varonly)@\\
\mbox{}\verb@    ret$Xfactor <- as.logical(ret$Xfactor)@\\
\mbox{}\verb@    if (nresample > 0) {@\\
\mbox{}\verb@        ret$PermutedLinearStatistic <-@\\
\mbox{}\verb@            .Call(R_PermutedLinearStatistic, X, Y, weights, subset,@\\
\mbox{}\verb@                  block, as.double(nresample))@\\
\mbox{}\verb@        if (standardise)@\\
\mbox{}\verb@            ret$StandardisedPermutedLinearStatistic <-@\\
\mbox{}\verb@                .Call(R_StandardisePermutedLinearStatistic, ret)@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    class(ret) <- c("LinStatExpCov1d", "LinStatExpCov")@\\
\mbox{}\verb@    ret@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb3a}{3a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}, \verb@R_ExpectationCovarianceStatistic@\nobreak\ \NWlink{nuweb31a}{31a}, \verb@R_PermutedLinearStatistic@\nobreak\ \NWlink{nuweb37}{37}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Here is a simple example. We have five groups and a uniform outcome (rounded
to one digit) and want
to test independence of group membership and outcome. The simplest way is
to set-up the dummy matrix explicitly:
<<1dex-1>>=
isequal <-
function(a, b) {
    attributes(a) <- NULL
    attributes(b) <- NULL
    if (!isTRUE(all.equal(a, b))) {
        print(a, digits = 10)
        print(b, digits = 10)
        FALSE
    } else
        TRUE
}
library("libcoin")
set.seed(290875)
x <- gl(5, 20)
y <- round(runif(length(x)), 1)
ls1 <- LinStatExpCov(X = model.matrix(~ x - 1), Y = matrix(y, ncol = 1))
ls1$LinearStatistic
tapply(y, x, sum)
@
The linear statistic is simply the sum of the response in each group.
Alternatively, we can compute the same object without setting-up the dummy
matrix:
<<1dex-2>>=
ls2 <- LinStatExpCov(X = x, Y = matrix(y, ncol = 1))
all.equal(ls1[-grep("Xfactor", names(ls1))],
          ls2[-grep("Xfactor", names(ls2))])
@
The results are identical, except for a logical indicating that a factor was
used to represent the dummy matrix \code{X}.

\subsection{Two-Dimensional Case (``2d'')}

Sometimes the data takes only a few unique values and considerable
computational speedups can be achieved taking this information into account.
Let \code{ix} denote an integer vector with elements $0, \dots, L_x$ of
length $N$ and
\code{iy} an integer vector with elements $0, \dots, L_y$, also of length
$N$. The matrix
\code{X} is now of dimension $(L_x + 1) \times P$ and the matrix \code{Y}
of dimension $(L_y + 1) \times Q$. The combination of \code{X} and \code{ix}
means that the $i$th observation corresponds to the row \code{X[ix[i] + 1,]}.
This looks cumbersome in \proglang{R} notation but is a very efficient way
of dealing with missing values at \proglang{C} level. By convention,
elements of \code{ix} being zero denote a missing value (\code{NA}s are not
allowed in \code{ix} and \code{iy}). Thus, the first row of \code{X}
corresponds to a missing value. If the first row is simply zero, missing
values do not contribute to any of the sums computed later. Even more
important is the fact that all entities, such as linear statistics etc., can
be computed from the two-way tabulation (therefore the abbreviation ``2d'')
over the $N$ elements of \code{ix} and \code{iy}. Once such a
table was computed, the remaining computations can be performed in
dimension $L_x \times L_y$, typically much smaller than $N$.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap7}\raggedright\small
\NWtarget{nuweb8}{} $\langle\,${\itshape LinStatExpCov2d}\nobreak\ {\footnotesize {8}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@.LinStatExpCov2d <-@\\
\mbox{}\verb@function(X = numeric(0), Y, ix, iy, weights = integer(0), subset = integer(0),@\\
\mbox{}\verb@         block = integer(0), checkNAs = TRUE, varonly = FALSE, nresample = 0,@\\
\mbox{}\verb@         standardise = FALSE, tol = sqrt(.Machine$double.eps))@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    IF <- function(x) is.integer(x) || is.factor(x)@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (!((length(ix) == length(iy)) && IF(ix) && IF(iy)))@\\
\mbox{}\verb@        stop("incorrect ix and/or iy")@\\
\mbox{}\verb@    N <- length(ix)@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Check ix}\nobreak\ {\footnotesize \NWlink{nuweb9a}{9a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Check iy}\nobreak\ {\footnotesize \NWlink{nuweb9b}{9b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (length(X) > 0) {@\\
\mbox{}\verb@        if (!(NROW(X) == (length(attr(ix, "levels")) + 1) &&@\\
\mbox{}\verb@              all(complete.cases(X))))@\\
\mbox{}\verb@            stop("incorrect X")@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (!(NROW(Y) == (length(attr(iy, "levels")) + 1) &&@\\
\mbox{}\verb@          all(complete.cases(Y))))@\\
\mbox{}\verb@        stop("incorrect Y")@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Check weights, subset, block}\nobreak\ {\footnotesize \NWlink{nuweb5a}{5a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    ret <- .Call(R_ExpectationCovarianceStatistic_2d, X, ix, Y, iy,@\\
\mbox{}\verb@                 weights, subset, block, as.integer(varonly), as.double(tol))@\\
\mbox{}\verb@    ret$varonly <- as.logical(ret$varonly)@\\
\mbox{}\verb@    ret$Xfactor <- as.logical(ret$Xfactor)@\\
\mbox{}\verb@    if (nresample > 0) {@\\
\mbox{}\verb@        ret$PermutedLinearStatistic <-@\\
\mbox{}\verb@            .Call(R_PermutedLinearStatistic_2d, X, ix, Y, iy, block, nresample, ret$Table)@\\
\mbox{}\verb@        if (standardise)@\\
\mbox{}\verb@            ret$StandardisedPermutedLinearStatistic <-@\\
\mbox{}\verb@                .Call(R_StandardisePermutedLinearStatistic, ret)@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    class(ret) <- c("LinStatExpCov2d", "LinStatExpCov")@\\
\mbox{}\verb@    ret@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb3a}{3a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}, \verb@R_ExpectationCovarianceStatistic_2d@\nobreak\ \NWlink{nuweb41a}{41a}, \verb@R_PermutedLinearStatistic_2d@\nobreak\ \NWlink{nuweb48}{48}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\code{ix} and \code{iy} can be factors but without any missing values

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap8}\raggedright\small
\NWtarget{nuweb9a}{} $\langle\,${\itshape Check ix}\nobreak\ {\footnotesize {9a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (is.null(attr(ix, "levels"))) {@\\
\mbox{}\verb@    rg <- range(ix)@\\
\mbox{}\verb@    if (anyNA(rg))@\\
\mbox{}\verb@        stop("no missing values allowed in ix")@\\
\mbox{}\verb@    stopifnot(rg[1] >= 0)@\\
\mbox{}\verb@    attr(ix, "levels") <- seq_len(rg[2])@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    ## lev can be data.frame (see inum::inum)@\\
\mbox{}\verb@    lev <- attr(ix, "levels")@\\
\mbox{}\verb@    if (!is.vector(lev)) lev <- seq_len(NROW(lev))@\\
\mbox{}\verb@    attr(ix, "levels") <- lev@\\
\mbox{}\verb@    if (checkNAs) stopifnot(!anyNA(ix))@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb8}{8}\NWlink{nuweb15b}{, 15b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap9}\raggedright\small
\NWtarget{nuweb9b}{} $\langle\,${\itshape Check iy}\nobreak\ {\footnotesize {9b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (is.null(attr(iy, "levels"))) {@\\
\mbox{}\verb@    rg <- range(iy)@\\
\mbox{}\verb@    if (anyNA(rg))@\\
\mbox{}\verb@        stop("no missing values allowed in iy")@\\
\mbox{}\verb@    stopifnot(rg[1] >= 0)@\\
\mbox{}\verb@    attr(iy, "levels") <- seq_len(rg[2])@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    ## lev can be data.frame (see inum::inum)@\\
\mbox{}\verb@    lev <- attr(iy, "levels")@\\
\mbox{}\verb@    if (!is.vector(lev)) lev <- seq_len(NROW(lev))@\\
\mbox{}\verb@    attr(iy, "levels") <- lev@\\
\mbox{}\verb@    if (checkNAs) stopifnot(!anyNA(iy))@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb8}{8}\NWlink{nuweb15b}{, 15b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
In our small example, we can set-up the data in the following way
<<2dex-1>>=
X <- rbind(0, diag(nlevels(x)))
ix <- unclass(x)
ylev <- sort(unique(y))
Y <- rbind(0, matrix(ylev, ncol = 1))
iy <- .bincode(y, breaks = c(-Inf, ylev, Inf))
ls3 <- LinStatExpCov(X = X, ix = ix, Y = Y, iy = iy)
all.equal(ls1[-grep("Table", names(ls1))],
          ls3[-grep("Table", names(ls3))])
### works also with factors
ls3 <- LinStatExpCov(X = X, ix = factor(ix), Y = Y, iy = factor(iy))
all.equal(ls1[-grep("Table", names(ls1))],
          ls3[-grep("Table", names(ls3))])
@
Similar to the one-dimensional case, we can also omit the \code{X} matrix
here
<<2dex-2>>=
ls4 <- LinStatExpCov(ix = ix, Y = Y, iy = iy)
all.equal(ls3[-grep("Xfactor", names(ls3))],
          ls4[-grep("Xfactor", names(ls4))])
@
It is important to note that all computations are based on the tabulations
<<2dex-3>>=
ls3$Table
xtabs(~ ix + iy)
@
where the former would record missing values in the first row / column.

\subsection{Methods and Tests}

Objects of class \code{"LinStatExpCov"} returned by \code{LinStatExpCov()}
contain the symmetric covariance matrix as a vector of the lower triangular
elements. The \code{vcov} method allows to extract the full covariance
matrix from such an object.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap10}\raggedright\small
\NWtarget{nuweb10}{} $\langle\,${\itshape vcov LinStatExpCov}\nobreak\ {\footnotesize {10}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@vcov.LinStatExpCov <-@\\
\mbox{}\verb@function(object, ...)@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (object$varonly)@\\
\mbox{}\verb@        stop("cannot extract covariance matrix")@\\
\mbox{}\verb@    drop(.Call(R_unpack_sym, object$Covariance, NULL, 0L))@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb3a}{3a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_unpack_sym@\nobreak\ \NWlink{nuweb140}{140}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<vcov-1>>=
ls1$Covariance
vcov(ls1)
@

The most important task is, however, to compute test statistics and
$p$-values. \code{doTest()} allows to compute the statistics $c_\text{max}$
(taking \code{alternative} into account) and $c_\text{quad}$ along with the
corresponding $p$-values. If \code{nresample = 0} was used in the call to
\code{LinStatExpCov()}, $p$-values are obtained from the limiting asymptotic
distribution whenever such a thing is available at reasonable costs.
Otherwise, the permutation $p$-value is returned (along with the permuted
test statistics when \code{PermutedStatistics} is \code{TRUE}). The
$p$-values (\code{lower = FALSE}) or $(1 - p)$-values (\code{lower = TRUE})
can be computed on the log-scale.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap11}\raggedright\small
\NWtarget{nuweb11}{} $\langle\,${\itshape doTest Prototype}\nobreak\ {\footnotesize {11}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@(object, teststat = c("maximum", "quadratic", "scalar"),@\\
\mbox{}\verb@ alternative = c("two.sided", "less", "greater"), pvalue = TRUE,@\\
\mbox{}\verb@ lower = FALSE, log = FALSE, PermutedStatistics = FALSE,@\\
\mbox{}\verb@ minbucket = 10L, ordered = TRUE, maxselect = object$Xfactor,@\\
\mbox{}\verb@ pargs = GenzBretz())@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb12}{12}\NWlink{nuweb18}{, 18}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap12}\raggedright\small
\NWtarget{nuweb12}{} $\langle\,${\itshape doTest}\nobreak\ {\footnotesize {12}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@### note: lower = FALSE => p-value; lower = TRUE => 1 - p-value@\\
\mbox{}\verb@doTest <-@\\
\mbox{}\verb@function@\hbox{$\langle\,${\itshape doTest Prototype}\nobreak\ {\footnotesize \NWlink{nuweb11}{11}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    teststat <- match.arg(teststat, choices = c("maximum", "quadratic", "scalar"))@\\
\mbox{}\verb@    if (!any(teststat == c("maximum", "quadratic", "scalar")))@\\
\mbox{}\verb@        stop("incorrect teststat")@\\
\mbox{}\verb@    alternative <- alternative[1]@\\
\mbox{}\verb@    if (!any(alternative == c("two.sided", "less", "greater")))@\\
\mbox{}\verb@        stop("incorrect alternative")@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (maxselect)@\\
\mbox{}\verb@        stopifnot(object$Xfactor)@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (teststat == "quadratic" || maxselect) {@\\
\mbox{}\verb@        if (alternative != "two.sided")@\\
\mbox{}\verb@            stop("incorrect alternative")@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    test <- which(c("maximum", "quadratic", "scalar") == teststat)@\\
\mbox{}\verb@    if (test == 3) {@\\
\mbox{}\verb@        if (length(object$LinearStatistic) != 1)@\\
\mbox{}\verb@            stop("scalar test statistic not applicable")@\\
\mbox{}\verb@        test <- 1L # scalar is maximum internally@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    alt <- which(c("two.sided", "less", "greater") == alternative)@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (!pvalue && (NCOL(object$PermutedLinearStatistic) > 0))@\\
\mbox{}\verb@        object$PermutedLinearStatistic <- matrix(NA_real_, nrow = 0, ncol = 0)@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (!maxselect) {@\\
\mbox{}\verb@        if (teststat == "quadratic") {@\\
\mbox{}\verb@            ret <- .Call(R_QuadraticTest, object, as.integer(pvalue), as.integer(lower),@\\
\mbox{}\verb@                         as.integer(log), as.integer(PermutedStatistics))@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            ret <- .Call(R_MaximumTest, object, as.integer(alt), as.integer(pvalue),@\\
\mbox{}\verb@                         as.integer(lower), as.integer(log), as.integer(PermutedStatistics),@\\
\mbox{}\verb@                         as.integer(pargs$maxpts), as.double(pargs$releps),@\\
\mbox{}\verb@                         as.double(pargs$abseps))@\\
\mbox{}\verb@            if (teststat == "scalar") {@\\
\mbox{}\verb@                var <- if (object$varonly) object$Variance else object$Covariance@\\
\mbox{}\verb@                ret$TestStatistic <- object$LinearStatistic - object$Expectation@\\
\mbox{}\verb@                ret$TestStatistic <-@\\
\mbox{}\verb@                    if (var > object$tol) ret$TestStatistic / sqrt(var) else NaN@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        ret <- .Call(R_MaximallySelectedTest, object, as.integer(ordered), as.integer(test),@\\
\mbox{}\verb@                     as.integer(minbucket), as.integer(lower), as.integer(log))@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    if (!PermutedStatistics) ret$PermutedStatistics <- NULL@\\
\mbox{}\verb@    ret@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb3a}{3a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<doTest-1>>=
### c_max test statistic
### no p-value
doTest(ls1, teststat = "maximum", pvalue = FALSE)
### p-value
doTest(ls1, teststat = "maximum")
### log(p)-value
doTest(ls1, teststat = "maximum", log = TRUE)
### (1-p)-value
doTest(ls1, teststat = "maximum", lower = TRUE)
### log(1 - p)-value
doTest(ls1, teststat = "maximum", lower = TRUE, log = TRUE)
### quadratic
doTest(ls1, teststat = "quadratic")
@

Sometimes we are interested in contrasts of linear statistics and their
corresponding properties. Examples include linear-by-linear association
tests, where we assign numeric scores to each level of a factor. To
implement this, we implement \code{lmult()} so that we can then left-multiply a
matrix to an object of class \code{"LinStatExpCov"}.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap13}\raggedright\small
\NWtarget{nuweb14}{} $\langle\,${\itshape Contrasts}\nobreak\ {\footnotesize {14}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@lmult <-@\\
\mbox{}\verb@function(x, object)@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    stopifnot(!object$varonly)@\\
\mbox{}\verb@    stopifnot(is.numeric(x))@\\
\mbox{}\verb@    if (is.vector(x)) x <- matrix(x, nrow = 1)@\\
\mbox{}\verb@    P <- object$dimension[1]@\\
\mbox{}\verb@    stopifnot(ncol(x) == P)@\\
\mbox{}\verb@    Q <- object$dimension[2]@\\
\mbox{}\verb@    ret <- object@\\
\mbox{}\verb@    xLS <- x %*% matrix(object$LinearStatistic, nrow = P)@\\
\mbox{}\verb@    xExp <- x %*% matrix(object$Expectation, nrow = P)@\\
\mbox{}\verb@    xExpX <- x %*% matrix(object$ExpectationX, nrow = P)@\\
\mbox{}\verb@    if (Q == 1) {@\\
\mbox{}\verb@        xCov <- tcrossprod(x %*% vcov(object), x)@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        zmat <- matrix(0, nrow = P * Q, ncol = nrow(x))@\\
\mbox{}\verb@        mat <- rbind(t(x), zmat)@\\
\mbox{}\verb@        mat <- mat[rep.int(seq_len(nrow(mat)), Q - 1),, drop = FALSE]@\\
\mbox{}\verb@        mat <- rbind(mat, t(x))@\\
\mbox{}\verb@        mat <- matrix(mat, ncol = Q * nrow(x))@\\
\mbox{}\verb@        mat <- t(mat)@\\
\mbox{}\verb@        xCov <- tcrossprod(mat %*% vcov(object), mat)@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    if (!is.matrix(xCov)) xCov <- matrix(xCov)@\\
\mbox{}\verb@    if (length(object$PermutedLinearStatistic) > 0) {@\\
\mbox{}\verb@        xPS <- apply(object$PermutedLinearStatistic, 2, function(y)@\\
\mbox{}\verb@                     as.vector(x %*% matrix(y, nrow = P)))@\\
\mbox{}\verb@        if (!is.matrix(xPS)) xPS <- matrix(xPS, nrow = 1)@\\
\mbox{}\verb@        ret$PermutedLinearStatistic <- xPS@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    ret$LinearStatistic <- as.vector(xLS)@\\
\mbox{}\verb@    ret$Expectation <- as.vector(xExp)@\\
\mbox{}\verb@    ret$ExpectationX <- as.vector(xExpX)@\\
\mbox{}\verb@    ret$Covariance <- as.vector(xCov[lower.tri(xCov, diag = TRUE)])@\\
\mbox{}\verb@    ret$Variance <- diag(xCov)@\\
\mbox{}\verb@    ret$dimension <- c(NROW(x), Q)@\\
\mbox{}\verb@    ret$Xfactor <- FALSE@\\
\mbox{}\verb@    if (length(object$StandardisedPermutedLinearStatistic) > 0)@\\
\mbox{}\verb@        ret$StandardisedPermutedLinearStatistic <-@\\
\mbox{}\verb@            .Call(R_StandardisePermutedLinearStatistic, ret)@\\
\mbox{}\verb@    ret@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb3a}{3a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Here is an example for a linear-by-linear association test.
<<Contrasts-1>>=
set.seed(29)
ls1d <- LinStatExpCov(X = model.matrix(~ x - 1), Y = matrix(y, ncol = 1),
                      nresample = 10, standardise = TRUE)
set.seed(29)
ls1s <- LinStatExpCov(X = as.double(1:5)[x], Y = matrix(y, ncol = 1),
                      nresample = 10, standardise = TRUE)
ls1c <- lmult(1:5, ls1d)
stopifnot(isequal(ls1c, ls1s))
set.seed(29)
ls1d <- LinStatExpCov(X = model.matrix(~ x - 1), Y = matrix(c(y, y), ncol = 2),
                      nresample = 10, standardise = TRUE)
set.seed(29)
ls1s <- LinStatExpCov(X = as.double(1:5)[x], Y = matrix(c(y, y), ncol = 2),
                      nresample = 10, standardise = TRUE)
ls1c <- lmult(1:5, ls1d)
stopifnot(isequal(ls1c, ls1s))
@

\subsection{Tabulations}

The tabulation of \code{ix} and \code{iy} can be computed without
necessarily computing the corresponding linear statistics via
\code{ctabs()}.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap14}\raggedright\small
\NWtarget{nuweb15a}{} $\langle\,${\itshape ctabs Prototype}\nobreak\ {\footnotesize {15a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@(ix, iy = integer(0), block = integer(0), weights = integer(0),@\\
\mbox{}\verb@ subset = integer(0), checkNAs = TRUE)@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb15b}{15b}\NWlink{nuweb19}{, 19}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap15}\raggedright\small
\NWtarget{nuweb15b}{} \verb@"ctabs.R"@\nobreak\ {\footnotesize {15b}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R Header}\nobreak\ {\footnotesize \NWlink{nuweb155a}{155a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@ctabs <-@\\
\mbox{}\verb@function@\hbox{$\langle\,${\itshape ctabs Prototype}\nobreak\ {\footnotesize \NWlink{nuweb15a}{15a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    stopifnot(is.integer(ix) || is.factor(ix))@\\
\mbox{}\verb@    N <- length(ix)@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Check ix}\nobreak\ {\footnotesize \NWlink{nuweb9a}{9a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (length(iy) > 0) {@\\
\mbox{}\verb@        stopifnot(length(iy) == N)@\\
\mbox{}\verb@        stopifnot(is.integer(iy) || is.factor(iy))@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape Check iy}\nobreak\ {\footnotesize \NWlink{nuweb9b}{9b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Check weights, subset, block}\nobreak\ {\footnotesize \NWlink{nuweb5a}{5a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (length(iy) == 0)@\\
\mbox{}\verb@        if (length(block) == 0)@\\
\mbox{}\verb@            .Call(R_OneTableSums, ix, weights, subset)@\\
\mbox{}\verb@        else@\\
\mbox{}\verb@            .Call(R_TwoTableSums, ix, block, weights, subset)[, -1, drop = FALSE]@\\
\mbox{}\verb@    else if (length(block) == 0)@\\
\mbox{}\verb@        .Call(R_TwoTableSums, ix, iy, weights, subset)@\\
\mbox{}\verb@    else@\\
\mbox{}\verb@        .Call(R_ThreeTableSums, ix, iy, block, weights, subset)@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@R_OneTableSums@\nobreak\ \NWlink{nuweb111a}{111a}, \verb@R_ThreeTableSums@\nobreak\ \NWlink{nuweb119b}{119b}, \verb@R_TwoTableSums@\nobreak\ \NWlink{nuweb115a}{115a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<ctabsex-1>>=
t1 <- ctabs(ix = ix, iy = iy)
t2 <- xtabs(~ ix + iy)
max(abs(t1[-1, -1] - t2))
@

\section{Manual Pages}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap16}\raggedright\small
\NWtarget{nuweb17}{} \verb@"LinStatExpCov.Rd"@\nobreak\ {\footnotesize {17}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@\name{LinStatExpCov}@\\
\mbox{}\verb@\alias{LinStatExpCov}@\\
\mbox{}\verb@\alias{lmult}@\\
\mbox{}\verb@\title{@\\
\mbox{}\verb@  Linear Statistics with Expectation and Covariance@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\description{@\\
\mbox{}\verb@  Strasser-Weber type linear statistics and their expectation@\\
\mbox{}\verb@  and covariance under the independence hypothesis@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\usage{@\\
\mbox{}\verb@LinStatExpCov@\hbox{$\langle\,${\itshape LinStatExpCov Prototype}\nobreak\ {\footnotesize \NWlink{nuweb3b}{3b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@lmult(x, object)@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\arguments{@\\
\mbox{}\verb@  \item{X}{numeric matrix of transformations.}@\\
\mbox{}\verb@  \item{Y}{numeric matrix of influence functions.}@\\
\mbox{}\verb@  \item{ix}{an optional integer vector expanding \code{X}.}@\\
\mbox{}\verb@  \item{iy}{an optional integer vector expanding \code{Y}.}@\\
\mbox{}\verb@  \item{weights}{an optional integer vector of non-negative case weights.}@\\
\mbox{}\verb@  \item{subset}{an optional integer vector defining a subset of observations.}@\\
\mbox{}\verb@  \item{block}{an optional factor defining independent blocks of observations.}@\\
\mbox{}\verb@  \item{checkNAs}{a logical for switching off missing value checks.  This@\\
\mbox{}\verb@    included switching off checks for suitable values of \code{subset}.@\\
\mbox{}\verb@    Use at your own risk.}@\\
\mbox{}\verb@  \item{varonly}{a logical asking for variances only.}@\\
\mbox{}\verb@  \item{nresample}{an integer defining the number of permuted statistics to draw.}@\\
\mbox{}\verb@  \item{standardise}{a logical asking to standardise the permuted statistics.}@\\
\mbox{}\verb@  \item{tol}{tolerance for zero variances.}@\\
\mbox{}\verb@  \item{x}{a contrast matrix to be left-multiplied in case \code{X} was a factor.}@\\
\mbox{}\verb@  \item{object}{an object of class \code{"LinStatExpCov"}.}@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\details{@\\
\mbox{}\verb@@\\
\mbox{}\verb@  This function implements the permutation test framework by@\\
\mbox{}\verb@  \bibcitet{libcoin::Strasser+Weber:1999}, see also@\\
\mbox{}\verb@  \bibcitet{libcoin::Hothorn+Hornik+vandeWiel+Zeileis:2006} and@\\
\mbox{}\verb@  \bibcitet{libcoin::Hothorn+Hornik+vandeWiel+Zeileis:2008}.@\\
\mbox{}\verb@@\\
\mbox{}\verb@  The function, after minimal preprocessing, calls the underlying C code@\\
\mbox{}\verb@  and computes the linear statistic, its expectation and covariance and,@\\
\mbox{}\verb@  optionally, \code{nresample} samples from its permutation distribution.@\\
\mbox{}\verb@@\\
\mbox{}\verb@  When both \code{ix} and \code{iy} are missing, the number of rows of@\\
\mbox{}\verb@  \code{X} and \code{Y} is the same, i.e., the number of observations.@\\
\mbox{}\verb@@\\
\mbox{}\verb@  When \code{X} is missing and \code{ix} a factor, the code proceeds as@\\
\mbox{}\verb@  if \code{X} were a dummy matrix of \code{ix} without explicitly@\\
\mbox{}\verb@  computing this matrix.@\\
\mbox{}\verb@@\\
\mbox{}\verb@  Both \code{ix} and \code{iy} being present means the code treats them@\\
\mbox{}\verb@  as subsetting vectors for \code{X} and \code{Y}.  Note that \code{ix = 0}@\\
\mbox{}\verb@  or \code{iy = 0} means that the corresponding observation is missing@\\
\mbox{}\verb@  and the first row or \code{X} and \code{Y} must be zero.@\\
\mbox{}\verb@@\\
\mbox{}\verb@  \code{lmult} allows left-multiplication of a contrast matrix when \code{X}@\\
\mbox{}\verb@  was (equivalent to) a factor.@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\value{@\\
\mbox{}\verb@  A list.@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\references{\bibshow{*}}@\\
\mbox{}\verb@\examples{@\\
\mbox{}\verb@wilcox.test(Ozone ~ Month, data = airquality, subset = Month \%in\% c(5, 8),@\\
\mbox{}\verb@            exact = FALSE, correct = FALSE)@\\
\mbox{}\verb@@\\
\mbox{}\verb@aq <- subset(airquality, Month \%in\% c(5, 8))@\\
\mbox{}\verb@X <- as.double(aq$Month == 5)@\\
\mbox{}\verb@Y <- as.double(rank(aq$Ozone, na.last = "keep"))@\\
\mbox{}\verb@doTest(LinStatExpCov(X, Y))@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\keyword{htest}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap17}\raggedright\small
\NWtarget{nuweb18}{} \verb@"doTest.Rd"@\nobreak\ {\footnotesize {18}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@\name{doTest}@\\
\mbox{}\verb@\alias{doTest}@\\
\mbox{}\verb@\title{@\\
\mbox{}\verb@  Permutation Test@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\description{@\\
\mbox{}\verb@  Perform permutation test for a linear statistic@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\usage{@\\
\mbox{}\verb@doTest@\hbox{$\langle\,${\itshape doTest Prototype}\nobreak\ {\footnotesize \NWlink{nuweb11}{11}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\arguments{@\\
\mbox{}\verb@  \item{object}{an object returned by \code{\link{LinStatExpCov}}.}@\\
\mbox{}\verb@  \item{teststat}{type of test statistic to use.}@\\
\mbox{}\verb@  \item{alternative}{alternative for scalar or maximum-type statistics.}@\\
\mbox{}\verb@  \item{pvalue}{a logical indicating if a p-value shall be computed.}@\\
\mbox{}\verb@  \item{lower}{a logical indicating if a p-value (\code{lower} is \code{FALSE})@\\
\mbox{}\verb@    or 1 - p-value (\code{lower} is \code{TRUE}) shall be returned.}@\\
\mbox{}\verb@  \item{log}{a logical, if \code{TRUE} probabilities are log-probabilities.}@\\
\mbox{}\verb@  \item{PermutedStatistics}{a logical, return permuted test statistics.}@\\
\mbox{}\verb@  \item{minbucket}{minimum weight in either of two groups for maximally selected@\\
\mbox{}\verb@    statistics.}@\\
\mbox{}\verb@  \item{ordered}{a logical, if \code{TRUE} maximally selected statistics assume@\\
\mbox{}\verb@    that the cutpoints are ordered.}@\\
\mbox{}\verb@  \item{maxselect}{a logical, if \code{TRUE} maximally selected statistics are@\\
\mbox{}\verb@    computed.  This requires that \code{X} was an implicitly defined design@\\
\mbox{}\verb@    matrix in \code{\link{LinStatExpCov}}.}@\\
\mbox{}\verb@  \item{pargs}{arguments as in \code{\link[mvtnorm:algorithms]{GenzBretz}}.}@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\details{@\\
\mbox{}\verb@  Computes a test statistic, a corresponding p-value and, optionally, cutpoints@\\
\mbox{}\verb@  for maximally selected statistics.@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\value{@\\
\mbox{}\verb@  A list.@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\keyword{htest}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap18}\raggedright\small
\NWtarget{nuweb19}{} \verb@"ctabs.Rd"@\nobreak\ {\footnotesize {19}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@\name{ctabs}@\\
\mbox{}\verb@\alias{ctabs}@\\
\mbox{}\verb@\title{@\\
\mbox{}\verb@  Cross Tabulation@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\description{@\\
\mbox{}\verb@  Efficient weighted cross tabulation of two factors and a block@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\usage{@\\
\mbox{}\verb@ctabs@\hbox{$\langle\,${\itshape ctabs Prototype}\nobreak\ {\footnotesize \NWlink{nuweb15a}{15a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\arguments{@\\
\mbox{}\verb@  \item{ix}{a integer of positive values with zero indicating a missing.}@\\
\mbox{}\verb@  \item{iy}{an optional integer of positive values with zero indicating a@\\
\mbox{}\verb@    missing.}@\\
\mbox{}\verb@  \item{block}{an optional blocking factor without missings.}@\\
\mbox{}\verb@  \item{weights}{an optional vector of case weights, integer or double.}@\\
\mbox{}\verb@  \item{subset}{an optional integer vector indicating a subset.}@\\
\mbox{}\verb@  \item{checkNAs}{a logical for switching off missing value checks.}@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\details{@\\
\mbox{}\verb@  A faster version of \code{xtabs(weights ~ ix + iy + block, subset)}.@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\value{@\\
\mbox{}\verb@  If \code{block} is present, a three-way table. Otherwise,@\\
\mbox{}\verb@  a one- or two-dimensional table.@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\examples{@\\
\mbox{}\verb@ctabs(ix = 1:5, iy = 1:5, weights = 1:5 / 5)@\\
\mbox{}\verb@}@\\
\mbox{}\verb@\keyword{univar}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\chapter{\proglang{C} Code}

The main motivation to implement the \pkg{libcoin} package comes from the
demand to compute high-dimensional linear statistics (with large $P$ and
$Q$) and the corresponding test statistics very often, either for sampling
from the permutation null distribution $H_0$ or for different subsets of the
data. Especially the latter task can be performed \emph{without} actually
subsetting the data via the \code{subset} argument very efficiently (in
terms of memory consumption and, depending on the circumstances, speed).

We start with the definition of some macros and global variables in the
header files.

\section{Header and Source Files}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap19}\raggedright\small
\NWtarget{nuweb20a}{} \verb@"libcoin_internal.h"@\nobreak\ {\footnotesize {20a}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C Header}\nobreak\ {\footnotesize \NWlink{nuweb155b}{155b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R Includes}\nobreak\ {\footnotesize \NWlink{nuweb20b}{20b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C Macros}\nobreak\ {\footnotesize \NWlink{nuweb21a}{21a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C Global Variables}\nobreak\ {\footnotesize \NWlink{nuweb21b}{21b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
These includes provide some \proglang{R} infrastructure at \proglang{C}
level.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap20}\raggedright\small
\NWtarget{nuweb20b}{} $\langle\,${\itshape R Includes}\nobreak\ {\footnotesize {20b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@#define USE_FC_LEN_T@\\
\mbox{}\verb@#include <float.h>        /* for DBL_MIN */@\\
\mbox{}\verb@#include <R.h>@\\
\mbox{}\verb@#include <Rinternals.h>@\\
\mbox{}\verb@#include <Rversion.h>     /* for R_VERSION */@\\
\mbox{}\verb@#include <R_ext/Lapack.h> /* for dspev */@\\
\mbox{}\verb@#ifndef FCONE@\\
\mbox{}\verb@# define FCONE@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb20a}{20a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
We need three macros: \code{S} computes the element $\sigma_{ij}$ of a
symmetric $n \times n$ matrix when only the lower triangular elements are
stored. \code{LE} implements $\le$ with some tolerance, \code{GE} implements
$\ge$.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap21}\raggedright\small
\NWtarget{nuweb21a}{} $\langle\,${\itshape C Macros}\nobreak\ {\footnotesize {21a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@#define S(i, j, n) ((i) >= (j) ? (n) * (j) + (i) - (j) * ((j) + 1) / 2 : (n) * (i) + (j) - (i) * ((i) + 1) / 2)@\\
\mbox{}\verb@#define LE(x, y, tol) ((x) < (y)) || (fabs((x) - (y)) < (tol))@\\
\mbox{}\verb@#define GE(x, y, tol) ((x) > (y)) || (fabs((x) - (y)) < (tol))@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb20a}{20a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@GE@\nobreak\ \NWlink{nuweb51}{51}\NWlink{nuweb54}{, 54}, \verb@LE@\nobreak\ \NWlink{nuweb54}{54}, \verb@S@\nobreak\ \NWlink{nuweb35b}{35b}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb57b}{, 57b}\NWlink{nuweb58b}{, 58b}\NWlink{nuweb59b}{, 59b}\NWlink{nuweb62}{, 62}\NWlink{nuweb64a}{, 64a}\NWlink{nuweb68}{, 68}\NWlink{nuweb69a}{, 69a}\NWlink{nuweb73a}{, 73a}\NWlink{nuweb76b}{, 76b}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb99}{, 99}\NWlink{nuweb135}{, 135}\NWlink{nuweb136a}{, 136a}\NWlink{nuweb138}{, 138}\NWlink{nuweb144b}{, 144b}.\item \NWtxtIdentsUsed\nobreak\  \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap22}\raggedright\small
\NWtarget{nuweb21b}{} $\langle\,${\itshape C Global Variables}\nobreak\ {\footnotesize {21b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@#define ALTERNATIVE_twosided                            1@\\
\mbox{}\verb@#define ALTERNATIVE_less                                2@\\
\mbox{}\verb@#define ALTERNATIVE_greater                             3@\\
\mbox{}\verb@@\\
\mbox{}\verb@#define TESTSTAT_maximum                                1@\\
\mbox{}\verb@#define TESTSTAT_quadratic                              2@\\
\mbox{}\verb@@\\
\mbox{}\verb@#define LinearStatistic_SLOT                            0@\\
\mbox{}\verb@#define Expectation_SLOT                                1@\\
\mbox{}\verb@#define Covariance_SLOT                                 2@\\
\mbox{}\verb@#define Variance_SLOT                                   3@\\
\mbox{}\verb@#define ExpectationX_SLOT                               4@\\
\mbox{}\verb@#define varonly_SLOT                                    5@\\
\mbox{}\verb@#define dim_SLOT                                        6@\\
\mbox{}\verb@#define ExpectationInfluence_SLOT                       7@\\
\mbox{}\verb@#define CovarianceInfluence_SLOT                        8@\\
\mbox{}\verb@#define VarianceInfluence_SLOT                          9@\\
\mbox{}\verb@#define Xfactor_SLOT                                    10@\\
\mbox{}\verb@#define tol_SLOT                                        11@\\
\mbox{}\verb@#define PermutedLinearStatistic_SLOT                    12@\\
\mbox{}\verb@#define StandardisedPermutedLinearStatistic_SLOT        13@\\
\mbox{}\verb@#define TableBlock_SLOT                                 14@\\
\mbox{}\verb@#define Sumweights_SLOT                                 15@\\
\mbox{}\verb@#define Table_SLOT                                      16@\\
\mbox{}\verb@@\\
\mbox{}\verb@#define DoSymmetric                                     1@\\
\mbox{}\verb@#define DoCenter                                        1@\\
\mbox{}\verb@#define DoVarOnly                                       1@\\
\mbox{}\verb@#define Power1                                          1@\\
\mbox{}\verb@#define Power2                                          2@\\
\mbox{}\verb@#define Offset0                                         0@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb20a}{20a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@CovarianceInfluence_SLOT@\nobreak\ \NWlink{nuweb145c}{145c}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@Covariance_SLOT@\nobreak\ \NWlink{nuweb144b}{144b}\NWlink{nuweb144c}{c}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@dim_SLOT@\nobreak\ \NWlink{nuweb142c}{142c}\NWlink{nuweb143a}{, 143a}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@DoCenter@\nobreak\ \NWlink{nuweb77d}{77d}\NWlink{nuweb81c}{, 81c}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb106c}{, 106c}, \verb@DoSymmetric@\nobreak\ \NWlink{nuweb77d}{77d}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb88a}{, 88a}, \verb@DoVarOnly@\nobreak\ \NWlink{nuweb35b}{35b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb44}{, 44}, \verb@ExpectationInfluence_SLOT@\nobreak\ \NWlink{nuweb145b}{145b}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@ExpectationX_SLOT@\nobreak\ \NWlink{nuweb145a}{145a}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@Expectation_SLOT@\nobreak\ \NWlink{nuweb144a}{144a}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@LinearStatistic_SLOT@\nobreak\ \NWlink{nuweb143d}{143d}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@Offset0@\nobreak\ \NWlink{nuweb33b}{33b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb127a}{, 127a}, \verb@PermutedLinearStatistic_SLOT@\nobreak\ \NWlink{nuweb147b}{147b}\NWlink{nuweb147c}{c}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@Power1@\nobreak\ \NWlink{nuweb81c}{81c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb106c}{, 106c}, \verb@Power2@\nobreak\ \NWlink{nuweb84a}{84a}\NWlink{nuweb88a}{, 88a}, \verb@StandardisedPermutedLinearStatistic_SLOT@\nobreak\ \NWlink{nuweb148b}{148b}\NWlink{nuweb149}{, 149}, \verb@Sumweights_SLOT@\nobreak\ \NWlink{nuweb146b}{146b}\NWlink{nuweb147a}{, 147a}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}\NWlink{nuweb150b}{, 150b}, \verb@TableBlock_SLOT@\nobreak\ \NWlink{nuweb34a}{34a}\NWlink{nuweb146a}{, 146a}\NWlink{nuweb147a}{, 147a}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}\NWlink{nuweb150b}{, 150b}, \verb@Table_SLOT@\nobreak\ \NWlink{nuweb146c}{146c}\NWlink{nuweb146d}{d}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}\NWlink{nuweb151}{, 151}, \verb@tol_SLOT@\nobreak\ \NWlink{nuweb147d}{147d}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@VarianceInfluence_SLOT@\nobreak\ \NWlink{nuweb145d}{145d}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@Variance_SLOT@\nobreak\ \NWlink{nuweb144b}{144b}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@varonly_SLOT@\nobreak\ \NWlink{nuweb143b}{143b}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}, \verb@Xfactor_SLOT@\nobreak\ \NWlink{nuweb143c}{143c}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The corresponding header file contains definitions of
functions that can be called via \code{.Call()} from the \pkg{libcoin}
package. In addition, packages linking to \pkg{libcoin} can access these
function at \proglang{C} level (at your own risk, of course!).

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap23}\raggedright\small
\NWtarget{nuweb22a}{} \verb@"libcoin.h"@\nobreak\ {\footnotesize {22a}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C Header}\nobreak\ {\footnotesize \NWlink{nuweb155b}{155b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@#include "libcoin_internal.h"@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Function Prototypes}\nobreak\ {\footnotesize \NWlink{nuweb22b}{22b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap24}\raggedright\small
\NWtarget{nuweb22b}{} $\langle\,${\itshape Function Prototypes}\nobreak\ {\footnotesize {22b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_ExpectationCovarianceStatistic Prototype}\nobreak\ {\footnotesize \NWlink{nuweb30c}{30c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_PermutedLinearStatistic Prototype}\nobreak\ {\footnotesize \NWlink{nuweb36b}{36b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_StandardisePermutedLinearStatistic Prototype}\nobreak\ {\footnotesize \NWlink{nuweb38b}{38b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_ExpectationCovarianceStatistic_2d Prototype}\nobreak\ {\footnotesize \NWlink{nuweb40a}{40a}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_PermutedLinearStatistic_2d Prototype}\nobreak\ {\footnotesize \NWlink{nuweb47a}{47a}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_QuadraticTest Prototype}\nobreak\ {\footnotesize \NWlink{nuweb50b}{50b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_MaximumTest Prototype}\nobreak\ {\footnotesize \NWlink{nuweb52b}{52b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_MaximallySelectedTest Prototype}\nobreak\ {\footnotesize \NWlink{nuweb55a}{55a}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_ExpectationInfluence Prototype}\nobreak\ {\footnotesize \NWlink{nuweb80b}{80b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_CovarianceInfluence Prototype}\nobreak\ {\footnotesize \NWlink{nuweb82}{82}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_ExpectationX Prototype}\nobreak\ {\footnotesize \NWlink{nuweb84b}{84b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_CovarianceX Prototype}\nobreak\ {\footnotesize \NWlink{nuweb86}{86}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_Sums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb89c}{89c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_KronSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb94a}{94a}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_KronSums_Permutation Prototype}\nobreak\ {\footnotesize \NWlink{nuweb102a}{102a}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_colSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb106b}{106b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_OneTableSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb110b}{110b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_TwoTableSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb114b}{114b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_ThreeTableSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb119a}{119a}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_order_subset_wrt_block Prototype}\nobreak\ {\footnotesize \NWlink{nuweb123b}{123b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_quadform Prototype}\nobreak\ {\footnotesize \NWlink{nuweb60b}{60b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_kronecker Prototype}\nobreak\ {\footnotesize \NWlink{nuweb132c}{132c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_MPinv_sym Prototype}\nobreak\ {\footnotesize \NWlink{nuweb136b}{136b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_unpack_sym Prototype}\nobreak\ {\footnotesize \NWlink{nuweb139a}{139a}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@extern @\hbox{$\langle\,${\itshape R_pack_sym Prototype}\nobreak\ {\footnotesize \NWlink{nuweb141a}{141a}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22a}{22a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The \proglang{C} file \file{libcoin.c} contains all \proglang{C}
functions and corresponding \proglang{R} interfaces.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap25}\raggedright\small
\NWtarget{nuweb22c}{} \verb@"libcoin.c"@\nobreak\ {\footnotesize {22c}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C Header}\nobreak\ {\footnotesize \NWlink{nuweb155b}{155b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@#include "libcoin_internal.h"@\\
\mbox{}\verb@#include <R_ext/stats_stubs.h>  /* for S_rcont2 */@\\
\mbox{}\verb@#include <mvtnormAPI.h>         /* for calling mvtnorm */@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Function Definitions}\nobreak\ {\footnotesize \NWlink{nuweb23a}{23a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap26}\raggedright\small
\NWtarget{nuweb23a}{} $\langle\,${\itshape Function Definitions}\nobreak\ {\footnotesize {23a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape MoreUtils}\nobreak\ {\footnotesize \NWlink{nuweb130a}{130a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Memory}\nobreak\ {\footnotesize \NWlink{nuweb142a}{142a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape P-Values}\nobreak\ {\footnotesize \NWlink{nuweb64b}{64b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape KronSums}\nobreak\ {\footnotesize \NWlink{nuweb93b}{93b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape colSums}\nobreak\ {\footnotesize \NWlink{nuweb106a}{106a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape SimpleSums}\nobreak\ {\footnotesize \NWlink{nuweb89b}{89b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Tables}\nobreak\ {\footnotesize \NWlink{nuweb110a}{110a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Utils}\nobreak\ {\footnotesize \NWlink{nuweb123a}{123a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape LinearStatistics}\nobreak\ {\footnotesize \NWlink{nuweb77b}{77b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Permutations}\nobreak\ {\footnotesize \NWlink{nuweb127b}{127b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape ExpectationCovariances}\nobreak\ {\footnotesize \NWlink{nuweb78a}{78a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Test Statistics}\nobreak\ {\footnotesize \NWlink{nuweb57a}{57a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape User Interface}\nobreak\ {\footnotesize \NWlink{nuweb30a}{30a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape 2d User Interface}\nobreak\ {\footnotesize \NWlink{nuweb39b}{39b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Tests}\nobreak\ {\footnotesize \NWlink{nuweb50a}{50a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22c}{22c}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\section{Variables}

$N$ is the number of observations

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap27}\raggedright\small
\NWtarget{nuweb23b}{} $\langle\,${\itshape R N Input}\nobreak\ {\footnotesize {23b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP N,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb89c}{89c}.
\item \NWtxtIdentsDefed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb5a}{5a}\NWlink{nuweb5b}{b}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15b}{, 15b}\NWlink{nuweb23c}{, 23c}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb67}{, 67}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb88c}{c}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb93a}{, 93a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb125a}{, 125a}\NWlink{nuweb125b}{b}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb127a}{, 127a}\NWlink{nuweb136a}{, 136a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
which at \proglang{C} level is represented as \code{R_xlen_t} to allow for
$N > $ \code{INT_MAX}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap28}\raggedright\small
\NWtarget{nuweb23c}{} $\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize {23c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@R_xlen_t N@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb24b}{24b}\NWlink{nuweb24c}{c}\NWlink{nuweb32}{, 32}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81b}{b}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb83b}{b}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb87b}{b}\NWlink{nuweb90b}{, 90b}\NWlink{nuweb91b}{, 91b}\NWlink{nuweb92a}{, 92a}\NWlink{nuweb92b}{b}\NWlink{nuweb92c}{c}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb95c}{, 95c}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124a}{, 124a}\NWlink{nuweb125a}{, 125a}\NWlink{nuweb125b}{b}\NWlink{nuweb126b}{, 126b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb5a}{5a}\NWlink{nuweb5b}{b}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15b}{, 15b}\NWlink{nuweb23b}{, 23b}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb67}{, 67}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb88c}{c}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb93a}{, 93a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb125a}{, 125a}\NWlink{nuweb125b}{b}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb127a}{, 127a}\NWlink{nuweb136a}{, 136a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The regressors $\x_i, i = 1, \dots, N$

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap29}\raggedright\small
\NWtarget{nuweb23d}{} $\langle\,${\itshape R x Input}\nobreak\ {\footnotesize {23d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP x,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb30b}{30b}\NWlink{nuweb39c}{, 39c}\NWlink{nuweb47a}{, 47a}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb84b}{, 84b}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb86}{, 86}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb94a}{, 94a}\NWlink{nuweb95c}{, 95c}\NWlink{nuweb102a}{, 102a}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb106b}{, 106b}\NWlink{nuweb110b}{, 110b}\NWlink{nuweb114b}{, 114b}\NWlink{nuweb119a}{, 119a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@x@\nobreak\ \NWlink{nuweb8}{8}\NWlink{nuweb14}{, 14}\NWlink{nuweb17}{, 17}\NWlink{nuweb21a}{, 21a}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb48}{, 48}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb95b}{, 95b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb130b}{, 130b}\NWlink{nuweb131a}{, 131a}\NWlink{nuweb131b}{b}\NWlink{nuweb136a}{, 136a}\NWlink{nuweb136b}{b}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb137b}{b}\NWlink{nuweb138}{, 138}\NWlink{nuweb139a}{, 139a}\NWlink{nuweb139b}{b}\NWlink{nuweb140}{, 140}\NWlink{nuweb141a}{, 141a}\NWlink{nuweb141b}{b}\NWlink{nuweb141c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
are either represented as a real matrix with $N$ rows and $P$ columns

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap30}\raggedright\small
\NWtarget{nuweb24a}{} $\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize {24a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int P@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb24b}{24b}\NWlink{nuweb24c}{c}\NWlink{nuweb32}{, 32}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb78b}{, 78b}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb95c}{, 95c}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb150b}{, 150b}\NWlink{nuweb151}{, 151}.
\item \NWtxtIdentsDefed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb14}{14}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb46}{, 46}\NWlink{nuweb48}{, 48}\NWlink{nuweb51}{, 51}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb54}{, 54}\NWlink{nuweb56}{, 56}\NWlink{nuweb70}{, 70}\NWlink{nuweb71}{, 71}\NWlink{nuweb72}{, 72}\NWlink{nuweb73a}{, 73a}\NWlink{nuweb74}{, 74}\NWlink{nuweb75a}{, 75a}\NWlink{nuweb75b}{b}\NWlink{nuweb76a}{, 76a}\NWlink{nuweb76b}{b}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb78b}{, 78b}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb84b}{, 84b}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb86}{, 86}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb94a}{, 94a}\NWlink{nuweb94b}{b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102a}{, 102a}\NWlink{nuweb102b}{b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb132a}{, 132a}\NWlink{nuweb132b}{b}\NWlink{nuweb136a}{, 136a}\NWlink{nuweb148a}{, 148a}\NWlink{nuweb149}{, 149}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap31}\raggedright\small
\NWtarget{nuweb24b}{} $\langle\,${\itshape C real x Input}\nobreak\ {\footnotesize {24b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *x,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb95d}{95d}\NWlink{nuweb104a}{, 104a}\NWlink{nuweb104b}{b}\NWlink{nuweb107c}{, 107c}\NWlink{nuweb136a}{, 136a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@x@\nobreak\ \NWlink{nuweb8}{8}\NWlink{nuweb14}{, 14}\NWlink{nuweb17}{, 17}\NWlink{nuweb21a}{, 21a}\NWlink{nuweb23d}{, 23d}\NWlink{nuweb24c}{, 24c}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb48}{, 48}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb95b}{, 95b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb130b}{, 130b}\NWlink{nuweb131a}{, 131a}\NWlink{nuweb131b}{b}\NWlink{nuweb136a}{, 136a}\NWlink{nuweb136b}{b}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb137b}{b}\NWlink{nuweb138}{, 138}\NWlink{nuweb139a}{, 139a}\NWlink{nuweb139b}{b}\NWlink{nuweb140}{, 140}\NWlink{nuweb141a}{, 141a}\NWlink{nuweb141b}{b}\NWlink{nuweb141c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
or as a factor (an integer at \proglang{C} level) at $P$ levels

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap32}\raggedright\small
\NWtarget{nuweb24c}{} $\langle\,${\itshape C integer x Input}\nobreak\ {\footnotesize {24c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int *x,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb100a}{100a}\NWlink{nuweb105a}{, 105a}\NWlink{nuweb105b}{b}\NWlink{nuweb112b}{, 112b}\NWlink{nuweb116b}{, 116b}\NWlink{nuweb120c}{, 120c}.
\item \NWtxtIdentsDefed\nobreak\  \verb@x@\nobreak\ \NWlink{nuweb8}{8}\NWlink{nuweb14}{, 14}\NWlink{nuweb17}{, 17}\NWlink{nuweb21a}{, 21a}\NWlink{nuweb23d}{, 23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb48}{, 48}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb95b}{, 95b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb130b}{, 130b}\NWlink{nuweb131a}{, 131a}\NWlink{nuweb131b}{b}\NWlink{nuweb136a}{, 136a}\NWlink{nuweb136b}{b}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb137b}{b}\NWlink{nuweb138}{, 138}\NWlink{nuweb139a}{, 139a}\NWlink{nuweb139b}{b}\NWlink{nuweb140}{, 140}\NWlink{nuweb141a}{, 141a}\NWlink{nuweb141b}{b}\NWlink{nuweb141c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The influence functions are also either a $N \times Q$ real matrix

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap33}\raggedright\small
\NWtarget{nuweb24d}{} $\langle\,${\itshape R y Input}\nobreak\ {\footnotesize {24d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP y,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb30b}{30b}\NWlink{nuweb39c}{, 39c}\NWlink{nuweb47a}{, 47a}\NWlink{nuweb80b}{, 80b}\NWlink{nuweb81b}{, 81b}\NWlink{nuweb82}{, 82}\NWlink{nuweb83b}{, 83b}\NWlink{nuweb94a}{, 94a}\NWlink{nuweb102a}{, 102a}\NWlink{nuweb114b}{, 114b}\NWlink{nuweb119a}{, 119a}\NWlink{nuweb123b}{, 123b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@y@\nobreak\ \NWlink{nuweb14}{14}\NWlink{nuweb21a}{, 21a}\NWlink{nuweb24f}{, 24f}\NWlink{nuweb25a}{, 25a}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb134}{, 134}\NWlink{nuweb135}{, 135}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap34}\raggedright\small
\NWtarget{nuweb24e}{} $\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize {24e}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int Q@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb24f}{24f}\NWlink{nuweb25a}{, 25a}\NWlink{nuweb32}{, 32}\NWlink{nuweb78b}{, 78b}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81b}{b}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb83b}{b}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb150b}{, 150b}\NWlink{nuweb151}{, 151}.
\item \NWtxtIdentsDefed\nobreak\  \verb@Q@\nobreak\ \NWlink{nuweb14}{14}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb46}{, 46}\NWlink{nuweb48}{, 48}\NWlink{nuweb51}{, 51}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb54}{, 54}\NWlink{nuweb70}{, 70}\NWlink{nuweb71}{, 71}\NWlink{nuweb72}{, 72}\NWlink{nuweb73a}{, 73a}\NWlink{nuweb73b}{b}\NWlink{nuweb73c}{c}\NWlink{nuweb74}{, 74}\NWlink{nuweb76a}{, 76a}\NWlink{nuweb76b}{b}\NWlink{nuweb77a}{, 77a}\NWlink{nuweb77d}{d}\NWlink{nuweb78b}{, 78b}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb132b}{, 132b}\NWlink{nuweb148a}{, 148a}\NWlink{nuweb149}{, 149}\NWlink{nuweb150a}{, 150a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap35}\raggedright\small
\NWtarget{nuweb24f}{} $\langle\,${\itshape C real y Input}\nobreak\ {\footnotesize {24f}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *y,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb77c}{77c}\NWlink{nuweb95c}{, 95c}\NWlink{nuweb95d}{d}\NWlink{nuweb100a}{, 100a}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb104a}{, 104a}\NWlink{nuweb104b}{b}\NWlink{nuweb105a}{, 105a}\NWlink{nuweb105b}{b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@y@\nobreak\ \NWlink{nuweb14}{14}\NWlink{nuweb21a}{, 21a}\NWlink{nuweb24d}{, 24d}\NWlink{nuweb25a}{, 25a}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb134}{, 134}\NWlink{nuweb135}{, 135}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
or a factor at $Q$ levels

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap36}\raggedright\small
\NWtarget{nuweb25a}{} $\langle\,${\itshape C integer y Input}\nobreak\ {\footnotesize {25a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int *y,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb116b}{116b}\NWlink{nuweb120c}{, 120c}.
\item \NWtxtIdentsDefed\nobreak\  \verb@y@\nobreak\ \NWlink{nuweb14}{14}\NWlink{nuweb21a}{, 21a}\NWlink{nuweb24d}{, 24d}\NWlink{nuweb24f}{f}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb134}{, 134}\NWlink{nuweb135}{, 135}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The case weights $w_i, i = 1, \dots, N$

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap37}\raggedright\small
\NWtarget{nuweb25b}{} $\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize {25b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP weights@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb30b}{30b}\NWlink{nuweb39c}{, 39c}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb80b}{, 80b}\NWlink{nuweb81b}{, 81b}\NWlink{nuweb82}{, 82}\NWlink{nuweb83b}{, 83b}\NWlink{nuweb84b}{, 84b}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb86}{, 86}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb89c}{, 89c}\NWlink{nuweb90b}{, 90b}\NWlink{nuweb94a}{, 94a}\NWlink{nuweb95a}{, 95a}\NWlink{nuweb106b}{, 106b}\NWlink{nuweb107a}{, 107a}\NWlink{nuweb110b}{, 110b}\NWlink{nuweb111b}{, 111b}\NWlink{nuweb114b}{, 114b}\NWlink{nuweb115b}{, 115b}\NWlink{nuweb119a}{, 119a}\NWlink{nuweb120a}{, 120a}\NWlink{nuweb123b}{, 123b}\NWlink{nuweb126b}{, 126b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@weights@\nobreak\ \NWlink{nuweb3b}{3b}\NWlink{nuweb4}{, 4}\NWlink{nuweb5a}{, 5a}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15a}{, 15a}\NWlink{nuweb15b}{b}\NWlink{nuweb17}{, 17}\NWlink{nuweb19}{, 19}\NWlink{nuweb25c}{, 25c}\NWlink{nuweb25d}{d}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb34b}{, 34b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb49a}{, 49a}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb127a}{, 127a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
can be constant one (\code{XLENGTH(weights) == 0} or \code{weights = integer(0)})
or integer-valued, with \code{HAS_WEIGHTS == 0} in the former case

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap38}\raggedright\small
\NWtarget{nuweb25c}{} $\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize {25c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int *weights,@\\
\mbox{}\verb@int HAS_WEIGHTS,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb92a}{92a}\NWlink{nuweb92b}{b}\NWlink{nuweb97c}{, 97c}\NWlink{nuweb98a}{, 98a}\NWlink{nuweb100c}{, 100c}\NWlink{nuweb100d}{d}\NWlink{nuweb108c}{, 108c}\NWlink{nuweb108d}{d}\NWlink{nuweb113a}{, 113a}\NWlink{nuweb113b}{b}\NWlink{nuweb117b}{, 117b}\NWlink{nuweb117c}{c}\NWlink{nuweb121c}{, 121c}\NWlink{nuweb121d}{d}.
\item \NWtxtIdentsDefed\nobreak\  \verb@HAS_WEIGHTS@\nobreak\ \NWlink{nuweb25d}{25d}\NWlink{nuweb93a}{, 93a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb122b}{, 122b}, \verb@weights,@\nobreak\ \NWlink{nuweb4}{4}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15b}{, 15b}\NWlink{nuweb19}{, 19}\NWlink{nuweb25d}{, 25d}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb34b}{, 34b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb127a}{, 127a}.\item \NWtxtIdentsUsed\nobreak\  \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Case weights larger than \code{INT_MAX} are stored as double

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap39}\raggedright\small
\NWtarget{nuweb25d}{} $\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize {25d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *weights,@\\
\mbox{}\verb@int HAS_WEIGHTS,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb91b}{91b}\NWlink{nuweb92c}{, 92c}\NWlink{nuweb97b}{, 97b}\NWlink{nuweb98b}{, 98b}\NWlink{nuweb100b}{, 100b}\NWlink{nuweb101a}{, 101a}\NWlink{nuweb108b}{, 108b}\NWlink{nuweb109a}{, 109a}\NWlink{nuweb112d}{, 112d}\NWlink{nuweb113c}{, 113c}\NWlink{nuweb117a}{, 117a}\NWlink{nuweb118a}{, 118a}\NWlink{nuweb121b}{, 121b}\NWlink{nuweb122a}{, 122a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@HAS_WEIGHTS@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb93a}{, 93a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb122b}{, 122b}, \verb@weights,@\nobreak\ \NWlink{nuweb4}{4}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15b}{, 15b}\NWlink{nuweb19}{, 19}\NWlink{nuweb25c}{, 25c}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb34b}{, 34b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb127a}{, 127a}.\item \NWtxtIdentsUsed\nobreak\  \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The sum of all case weights is a double

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap40}\raggedright\small
\NWtarget{nuweb25e}{} $\langle\,${\itshape C sumweights Input}\nobreak\ {\footnotesize {25e}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double sumweights@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb79}{79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb81b}{, 81b}\NWlink{nuweb83b}{, 83b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@sumweights@\nobreak\ \NWlink{nuweb32}{32}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb43a}{, 43a}\NWlink{nuweb43b}{b}\NWlink{nuweb44}{, 44}\NWlink{nuweb46}{, 46}\NWlink{nuweb48}{, 48}\NWlink{nuweb49b}{, 49b}\NWlink{nuweb49d}{d}\NWlink{nuweb71}{, 71}\NWlink{nuweb72}{, 72}\NWlink{nuweb73b}{, 73b}\NWlink{nuweb77a}{, 77a}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb127a}{, 127a}\NWlink{nuweb146b}{, 146b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Subsets $\A \subseteq \{1, \dots, N\}$ are \proglang{R} style indices

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap41}\raggedright\small
\NWtarget{nuweb26a}{} $\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize {26a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP subset@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb30b}{30b}\NWlink{nuweb39c}{, 39c}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb80b}{, 80b}\NWlink{nuweb81b}{, 81b}\NWlink{nuweb82}{, 82}\NWlink{nuweb83b}{, 83b}\NWlink{nuweb84b}{, 84b}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb86}{, 86}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb89c}{, 89c}\NWlink{nuweb90b}{, 90b}\NWlink{nuweb94a}{, 94a}\NWlink{nuweb95a}{, 95a}\NWlink{nuweb102a}{, 102a}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb106b}{, 106b}\NWlink{nuweb107a}{, 107a}\NWlink{nuweb110b}{, 110b}\NWlink{nuweb111b}{, 111b}\NWlink{nuweb114b}{, 114b}\NWlink{nuweb115b}{, 115b}\NWlink{nuweb119a}{, 119a}\NWlink{nuweb120a}{, 120a}\NWlink{nuweb123b}{, 123b}\NWlink{nuweb124a}{, 124a}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb126b}{b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@subset@\nobreak\ \NWlink{nuweb3b}{3b}\NWlink{nuweb4}{, 4}\NWlink{nuweb5a}{, 5a}\NWlink{nuweb5b}{b}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15a}{, 15a}\NWlink{nuweb15b}{b}\NWlink{nuweb17}{, 17}\NWlink{nuweb19}{, 19}\NWlink{nuweb26d}{, 26d}\NWlink{nuweb26e}{e}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb32}{, 32}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb89a}{, 89a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb127a}{, 127a}\NWlink{nuweb128a}{, 128a}\NWlink{nuweb128b}{b}\NWlink{nuweb129a}{, 129a}\NWlink{nuweb129b}{b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
are either not existent (\code{XLENGTH(subset) == 0}) or of length

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap42}\raggedright\small
\NWtarget{nuweb26b}{} $\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize {26b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@R_xlen_t Nsubset@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb26c}{26c}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb128a}{, 128a}\NWlink{nuweb128b}{b}\NWlink{nuweb129b}{, 129b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@Nsubset@\nobreak\ \NWlink{nuweb34b}{34b}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb88c}{c}\NWlink{nuweb89a}{, 89a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb93a}{, 93a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb128a}{, 128a}\NWlink{nuweb128b}{b}\NWlink{nuweb129b}{, 129b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Optionally, one can specify a subset of the subset via

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap43}\raggedright\small
\NWtarget{nuweb26c}{} $\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize {26c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@R_xlen_t offset,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb26d}{26d}\NWlink{nuweb26e}{e}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb81b}{, 81b}\NWlink{nuweb83b}{, 83b}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb90b}{, 90b}\NWlink{nuweb95a}{, 95a}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb107a}{, 107a}\NWlink{nuweb111b}{, 111b}\NWlink{nuweb115b}{, 115b}\NWlink{nuweb120a}{, 120a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@offset@\nobreak\ \NWlink{nuweb32}{32}\NWlink{nuweb34b}{, 34b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81c}{, 81c}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb120b}{, 120b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
where \code{offset} is a \proglang{C} style index for \code{subset}.

Subsets are stored either as integer

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap44}\raggedright\small
\NWtarget{nuweb26d}{} $\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize {26d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int *subset,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb92b}{92b}\NWlink{nuweb92c}{c}\NWlink{nuweb98a}{, 98a}\NWlink{nuweb98b}{b}\NWlink{nuweb100d}{, 100d}\NWlink{nuweb101a}{, 101a}\NWlink{nuweb104b}{, 104b}\NWlink{nuweb105b}{, 105b}\NWlink{nuweb108d}{, 108d}\NWlink{nuweb109a}{, 109a}\NWlink{nuweb113b}{, 113b}\NWlink{nuweb113c}{c}\NWlink{nuweb117c}{, 117c}\NWlink{nuweb118a}{, 118a}\NWlink{nuweb121d}{, 121d}\NWlink{nuweb122a}{, 122a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@subset@\nobreak\ \NWlink{nuweb3b}{3b}\NWlink{nuweb4}{, 4}\NWlink{nuweb5a}{, 5a}\NWlink{nuweb5b}{b}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15a}{, 15a}\NWlink{nuweb15b}{b}\NWlink{nuweb17}{, 17}\NWlink{nuweb19}{, 19}\NWlink{nuweb26a}{, 26a}\NWlink{nuweb26e}{e}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb32}{, 32}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb89a}{, 89a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb127a}{, 127a}\NWlink{nuweb128a}{, 128a}\NWlink{nuweb128b}{b}\NWlink{nuweb129a}{, 129a}\NWlink{nuweb129b}{b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
or double (to allow for indices larger than \code{INT_MAX})

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap45}\raggedright\small
\NWtarget{nuweb26e}{} $\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize {26e}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *subset,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb91b}{91b}\NWlink{nuweb92a}{, 92a}\NWlink{nuweb97b}{, 97b}\NWlink{nuweb97c}{c}\NWlink{nuweb100b}{, 100b}\NWlink{nuweb100c}{c}\NWlink{nuweb104a}{, 104a}\NWlink{nuweb105a}{, 105a}\NWlink{nuweb108b}{, 108b}\NWlink{nuweb108c}{c}\NWlink{nuweb112d}{, 112d}\NWlink{nuweb113a}{, 113a}\NWlink{nuweb117a}{, 117a}\NWlink{nuweb117b}{b}\NWlink{nuweb121b}{, 121b}\NWlink{nuweb121c}{c}.
\item \NWtxtIdentsDefed\nobreak\  \verb@subset@\nobreak\ \NWlink{nuweb3b}{3b}\NWlink{nuweb4}{, 4}\NWlink{nuweb5a}{, 5a}\NWlink{nuweb5b}{b}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15a}{, 15a}\NWlink{nuweb15b}{b}\NWlink{nuweb17}{, 17}\NWlink{nuweb19}{, 19}\NWlink{nuweb26a}{, 26a}\NWlink{nuweb26d}{d}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb32}{, 32}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb89a}{, 89a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb127a}{, 127a}\NWlink{nuweb128a}{, 128a}\NWlink{nuweb128b}{b}\NWlink{nuweb129a}{, 129a}\NWlink{nuweb129b}{b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Blocks $\text{block}_i, i = 1, \dots, N$

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap46}\raggedright\small
\NWtarget{nuweb26f}{} $\langle\,${\itshape R block Input}\nobreak\ {\footnotesize {26f}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP block@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb30b}{30b}\NWlink{nuweb39c}{, 39c}\NWlink{nuweb47a}{, 47a}\NWlink{nuweb119a}{, 119a}\NWlink{nuweb123b}{, 123b}\NWlink{nuweb124a}{, 124a}\NWlink{nuweb125b}{, 125b}\NWlink{nuweb126a}{, 126a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb3b}{3b}\NWlink{nuweb4}{, 4}\NWlink{nuweb5a}{, 5a}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15a}{, 15a}\NWlink{nuweb15b}{b}\NWlink{nuweb17}{, 17}\NWlink{nuweb19}{, 19}\NWlink{nuweb27b}{, 27b}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb125b}{, 125b}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb146a}{, 146a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
at $B$ levels

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap47}\raggedright\small
\NWtarget{nuweb27a}{} $\langle\,${\itshape C integer B Input}\nobreak\ {\footnotesize {27a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int B@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb27b}{27b}\NWlink{nuweb32}{, 32}\NWlink{nuweb150b}{, 150b}\NWlink{nuweb151}{, 151}.
\item \NWtxtIdentsDefed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb31a}{31a}\NWlink{nuweb31b}{b}\NWlink{nuweb32}{, 32}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42b}{, 42b}\NWlink{nuweb45}{, 45}\NWlink{nuweb46}{, 46}\NWlink{nuweb48}{, 48}\NWlink{nuweb49b}{, 49b}\NWlink{nuweb70}{, 70}\NWlink{nuweb71}{, 71}\NWlink{nuweb74}{, 74}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb132b}{, 132b}\NWlink{nuweb132c}{c}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb133b}{b}\NWlink{nuweb134}{, 134}\NWlink{nuweb135}{, 135}\NWlink{nuweb148a}{, 148a}\NWlink{nuweb149}{, 149}\NWlink{nuweb150b}{, 150b}\NWlink{nuweb151}{, 151}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
are stored as a factor

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap48}\raggedright\small
\NWtarget{nuweb27b}{} $\langle\,${\itshape C integer block Input}\nobreak\ {\footnotesize {27b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int *block,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer B Input}\nobreak\ {\footnotesize \NWlink{nuweb27a}{27a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb120c}{120c}.
\item \NWtxtIdentsDefed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb3b}{3b}\NWlink{nuweb4}{, 4}\NWlink{nuweb5a}{, 5a}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15a}{, 15a}\NWlink{nuweb15b}{b}\NWlink{nuweb17}{, 17}\NWlink{nuweb19}{, 19}\NWlink{nuweb26f}{, 26f}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb125b}{, 125b}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb146a}{, 146a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The tabulation of block (potentially in subsets) is

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap49}\raggedright\small
\NWtarget{nuweb27c}{} $\langle\,${\itshape R blockTable Input}\nobreak\ {\footnotesize {27c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP blockTable@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb124a}{124a}\NWlink{nuweb125b}{, 125b}\NWlink{nuweb126a}{, 126a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@blockTable@\nobreak\ \NWlink{nuweb37}{37}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb125b}{, 125b}\NWlink{nuweb126a}{, 126a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
where the table is of length $B + 1$ and the first element
counts the number of missing values (although these are NOT allowed in
block).

\subsection{Example Data and Code}

We start with setting-up some toy data sets to be used as test bed. The data
over both the 1d and the 2d case, including case weights, subsets and blocks.
<<ex-setup>>=
N <- 20L
P <- 3L
Lx <- 10L
Ly <- 5L
Q <- 4L
B <- 2L
iX2d <- rbind(0, matrix(runif(Lx * P), nrow = Lx))
ix <- sample(1:Lx, size = N, replace = TRUE)
levels(ix) <- 1:Lx
ixf <- factor(ix, levels = 1:Lx, labels = 1:Lx)
x <- iX2d[ix + 1,]
Xfactor <- diag(Lx)[ix,]
iY2d <- rbind(0, matrix(runif(Ly * Q), nrow = Ly))
iy <- sample(1:Ly, size = N, replace = TRUE)
levels(iy) <- 1:Ly
iyf <- factor(iy, levels = 1:Ly, labels = 1:Ly)
y <- iY2d[iy + 1,]
weights <- sample(0:5, size = N, replace = TRUE)
block <- sample(gl(B, ceiling(N / B))[1:N])
subset <- sort(sample(1:N, floor(N * 1.5), replace = TRUE))
subsety <- sample(1:N, floor(N * 1.5), replace = TRUE)
r1 <- rep(1:ncol(x), ncol(y))
r1Xfactor <- rep(1:ncol(Xfactor), ncol(y))
r2 <- rep(1:ncol(y), each = ncol(x))
r2Xfactor <- rep(1:ncol(y), each = ncol(Xfactor))
@

As a benchmark, we implement linear statistics, their expectation and
covariance, taking case weights, subsets and blocks into account, at \proglang{R}
level. In a sense, the core of the \pkg{libcoin} package is ``just'' a less
memory-hungry and sometimes faster version of this simple function.

<<Rlibcoin>>=
LSEC <-
function(X, Y, weights = integer(0), subset = integer(0), block = integer(0))
{
    if (length(weights) == 0) weights <- rep.int(1, NROW(X))
    if (length(subset) == 0) subset <- seq_len(NROW(X))

    X <- X[subset,, drop = FALSE]
    Y <- Y[subset,, drop = FALSE]
    weights <- weights[subset]

    if (length(block) == 0) {
        w. <- sum(weights)
        wX <- weights * X
        wY <- weights * Y
        ExpX <- colSums(wX)
        ExpY <- colSums(wY) / w.
        CovX <- crossprod(X, wX)
        Yc <- t(t(Y) - ExpY)
        CovY <- crossprod(Yc, weights * Yc) / w.
        T <- crossprod(X, wY)
        Exp <- kronecker(ExpY, ExpX)
        Cov <- w. / (w. - 1) * kronecker(CovY, CovX) -
                1 / (w. - 1) * kronecker(CovY, tcrossprod(ExpX))

        list(LinearStatistic = as.vector(T), Expectation = as.vector(Exp),
             Covariance = Cov, Variance = diag(Cov))
    } else {
        block <- block[subset]
        ret <- list(LinearStatistic = 0, Expectation = 0,
                    Covariance = 0, Variance = 0)
        for (b in levels(block)) {
            tmp <- LSEC(X = X, Y = Y, weights = weights, subset = which(block == b))
            for (l in names(ret)) ret[[l]] <- ret[[l]] + tmp[[l]]
        }
        ret
    }
}
@

<<cmpr>>=
cmpr <-
function(ret1, ret2)
{
    if (inherits(ret1, "LinStatExpCov")) {
        if (!ret1$varonly)
            ret1$Covariance <- vcov(ret1)
    }
    ret1 <- ret1[!sapply(ret1, is.null)]
    ret2 <- ret2[!sapply(ret2, is.null)]
    nm1 <- names(ret1)
    nm2 <- names(ret2)
    nm <- c(nm1, nm2)
    nm <- names(table(nm))[table(nm) == 2]
    isequal(ret1[nm], ret2[nm])
}
@

We now compute the linear statistic along with corresponding expectation,
variance and covariance for later reuse.

<<benchmarks>>=
LECVxyws <- LinStatExpCov(x, y, weights = weights, subset = subset)
LEVxyws <- LinStatExpCov(x, y, weights = weights, subset = subset, varonly = TRUE)
@

The following tests compare the high-level \proglang{R} implementation
(function \code{LSEC()}) with the 1d and 2d \proglang{C} level
implementations in the two situations with and without specification of
\code{X} (i.e., the dummy matrix in the latter case).

<<tests>>=
### with X given
testit <-
function(...)
{
    a <- LinStatExpCov(x, y, ...)
    b <- LSEC(x, y, ...)
    d <- LinStatExpCov(X = iX2d, ix = ix, Y = iY2d, iy = iy, ...)
    cmpr(a, b) && cmpr(d, b)
}

stopifnot(
    testit() && testit(weights = weights) &&
    testit(subset = subset) && testit(weights = weights, subset = subset) &&
    testit(block = block) && testit(weights = weights, block = block) &&
    testit(subset = subset, block = block) &&
    testit(weights = weights, subset = subset, block = block)
)

### without dummy matrix X
testit <-
function(...)
{
    a <- LinStatExpCov(X = ix, y, ...)
    b <- LSEC(Xfactor, y, ...)
    d <- LinStatExpCov(X = integer(0), ix = ix, Y = iY2d, iy = iy, ...)
    cmpr(a, b) && cmpr(d, b)
}

stopifnot(
    testit() && testit(weights = weights) &&
    testit(subset = subset) && testit(weights = weights, subset = subset) &&
    testit(block = block) && testit(weights = weights, block = block) &&
    testit(subset = subset, block = block) &&
    testit(weights = weights, subset = subset, block = block)
)
@

All three implementations give the same results.

\section{Conventions}

Functions starting with \code{R_} are \proglang{C} functions callable via
\code{.Call()} from \proglang{R}. That means they all return \code{SEXP}.
These functions allocate memory handled by \proglang{R}.

Functions starting with \code{RC_} are \proglang{C} functions with
\code{SEXP} or pointer arguments and possibly an \code{SEXP} return value.

Functions starting with \code{C_} are \proglang{C} functions with pointer
arguments only and return a scalar or nothing.

Return values (arguments modified by a function) are named \code{ans},
sometimes with dimension (for example: \code{PQ_ans}).

\section{\proglang{C} User Interface}

\subsection{One-Dimensional Case (``1d'')}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap50}\raggedright\small
\NWtarget{nuweb30a}{} $\langle\,${\itshape User Interface}\nobreak\ {\footnotesize {30a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_ExpectationCovarianceStatistic}\nobreak\ {\footnotesize \NWlink{nuweb32}{32}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_ExpectationCovarianceStatistic}\nobreak\ {\footnotesize \NWlink{nuweb31a}{31a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_PermutedLinearStatistic}\nobreak\ {\footnotesize \NWlink{nuweb37}{37}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_StandardisePermutedLinearStatistic}\nobreak\ {\footnotesize \NWlink{nuweb39a}{39a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The data are given as $\x_i$ and $\y_i$ for $i = 1, \dots, N$, optionally
with case weights, subset and blocks. The latter three variables are ignored when
specified as \code{integer(0)}.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap51}\raggedright\small
\NWtarget{nuweb30b}{} $\langle\,${\itshape User Interface Input}\nobreak\ {\footnotesize {30b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R block Input}\nobreak\ {\footnotesize \NWlink{nuweb26f}{26f}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb30c}{30c}\NWlink{nuweb32}{, 32}\NWlink{nuweb36b}{, 36b}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap52}\raggedright\small
\NWtarget{nuweb30c}{} $\langle\,${\itshape R_ExpectationCovarianceStatistic Prototype}\nobreak\ {\footnotesize {30c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_ExpectationCovarianceStatistic@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape User Interface Input}\nobreak\ {\footnotesize \NWlink{nuweb30b}{30b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP varonly,@\\
\mbox{}\verb@    SEXP tol@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb31a}{, 31a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_ExpectationCovarianceStatistic@\nobreak\ \NWlink{nuweb31a}{31a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap53}\raggedright\small
\NWtarget{nuweb30d}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {30d}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C Header}\nobreak\ {\footnotesize \NWlink{nuweb155b}{155b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@#include <R_ext/Rdynload.h>@\\
\mbox{}\verb@#include <libcoin.h>@\\
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_ExpectationCovarianceStatistic(@\\
\mbox{}\verb@    SEXP x, SEXP y, SEXP weights, SEXP subset, SEXP block, SEXP varonly,@\\
\mbox{}\verb@    SEXP tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_ExpectationCovarianceStatistic");@\\
\mbox{}\verb@    return fun(x, y, weights, subset, block, varonly, tol);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@R_ExpectationCovarianceStatistic@\nobreak\ \NWlink{nuweb31a}{31a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The \proglang{C} interface essentially sets-up the necessary memory and
calls a \proglang{C} level function for the computations.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap54}\raggedright\small
\NWtarget{nuweb31a}{} $\langle\,${\itshape R_ExpectationCovarianceStatistic}\nobreak\ {\footnotesize {31a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_ExpectationCovarianceStatistic Prototype}\nobreak\ {\footnotesize \NWlink{nuweb30c}{30c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup Dimensions}\nobreak\ {\footnotesize \NWlink{nuweb31b}{31b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = RC_init_LECV_1d(P, Q, INTEGER(varonly)[0], B, TYPEOF(x) == INTSXP, REAL(tol)[0]));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    RC_ExpectationCovarianceStatistic(x, y, weights, subset, block, ans);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb30a}{30a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_ExpectationCovarianceStatistic@\nobreak\ \NWlink{nuweb6}{6}\NWlink{nuweb30c}{, 30c}\NWlink{nuweb30d}{d}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_ExpectationCovarianceStatistic@\nobreak\ \NWlink{nuweb32}{32}\NWlink{nuweb45}{, 45}, \verb@RC_init_LECV_1d@\nobreak\ \NWlink{nuweb150b}{150b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
$P$, $Q$ and $B$ are first extracted from the data. The case where \code{X}
is an implicitly specified dummy matrix, the dimension $P$ is the number of
levels of \code{x}.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap55}\raggedright\small
\NWtarget{nuweb31b}{} $\langle\,${\itshape Setup Dimensions}\nobreak\ {\footnotesize {31b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int P, Q, B;@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (TYPEOF(x) == INTSXP) {@\\
\mbox{}\verb@    P = NLEVELS(x);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    P = NCOL(x);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@Q = NCOL(y);@\\
\mbox{}\verb@@\\
\mbox{}\verb@B = 1;@\\
\mbox{}\verb@if (LENGTH(block) > 0)@\\
\mbox{}\verb@    B = NLEVELS(block);@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb31a}{31a}\NWlink{nuweb37}{, 37}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}, \verb@NLEVELS@\nobreak\ \NWlink{nuweb131b}{131b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The core function first computes the linear statistic (as there is no need
to pay attention to blocks) and, in a second step, starts a loop over
potential blocks.

FIXME:  \code{x} being an integer (\code{Xfactor}) with some 0 elements is not handled
        correctly (as \code{sumweights} doesn't take this information into
        account; use \code{subset} to exclude these missings (as done in
        \code{LinStatExpCov()})

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap56}\raggedright\small
\NWtarget{nuweb32}{} $\langle\,${\itshape RC_ExpectationCovarianceStatistic}\nobreak\ {\footnotesize {32}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_ExpectationCovarianceStatistic@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape User Interface Input}\nobreak\ {\footnotesize \NWlink{nuweb30b}{30b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer B Input}\nobreak\ {\footnotesize \NWlink{nuweb27a}{27a}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    double *sumweights, *table;@\\
\mbox{}\verb@    double *ExpInf, *VarInf, *CovInf, *ExpX, *ExpXtotal, *VarX, *CovX;@\\
\mbox{}\verb@    double *tmpV, *tmpCV;@\\
\mbox{}\verb@    SEXP nullvec, subset_block;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Extract Dimensions}\nobreak\ {\footnotesize \NWlink{nuweb33a}{33a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Compute Linear Statistic}\nobreak\ {\footnotesize \NWlink{nuweb33b}{33b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup Memory and Subsets in Blocks}\nobreak\ {\footnotesize \NWlink{nuweb34a}{34a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* start with subset[0] */@\\
\mbox{}\verb@    R_xlen_t offset = (R_xlen_t) table[0];@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int b = 0; b < B; b++) {@\\
\mbox{}\verb@@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape Compute Sum of Weights in Block}\nobreak\ {\footnotesize \NWlink{nuweb34b}{34b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@        /* don't do anything for empty blocks or blocks with weight 1 */@\\
\mbox{}\verb@        if (sumweights[b] > 1) {@\\
\mbox{}\verb@@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape Compute Expectation Linear Statistic}\nobreak\ {\footnotesize \NWlink{nuweb35a}{35a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape Compute Covariance Influence}\nobreak\ {\footnotesize \NWlink{nuweb35b}{35b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@            if (C_get_varonly(ans)) {@\\
\mbox{}\verb@                @\hbox{$\langle\,${\itshape Compute Variance Linear Statistic}\nobreak\ {\footnotesize \NWlink{nuweb35c}{35c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            } else {@\\
\mbox{}\verb@                @\hbox{$\langle\,${\itshape Compute Covariance Linear Statistic}\nobreak\ {\footnotesize \NWlink{nuweb35d}{35d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@@\\
\mbox{}\verb@        /* next iteration starts with subset[cumsum(table[1:(b + 1)])] */@\\
\mbox{}\verb@        offset += (R_xlen_t) table[b + 1];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Compute Variance from Covariance}\nobreak\ {\footnotesize \NWlink{nuweb36a}{36a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    R_Free(ExpX); R_Free(VarX); R_Free(CovX);@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb30a}{30a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_ExpectationCovarianceStatistic@\nobreak\ \NWlink{nuweb31a}{31a}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The dimensions are available from the return object:

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap57}\raggedright\small
\NWtarget{nuweb33a}{} $\langle\,${\itshape Extract Dimensions}\nobreak\ {\footnotesize {33a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@P = C_get_P(ans);@\\
\mbox{}\verb@Q = C_get_Q(ans);@\\
\mbox{}\verb@N = NROW(x);@\\
\mbox{}\verb@B = C_get_B(ans);@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb32}{32}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@C_get_B@\nobreak\ \NWlink{nuweb147a}{147a}, \verb@C_get_P@\nobreak\ \NWlink{nuweb142c}{142c}, \verb@C_get_Q@\nobreak\ \NWlink{nuweb143a}{143a}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The linear statistic $\T(\A)$ can be computed without taking blocks into account.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap58}\raggedright\small
\NWtarget{nuweb33b}{} $\langle\,${\itshape Compute Linear Statistic}\nobreak\ {\footnotesize {33b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@RC_LinearStatistic(x, N, P, REAL(y), Q, weights, subset,@\\
\mbox{}\verb@                   Offset0, XLENGTH(subset),@\\
\mbox{}\verb@                   C_get_LinearStatistic(ans));@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb32}{32}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_get_LinearStatistic@\nobreak\ \NWlink{nuweb143d}{143d}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_LinearStatistic@\nobreak\ \NWlink{nuweb77d}{77d}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
We next extract memory from the return object and allocate some additional
memory. The most important step is to tabulate blocks and to order the
subset with respect to blocks. In absence of block, this just returns
subset.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap59}\raggedright\small
\NWtarget{nuweb34a}{} $\langle\,${\itshape Setup Memory and Subsets in Blocks}\nobreak\ {\footnotesize {34a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@ExpInf = C_get_ExpectationInfluence(ans);@\\
\mbox{}\verb@VarInf = C_get_VarianceInfluence(ans);@\\
\mbox{}\verb@CovInf = C_get_CovarianceInfluence(ans);@\\
\mbox{}\verb@ExpXtotal = C_get_ExpectationX(ans);@\\
\mbox{}\verb@for (int p = 0; p < P; p++) ExpXtotal[p] = 0.0;@\\
\mbox{}\verb@ExpX = R_Calloc(P, double);@\\
\mbox{}\verb@/* Fix by Joanidis Kristoforos: P > INT_MAX is possible@\\
\mbox{}\verb@   for maximally selected statistics (when X is an integer).@\\
\mbox{}\verb@   2018-12-13 */@\\
\mbox{}\verb@if (C_get_varonly(ans)) {@\\
\mbox{}\verb@    VarX = R_Calloc(P, double);@\\
\mbox{}\verb@    CovX = R_Calloc(1, double);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    VarX = R_Calloc(1, double);@\\
\mbox{}\verb@    CovX = R_Calloc(PP12(P), double);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@table = C_get_TableBlock(ans);@\\
\mbox{}\verb@sumweights = C_get_Sumweights(ans);@\\
\mbox{}\verb@PROTECT(nullvec = allocVector(INTSXP, 0));@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (B == 1) {@\\
\mbox{}\verb@    table[0] = 0.0;@\\
\mbox{}\verb@    table[1] = RC_Sums(N, nullvec, subset, Offset0, XLENGTH(subset));@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    RC_OneTableSums(INTEGER(block), N, B + 1, nullvec, subset, Offset0,@\\
\mbox{}\verb@                    XLENGTH(subset), table);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@if (table[0] > 0)@\\
\mbox{}\verb@    error("No missing values allowed in block");@\\
\mbox{}\verb@PROTECT(subset_block = RC_order_subset_wrt_block(N, subset, block,@\\
\mbox{}\verb@                                                 VECTOR_ELT(ans, TableBlock_SLOT)));@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb32}{32}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@C_get_CovarianceInfluence@\nobreak\ \NWlink{nuweb145c}{145c}, \verb@C_get_ExpectationInfluence@\nobreak\ \NWlink{nuweb145b}{145b}, \verb@C_get_ExpectationX@\nobreak\ \NWlink{nuweb145a}{145a}, \verb@C_get_Sumweights@\nobreak\ \NWlink{nuweb146b}{146b}, \verb@C_get_TableBlock@\nobreak\ \NWlink{nuweb146a}{146a}, \verb@C_get_VarianceInfluence@\nobreak\ \NWlink{nuweb145d}{145d}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@PP12@\nobreak\ \NWlink{nuweb132a}{132a}, \verb@RC_OneTableSums@\nobreak\ \NWlink{nuweb112a}{112a}, \verb@RC_order_subset_wrt_block@\nobreak\ \NWlink{nuweb124b}{124b}, \verb@RC_Sums@\nobreak\ \NWlink{nuweb91a}{91a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@TableBlock_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
We compute $\mub(\A)$ based on $\E(h \mid S(\A))$ and $\sum_{i \in \A} w_i \x_i$
for the subset given by subset and the $b$th level of block. The expectation
is initialised zero when $b = 0$ and values add-up over blocks.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap60}\raggedright\small
\NWtarget{nuweb34b}{} $\langle\,${\itshape Compute Sum of Weights in Block}\nobreak\ {\footnotesize {34b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/* compute sum of case weights in block b of subset */@\\
\mbox{}\verb@if (table[b + 1] > 0) {@\\
\mbox{}\verb@    sumweights[b] = RC_Sums(N, weights, subset_block,@\\
\mbox{}\verb@                            offset, (R_xlen_t) table[b + 1]);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    /* offset = something and Nsubset = 0 means Nsubset = N in@\\
\mbox{}\verb@       RC_Sums; catch empty or zero-weight block levels here */@\\
\mbox{}\verb@    sumweights[b] = 0.0;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb32}{32}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@RC_Sums@\nobreak\ \NWlink{nuweb91a}{91a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap61}\raggedright\small
\NWtarget{nuweb35a}{} $\langle\,${\itshape Compute Expectation Linear Statistic}\nobreak\ {\footnotesize {35a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@RC_ExpectationInfluence(N, y, Q, weights, subset_block, offset,@\\
\mbox{}\verb@                        (R_xlen_t) table[b + 1], sumweights[b], ExpInf + b * Q);@\\
\mbox{}\verb@RC_ExpectationX(x, N, P, weights, subset_block, offset,@\\
\mbox{}\verb@                (R_xlen_t) table[b + 1], ExpX);@\\
\mbox{}\verb@for (int p = 0; p < P; p++) ExpXtotal[p] += ExpX[p];@\\
\mbox{}\verb@C_ExpectationLinearStatistic(P, Q, ExpInf + b * Q, ExpX, b,@\\
\mbox{}\verb@                             C_get_Expectation(ans));@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb32}{32}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_ExpectationLinearStatistic@\nobreak\ \NWlink{nuweb78b}{78b}, \verb@C_get_Expectation@\nobreak\ \NWlink{nuweb144a}{144a}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_ExpectationInfluence@\nobreak\ \NWlink{nuweb81c}{81c}, \verb@RC_ExpectationX@\nobreak\ \NWlink{nuweb85b}{85b}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The covariance $\V(h \mid S(\A))$ is now computed for the subset given by
subset and the $b$th level of block. Note that \code{CovInf} stores the
values for each block in the return object (for later reuse).

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap62}\raggedright\small
\NWtarget{nuweb35b}{} $\langle\,${\itshape Compute Covariance Influence}\nobreak\ {\footnotesize {35b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/* C_ordered_Xfactor and C_unordered_Xfactor need both VarInf and CovInf */@\\
\mbox{}\verb@RC_CovarianceInfluence(N, y, Q, weights, subset_block, offset,@\\
\mbox{}\verb@                      (R_xlen_t) table[b + 1], ExpInf + b * Q, sumweights[b],@\\
\mbox{}\verb@                      !DoVarOnly, CovInf + b * Q * (Q + 1) / 2);@\\
\mbox{}\verb@/* extract variance from covariance */@\\
\mbox{}\verb@tmpCV = CovInf + b * Q * (Q + 1) / 2;@\\
\mbox{}\verb@tmpV = VarInf + b * Q;@\\
\mbox{}\verb@for (int q = 0; q < Q; q++) tmpV[q] = tmpCV[S(q, q, Q)];@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb32}{32}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_ordered_Xfactor@\nobreak\ \NWlink{nuweb70}{70}, \verb@C_unordered_Xfactor@\nobreak\ \NWlink{nuweb74}{74}, \verb@DoVarOnly@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_CovarianceInfluence@\nobreak\ \NWlink{nuweb84a}{84a}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
We can now compute the variance or covariance of the linear statistic
$\Sigmab(\A)$:

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap63}\raggedright\small
\NWtarget{nuweb35c}{} $\langle\,${\itshape Compute Variance Linear Statistic}\nobreak\ {\footnotesize {35c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@RC_CovarianceX(x, N, P, weights, subset_block, offset,@\\
\mbox{}\verb@               (R_xlen_t) table[b + 1], ExpX, DoVarOnly, VarX);@\\
\mbox{}\verb@C_VarianceLinearStatistic(P, Q, VarInf + b * Q, ExpX, VarX, sumweights[b],@\\
\mbox{}\verb@                          b, C_get_Variance(ans));@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb32}{32}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_get_Variance@\nobreak\ \NWlink{nuweb144b}{144b}, \verb@C_VarianceLinearStatistic@\nobreak\ \NWlink{nuweb80a}{80a}, \verb@DoVarOnly@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_CovarianceX@\nobreak\ \NWlink{nuweb88a}{88a}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap64}\raggedright\small
\NWtarget{nuweb35d}{} $\langle\,${\itshape Compute Covariance Linear Statistic}\nobreak\ {\footnotesize {35d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@RC_CovarianceX(x, N, P, weights, subset_block, offset,@\\
\mbox{}\verb@               (R_xlen_t) table[b + 1], ExpX, !DoVarOnly, CovX);@\\
\mbox{}\verb@C_CovarianceLinearStatistic(P, Q, CovInf + b * Q * (Q + 1) / 2,@\\
\mbox{}\verb@                            ExpX, CovX, sumweights[b], b,@\\
\mbox{}\verb@                            C_get_Covariance(ans));@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb32}{32}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_CovarianceLinearStatistic@\nobreak\ \NWlink{nuweb79}{79}, \verb@C_get_Covariance@\nobreak\ \NWlink{nuweb144c}{144c}, \verb@DoVarOnly@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_CovarianceX@\nobreak\ \NWlink{nuweb88a}{88a}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap65}\raggedright\small
\NWtarget{nuweb36a}{} $\langle\,${\itshape Compute Variance from Covariance}\nobreak\ {\footnotesize {36a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/* always return variances */@\\
\mbox{}\verb@if (!C_get_varonly(ans)) {@\\
\mbox{}\verb@    for (int p = 0; p < mPQB(P, Q, 1); p++)@\\
\mbox{}\verb@        C_get_Variance(ans)[p] = C_get_Covariance(ans)[S(p, p, mPQB(P, Q, 1))];@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb32}{32}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_get_Covariance@\nobreak\ \NWlink{nuweb144c}{144c}, \verb@C_get_Variance@\nobreak\ \NWlink{nuweb144b}{144b}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The computation of permuted linear statistics is done outside this general
function. The user interface is the same, except for an additional number of
permutations to be specified.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap66}\raggedright\small
\NWtarget{nuweb36b}{} $\langle\,${\itshape R_PermutedLinearStatistic Prototype}\nobreak\ {\footnotesize {36b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_PermutedLinearStatistic@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape User Interface Input}\nobreak\ {\footnotesize \NWlink{nuweb30b}{30b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP nresample@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb37}{, 37}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_PermutedLinearStatistic@\nobreak\ \NWlink{nuweb37}{37}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap67}\raggedright\small
\NWtarget{nuweb36c}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {36c}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_PermutedLinearStatistic(@\\
\mbox{}\verb@    SEXP x, SEXP y, SEXP weights, SEXP subset, SEXP block, SEXP nresample@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_PermutedLinearStatistic");@\\
\mbox{}\verb@    return fun(x, y, weights, subset, block, nresample);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@R_PermutedLinearStatistic@\nobreak\ \NWlink{nuweb37}{37}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
The dimensions are extracted from the data in the same ways as above. The
function differentiates between the absence and presence of blocks.
Case weights are removed by expanding subset accordingly. Once within-block
permutations were set-up the Kronecker product of \code{X} and \code{Y} is
computed. Note that this function returns the matrix of permuted linear
statistics; the \proglang{R} interface assigns this matrix to the
corresponding element of the \code{LinStatExpCov} object (because we are not
allowed to modify existing \proglang{R} objects at \proglang{C} level).

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap68}\raggedright\small
\NWtarget{nuweb37}{} $\langle\,${\itshape R_PermutedLinearStatistic}\nobreak\ {\footnotesize {37}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_PermutedLinearStatistic Prototype}\nobreak\ {\footnotesize \NWlink{nuweb36b}{36b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans, expand_subset, block_subset, perm, tmp, blockTable;@\\
\mbox{}\verb@    double *linstat;@\\
\mbox{}\verb@    int PQ;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    R_xlen_t inresample;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup Dimensions}\nobreak\ {\footnotesize \NWlink{nuweb31b}{31b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    PQ = mPQB(P, Q, 1);@\\
\mbox{}\verb@    N = NROW(y);@\\
\mbox{}\verb@    inresample = (R_xlen_t) REAL(nresample)[0];@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocMatrix(REALSXP, PQ, inresample));@\\
\mbox{}\verb@    PROTECT(expand_subset = RC_setup_subset(N, weights, subset));@\\
\mbox{}\verb@    Nsubset = XLENGTH(expand_subset);@\\
\mbox{}\verb@    PROTECT(tmp = allocVector(REALSXP, Nsubset));@\\
\mbox{}\verb@    PROTECT(perm = allocVector(REALSXP, Nsubset));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    GetRNGstate();@\\
\mbox{}\verb@    if (B == 1) {@\\
\mbox{}\verb@        for (R_xlen_t np = 0; np < inresample; np++) {@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape Setup Linear Statistic}\nobreak\ {\footnotesize \NWlink{nuweb38a}{38a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            C_doPermute(REAL(expand_subset), Nsubset, REAL(tmp), REAL(perm));@\\
\mbox{}\verb@            RC_KronSums_Permutation(x, NROW(x), P, REAL(y), Q, expand_subset,@\\
\mbox{}\verb@                                    Offset0, Nsubset, perm, linstat);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PROTECT(blockTable = allocVector(REALSXP, B + 1));@\\
\mbox{}\verb@        /* same as RC_OneTableSums(block, noweights, expand_subset) */@\\
\mbox{}\verb@        RC_OneTableSums(INTEGER(block), XLENGTH(block), B + 1, weights, subset, Offset0,@\\
\mbox{}\verb@                        XLENGTH(subset), REAL(blockTable));@\\
\mbox{}\verb@        PROTECT(block_subset = RC_order_subset_wrt_block(XLENGTH(block), expand_subset,@\\
\mbox{}\verb@                                                         block, blockTable));@\\
\mbox{}\verb@@\\
\mbox{}\verb@        for (R_xlen_t np = 0; np < inresample; np++) {@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape Setup Linear Statistic}\nobreak\ {\footnotesize \NWlink{nuweb38a}{38a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            C_doPermuteBlock(REAL(block_subset), Nsubset, REAL(blockTable),@\\
\mbox{}\verb@                             B + 1, REAL(tmp), REAL(perm));@\\
\mbox{}\verb@            RC_KronSums_Permutation(x, NROW(x), P, REAL(y), Q, block_subset,@\\
\mbox{}\verb@                                    Offset0, Nsubset, perm, linstat);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        UNPROTECT(2);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    PutRNGstate();@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(4);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb30a}{30a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_PermutedLinearStatistic@\nobreak\ \NWlink{nuweb6}{6}\NWlink{nuweb36b}{, 36b}\NWlink{nuweb36c}{c}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@blockTable@\nobreak\ \NWlink{nuweb27c}{27c}, \verb@C_doPermute@\nobreak\ \NWlink{nuweb128b}{128b}, \verb@C_doPermuteBlock@\nobreak\ \NWlink{nuweb129b}{129b}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_KronSums_Permutation@\nobreak\ \NWlink{nuweb103b}{103b}, \verb@RC_OneTableSums@\nobreak\ \NWlink{nuweb112a}{112a}, \verb@RC_order_subset_wrt_block@\nobreak\ \NWlink{nuweb124b}{124b}, \verb@RC_setup_subset@\nobreak\ \NWlink{nuweb127a}{127a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap69}\raggedright\small
\NWtarget{nuweb38a}{} $\langle\,${\itshape Setup Linear Statistic}\nobreak\ {\footnotesize {38a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (np % 256 == 0) R_CheckUserInterrupt();@\\
\mbox{}\verb@linstat = REAL(ans) + PQ * np;@\\
\mbox{}\verb@for (int p = 0; p < PQ; p++)@\\
\mbox{}\verb@    linstat[p] = 0.0;@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb37}{37}\NWlink{nuweb48}{, 48}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This small function takes an object containing permuted linear statistics
and returns the matrix of standardised linear statistics.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap70}\raggedright\small
\NWtarget{nuweb38b}{} $\langle\,${\itshape R_StandardisePermutedLinearStatistic Prototype}\nobreak\ {\footnotesize {38b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_StandardisePermutedLinearStatistic@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    SEXP LECV@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb39a}{, 39a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap71}\raggedright\small
\NWtarget{nuweb38c}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {38c}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_StandardisePermutedLinearStatistic(@\\
\mbox{}\verb@    SEXP LECV@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_StandardisePermutedLinearStatistic");@\\
\mbox{}\verb@    return fun(LECV);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap72}\raggedright\small
\NWtarget{nuweb39a}{} $\langle\,${\itshape R_StandardisePermutedLinearStatistic}\nobreak\ {\footnotesize {39a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_StandardisePermutedLinearStatistic Prototype}\nobreak\ {\footnotesize \NWlink{nuweb38b}{38b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    R_xlen_t nresample = C_get_nresample(LECV);@\\
\mbox{}\verb@    double *ls;@\\
\mbox{}\verb@    if (!nresample) return(R_NilValue);@\\
\mbox{}\verb@    int PQ = C_get_P(LECV) * C_get_Q(LECV);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocMatrix(REALSXP, PQ, nresample));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (R_xlen_t np = 0; np < nresample; np++) {@\\
\mbox{}\verb@        ls = REAL(ans) + PQ * np;@\\
\mbox{}\verb@        /* copy first; standarisation is in place */@\\
\mbox{}\verb@        for (int p = 0; p < PQ; p++)@\\
\mbox{}\verb@            ls[p] = C_get_PermutedLinearStatistic(LECV)[p + PQ * np];@\\
\mbox{}\verb@        if (C_get_varonly(LECV)) {@\\
\mbox{}\verb@            C_standardise(PQ, ls, C_get_Expectation(LECV),@\\
\mbox{}\verb@                          C_get_Variance(LECV), 1, C_get_tol(LECV));@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_standardise(PQ, ls, C_get_Expectation(LECV),@\\
\mbox{}\verb@                          C_get_Covariance(LECV), 0, C_get_tol(LECV));@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb30a}{30a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_get_Covariance@\nobreak\ \NWlink{nuweb144c}{144c}, \verb@C_get_Expectation@\nobreak\ \NWlink{nuweb144a}{144a}, \verb@C_get_nresample@\nobreak\ \NWlink{nuweb147b}{147b}, \verb@C_get_P@\nobreak\ \NWlink{nuweb142c}{142c}, \verb@C_get_PermutedLinearStatistic@\nobreak\ \NWlink{nuweb147c}{147c}, \verb@C_get_Q@\nobreak\ \NWlink{nuweb143a}{143a}, \verb@C_get_tol@\nobreak\ \NWlink{nuweb147d}{147d}, \verb@C_get_Variance@\nobreak\ \NWlink{nuweb144b}{144b}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@C_standardise@\nobreak\ \NWlink{nuweb64a}{64a}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{Two-Dimensional Case (``2d'')}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap73}\raggedright\small
\NWtarget{nuweb39b}{} $\langle\,${\itshape 2d User Interface}\nobreak\ {\footnotesize {39b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_ExpectationCovarianceStatistic_2d}\nobreak\ {\footnotesize \NWlink{nuweb45}{45}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_ExpectationCovarianceStatistic_2d}\nobreak\ {\footnotesize \NWlink{nuweb41a}{41a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_PermutedLinearStatistic_2d}\nobreak\ {\footnotesize \NWlink{nuweb48}{48}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap74}\raggedright\small
\NWtarget{nuweb39c}{} $\langle\,${\itshape 2d User Interface Input}\nobreak\ {\footnotesize {39c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@SEXP ix,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@SEXP iy,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R block Input}\nobreak\ {\footnotesize \NWlink{nuweb26f}{26f}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb40a}{40a}\NWlink{nuweb45}{, 45}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap75}\raggedright\small
\NWtarget{nuweb40a}{} $\langle\,${\itshape R_ExpectationCovarianceStatistic_2d Prototype}\nobreak\ {\footnotesize {40a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_ExpectationCovarianceStatistic_2d@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape 2d User Interface Input}\nobreak\ {\footnotesize \NWlink{nuweb39c}{39c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP varonly,@\\
\mbox{}\verb@    SEXP tol@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb41a}{, 41a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_ExpectationCovarianceStatistic_2d@\nobreak\ \NWlink{nuweb41a}{41a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap76}\raggedright\small
\NWtarget{nuweb40b}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {40b}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_ExpectationCovarianceStatistic_2d(@\\
\mbox{}\verb@    SEXP x, SEXP ix, SEXP y, SEXP iy, SEXP weights, SEXP subset, SEXP block,@\\
\mbox{}\verb@    SEXP varonly, SEXP tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_ExpectationCovarianceStatistic_2d");@\\
\mbox{}\verb@    return fun(x, ix, y, iy, weights, subset, block, varonly, tol);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@R_ExpectationCovarianceStatistic_2d@\nobreak\ \NWlink{nuweb41a}{41a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap77}\raggedright\small
\NWtarget{nuweb41a}{} $\langle\,${\itshape R_ExpectationCovarianceStatistic_2d}\nobreak\ {\footnotesize {41a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_ExpectationCovarianceStatistic_2d Prototype}\nobreak\ {\footnotesize \NWlink{nuweb40a}{40a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    int Xfactor;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    N = XLENGTH(ix);@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@    Xfactor = XLENGTH(x) == 0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup Dimensions 2d}\nobreak\ {\footnotesize \NWlink{nuweb41b}{41b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = RC_init_LECV_2d(P, Q, INTEGER(varonly)[0],@\\
\mbox{}\verb@                                  Lx, Ly, B, Xfactor, REAL(tol)[0]));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (B == 1) {@\\
\mbox{}\verb@        RC_TwoTableSums(INTEGER(ix), N, Lx + 1, INTEGER(iy), Ly + 1,@\\
\mbox{}\verb@                        weights, subset, Offset0, Nsubset,@\\
\mbox{}\verb@                        C_get_Table(ans));@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        RC_ThreeTableSums(INTEGER(ix), N, Lx + 1, INTEGER(iy), Ly + 1,@\\
\mbox{}\verb@                          INTEGER(block), B, weights, subset, Offset0, Nsubset,@\\
\mbox{}\verb@                          C_get_Table(ans));@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    RC_ExpectationCovarianceStatistic_2d(x, ix, y, iy, weights,@\\
\mbox{}\verb@                                         subset, block, ans);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb39b}{39b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_ExpectationCovarianceStatistic_2d@\nobreak\ \NWlink{nuweb8}{8}\NWlink{nuweb40a}{, 40a}\NWlink{nuweb40b}{b}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@C_get_Table@\nobreak\ \NWlink{nuweb146c}{146c}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_init_LECV_2d@\nobreak\ \NWlink{nuweb151}{151}, \verb@RC_ThreeTableSums@\nobreak\ \NWlink{nuweb120b}{120b}, \verb@RC_TwoTableSums@\nobreak\ \NWlink{nuweb116a}{116a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap78}\raggedright\small
\NWtarget{nuweb41b}{} $\langle\,${\itshape Setup Dimensions 2d}\nobreak\ {\footnotesize {41b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int P, Q, B, Lx, Ly;@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (XLENGTH(x) == 0) {@\\
\mbox{}\verb@    P = NLEVELS(ix);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    P = NCOL(x);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@Q = NCOL(y);@\\
\mbox{}\verb@@\\
\mbox{}\verb@B = 1;@\\
\mbox{}\verb@if (XLENGTH(block) > 0)@\\
\mbox{}\verb@    B = NLEVELS(block);@\\
\mbox{}\verb@@\\
\mbox{}\verb@Lx = NLEVELS(ix);@\\
\mbox{}\verb@Ly = NLEVELS(iy);@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb41a}{41a}\NWlink{nuweb48}{, 48}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}, \verb@NLEVELS@\nobreak\ \NWlink{nuweb131b}{131b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap79}\raggedright\small
\NWtarget{nuweb42a}{} $\langle\,${\itshape Linear Statistic 2d}\nobreak\ {\footnotesize {42a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (Xfactor) {@\\
\mbox{}\verb@    for (int j = 1; j < Lyp1; j++) {     /* j = 0 means NA */@\\
\mbox{}\verb@        for (int i = 1; i < Lxp1; i++) { /* i = 0 means NA */@\\
\mbox{}\verb@            for (int q = 0; q < Q; q++)@\\
\mbox{}\verb@                linstat[q * (Lxp1 - 1) + (i - 1)] +=@\\
\mbox{}\verb@                    btab[j * Lxp1 + i] * REAL(y)[q * Lyp1 + j];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@        for (int q = 0; q < Q; q++) {@\\
\mbox{}\verb@            int qPp = q * P + p;@\\
\mbox{}\verb@            int qLy = q * Lyp1;@\\
\mbox{}\verb@            for (int i = 0; i < Lxp1; i++) {@\\
\mbox{}\verb@                int pLxi = p * Lxp1 + i;@\\
\mbox{}\verb@                for (int j = 0; j < Lyp1; j++)@\\
\mbox{}\verb@                    linstat[qPp] += REAL(y)[qLy + j] * REAL(x)[pLxi] * btab[j * Lxp1 + i];@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb45}{45}\NWlink{nuweb49d}{, 49d}.
\item \NWtxtIdentsUsed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap80}\raggedright\small
\NWtarget{nuweb42b}{} $\langle\,${\itshape 2d Total Table}\nobreak\ {\footnotesize {42b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@for (int i = 0; i < Lxp1 * Lyp1; i++)@\\
\mbox{}\verb@    table2d[i] = 0.0;@\\
\mbox{}\verb@for (int b = 0; b < B; b++) {@\\
\mbox{}\verb@    for (int i = 0; i < Lxp1; i++) {@\\
\mbox{}\verb@        for (int j = 0; j < Lyp1; j++)@\\
\mbox{}\verb@            table2d[j * Lxp1 + i] += table[b * Lxp1 * Lyp1 + j * Lxp1 + i];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb45}{45}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap81}\raggedright\small
\NWtarget{nuweb43a}{} $\langle\,${\itshape Col Row Total Sums}\nobreak\ {\footnotesize {43a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/* Remember: first row / column count NAs */@\\
\mbox{}\verb@/* column sums */@\\
\mbox{}\verb@for (int q = 1; q < Lyp1; q++) {@\\
\mbox{}\verb@    csum[q] = 0;@\\
\mbox{}\verb@    for (int p = 1; p < Lxp1; p++)@\\
\mbox{}\verb@        csum[q] += btab[q * Lxp1 + p];@\\
\mbox{}\verb@}@\\
\mbox{}\verb@csum[0] = 0; /* NA */@\\
\mbox{}\verb@/* row sums */@\\
\mbox{}\verb@for (int p = 1; p < Lxp1; p++) {@\\
\mbox{}\verb@    rsum[p] = 0;@\\
\mbox{}\verb@    for (int q = 1; q < Lyp1; q++)@\\
\mbox{}\verb@        rsum[p] += btab[q * Lxp1 + p];@\\
\mbox{}\verb@}@\\
\mbox{}\verb@rsum[0] = 0; /* NA */@\\
\mbox{}\verb@/* total sum */@\\
\mbox{}\verb@sumweights[b] = 0;@\\
\mbox{}\verb@for (int i = 1; i < Lxp1; i++) sumweights[b] += rsum[i];@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb45}{45}\NWlink{nuweb48}{, 48}.
\item \NWtxtIdentsUsed\nobreak\  \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap82}\raggedright\small
\NWtarget{nuweb43b}{} $\langle\,${\itshape 2d Expectation}\nobreak\ {\footnotesize {43b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@RC_ExpectationInfluence(NROW(y), y, Q, Rcsum, subset, Offset0, 0, sumweights[b], ExpInf);@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (LENGTH(x) == 0) {@\\
\mbox{}\verb@    for (int p = 0; p < P; p++)@\\
\mbox{}\verb@        ExpX[p] = rsum[p + 1];@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        RC_ExpectationX(x, NROW(x), P, Rrsum, subset, Offset0, 0, ExpX);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@\\
\mbox{}\verb@C_ExpectationLinearStatistic(P, Q, ExpInf, ExpX, b, C_get_Expectation(ans));@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb45}{45}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_ExpectationLinearStatistic@\nobreak\ \NWlink{nuweb78b}{78b}, \verb@C_get_Expectation@\nobreak\ \NWlink{nuweb144a}{144a}, \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_ExpectationInfluence@\nobreak\ \NWlink{nuweb81c}{81c}, \verb@RC_ExpectationX@\nobreak\ \NWlink{nuweb85b}{85b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap83}\raggedright\small
\NWtarget{nuweb44}{} $\langle\,${\itshape 2d Covariance}\nobreak\ {\footnotesize {44}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/* C_ordered_Xfactor needs both VarInf and CovInf */@\\
\mbox{}\verb@RC_CovarianceInfluence(NROW(y), y, Q, Rcsum, subset, Offset0, 0, ExpInf, sumweights[b],@\\
\mbox{}\verb@                       !DoVarOnly, C_get_CovarianceInfluence(ans));@\\
\mbox{}\verb@for (int q = 0; q < Q; q++)@\\
\mbox{}\verb@    C_get_VarianceInfluence(ans)[q] = C_get_CovarianceInfluence(ans)[S(q, q, Q)];@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (C_get_varonly(ans)) {@\\
\mbox{}\verb@    if (LENGTH(x) == 0) {@\\
\mbox{}\verb@        for (int p = 0; p < P; p++) CovX[p] = ExpX[p];@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        RC_CovarianceX(x, NROW(x), P, Rrsum, subset, Offset0, 0, ExpX, DoVarOnly, CovX);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    C_VarianceLinearStatistic(P, Q, C_get_VarianceInfluence(ans),@\\
\mbox{}\verb@                              ExpX, CovX, sumweights[b], b,@\\
\mbox{}\verb@                              C_get_Variance(ans));@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    if (LENGTH(x) == 0) {@\\
\mbox{}\verb@        for (int p = 0; p < PP12(P); p++) CovX[p] = 0.0;@\\
\mbox{}\verb@        for (int p = 0; p < P; p++) CovX[S(p, p, P)] = ExpX[p];@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        RC_CovarianceX(x, NROW(x), P, Rrsum, subset, Offset0, 0, ExpX, !DoVarOnly, CovX);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    C_CovarianceLinearStatistic(P, Q, C_get_CovarianceInfluence(ans),@\\
\mbox{}\verb@                                ExpX, CovX, sumweights[b], b,@\\
\mbox{}\verb@                                C_get_Covariance(ans));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb45}{45}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_CovarianceLinearStatistic@\nobreak\ \NWlink{nuweb79}{79}, \verb@C_get_Covariance@\nobreak\ \NWlink{nuweb144c}{144c}, \verb@C_get_CovarianceInfluence@\nobreak\ \NWlink{nuweb145c}{145c}, \verb@C_get_Variance@\nobreak\ \NWlink{nuweb144b}{144b}, \verb@C_get_VarianceInfluence@\nobreak\ \NWlink{nuweb145d}{145d}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@C_ordered_Xfactor@\nobreak\ \NWlink{nuweb70}{70}, \verb@C_VarianceLinearStatistic@\nobreak\ \NWlink{nuweb80a}{80a}, \verb@DoVarOnly@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@PP12@\nobreak\ \NWlink{nuweb132a}{132a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_CovarianceInfluence@\nobreak\ \NWlink{nuweb84a}{84a}, \verb@RC_CovarianceX@\nobreak\ \NWlink{nuweb88a}{88a}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap84}\raggedright\small
\NWtarget{nuweb45}{} $\langle\,${\itshape RC_ExpectationCovarianceStatistic_2d}\nobreak\ {\footnotesize {45}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_ExpectationCovarianceStatistic_2d@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape 2d User Interface Input}\nobreak\ {\footnotesize \NWlink{nuweb39c}{39c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape 2d Memory}\nobreak\ {\footnotesize \NWlink{nuweb46}{46}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape 2d Total Table}\nobreak\ {\footnotesize \NWlink{nuweb42b}{42b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    linstat = C_get_LinearStatistic(ans);@\\
\mbox{}\verb@    for (int p = 0; p < mPQB(P, Q, 1); p++)@\\
\mbox{}\verb@        linstat[p] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int b = 0; b < B; b++) {@\\
\mbox{}\verb@        btab = table + Lxp1 * Lyp1 * b;@\\
\mbox{}\verb@@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape Linear Statistic 2d}\nobreak\ {\footnotesize \NWlink{nuweb42a}{42a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape Col Row Total Sums}\nobreak\ {\footnotesize \NWlink{nuweb43a}{43a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape 2d Expectation}\nobreak\ {\footnotesize \NWlink{nuweb43b}{43b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape 2d Covariance}\nobreak\ {\footnotesize \NWlink{nuweb44}{44}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* always return variances */@\\
\mbox{}\verb@    if (!C_get_varonly(ans)) {@\\
\mbox{}\verb@        for (int p = 0; p < mPQB(P, Q, 1); p++)@\\
\mbox{}\verb@            C_get_Variance(ans)[p] = C_get_Covariance(ans)[S(p, p, mPQB(P, Q, 1))];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    R_Free(CovX);@\\
\mbox{}\verb@    R_Free(table2d);@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb39b}{39b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_ExpectationCovarianceStatistic@\nobreak\ \NWlink{nuweb31a}{31a}\NWlink{nuweb32}{, 32}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@C_get_Covariance@\nobreak\ \NWlink{nuweb144c}{144c}, \verb@C_get_LinearStatistic@\nobreak\ \NWlink{nuweb143d}{143d}, \verb@C_get_Variance@\nobreak\ \NWlink{nuweb144b}{144b}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap85}\raggedright\small
\NWtarget{nuweb46}{} $\langle\,${\itshape 2d Memory}\nobreak\ {\footnotesize {46}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP Rcsum, Rrsum;@\\
\mbox{}\verb@int P, Q, Lxp1, Lyp1, B, Xfactor;@\\
\mbox{}\verb@double *ExpInf, *ExpX, *CovX;@\\
\mbox{}\verb@double *table, *table2d, *csum, *rsum, *sumweights, *btab, *linstat;@\\
\mbox{}\verb@@\\
\mbox{}\verb@P = C_get_P(ans);@\\
\mbox{}\verb@Q = C_get_Q(ans);@\\
\mbox{}\verb@@\\
\mbox{}\verb@ExpInf = C_get_ExpectationInfluence(ans);@\\
\mbox{}\verb@ExpX = C_get_ExpectationX(ans);@\\
\mbox{}\verb@table = C_get_Table(ans);@\\
\mbox{}\verb@sumweights = C_get_Sumweights(ans);@\\
\mbox{}\verb@@\\
\mbox{}\verb@Lxp1 = C_get_dimTable(ans)[0];@\\
\mbox{}\verb@Lyp1 = C_get_dimTable(ans)[1];@\\
\mbox{}\verb@B = C_get_B(ans);@\\
\mbox{}\verb@Xfactor = C_get_Xfactor(ans);@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (C_get_varonly(ans)) {@\\
\mbox{}\verb@    CovX = R_Calloc(P, double);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    CovX = R_Calloc(PP12(P), double);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@\\
\mbox{}\verb@table2d = R_Calloc(Lxp1 * Lyp1, double);@\\
\mbox{}\verb@PROTECT(Rcsum = allocVector(REALSXP, Lyp1));@\\
\mbox{}\verb@csum = REAL(Rcsum);@\\
\mbox{}\verb@PROTECT(Rrsum = allocVector(REALSXP, Lxp1));@\\
\mbox{}\verb@rsum = REAL(Rrsum);@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb45}{45}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@C_get_B@\nobreak\ \NWlink{nuweb147a}{147a}, \verb@C_get_dimTable@\nobreak\ \NWlink{nuweb146d}{146d}, \verb@C_get_ExpectationInfluence@\nobreak\ \NWlink{nuweb145b}{145b}, \verb@C_get_ExpectationX@\nobreak\ \NWlink{nuweb145a}{145a}, \verb@C_get_P@\nobreak\ \NWlink{nuweb142c}{142c}, \verb@C_get_Q@\nobreak\ \NWlink{nuweb143a}{143a}, \verb@C_get_Sumweights@\nobreak\ \NWlink{nuweb146b}{146b}, \verb@C_get_Table@\nobreak\ \NWlink{nuweb146c}{146c}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@C_get_Xfactor@\nobreak\ \NWlink{nuweb143c}{143c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@PP12@\nobreak\ \NWlink{nuweb132a}{132a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<permutations-2d>>=
LinStatExpCov(X = iX2d, ix = ix, Y = iY2d, iy = iy,
              weights = weights, subset = subset, nresample = 10)$PermutedLinearStatistic
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap86}\raggedright\small
\NWtarget{nuweb47a}{} $\langle\,${\itshape R_PermutedLinearStatistic_2d Prototype}\nobreak\ {\footnotesize {47a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_PermutedLinearStatistic_2d@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP ix,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP iy,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R block Input}\nobreak\ {\footnotesize \NWlink{nuweb26f}{26f}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP nresample,@\\
\mbox{}\verb@    SEXP itable@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb48}{, 48}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_PermutedLinearStatistic_2d@\nobreak\ \NWlink{nuweb48}{48}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap87}\raggedright\small
\NWtarget{nuweb47b}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {47b}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_PermutedLinearStatistic_2d(@\\
\mbox{}\verb@    SEXP x, SEXP ix, SEXP y, SEXP iy, SEXP block, SEXP nresample,@\\
\mbox{}\verb@    SEXP itable@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_PermutedLinearStatistic_2d");@\\
\mbox{}\verb@    return fun(x, ix, y, iy, block, nresample, itable);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@R_PermutedLinearStatistic_2d@\nobreak\ \NWlink{nuweb48}{48}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap88}\raggedright\small
\NWtarget{nuweb48}{} $\langle\,${\itshape R_PermutedLinearStatistic_2d}\nobreak\ {\footnotesize {48}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_PermutedLinearStatistic_2d Prototype}\nobreak\ {\footnotesize \NWlink{nuweb47a}{47a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans, Ritable;@\\
\mbox{}\verb@    int *csum, *rsum, *sumweights, *jwork, *table, *rtable2, maxn = 0, Lxp1, Lyp1, *btab, PQ, Xfactor;@\\
\mbox{}\verb@    R_xlen_t inresample;@\\
\mbox{}\verb@    double *fact, *linstat;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup Dimensions 2d}\nobreak\ {\footnotesize \NWlink{nuweb41b}{41b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PQ = mPQB(P, Q, 1);@\\
\mbox{}\verb@    Xfactor = XLENGTH(x) == 0;@\\
\mbox{}\verb@    Lxp1 = Lx + 1;@\\
\mbox{}\verb@    Lyp1 = Ly + 1;@\\
\mbox{}\verb@    inresample = (R_xlen_t) REAL(nresample)[0];@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocMatrix(REALSXP, PQ, inresample));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup Working Memory}\nobreak\ {\footnotesize \NWlink{nuweb49b}{49b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Convert Table to Integer}\nobreak\ {\footnotesize \NWlink{nuweb49a}{49a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int b = 0; b < B; b++) {@\\
\mbox{}\verb@        btab = INTEGER(Ritable) + Lxp1 * Lyp1 * b;@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape Col Row Total Sums}\nobreak\ {\footnotesize \NWlink{nuweb43a}{43a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@        if (sumweights[b] > maxn) maxn = sumweights[b];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup Log-Factorials}\nobreak\ {\footnotesize \NWlink{nuweb49c}{49c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    GetRNGstate();@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (R_xlen_t np = 0; np < inresample; np++) {@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape Setup Linear Statistic}\nobreak\ {\footnotesize \NWlink{nuweb38a}{38a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@        for (int p = 0; p < Lxp1 * Lyp1; p++)@\\
\mbox{}\verb@            table[p] = 0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@        for (int b = 0; b < B; b++) {@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape Compute Permuted Linear Statistic 2d}\nobreak\ {\footnotesize \NWlink{nuweb49d}{49d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PutRNGstate();@\\
\mbox{}\verb@@\\
\mbox{}\verb@    R_Free(csum); R_Free(rsum); R_Free(sumweights); R_Free(rtable2);@\\
\mbox{}\verb@    R_Free(jwork); R_Free(fact); R_Free(table);@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb39b}{39b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_PermutedLinearStatistic_2d@\nobreak\ \NWlink{nuweb8}{8}\NWlink{nuweb47a}{, 47a}\NWlink{nuweb47b}{b}\NWlink{nuweb49a}{, 49a}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap89}\raggedright\small
\NWtarget{nuweb49a}{} $\langle\,${\itshape Convert Table to Integer}\nobreak\ {\footnotesize {49a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@PROTECT(Ritable = allocVector(INTSXP, LENGTH(itable)));@\\
\mbox{}\verb@for (int i = 0; i < LENGTH(itable); i++) {@\\
\mbox{}\verb@    if (REAL(itable)[i] > INT_MAX)@\\
\mbox{}\verb@        error("cannot deal with weights larger INT_MAX in R_PermutedLinearStatistic_2d");@\\
\mbox{}\verb@    INTEGER(Ritable)[i] = (int) REAL(itable)[i];@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb48}{48}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_PermutedLinearStatistic_2d@\nobreak\ \NWlink{nuweb48}{48}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap90}\raggedright\small
\NWtarget{nuweb49b}{} $\langle\,${\itshape Setup Working Memory}\nobreak\ {\footnotesize {49b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@csum = R_Calloc(Lyp1 * B, int);@\\
\mbox{}\verb@rsum = R_Calloc(Lxp1 * B, int);@\\
\mbox{}\verb@sumweights = R_Calloc(B, int);@\\
\mbox{}\verb@table = R_Calloc(Lxp1 * Lyp1, int);@\\
\mbox{}\verb@rtable2 = R_Calloc(Lx * Ly , int);@\\
\mbox{}\verb@jwork = R_Calloc(Lyp1, int);@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb48}{48}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap91}\raggedright\small
\NWtarget{nuweb49c}{} $\langle\,${\itshape Setup Log-Factorials}\nobreak\ {\footnotesize {49c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@fact = R_Calloc(maxn + 1, double);@\\
\mbox{}\verb@/* Calculate log-factorials.  fact[i] = lgamma(i+1) */@\\
\mbox{}\verb@fact[0] = fact[1] = 0.;@\\
\mbox{}\verb@for (int j = 2; j <= maxn; j++)@\\
\mbox{}\verb@    fact[j] = fact[j - 1] + log(j);@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb48}{48}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Note: the interface to \code{S_rcont2} changed in \textsf{R}-4.1.0.
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap92}\raggedright\small
\NWtarget{nuweb49d}{} $\langle\,${\itshape Compute Permuted Linear Statistic 2d}\nobreak\ {\footnotesize {49d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@#if defined(R_VERSION) && R_VERSION >= R_Version(4, 1, 0)@\\
\mbox{}\verb@            S_rcont2(Lx, Ly,@\\
\mbox{}\verb@                     rsum + Lxp1 * b + 1,@\\
\mbox{}\verb@                     csum + Lyp1 * b + 1,@\\
\mbox{}\verb@                     sumweights[b], fact, jwork, rtable2);@\\
\mbox{}\verb@#else@\\
\mbox{}\verb@            S_rcont2(&Lx, &Ly,@\\
\mbox{}\verb@                     rsum + Lxp1 * b + 1,@\\
\mbox{}\verb@                     csum + Lyp1 * b + 1,@\\
\mbox{}\verb@                     sumweights + b, fact, jwork, rtable2);@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int j1 = 1; j1 <= Lx; j1++) {@\\
\mbox{}\verb@    for (int j2 = 1; j2 <= Ly; j2++)@\\
\mbox{}\verb@        table[j2 * Lxp1 + j1] = rtable2[(j2 - 1) * Lx + (j1 - 1)];@\\
\mbox{}\verb@}@\\
\mbox{}\verb@btab = table;@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Linear Statistic 2d}\nobreak\ {\footnotesize \NWlink{nuweb42a}{42a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb48}{48}.
\item \NWtxtIdentsUsed\nobreak\  \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\section{Tests}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap93}\raggedright\small
\NWtarget{nuweb50a}{} $\langle\,${\itshape Tests}\nobreak\ {\footnotesize {50a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_QuadraticTest}\nobreak\ {\footnotesize \NWlink{nuweb51}{51}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_MaximumTest}\nobreak\ {\footnotesize \NWlink{nuweb54}{54}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_MaximallySelectedTest}\nobreak\ {\footnotesize \NWlink{nuweb56}{56}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap94}\raggedright\small
\NWtarget{nuweb50b}{} $\langle\,${\itshape R_QuadraticTest Prototype}\nobreak\ {\footnotesize {50b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_QuadraticTest@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP pvalue,@\\
\mbox{}\verb@    SEXP lower,@\\
\mbox{}\verb@    SEXP give_log,@\\
\mbox{}\verb@    SEXP PermutedStatistics@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb51}{, 51}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap95}\raggedright\small
\NWtarget{nuweb50c}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {50c}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_QuadraticTest(@\\
\mbox{}\verb@    SEXP LECV, SEXP pvalue, SEXP lower, SEXP give_log, SEXP PermutedStatistics@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP, SEXP, SEXP, SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP, SEXP, SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_QuadraticTest");@\\
\mbox{}\verb@    return fun(LECV, pvalue, lower, give_log, PermutedStatistics);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap96}\raggedright\small
\NWtarget{nuweb51}{} $\langle\,${\itshape R_QuadraticTest}\nobreak\ {\footnotesize {51}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_QuadraticTest Prototype}\nobreak\ {\footnotesize \NWlink{nuweb50b}{50b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans, stat, pval, names, permstat;@\\
\mbox{}\verb@    double *MPinv, *ls, st, pst, *ex;@\\
\mbox{}\verb@    int rank, P, Q, PQ, greater = 0;@\\
\mbox{}\verb@    R_xlen_t nresample;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup Test Memory}\nobreak\ {\footnotesize \NWlink{nuweb52a}{52a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    MPinv = R_Calloc(PP12(PQ), double); /* was: C_get_MPinv(LECV); */@\\
\mbox{}\verb@    C_MPinv_sym(C_get_Covariance(LECV), PQ, C_get_tol(LECV), MPinv, &rank);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    REAL(stat)[0] = C_quadform(PQ, C_get_LinearStatistic(LECV),@\\
\mbox{}\verb@                               C_get_Expectation(LECV), MPinv);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (!PVALUE) {@\\
\mbox{}\verb@        UNPROTECT(2);@\\
\mbox{}\verb@        R_Free(MPinv);@\\
\mbox{}\verb@        return(ans);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (C_get_nresample(LECV) == 0) {@\\
\mbox{}\verb@        REAL(pval)[0] = C_chisq_pvalue(REAL(stat)[0], rank, LOWER, GIVELOG);@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        nresample = C_get_nresample(LECV);@\\
\mbox{}\verb@        ls = C_get_PermutedLinearStatistic(LECV);@\\
\mbox{}\verb@        st = REAL(stat)[0];@\\
\mbox{}\verb@        ex = C_get_Expectation(LECV);@\\
\mbox{}\verb@        greater = 0;@\\
\mbox{}\verb@        for (R_xlen_t np = 0; np < nresample; np++) {@\\
\mbox{}\verb@            pst = C_quadform(PQ, ls + PQ * np, ex, MPinv);@\\
\mbox{}\verb@            if (GE(pst, st, C_get_tol(LECV)))@\\
\mbox{}\verb@                greater++;@\\
\mbox{}\verb@            if (PSTAT) REAL(permstat)[np] = pst;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        REAL(pval)[0] = C_perm_pvalue(greater, nresample, LOWER, GIVELOG);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    R_Free(MPinv);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb50a}{50a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_chisq_pvalue@\nobreak\ \NWlink{nuweb64c}{64c}, \verb@C_get_Covariance@\nobreak\ \NWlink{nuweb144c}{144c}, \verb@C_get_Expectation@\nobreak\ \NWlink{nuweb144a}{144a}, \verb@C_get_LinearStatistic@\nobreak\ \NWlink{nuweb143d}{143d}, \verb@C_get_nresample@\nobreak\ \NWlink{nuweb147b}{147b}, \verb@C_get_PermutedLinearStatistic@\nobreak\ \NWlink{nuweb147c}{147c}, \verb@C_get_tol@\nobreak\ \NWlink{nuweb147d}{147d}, \verb@C_perm_pvalue@\nobreak\ \NWlink{nuweb65}{65}, \verb@C_quadform@\nobreak\ \NWlink{nuweb62}{62}, \verb@GE@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@PP12@\nobreak\ \NWlink{nuweb132a}{132a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap97}\raggedright\small
\NWtarget{nuweb52a}{} $\langle\,${\itshape Setup Test Memory}\nobreak\ {\footnotesize {52a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@P = C_get_P(LECV);@\\
\mbox{}\verb@Q = C_get_Q(LECV);@\\
\mbox{}\verb@PQ = mPQB(P, Q, 1);@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (C_get_varonly(LECV) && PQ > 1)@\\
\mbox{}\verb@        error("cannot compute adjusted p-value based on variances only");@\\
\mbox{}\verb@/*  if (C_get_nresample(LECV) > 0 && INTEGER(PermutedStatistics)[0]) { */@\\
\mbox{}\verb@    PROTECT(ans = allocVector(VECSXP, 3));@\\
\mbox{}\verb@    PROTECT(names = allocVector(STRSXP, 3));@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, 2, permstat = allocVector(REALSXP, C_get_nresample(LECV)));@\\
\mbox{}\verb@    SET_STRING_ELT(names, 2, mkChar("PermutedStatistics"));@\\
\mbox{}\verb@/*  } else {@\\
\mbox{}\verb@    PROTECT(ans = allocVector(VECSXP, 2));@\\
\mbox{}\verb@    PROTECT(names = allocVector(STRSXP, 2));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@*/@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, 0, stat = allocVector(REALSXP, 1));@\\
\mbox{}\verb@SET_STRING_ELT(names, 0, mkChar("TestStatistic"));@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, 1, pval = allocVector(REALSXP, 1));@\\
\mbox{}\verb@SET_STRING_ELT(names, 1, mkChar("p.value"));@\\
\mbox{}\verb@namesgets(ans, names);@\\
\mbox{}\verb@REAL(pval)[0] = NA_REAL;@\\
\mbox{}\verb@int LOWER = INTEGER(lower)[0];@\\
\mbox{}\verb@int GIVELOG = INTEGER(give_log)[0];@\\
\mbox{}\verb@int PVALUE = INTEGER(pvalue)[0];@\\
\mbox{}\verb@int PSTAT = INTEGER(PermutedStatistics)[0];@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb51}{51}\NWlink{nuweb54}{, 54}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_get_nresample@\nobreak\ \NWlink{nuweb147b}{147b}, \verb@C_get_P@\nobreak\ \NWlink{nuweb142c}{142c}, \verb@C_get_Q@\nobreak\ \NWlink{nuweb143a}{143a}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap98}\raggedright\small
\NWtarget{nuweb52b}{} $\langle\,${\itshape R_MaximumTest Prototype}\nobreak\ {\footnotesize {52b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_MaximumTest@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP alternative,@\\
\mbox{}\verb@    SEXP pvalue,@\\
\mbox{}\verb@    SEXP lower,@\\
\mbox{}\verb@    SEXP give_log,@\\
\mbox{}\verb@    SEXP PermutedStatistics,@\\
\mbox{}\verb@    SEXP maxpts,@\\
\mbox{}\verb@    SEXP releps,@\\
\mbox{}\verb@    SEXP abseps@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb54}{, 54}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap99}\raggedright\small
\NWtarget{nuweb53}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {53}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_MaximumTest(@\\
\mbox{}\verb@    SEXP LECV, SEXP alternative, SEXP pvalue, SEXP lower, SEXP give_log,@\\
\mbox{}\verb@    SEXP PermutedStatistics, SEXP maxpts, SEXP releps, SEXP abseps@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@  static SEXP(*fun)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_MaximumTest");@\\
\mbox{}\verb@    return fun(LECV, alternative, pvalue, lower, give_log, PermutedStatistics, maxpts, releps,@\\
\mbox{}\verb@               abseps);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap100}\raggedright\small
\NWtarget{nuweb54}{} $\langle\,${\itshape R_MaximumTest}\nobreak\ {\footnotesize {54}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_MaximumTest Prototype}\nobreak\ {\footnotesize \NWlink{nuweb52b}{52b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans, stat, pval, names, permstat;@\\
\mbox{}\verb@    double st, pst, *ex, *cv, *ls, tl;@\\
\mbox{}\verb@    int P, Q, PQ, vo, alt, greater;@\\
\mbox{}\verb@    R_xlen_t nresample;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup Test Memory}\nobreak\ {\footnotesize \NWlink{nuweb52a}{52a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (C_get_varonly(LECV)) {@\\
\mbox{}\verb@        cv = C_get_Variance(LECV);@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        cv = C_get_Covariance(LECV);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    REAL(stat)[0] = C_maxtype(PQ, C_get_LinearStatistic(LECV),@\\
\mbox{}\verb@        C_get_Expectation(LECV), cv, C_get_varonly(LECV), C_get_tol(LECV),@\\
\mbox{}\verb@        INTEGER(alternative)[0]);@\\
\mbox{}\verb@    if (!PVALUE) {@\\
\mbox{}\verb@        UNPROTECT(2);@\\
\mbox{}\verb@        return(ans);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (C_get_nresample(LECV) == 0) {@\\
\mbox{}\verb@        if (C_get_varonly(LECV) && PQ > 1) {@\\
\mbox{}\verb@            REAL(pval)[0] = NA_REAL;@\\
\mbox{}\verb@            UNPROTECT(2);@\\
\mbox{}\verb@            return(ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        REAL(pval)[0] = C_maxtype_pvalue(REAL(stat)[0], cv,@\\
\mbox{}\verb@            PQ, INTEGER(alternative)[0], LOWER, GIVELOG, INTEGER(maxpts)[0],@\\
\mbox{}\verb@            REAL(releps)[0], REAL(abseps)[0], C_get_tol(LECV));@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        nresample = C_get_nresample(LECV);@\\
\mbox{}\verb@        ls = C_get_PermutedLinearStatistic(LECV);@\\
\mbox{}\verb@        ex = C_get_Expectation(LECV);@\\
\mbox{}\verb@        vo = C_get_varonly(LECV);@\\
\mbox{}\verb@        alt = INTEGER(alternative)[0];@\\
\mbox{}\verb@        st = REAL(stat)[0];@\\
\mbox{}\verb@        tl = C_get_tol(LECV);@\\
\mbox{}\verb@        greater = 0;@\\
\mbox{}\verb@        for (R_xlen_t np = 0; np < nresample; np++) {@\\
\mbox{}\verb@            pst = C_maxtype(PQ, ls + PQ * np, ex, cv, vo, tl, alt);@\\
\mbox{}\verb@            if (alt == ALTERNATIVE_less) {@\\
\mbox{}\verb@                if (LE(pst, st, tl)) greater++;@\\
\mbox{}\verb@            } else {@\\
\mbox{}\verb@                if (GE(pst, st, tl)) greater++;@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@            if (PSTAT) REAL(permstat)[np] = pst;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        REAL(pval)[0] = C_perm_pvalue(greater, nresample, LOWER, GIVELOG);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb50a}{50a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_get_Covariance@\nobreak\ \NWlink{nuweb144c}{144c}, \verb@C_get_Expectation@\nobreak\ \NWlink{nuweb144a}{144a}, \verb@C_get_LinearStatistic@\nobreak\ \NWlink{nuweb143d}{143d}, \verb@C_get_nresample@\nobreak\ \NWlink{nuweb147b}{147b}, \verb@C_get_PermutedLinearStatistic@\nobreak\ \NWlink{nuweb147c}{147c}, \verb@C_get_tol@\nobreak\ \NWlink{nuweb147d}{147d}, \verb@C_get_Variance@\nobreak\ \NWlink{nuweb144b}{144b}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@C_maxtype@\nobreak\ \NWlink{nuweb63}{63}, \verb@C_maxtype_pvalue@\nobreak\ \NWlink{nuweb67}{67}, \verb@C_perm_pvalue@\nobreak\ \NWlink{nuweb65}{65}, \verb@GE@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@LE@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap101}\raggedright\small
\NWtarget{nuweb55a}{} $\langle\,${\itshape R_MaximallySelectedTest Prototype}\nobreak\ {\footnotesize {55a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_MaximallySelectedTest@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    SEXP LECV,@\\
\mbox{}\verb@    SEXP ordered,@\\
\mbox{}\verb@    SEXP teststat,@\\
\mbox{}\verb@    SEXP minbucket,@\\
\mbox{}\verb@    SEXP lower,@\\
\mbox{}\verb@    SEXP give_log@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb56}{, 56}.
\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap102}\raggedright\small
\NWtarget{nuweb55b}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {55b}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_MaximallySelectedTest(@\\
\mbox{}\verb@    SEXP LECV, SEXP ordered, SEXP teststat, SEXP minbucket, SEXP lower, SEXP give_log@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_MaximallySelectedTest");@\\
\mbox{}\verb@    return fun(LECV, ordered, teststat, minbucket, lower, give_log);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap103}\raggedright\small
\NWtarget{nuweb56}{} $\langle\,${\itshape R_MaximallySelectedTest}\nobreak\ {\footnotesize {56}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_MaximallySelectedTest Prototype}\nobreak\ {\footnotesize \NWlink{nuweb55a}{55a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans, index, stat, pval, names, permstat;@\\
\mbox{}\verb@    int P, mb;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    P = C_get_P(LECV);@\\
\mbox{}\verb@    mb = INTEGER(minbucket)[0];@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(VECSXP, 4));@\\
\mbox{}\verb@    PROTECT(names = allocVector(STRSXP, 4));@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, 0, stat = allocVector(REALSXP, 1));@\\
\mbox{}\verb@    SET_STRING_ELT(names, 0, mkChar("TestStatistic"));@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, 1, pval = allocVector(REALSXP, 1));@\\
\mbox{}\verb@    SET_STRING_ELT(names, 1, mkChar("p.value"));@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, 3, permstat = allocVector(REALSXP, C_get_nresample(LECV)));@\\
\mbox{}\verb@    SET_STRING_ELT(names, 3, mkChar("PermutedStatistics"));@\\
\mbox{}\verb@    REAL(pval)[0] = NA_REAL;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (INTEGER(ordered)[0]) {@\\
\mbox{}\verb@        SET_VECTOR_ELT(ans, 2, index = allocVector(INTSXP, 1));@\\
\mbox{}\verb@        C_ordered_Xfactor(LECV, mb, INTEGER(teststat)[0],@\\
\mbox{}\verb@                          INTEGER(index), REAL(stat), REAL(permstat),@\\
\mbox{}\verb@                          REAL(pval), INTEGER(lower)[0],@\\
\mbox{}\verb@                          INTEGER(give_log)[0]);@\\
\mbox{}\verb@        if (REAL(stat)[0] > 0)@\\
\mbox{}\verb@            INTEGER(index)[0]++; /* R style indexing */@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        SET_VECTOR_ELT(ans, 2, index = allocVector(INTSXP, P));@\\
\mbox{}\verb@        C_unordered_Xfactor(LECV, mb, INTEGER(teststat)[0],@\\
\mbox{}\verb@                            INTEGER(index), REAL(stat), REAL(permstat),@\\
\mbox{}\verb@                            REAL(pval), INTEGER(lower)[0],@\\
\mbox{}\verb@                            INTEGER(give_log)[0]);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    SET_STRING_ELT(names, 2, mkChar("index"));@\\
\mbox{}\verb@    namesgets(ans, names);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb50a}{50a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_get_nresample@\nobreak\ \NWlink{nuweb147b}{147b}, \verb@C_get_P@\nobreak\ \NWlink{nuweb142c}{142c}, \verb@C_ordered_Xfactor@\nobreak\ \NWlink{nuweb70}{70}, \verb@C_unordered_Xfactor@\nobreak\ \NWlink{nuweb74}{74}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\section{Test Statistics}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap104}\raggedright\small
\NWtarget{nuweb57a}{} $\langle\,${\itshape Test Statistics}\nobreak\ {\footnotesize {57a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_maxstand_Covariance}\nobreak\ {\footnotesize \NWlink{nuweb57b}{57b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_maxstand_Variance}\nobreak\ {\footnotesize \NWlink{nuweb58a}{58a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_minstand_Covariance}\nobreak\ {\footnotesize \NWlink{nuweb58b}{58b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_minstand_Variance}\nobreak\ {\footnotesize \NWlink{nuweb59a}{59a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_maxabsstand_Covariance}\nobreak\ {\footnotesize \NWlink{nuweb59b}{59b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_maxabsstand_Variance}\nobreak\ {\footnotesize \NWlink{nuweb60a}{60a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_quadform}\nobreak\ {\footnotesize \NWlink{nuweb62}{62}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_quadform}\nobreak\ {\footnotesize \NWlink{nuweb61b}{61b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_maxtype}\nobreak\ {\footnotesize \NWlink{nuweb63}{63}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_standardise}\nobreak\ {\footnotesize \NWlink{nuweb64a}{64a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_ordered_Xfactor}\nobreak\ {\footnotesize \NWlink{nuweb70}{70}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_unordered_Xfactor}\nobreak\ {\footnotesize \NWlink{nuweb74}{74}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap105}\raggedright\small
\NWtarget{nuweb57b}{} $\langle\,${\itshape C_maxstand_Covariance}\nobreak\ {\footnotesize {57b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_maxstand_Covariance@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const int PQ,@\\
\mbox{}\verb@    const double *linstat,@\\
\mbox{}\verb@    const double *expect,@\\
\mbox{}\verb@    const double *covar_sym,@\\
\mbox{}\verb@    const double tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ans = R_NegInf, tmp = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < PQ; p++) {@\\
\mbox{}\verb@        tmp = 0.0;@\\
\mbox{}\verb@        if (covar_sym[S(p, p, PQ)] > tol)@\\
\mbox{}\verb@            tmp = (linstat[p] - expect[p]) / sqrt(covar_sym[S(p, p, PQ)]);@\\
\mbox{}\verb@        if (tmp > ans) ans = tmp;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_maxstand_Covariance@\nobreak\ \NWlink{nuweb63}{63}.\item \NWtxtIdentsUsed\nobreak\  \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap106}\raggedright\small
\NWtarget{nuweb58a}{} $\langle\,${\itshape C_maxstand_Variance}\nobreak\ {\footnotesize {58a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_maxstand_Variance@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const int PQ,@\\
\mbox{}\verb@    const double *linstat,@\\
\mbox{}\verb@    const double *expect,@\\
\mbox{}\verb@    const double *var,@\\
\mbox{}\verb@    const double tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ans = R_NegInf, tmp = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < PQ; p++) {@\\
\mbox{}\verb@        tmp = 0.0;@\\
\mbox{}\verb@        if (var[p] > tol)@\\
\mbox{}\verb@            tmp = (linstat[p] - expect[p]) / sqrt(var[p]);@\\
\mbox{}\verb@        if (tmp > ans) ans = tmp;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_maxstand_Variance@\nobreak\ \NWlink{nuweb63}{63}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap107}\raggedright\small
\NWtarget{nuweb58b}{} $\langle\,${\itshape C_minstand_Covariance}\nobreak\ {\footnotesize {58b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_minstand_Covariance@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const int PQ,@\\
\mbox{}\verb@    const double *linstat,@\\
\mbox{}\verb@    const double *expect,@\\
\mbox{}\verb@    const double *covar_sym,@\\
\mbox{}\verb@    const double tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ans = R_PosInf, tmp = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < PQ; p++) {@\\
\mbox{}\verb@        tmp = 0.0;@\\
\mbox{}\verb@        if (covar_sym[S(p, p, PQ)] > tol)@\\
\mbox{}\verb@            tmp = (linstat[p] - expect[p]) / sqrt(covar_sym[S(p, p, PQ)]);@\\
\mbox{}\verb@        if (tmp < ans) ans = tmp;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_minstand_Covariance@\nobreak\ \NWlink{nuweb63}{63}.\item \NWtxtIdentsUsed\nobreak\  \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap108}\raggedright\small
\NWtarget{nuweb59a}{} $\langle\,${\itshape C_minstand_Variance}\nobreak\ {\footnotesize {59a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_minstand_Variance@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const int PQ,@\\
\mbox{}\verb@    const double *linstat,@\\
\mbox{}\verb@    const double *expect,@\\
\mbox{}\verb@    const double *var,@\\
\mbox{}\verb@    const double tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ans = R_PosInf, tmp = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < PQ; p++) {@\\
\mbox{}\verb@        tmp = 0.0;@\\
\mbox{}\verb@        if (var[p] > tol)@\\
\mbox{}\verb@            tmp = (linstat[p] - expect[p]) / sqrt(var[p]);@\\
\mbox{}\verb@        if (tmp < ans) ans = tmp;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_minstand_Variance@\nobreak\ \NWlink{nuweb63}{63}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap109}\raggedright\small
\NWtarget{nuweb59b}{} $\langle\,${\itshape C_maxabsstand_Covariance}\nobreak\ {\footnotesize {59b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_maxabsstand_Covariance@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const int PQ,@\\
\mbox{}\verb@    const double *linstat,@\\
\mbox{}\verb@    const double *expect,@\\
\mbox{}\verb@    const double *covar_sym,@\\
\mbox{}\verb@    const double tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ans = R_NegInf, tmp = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < PQ; p++) {@\\
\mbox{}\verb@        tmp = 0.0;@\\
\mbox{}\verb@        if (covar_sym[S(p, p, PQ)] > tol)@\\
\mbox{}\verb@            tmp = fabs((linstat[p] - expect[p]) /@\\
\mbox{}\verb@                  sqrt(covar_sym[S(p, p, PQ)]));@\\
\mbox{}\verb@        if (tmp > ans) ans = tmp;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_maxabsstand_Covariance@\nobreak\ \NWlink{nuweb63}{63}.\item \NWtxtIdentsUsed\nobreak\  \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap110}\raggedright\small
\NWtarget{nuweb60a}{} $\langle\,${\itshape C_maxabsstand_Variance}\nobreak\ {\footnotesize {60a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_maxabsstand_Variance@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const int PQ,@\\
\mbox{}\verb@    const double *linstat,@\\
\mbox{}\verb@    const double *expect,@\\
\mbox{}\verb@    const double *var,@\\
\mbox{}\verb@    const double tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ans = R_NegInf, tmp = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < PQ; p++) {@\\
\mbox{}\verb@        tmp = 0.0;@\\
\mbox{}\verb@        if (var[p] > tol)@\\
\mbox{}\verb@            tmp = fabs((linstat[p] - expect[p]) / sqrt(var[p]));@\\
\mbox{}\verb@        if (tmp > ans) ans = tmp;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_maxabsstand_Variance@\nobreak\ \NWlink{nuweb63}{63}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<quadform>>=
MPinverse <-
function(x, tol = sqrt(.Machine$double.eps))
{
    SVD <- svd(x)
    pos <- SVD$d > max(tol * SVD$d[1L], 0)
    inv <- SVD$v[, pos, drop = FALSE] %*%
             ((1/SVD$d[pos]) * t(SVD$u[, pos, drop = FALSE]))
    list(MPinv = inv, rank = sum(pos))
}

quadform <-
function(linstat, expect, MPinv)
{
    censtat <- linstat - expect
    censtat %*% MPinv %*% censtat
}

linstat <- ls1$LinearStatistic
expect <- ls1$Expectation
MPinv <- MPinverse(vcov(ls1))$MPinv
MPinv_sym <- MPinv[lower.tri(MPinv, diag = TRUE)]
qf1 <- quadform(linstat, expect, MPinv)
qf2 <- .Call(libcoin:::R_quadform, linstat, expect, MPinv_sym)

stopifnot(isequal(qf1, qf2))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap111}\raggedright\small
\NWtarget{nuweb60b}{} $\langle\,${\itshape R_quadform Prototype}\nobreak\ {\footnotesize {60b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_quadform@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    SEXP linstat,@\\
\mbox{}\verb@    SEXP expect,@\\
\mbox{}\verb@    SEXP MPinv_sym@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb61b}{, 61b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_quadform@\nobreak\ \NWlink{nuweb61b}{61b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap112}\raggedright\small
\NWtarget{nuweb61a}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {61a}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_quadform(@\\
\mbox{}\verb@    SEXP linstat, SEXP expect, SEXP MPinv_sym@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP, SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_quadform");@\\
\mbox{}\verb@    return fun(linstat, expect, MPinv_sym);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_quadform@\nobreak\ \NWlink{nuweb61b}{61b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap113}\raggedright\small
\NWtarget{nuweb61b}{} $\langle\,${\itshape R_quadform}\nobreak\ {\footnotesize {61b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_quadform Prototype}\nobreak\ {\footnotesize \NWlink{nuweb60b}{60b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    int n, PQ;@\\
\mbox{}\verb@    double *dlinstat, *dexpect, *dMPinv_sym, *dans;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    n = NCOL(linstat);@\\
\mbox{}\verb@    PQ = NROW(linstat);@\\
\mbox{}\verb@    dlinstat = REAL(linstat);@\\
\mbox{}\verb@    dexpect = REAL(expect);@\\
\mbox{}\verb@    dMPinv_sym = REAL(MPinv_sym);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, n));@\\
\mbox{}\verb@    dans = REAL(ans);@\\
\mbox{}\verb@    for (int i = 0; i < n; i++)@\\
\mbox{}\verb@      dans[i] = C_quadform(PQ, dlinstat + PQ * i, dexpect, dMPinv_sym);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_quadform@\nobreak\ \NWlink{nuweb60b}{60b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_quadform@\nobreak\ \NWlink{nuweb62}{62}, \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}, \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap114}\raggedright\small
\NWtarget{nuweb62}{} $\langle\,${\itshape C_quadform}\nobreak\ {\footnotesize {62}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_quadform@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const int PQ,@\\
\mbox{}\verb@    const double *linstat,@\\
\mbox{}\verb@    const double *expect,@\\
\mbox{}\verb@    const double *MPinv_sym@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ans = 0.0, tmp = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int q = 0; q < PQ; q++) {@\\
\mbox{}\verb@        tmp = 0.0;@\\
\mbox{}\verb@        for (int p = 0; p < PQ; p++)@\\
\mbox{}\verb@            tmp += (linstat[p] - expect[p]) * MPinv_sym[S(p, q, PQ)];@\\
\mbox{}\verb@        ans += tmp * (linstat[q] - expect[q]);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_quadform@\nobreak\ \NWlink{nuweb51}{51}\NWlink{nuweb61b}{, 61b}\NWlink{nuweb73c}{, 73c}.\item \NWtxtIdentsUsed\nobreak\  \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap115}\raggedright\small
\NWtarget{nuweb63}{} $\langle\,${\itshape C_maxtype}\nobreak\ {\footnotesize {63}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_maxtype@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const int PQ,@\\
\mbox{}\verb@    const double *linstat,@\\
\mbox{}\verb@    const double *expect,@\\
\mbox{}\verb@    const double *covar,@\\
\mbox{}\verb@    const int varonly,@\\
\mbox{}\verb@    const double tol,@\\
\mbox{}\verb@    const int alternative@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ret = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (varonly) {@\\
\mbox{}\verb@        if (alternative == ALTERNATIVE_twosided) {@\\
\mbox{}\verb@            ret = C_maxabsstand_Variance(PQ, linstat, expect, covar, tol);@\\
\mbox{}\verb@        } else if (alternative == ALTERNATIVE_less) {@\\
\mbox{}\verb@            ret = C_minstand_Variance(PQ, linstat, expect, covar, tol);@\\
\mbox{}\verb@        } else if (alternative == ALTERNATIVE_greater) {@\\
\mbox{}\verb@            ret = C_maxstand_Variance(PQ, linstat, expect, covar, tol);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (alternative == ALTERNATIVE_twosided) {@\\
\mbox{}\verb@            ret = C_maxabsstand_Covariance(PQ, linstat, expect, covar, tol);@\\
\mbox{}\verb@        } else if (alternative == ALTERNATIVE_less) {@\\
\mbox{}\verb@            ret = C_minstand_Covariance(PQ, linstat, expect, covar, tol);@\\
\mbox{}\verb@        } else if (alternative == ALTERNATIVE_greater) {@\\
\mbox{}\verb@            ret = C_maxstand_Covariance(PQ, linstat, expect, covar, tol);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    return(ret);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_maxtype@\nobreak\ \NWlink{nuweb54}{54}\NWlink{nuweb73c}{, 73c}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_maxabsstand_Covariance@\nobreak\ \NWlink{nuweb59b}{59b}, \verb@C_maxabsstand_Variance@\nobreak\ \NWlink{nuweb60a}{60a}, \verb@C_maxstand_Covariance@\nobreak\ \NWlink{nuweb57b}{57b}, \verb@C_maxstand_Variance@\nobreak\ \NWlink{nuweb58a}{58a}, \verb@C_minstand_Covariance@\nobreak\ \NWlink{nuweb58b}{58b}, \verb@C_minstand_Variance@\nobreak\ \NWlink{nuweb59a}{59a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap116}\raggedright\small
\NWtarget{nuweb64a}{} $\langle\,${\itshape C_standardise}\nobreak\ {\footnotesize {64a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_standardise@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const int PQ,@\\
\mbox{}\verb@    double *linstat,      /* in place standardisation */@\\
\mbox{}\verb@    const double *expect,@\\
\mbox{}\verb@    const double *covar,@\\
\mbox{}\verb@    const int varonly,@\\
\mbox{}\verb@    const double tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double var;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < PQ; p++) {@\\
\mbox{}\verb@        if (varonly) {@\\
\mbox{}\verb@            var = covar[p];@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            var = covar[S(p, p, PQ)];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        if (var > tol) {@\\
\mbox{}\verb@            linstat[p] = (linstat[p] - expect[p]) / sqrt(var);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            linstat[p] = NAN;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_standardise@\nobreak\ \NWlink{nuweb39a}{39a}.\item \NWtxtIdentsUsed\nobreak\  \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap117}\raggedright\small
\NWtarget{nuweb64b}{} $\langle\,${\itshape P-Values}\nobreak\ {\footnotesize {64b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_chisq_pvalue}\nobreak\ {\footnotesize \NWlink{nuweb64c}{64c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_perm_pvalue}\nobreak\ {\footnotesize \NWlink{nuweb65}{65}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_norm_pvalue}\nobreak\ {\footnotesize \NWlink{nuweb66}{66}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_maxtype_pvalue}\nobreak\ {\footnotesize \NWlink{nuweb67}{67}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap118}\raggedright\small
\NWtarget{nuweb64c}{} $\langle\,${\itshape C_chisq_pvalue}\nobreak\ {\footnotesize {64c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/* lower = 1 means p-value, lower = 0 means 1 - p-value */@\\
\mbox{}\verb@double C_chisq_pvalue@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const double stat,@\\
\mbox{}\verb@    const int df,@\\
\mbox{}\verb@    const int lower,@\\
\mbox{}\verb@    const int give_log@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(pchisq(stat, (double) df, lower, give_log));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb64b}{64b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_chisq_pvalue@\nobreak\ \NWlink{nuweb51}{51}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap119}\raggedright\small
\NWtarget{nuweb65}{} $\langle\,${\itshape C_perm_pvalue}\nobreak\ {\footnotesize {65}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_perm_pvalue@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const int greater,@\\
\mbox{}\verb@    const double nresample,@\\
\mbox{}\verb@    const int lower,@\\
\mbox{}\verb@    const int give_log@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ret;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (give_log) {@\\
\mbox{}\verb@         if (lower) {@\\
\mbox{}\verb@             ret = log1p(- (double) greater / nresample);@\\
\mbox{}\verb@         } else {@\\
\mbox{}\verb@             ret = log(greater) - log(nresample);@\\
\mbox{}\verb@         }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (lower) {@\\
\mbox{}\verb@            ret = 1.0 - (double) greater / nresample;@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            ret = (double) greater / nresample;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    return(ret);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb64b}{64b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_perm_pvalue@\nobreak\ \NWlink{nuweb51}{51}\NWlink{nuweb54}{, 54}\NWlink{nuweb73d}{, 73d}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap120}\raggedright\small
\NWtarget{nuweb66}{} $\langle\,${\itshape C_norm_pvalue}\nobreak\ {\footnotesize {66}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_norm_pvalue@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const double stat,@\\
\mbox{}\verb@    const int alternative,@\\
\mbox{}\verb@    const int lower,@\\
\mbox{}\verb@    const int give_log@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ret;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (alternative == ALTERNATIVE_less) {@\\
\mbox{}\verb@        return(pnorm(stat, 0.0, 1.0, 1 - lower, give_log));@\\
\mbox{}\verb@    } else if (alternative == ALTERNATIVE_greater) {@\\
\mbox{}\verb@        return(pnorm(stat, 0.0, 1.0, lower, give_log));@\\
\mbox{}\verb@    } else if (alternative == ALTERNATIVE_twosided) {@\\
\mbox{}\verb@        if (lower) {@\\
\mbox{}\verb@            ret = pnorm(fabs(stat)*-1.0, 0.0, 1.0, 1, 0);@\\
\mbox{}\verb@            if (give_log) {@\\
\mbox{}\verb@                return(log1p(- 2 * ret));@\\
\mbox{}\verb@            } else {@\\
\mbox{}\verb@                return(1 - 2 * ret);@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            ret = pnorm(fabs(stat)*-1.0, 0.0, 1.0, 1, give_log);@\\
\mbox{}\verb@            if (give_log) {@\\
\mbox{}\verb@                return(ret + log(2));@\\
\mbox{}\verb@            } else {@\\
\mbox{}\verb@                return(2 * ret);@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    return(NA_REAL);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb64b}{64b}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap121}\raggedright\small
\NWtarget{nuweb67}{} $\langle\,${\itshape C_maxtype_pvalue}\nobreak\ {\footnotesize {67}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_maxtype_pvalue@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const double stat,@\\
\mbox{}\verb@    const double *Covariance,@\\
\mbox{}\verb@    const int n,@\\
\mbox{}\verb@    const int alternative,@\\
\mbox{}\verb@    const int lower,@\\
\mbox{}\verb@    const int give_log,@\\
\mbox{}\verb@    int maxpts, /* const? */@\\
\mbox{}\verb@    double releps,@\\
\mbox{}\verb@    double abseps,@\\
\mbox{}\verb@    double tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int nu = 0, inform, i, j, sub, nonzero, *infin, *index, rnd = 0;@\\
\mbox{}\verb@    double ans, myerror, *lowerbnd, *upperbnd, *delta, *corr, *sd;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* univariate problem */@\\
\mbox{}\verb@    if (n == 1)@\\
\mbox{}\verb@        return(C_norm_pvalue(stat, alternative, lower, give_log));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup mvtnorm Memory}\nobreak\ {\footnotesize \NWlink{nuweb68}{68}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup mvtnorm Correlation}\nobreak\ {\footnotesize \NWlink{nuweb69a}{69a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* call mvtnorm's mvtdst C function defined in mvtnorm/include/mvtnormAPI.h */@\\
\mbox{}\verb@    mvtnorm_C_mvtdst(&nonzero, &nu, lowerbnd, upperbnd, infin, corr, delta,@\\
\mbox{}\verb@                     &maxpts, &abseps, &releps, &myerror, &ans, &inform, &rnd);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* inform == 0 means: everything is OK */@\\
\mbox{}\verb@    switch (inform) {@\\
\mbox{}\verb@        case 0: break;@\\
\mbox{}\verb@        case 1: warning("cmvnorm: completion with ERROR > EPS"); break;@\\
\mbox{}\verb@        case 2: warning("cmvnorm: N > 1000 or N < 1");@\\
\mbox{}\verb@                ans = 0.0;@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@        case 3: warning("cmvnorm: correlation matrix not positive semi-definite");@\\
\mbox{}\verb@                ans = 0.0;@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@        default: warning("cmvnorm: unknown problem in MVTDST");@\\
\mbox{}\verb@                ans = 0.0;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    R_Free(corr); R_Free(sd); R_Free(lowerbnd); R_Free(upperbnd);@\\
\mbox{}\verb@    R_Free(infin); R_Free(delta); R_Free(index);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* ans = 1 - p-value */@\\
\mbox{}\verb@    if (lower) {@\\
\mbox{}\verb@        if (give_log)@\\
\mbox{}\verb@            return(log(ans));   /* log(1 - p-value) */@\\
\mbox{}\verb@        return(ans);            /* 1 - p-value */@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (give_log)@\\
\mbox{}\verb@            return(log1p(ans)); /* log(p-value) */@\\
\mbox{}\verb@        return(1 - ans);        /* p-value */@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb64b}{64b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_maxtype_pvalue@\nobreak\ \NWlink{nuweb54}{54}.\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap122}\raggedright\small
\NWtarget{nuweb68}{} $\langle\,${\itshape Setup mvtnorm Memory}\nobreak\ {\footnotesize {68}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (n == 2)@\\
\mbox{}\verb@    corr = R_Calloc(1, double);@\\
\mbox{}\verb@else@\\
\mbox{}\verb@    corr = R_Calloc(n + ((n - 2) * (n - 1))/2, double);@\\
\mbox{}\verb@@\\
\mbox{}\verb@sd = R_Calloc(n, double);@\\
\mbox{}\verb@lowerbnd = R_Calloc(n, double);@\\
\mbox{}\verb@upperbnd = R_Calloc(n, double);@\\
\mbox{}\verb@infin = R_Calloc(n, int);@\\
\mbox{}\verb@delta = R_Calloc(n, double);@\\
\mbox{}\verb@index = R_Calloc(n, int);@\\
\mbox{}\verb@@\\
\mbox{}\verb@/* determine elements with non-zero variance */@\\
\mbox{}\verb@@\\
\mbox{}\verb@nonzero = 0;@\\
\mbox{}\verb@for (i = 0; i < n; i++) {@\\
\mbox{}\verb@    if (Covariance[S(i, i, n)] > tol) {@\\
\mbox{}\verb@        index[nonzero] = i;@\\
\mbox{}\verb@        nonzero++;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb67}{67}.
\item \NWtxtIdentsUsed\nobreak\  \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\code{mvtdst} assumes the unique elements of the triangular
covariance matrix to be passed as argument \code{CORREL}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap123}\raggedright\small
\NWtarget{nuweb69a}{} $\langle\,${\itshape Setup mvtnorm Correlation}\nobreak\ {\footnotesize {69a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@for (int nz = 0; nz < nonzero; nz++) {@\\
\mbox{}\verb@    /* handle elements with non-zero variance only */@\\
\mbox{}\verb@    i = index[nz];@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* standard deviations */@\\
\mbox{}\verb@    sd[i] = sqrt(Covariance[S(i, i, n)]);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (alternative == ALTERNATIVE_less) {@\\
\mbox{}\verb@        lowerbnd[nz] = stat;@\\
\mbox{}\verb@        upperbnd[nz] = R_PosInf;@\\
\mbox{}\verb@        infin[nz] = 1;@\\
\mbox{}\verb@    } else if (alternative == ALTERNATIVE_greater) {@\\
\mbox{}\verb@        lowerbnd[nz] = R_NegInf;@\\
\mbox{}\verb@        upperbnd[nz] = stat;@\\
\mbox{}\verb@        infin[nz] = 0;@\\
\mbox{}\verb@    } else if (alternative == ALTERNATIVE_twosided) {@\\
\mbox{}\verb@        lowerbnd[nz] = fabs(stat) * -1.0;@\\
\mbox{}\verb@        upperbnd[nz] = fabs(stat);@\\
\mbox{}\verb@        infin[nz] = 2;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    delta[nz] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* set up vector of correlations, i.e., the upper@\\
\mbox{}\verb@       triangular part of the covariance matrix) */@\\
\mbox{}\verb@    for (int jz = 0; jz < nz; jz++) {@\\
\mbox{}\verb@        j = index[jz];@\\
\mbox{}\verb@        sub = (int) (jz + 1) + (double) ((nz - 1) * nz) / 2 - 1;@\\
\mbox{}\verb@        if (sd[i] == 0.0 || sd[j] == 0.0)@\\
\mbox{}\verb@            corr[sub] = 0.0;@\\
\mbox{}\verb@        else@\\
\mbox{}\verb@            corr[sub] = Covariance[S(i, j, n)] / (sd[i] * sd[j]);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb67}{67}.
\item \NWtxtIdentsUsed\nobreak\  \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap124}\raggedright\small
\NWtarget{nuweb69b}{} $\langle\,${\itshape maxstat Xfactor Variables}\nobreak\ {\footnotesize {69b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP LECV,@\\
\mbox{}\verb@const int minbucket,@\\
\mbox{}\verb@const int teststat,@\\
\mbox{}\verb@int *wmax,@\\
\mbox{}\verb@double *maxstat,@\\
\mbox{}\verb@double *bmaxstat,@\\
\mbox{}\verb@double *pval,@\\
\mbox{}\verb@const int lower,@\\
\mbox{}\verb@const int give_log@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb70}{70}\NWlink{nuweb74}{, 74}.
\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap125}\raggedright\small
\NWtarget{nuweb70}{} $\langle\,${\itshape C_ordered_Xfactor}\nobreak\ {\footnotesize {70}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_ordered_Xfactor@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape maxstat Xfactor Variables}\nobreak\ {\footnotesize \NWlink{nuweb69b}{69b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup maxstat Variables}\nobreak\ {\footnotesize \NWlink{nuweb71}{71}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup maxstat Memory}\nobreak\ {\footnotesize \NWlink{nuweb72}{72}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    wmax[0] = NA_INTEGER;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@        sumleft += ExpX[p];@\\
\mbox{}\verb@        sumright -= ExpX[p];@\\
\mbox{}\verb@@\\
\mbox{}\verb@        for (int q = 0; q < Q; q++) {@\\
\mbox{}\verb@            mlinstat[q] += linstat[q * P + p];@\\
\mbox{}\verb@            for (R_xlen_t np = 0; np < nresample; np++)@\\
\mbox{}\verb@                mblinstat[q + np * Q] += blinstat[q * P + p + np * PQ];@\\
\mbox{}\verb@            mexpect[q] += expect[q * P + p];@\\
\mbox{}\verb@            if (B == 1) {@\\
\mbox{}\verb@                @\hbox{$\langle\,${\itshape Compute maxstat Variance / Covariance Directly}\nobreak\ {\footnotesize \NWlink{nuweb73b}{73b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            } else {@\\
\mbox{}\verb@                @\hbox{$\langle\,${\itshape Compute maxstat Variance / Covariance from Total Covariance}\nobreak\ {\footnotesize \NWlink{nuweb73a}{73a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@@\\
\mbox{}\verb@        if ((sumleft >= minbucket) && (sumright >= minbucket) && (ExpX[p] > 0)) {@\\
\mbox{}\verb@            ls = mlinstat;@\\
\mbox{}\verb@            /* compute MPinv only once */@\\
\mbox{}\verb@            if (teststat != TESTSTAT_maximum)@\\
\mbox{}\verb@                C_MPinv_sym(mcovar, Q, tol, mMPinv, &rank);@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape Compute maxstat Test Statistic}\nobreak\ {\footnotesize \NWlink{nuweb73c}{73c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            if (tmp > maxstat[0]) {@\\
\mbox{}\verb@                wmax[0] = p;@\\
\mbox{}\verb@                maxstat[0] = tmp;@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@@\\
\mbox{}\verb@            for (R_xlen_t np = 0; np < nresample; np++) {@\\
\mbox{}\verb@                ls = mblinstat + np * Q;@\\
\mbox{}\verb@                @\hbox{$\langle\,${\itshape Compute maxstat Test Statistic}\nobreak\ {\footnotesize \NWlink{nuweb73c}{73c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@                if (tmp > bmaxstat[np])@\\
\mbox{}\verb@                    bmaxstat[np] = tmp;@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Compute maxstat Permutation P-Value}\nobreak\ {\footnotesize \NWlink{nuweb73d}{73d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    R_Free(mlinstat); R_Free(mexpect); R_Free(mblinstat);@\\
\mbox{}\verb@    R_Free(mvar); R_Free(mcovar); R_Free(mMPinv);@\\
\mbox{}\verb@    if (nresample == 0) R_Free(blinstat);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_ordered_Xfactor@\nobreak\ \NWlink{nuweb35b}{35b}\NWlink{nuweb44}{, 44}\NWlink{nuweb56}{, 56}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap126}\raggedright\small
\NWtarget{nuweb71}{} $\langle\,${\itshape Setup maxstat Variables}\nobreak\ {\footnotesize {71}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *linstat, *expect, *covar, *varinf, *covinf, *ExpX, *blinstat, tol, *ls;@\\
\mbox{}\verb@int P, Q, B;@\\
\mbox{}\verb@R_xlen_t nresample;@\\
\mbox{}\verb@@\\
\mbox{}\verb@double *mlinstat, *mblinstat, *mexpect, *mvar, *mcovar, *mMPinv,@\\
\mbox{}\verb@       tmp, sumleft, sumright, sumweights;@\\
\mbox{}\verb@int rank, PQ, greater;@\\
\mbox{}\verb@@\\
\mbox{}\verb@Q = C_get_Q(LECV);@\\
\mbox{}\verb@P = C_get_P(LECV);@\\
\mbox{}\verb@PQ = mPQB(P, Q, 1);@\\
\mbox{}\verb@B = C_get_B(LECV);@\\
\mbox{}\verb@if (B > 1) {@\\
\mbox{}\verb@    if (C_get_varonly(LECV))@\\
\mbox{}\verb@        error("need covariance for maximally statistics with blocks");@\\
\mbox{}\verb@    covar = C_get_Covariance(LECV);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    covar = C_get_Variance(LECV); /* make -Wall happy */@\\
\mbox{}\verb@}@\\
\mbox{}\verb@linstat = C_get_LinearStatistic(LECV);@\\
\mbox{}\verb@expect = C_get_Expectation(LECV);@\\
\mbox{}\verb@ExpX = C_get_ExpectationX(LECV);@\\
\mbox{}\verb@/* both need to be there */@\\
\mbox{}\verb@varinf = C_get_VarianceInfluence(LECV);@\\
\mbox{}\verb@covinf = C_get_CovarianceInfluence(LECV);@\\
\mbox{}\verb@nresample = C_get_nresample(LECV);@\\
\mbox{}\verb@if (nresample > 0)@\\
\mbox{}\verb@    blinstat = C_get_PermutedLinearStatistic(LECV);@\\
\mbox{}\verb@tol = C_get_tol(LECV);@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb70}{70}\NWlink{nuweb74}{, 74}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@C_get_B@\nobreak\ \NWlink{nuweb147a}{147a}, \verb@C_get_Covariance@\nobreak\ \NWlink{nuweb144c}{144c}, \verb@C_get_CovarianceInfluence@\nobreak\ \NWlink{nuweb145c}{145c}, \verb@C_get_Expectation@\nobreak\ \NWlink{nuweb144a}{144a}, \verb@C_get_ExpectationX@\nobreak\ \NWlink{nuweb145a}{145a}, \verb@C_get_LinearStatistic@\nobreak\ \NWlink{nuweb143d}{143d}, \verb@C_get_nresample@\nobreak\ \NWlink{nuweb147b}{147b}, \verb@C_get_P@\nobreak\ \NWlink{nuweb142c}{142c}, \verb@C_get_PermutedLinearStatistic@\nobreak\ \NWlink{nuweb147c}{147c}, \verb@C_get_Q@\nobreak\ \NWlink{nuweb143a}{143a}, \verb@C_get_tol@\nobreak\ \NWlink{nuweb147d}{147d}, \verb@C_get_Variance@\nobreak\ \NWlink{nuweb144b}{144b}, \verb@C_get_VarianceInfluence@\nobreak\ \NWlink{nuweb145d}{145d}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap127}\raggedright\small
\NWtarget{nuweb72}{} $\langle\,${\itshape Setup maxstat Memory}\nobreak\ {\footnotesize {72}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@mlinstat = R_Calloc(Q, double);@\\
\mbox{}\verb@mexpect = R_Calloc(Q, double);@\\
\mbox{}\verb@if (teststat == TESTSTAT_maximum) {@\\
\mbox{}\verb@    mvar = R_Calloc(Q, double);@\\
\mbox{}\verb@    /* not needed, but allocate anyway to make -Wmaybe-uninitialized happy */@\\
\mbox{}\verb@    mcovar = R_Calloc(1, double);@\\
\mbox{}\verb@    mMPinv = R_Calloc(1, double);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    mcovar = R_Calloc(Q * (Q + 1) / 2, double);@\\
\mbox{}\verb@    mMPinv = R_Calloc(Q * (Q + 1) / 2, double);@\\
\mbox{}\verb@    /* not needed, but allocate anyway to make -Wmaybe-uninitialized happy */@\\
\mbox{}\verb@    mvar = R_Calloc(1, double);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@if (nresample > 0) {@\\
\mbox{}\verb@    mblinstat = R_Calloc(Q * nresample, double);@\\
\mbox{}\verb@} else { /* not needed, but allocate anyway to make -Wmaybe-uninitialized happy */@\\
\mbox{}\verb@    mblinstat = R_Calloc(1, double);@\\
\mbox{}\verb@    blinstat = R_Calloc(1, double);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@\\
\mbox{}\verb@maxstat[0] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int q = 0; q < Q; q++) {@\\
\mbox{}\verb@    mlinstat[q] = 0.0;@\\
\mbox{}\verb@    mexpect[q] = 0.0;@\\
\mbox{}\verb@    if (teststat == TESTSTAT_maximum)@\\
\mbox{}\verb@        mvar[q] = 0.0;@\\
\mbox{}\verb@    for (R_xlen_t np = 0; np < nresample; np++) {@\\
\mbox{}\verb@        mblinstat[q + np * Q] = 0.0;@\\
\mbox{}\verb@        bmaxstat[np] = 0.0;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@if (teststat == TESTSTAT_quadratic) {@\\
\mbox{}\verb@    for (int q = 0; q < Q * (Q + 1) / 2; q++)@\\
\mbox{}\verb@        mcovar[q] = 0.0;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@\\
\mbox{}\verb@sumleft = 0.0;@\\
\mbox{}\verb@sumright = 0.0;@\\
\mbox{}\verb@for (int p = 0; p < P; p++)@\\
\mbox{}\verb@    sumright += ExpX[p];@\\
\mbox{}\verb@sumweights = sumright;@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb70}{70}\NWlink{nuweb74}{, 74}.
\item \NWtxtIdentsUsed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap128}\raggedright\small
\NWtarget{nuweb73a}{} $\langle\,${\itshape Compute maxstat Variance / Covariance from Total Covariance}\nobreak\ {\footnotesize {73a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (teststat == TESTSTAT_maximum) {@\\
\mbox{}\verb@    for (int pp = 0; pp < p; pp++)@\\
\mbox{}\verb@        mvar[q] += 2 * covar[S(pp + q * P, p + P * q, mPQB(P, Q, 1))];@\\
\mbox{}\verb@    mvar[q] += covar[S(p + q * P, p + P * q, mPQB(P, Q, 1))];@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    for (int qq = 0; qq <= q; qq++) {@\\
\mbox{}\verb@        for (int pp = 0; pp < p; pp++)@\\
\mbox{}\verb@            mcovar[S(q, qq, Q)] += 2 * covar[S(pp + q * P, p + P * qq, mPQB(P, Q, 1))];@\\
\mbox{}\verb@        mcovar[S(q, qq, Q)] += covar[S(p + q * P, p + P * qq, mPQB(P, Q, 1))];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb70}{70}.
\item \NWtxtIdentsUsed\nobreak\  \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap129}\raggedright\small
\NWtarget{nuweb73b}{} $\langle\,${\itshape Compute maxstat Variance / Covariance Directly}\nobreak\ {\footnotesize {73b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/* does not work with blocks! */@\\
\mbox{}\verb@if (teststat == TESTSTAT_maximum) {@\\
\mbox{}\verb@    C_VarianceLinearStatistic(1, Q, varinf, &sumleft, &sumleft,@\\
\mbox{}\verb@                              sumweights, 0, mvar);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    C_CovarianceLinearStatistic(1, Q, covinf, &sumleft, &sumleft,@\\
\mbox{}\verb@                                sumweights, 0, mcovar);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb70}{70}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_CovarianceLinearStatistic@\nobreak\ \NWlink{nuweb79}{79}, \verb@C_VarianceLinearStatistic@\nobreak\ \NWlink{nuweb80a}{80a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap130}\raggedright\small
\NWtarget{nuweb73c}{} $\langle\,${\itshape Compute maxstat Test Statistic}\nobreak\ {\footnotesize {73c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (teststat == TESTSTAT_maximum) {@\\
\mbox{}\verb@    tmp = C_maxtype(Q, ls, mexpect, mvar, 1, tol,@\\
\mbox{}\verb@                    ALTERNATIVE_twosided);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    tmp = C_quadform(Q, ls, mexpect, mMPinv);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb70}{70}\NWlink{nuweb74}{, 74}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_maxtype@\nobreak\ \NWlink{nuweb63}{63}, \verb@C_quadform@\nobreak\ \NWlink{nuweb62}{62}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap131}\raggedright\small
\NWtarget{nuweb73d}{} $\langle\,${\itshape Compute maxstat Permutation P-Value}\nobreak\ {\footnotesize {73d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (nresample > 0) {@\\
\mbox{}\verb@    greater = 0;@\\
\mbox{}\verb@    for (R_xlen_t np = 0; np < nresample; np++) {@\\
\mbox{}\verb@        if (bmaxstat[np] > maxstat[0]) greater++;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    pval[0] = C_perm_pvalue(greater, nresample, lower, give_log);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb70}{70}\NWlink{nuweb74}{, 74}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_perm_pvalue@\nobreak\ \NWlink{nuweb65}{65}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap132}\raggedright\small
\NWtarget{nuweb74}{} $\langle\,${\itshape C_unordered_Xfactor}\nobreak\ {\footnotesize {74}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_unordered_Xfactor@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape maxstat Xfactor Variables}\nobreak\ {\footnotesize \NWlink{nuweb69b}{69b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *mtmp;@\\
\mbox{}\verb@    int qPp, nc, *levels, Pnonzero, *indl, *contrast;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup maxstat Variables}\nobreak\ {\footnotesize \NWlink{nuweb71}{71}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Setup maxstat Memory}\nobreak\ {\footnotesize \NWlink{nuweb72}{72}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    mtmp = R_Calloc(P, double);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < P; p++) wmax[p] = NA_INTEGER;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Count Levels}\nobreak\ {\footnotesize \NWlink{nuweb75a}{75a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int j = 1; j < mi; j++) { /* go though all splits */@\\
\mbox{}\verb@@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape Setup unordered maxstat Contrasts}\nobreak\ {\footnotesize \NWlink{nuweb75b}{75b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape Compute unordered maxstat Linear Statistic and Expectation}\nobreak\ {\footnotesize \NWlink{nuweb76a}{76a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@        if (B == 1) {@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape Compute unordered maxstat Variance / Covariance Directly}\nobreak\ {\footnotesize \NWlink{nuweb77a}{77a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape Compute unordered maxstat Variance / Covariance from Total Covariance}\nobreak\ {\footnotesize \NWlink{nuweb76b}{76b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@@\\
\mbox{}\verb@        if ((sumleft >= minbucket) && (sumright >= minbucket)) {@\\
\mbox{}\verb@            ls = mlinstat;@\\
\mbox{}\verb@            /* compute MPinv only once */@\\
\mbox{}\verb@            if (teststat != TESTSTAT_maximum)@\\
\mbox{}\verb@                C_MPinv_sym(mcovar, Q, tol, mMPinv, &rank);@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape Compute maxstat Test Statistic}\nobreak\ {\footnotesize \NWlink{nuweb73c}{73c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            if (tmp > maxstat[0]) {@\\
\mbox{}\verb@                for (int p = 0; p < Pnonzero; p++)@\\
\mbox{}\verb@                    wmax[levels[p]] = contrast[levels[p]];@\\
\mbox{}\verb@                maxstat[0] = tmp;@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@@\\
\mbox{}\verb@            for (R_xlen_t np = 0; np < nresample; np++) {@\\
\mbox{}\verb@                ls = mblinstat + np * Q;@\\
\mbox{}\verb@                @\hbox{$\langle\,${\itshape Compute maxstat Test Statistic}\nobreak\ {\footnotesize \NWlink{nuweb73c}{73c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@                if (tmp > bmaxstat[np])@\\
\mbox{}\verb@                    bmaxstat[np] = tmp;@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Compute maxstat Permutation P-Value}\nobreak\ {\footnotesize \NWlink{nuweb73d}{73d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    R_Free(mlinstat); R_Free(mexpect); R_Free(levels); R_Free(contrast); R_Free(indl); R_Free(mtmp);@\\
\mbox{}\verb@    R_Free(mblinstat); R_Free(mvar); R_Free(mcovar); R_Free(mMPinv);@\\
\mbox{}\verb@    if (nresample == 0) R_Free(blinstat);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb57a}{57a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_unordered_Xfactor@\nobreak\ \NWlink{nuweb35b}{35b}\NWlink{nuweb56}{, 56}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap133}\raggedright\small
\NWtarget{nuweb75a}{} $\langle\,${\itshape Count Levels}\nobreak\ {\footnotesize {75a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@contrast = R_Calloc(P, int);@\\
\mbox{}\verb@Pnonzero = 0;@\\
\mbox{}\verb@for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@    if (ExpX[p] > 0) Pnonzero++;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@levels = R_Calloc(Pnonzero, int);@\\
\mbox{}\verb@nc = 0;@\\
\mbox{}\verb@for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@    if (ExpX[p] > 0) {@\\
\mbox{}\verb@        levels[nc] = p;@\\
\mbox{}\verb@        nc++;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (Pnonzero >= 31)@\\
\mbox{}\verb@    error("cannot search for unordered splits in >= 31 levels");@\\
\mbox{}\verb@@\\
\mbox{}\verb@int mi = 1;@\\
\mbox{}\verb@for (int l = 1; l < Pnonzero; l++) mi *= 2;@\\
\mbox{}\verb@indl = R_Calloc(Pnonzero, int);@\\
\mbox{}\verb@for (int p = 0; p < Pnonzero; p++) indl[p] = 0;@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb74}{74}.
\item \NWtxtIdentsUsed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap134}\raggedright\small
\NWtarget{nuweb75b}{} $\langle\,${\itshape Setup unordered maxstat Contrasts}\nobreak\ {\footnotesize {75b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/* indl determines if level p is left or right */@\\
\mbox{}\verb@int jj = j;@\\
\mbox{}\verb@for (int l = 1; l < Pnonzero; l++) {@\\
\mbox{}\verb@    indl[l] = (jj%2);@\\
\mbox{}\verb@    jj /= 2;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@\\
\mbox{}\verb@sumleft = 0.0;@\\
\mbox{}\verb@sumright = 0.0;@\\
\mbox{}\verb@for (int p = 0; p < P; p++) contrast[p] = 0;@\\
\mbox{}\verb@for (int p = 0; p < Pnonzero; p++) {@\\
\mbox{}\verb@    sumleft += indl[p] * ExpX[levels[p]];@\\
\mbox{}\verb@    sumright += (1 - indl[p]) * ExpX[levels[p]];@\\
\mbox{}\verb@    contrast[levels[p]] = indl[p];@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb74}{74}.
\item \NWtxtIdentsUsed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap135}\raggedright\small
\NWtarget{nuweb76a}{} $\langle\,${\itshape Compute unordered maxstat Linear Statistic and Expectation}\nobreak\ {\footnotesize {76a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@for (int q = 0; q < Q; q++) {@\\
\mbox{}\verb@    mlinstat[q] = 0.0;@\\
\mbox{}\verb@    mexpect[q] = 0.0;@\\
\mbox{}\verb@    for (R_xlen_t np = 0; np < nresample; np++)@\\
\mbox{}\verb@        mblinstat[q + np * Q] = 0.0;@\\
\mbox{}\verb@    for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@        qPp = q * P + p;@\\
\mbox{}\verb@        mlinstat[q] += contrast[p] * linstat[qPp];@\\
\mbox{}\verb@        mexpect[q] += contrast[p] * expect[qPp];@\\
\mbox{}\verb@        for (R_xlen_t np = 0; np < nresample; np++)@\\
\mbox{}\verb@            mblinstat[q + np * Q] += contrast[p] * blinstat[q * P + p + np * PQ];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb74}{74}.
\item \NWtxtIdentsUsed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap136}\raggedright\small
\NWtarget{nuweb76b}{} $\langle\,${\itshape Compute unordered maxstat Variance / Covariance from Total Covariance}\nobreak\ {\footnotesize {76b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (teststat == TESTSTAT_maximum) {@\\
\mbox{}\verb@    for (int q = 0; q < Q; q++) {@\\
\mbox{}\verb@        mvar[q] = 0.0;@\\
\mbox{}\verb@        for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@            qPp = q * P + p;@\\
\mbox{}\verb@            mtmp[p] = 0.0;@\\
\mbox{}\verb@            for (int pp = 0; pp < P; pp++)@\\
\mbox{}\verb@                mtmp[p] += contrast[pp] * covar[S(pp + q * P, qPp, PQ)];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        for (int p = 0; p < P; p++)@\\
\mbox{}\verb@            mvar[q] += contrast[p] * mtmp[p];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    for (int q = 0; q < Q; q++) {@\\
\mbox{}\verb@        for (int qq = 0; qq <= q; qq++)@\\
\mbox{}\verb@            mcovar[S(q, qq, Q)] = 0.0;@\\
\mbox{}\verb@        for (int qq = 0; qq <= q; qq++) {@\\
\mbox{}\verb@            for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@                mtmp[p] = 0.0;@\\
\mbox{}\verb@                for (int pp = 0; pp < P; pp++)@\\
\mbox{}\verb@                    mtmp[p] += contrast[pp] * covar[S(pp + q * P, p + P * qq,@\\
\mbox{}\verb@                                                      mPQB(P, Q, 1))];@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@            for (int p = 0; p < P; p++)@\\
\mbox{}\verb@                mcovar[S(q, qq, Q)] += contrast[p] * mtmp[p];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb74}{74}.
\item \NWtxtIdentsUsed\nobreak\  \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap137}\raggedright\small
\NWtarget{nuweb77a}{} $\langle\,${\itshape Compute unordered maxstat Variance / Covariance Directly}\nobreak\ {\footnotesize {77a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (teststat == TESTSTAT_maximum) {@\\
\mbox{}\verb@    C_VarianceLinearStatistic(1, Q, varinf, &sumleft, &sumleft,@\\
\mbox{}\verb@                              sumweights, 0, mvar);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    C_CovarianceLinearStatistic(1, Q, covinf, &sumleft, &sumleft,@\\
\mbox{}\verb@                                sumweights, 0, mcovar);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb74}{74}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_CovarianceLinearStatistic@\nobreak\ \NWlink{nuweb79}{79}, \verb@C_VarianceLinearStatistic@\nobreak\ \NWlink{nuweb80a}{80a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\section{Linear Statistics}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap138}\raggedright\small
\NWtarget{nuweb77b}{} $\langle\,${\itshape LinearStatistics}\nobreak\ {\footnotesize {77b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_LinearStatistic}\nobreak\ {\footnotesize \NWlink{nuweb77d}{77d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap139}\raggedright\small
\NWtarget{nuweb77c}{} $\langle\,${\itshape RC_LinearStatistic Prototype}\nobreak\ {\footnotesize {77c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_LinearStatistic@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real y Input}\nobreak\ {\footnotesize \NWlink{nuweb24f}{24f}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb77d}{77d}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_LinearStatistic@\nobreak\ \NWlink{nuweb77d}{77d}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap140}\raggedright\small
\NWtarget{nuweb77d}{} $\langle\,${\itshape RC_LinearStatistic}\nobreak\ {\footnotesize {77d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_LinearStatistic Prototype}\nobreak\ {\footnotesize \NWlink{nuweb77c}{77c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    double center;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    RC_KronSums(x, N, P, y, Q, !DoSymmetric, &center, &center, !DoCenter, weights,@\\
\mbox{}\verb@                subset, offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb77b}{77b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_LinearStatistic@\nobreak\ \NWlink{nuweb33b}{33b}\NWlink{nuweb77c}{, 77c}.\item \NWtxtIdentsUsed\nobreak\  \verb@DoCenter@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@DoSymmetric@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_KronSums@\nobreak\ \NWlink{nuweb95b}{95b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\section{Expectation and Covariance}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap141}\raggedright\small
\NWtarget{nuweb78a}{} $\langle\,${\itshape ExpectationCovariances}\nobreak\ {\footnotesize {78a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_ExpectationInfluence}\nobreak\ {\footnotesize \NWlink{nuweb81c}{81c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_ExpectationInfluence}\nobreak\ {\footnotesize \NWlink{nuweb81a}{81a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_CovarianceInfluence}\nobreak\ {\footnotesize \NWlink{nuweb84a}{84a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_CovarianceInfluence}\nobreak\ {\footnotesize \NWlink{nuweb83a}{83a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_ExpectationX}\nobreak\ {\footnotesize \NWlink{nuweb85b}{85b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_ExpectationX}\nobreak\ {\footnotesize \NWlink{nuweb84c}{84c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_CovarianceX}\nobreak\ {\footnotesize \NWlink{nuweb88a}{88a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_CovarianceX}\nobreak\ {\footnotesize \NWlink{nuweb87a}{87a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_ExpectationLinearStatistic}\nobreak\ {\footnotesize \NWlink{nuweb78b}{78b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_CovarianceLinearStatistic}\nobreak\ {\footnotesize \NWlink{nuweb79}{79}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_VarianceLinearStatistic}\nobreak\ {\footnotesize \NWlink{nuweb80a}{80a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{Linear Statistic}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap142}\raggedright\small
\NWtarget{nuweb78b}{} $\langle\,${\itshape C_ExpectationLinearStatistic}\nobreak\ {\footnotesize {78b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_ExpectationLinearStatistic@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    double *ExpInf,@\\
\mbox{}\verb@    double *ExpX,@\\
\mbox{}\verb@    const int add,@\\
\mbox{}\verb@    double *PQ_ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    if (!add)@\\
\mbox{}\verb@        for (int p = 0; p < mPQB(P, Q, 1); p++) PQ_ans[p] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@        for (int q = 0; q < Q; q++)@\\
\mbox{}\verb@            PQ_ans[q * P + p] += ExpX[p] * ExpInf[q];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_ExpectationLinearStatistic@\nobreak\ \NWlink{nuweb35a}{35a}\NWlink{nuweb43b}{, 43b}.\item \NWtxtIdentsUsed\nobreak\  \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap143}\raggedright\small
\NWtarget{nuweb79}{} $\langle\,${\itshape C_CovarianceLinearStatistic}\nobreak\ {\footnotesize {79}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_CovarianceLinearStatistic@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    double *CovInf,@\\
\mbox{}\verb@    double *ExpX,@\\
\mbox{}\verb@    double *CovX,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C sumweights Input}\nobreak\ {\footnotesize \NWlink{nuweb25e}{25e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    const int add,@\\
\mbox{}\verb@    double *PQPQ_sym_ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double f1 = sumweights / (sumweights - 1);@\\
\mbox{}\verb@    double f2 = 1.0 / (sumweights - 1);@\\
\mbox{}\verb@    double tmp, *PP_sym_tmp;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (mPQB(P, Q, 1) == 1) {@\\
\mbox{}\verb@        tmp = f1 * CovInf[0] * CovX[0];@\\
\mbox{}\verb@        tmp -= f2 * CovInf[0] * ExpX[0] * ExpX[0];@\\
\mbox{}\verb@        if (add) {@\\
\mbox{}\verb@            PQPQ_sym_ans[0] += tmp;@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            PQPQ_sym_ans[0] = tmp;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PP_sym_tmp = R_Calloc(PP12(P), double);@\\
\mbox{}\verb@        C_KronSums_sym_(ExpX, 1, P,@\\
\mbox{}\verb@                        PP_sym_tmp);@\\
\mbox{}\verb@        for (int p = 0; p < PP12(P); p++)@\\
\mbox{}\verb@            PP_sym_tmp[p] = f1 * CovX[p] - f2 * PP_sym_tmp[p];@\\
\mbox{}\verb@        C_kronecker_sym(CovInf, Q, PP_sym_tmp, P, 1 - (add >= 1),@\\
\mbox{}\verb@                        PQPQ_sym_ans);@\\
\mbox{}\verb@        R_Free(PP_sym_tmp);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_CovarianceLinearStatistic@\nobreak\ \NWlink{nuweb35d}{35d}\NWlink{nuweb44}{, 44}\NWlink{nuweb73b}{, 73b}\NWlink{nuweb77a}{, 77a}\NWlink{nuweb80a}{, 80a}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_kronecker_sym@\nobreak\ \NWlink{nuweb135}{135}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@PP12@\nobreak\ \NWlink{nuweb132a}{132a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap144}\raggedright\small
\NWtarget{nuweb80a}{} $\langle\,${\itshape C_VarianceLinearStatistic}\nobreak\ {\footnotesize {80a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_VarianceLinearStatistic@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    double *VarInf,@\\
\mbox{}\verb@    double *ExpX,@\\
\mbox{}\verb@    double *VarX,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C sumweights Input}\nobreak\ {\footnotesize \NWlink{nuweb25e}{25e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    const int add,@\\
\mbox{}\verb@    double *PQ_ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    if (mPQB(P, Q, 1) == 1) {@\\
\mbox{}\verb@        C_CovarianceLinearStatistic(P, Q, VarInf, ExpX, VarX,@\\
\mbox{}\verb@                                    sumweights, (add >= 1),@\\
\mbox{}\verb@                                    PQ_ans);@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        double *P_tmp;@\\
\mbox{}\verb@        P_tmp = R_Calloc(P, double);@\\
\mbox{}\verb@        double f1 = sumweights / (sumweights - 1);@\\
\mbox{}\verb@        double f2 = 1.0 / (sumweights - 1);@\\
\mbox{}\verb@        for (int p = 0; p < P; p++)@\\
\mbox{}\verb@            P_tmp[p] = f1 * VarX[p] - f2 * ExpX[p] * ExpX[p];@\\
\mbox{}\verb@        C_kronecker(VarInf, 1, Q, P_tmp, 1, P, 1 - (add >= 1),@\\
\mbox{}\verb@                    PQ_ans);@\\
\mbox{}\verb@        R_Free(P_tmp);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_VarianceLinearStatistic@\nobreak\ \NWlink{nuweb35c}{35c}\NWlink{nuweb44}{, 44}\NWlink{nuweb73b}{, 73b}\NWlink{nuweb77a}{, 77a}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_CovarianceLinearStatistic@\nobreak\ \NWlink{nuweb79}{79}, \verb@C_kronecker@\nobreak\ \NWlink{nuweb134}{134}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{Influence}

<<ExpectationInfluence>>=
sumweights <- sum(weights[subset])
expecty <- colSums(y[subset, ] * weights[subset]) / sumweights

a0 <- expecty
a1 <- .Call(libcoin:::R_ExpectationInfluence, y, weights, subset)
a2 <- .Call(libcoin:::R_ExpectationInfluence, y, as.double(weights), as.double(subset))
a3 <- .Call(libcoin:::R_ExpectationInfluence, y, weights, as.double(subset))
a4 <- .Call(libcoin:::R_ExpectationInfluence, y, as.double(weights), subset)
a5 <- LinStatExpCov(x, y, weights = weights, subset = subset)$ExpectationInfluence

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4) &&
          isequal(a0, a5))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap145}\raggedright\small
\NWtarget{nuweb80b}{} $\langle\,${\itshape R_ExpectationInfluence Prototype}\nobreak\ {\footnotesize {80b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_ExpectationInfluence@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb81a}{, 81a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_ExpectationInfluence@\nobreak\ \NWlink{nuweb81a}{81a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap146}\raggedright\small
\NWtarget{nuweb81a}{} $\langle\,${\itshape R_ExpectationInfluence}\nobreak\ {\footnotesize {81a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_ExpectationInfluence Prototype}\nobreak\ {\footnotesize \NWlink{nuweb80b}{80b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    double sumweights;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    Q = NCOL(y);@\\
\mbox{}\verb@    N = XLENGTH(y) / Q;@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    sumweights = RC_Sums(N, weights, subset, Offset0, Nsubset);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, Q));@\\
\mbox{}\verb@    RC_ExpectationInfluence(N, y, Q, weights, subset, Offset0, Nsubset, sumweights, REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_ExpectationInfluence@\nobreak\ \NWlink{nuweb80b}{80b}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_ExpectationInfluence@\nobreak\ \NWlink{nuweb81c}{81c}, \verb@RC_Sums@\nobreak\ \NWlink{nuweb91a}{91a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap147}\raggedright\small
\NWtarget{nuweb81b}{} $\langle\,${\itshape RC_ExpectationInfluence Prototype}\nobreak\ {\footnotesize {81b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_ExpectationInfluence@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C sumweights Input}\nobreak\ {\footnotesize \NWlink{nuweb25e}{25e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb108a}{108a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb81c}{81c}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_ExpectationInfluence@\nobreak\ \NWlink{nuweb81c}{81c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap148}\raggedright\small
\NWtarget{nuweb81c}{} $\langle\,${\itshape RC_ExpectationInfluence}\nobreak\ {\footnotesize {81c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_ExpectationInfluence Prototype}\nobreak\ {\footnotesize \NWlink{nuweb81b}{81b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    double center;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    RC_colSums(REAL(y), N, Q, Power1, &center, !DoCenter, weights,@\\
\mbox{}\verb@               subset, offset, Nsubset, P_ans);@\\
\mbox{}\verb@    for (int q = 0; q < Q; q++)@\\
\mbox{}\verb@        P_ans[q] = P_ans[q] / sumweights;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_ExpectationInfluence@\nobreak\ \NWlink{nuweb35a}{35a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81b}{b}.\item \NWtxtIdentsUsed\nobreak\  \verb@DoCenter@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@Power1@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_colSums@\nobreak\ \NWlink{nuweb107b}{107b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<CovarianceInfluence>>=
sumweights <- sum(weights[subset])
yc <- t(t(y) - expecty)
r1y <- rep(1:ncol(y), ncol(y))
r2y <- rep(1:ncol(y), each = ncol(y))
a0 <- colSums(yc[subset, r1y] * yc[subset, r2y] * weights[subset]) / sumweights
a0 <- matrix(a0, ncol = ncol(y))
vary <- diag(a0)

a0 <- a0[lower.tri(a0, diag = TRUE)]
a1 <- .Call(libcoin:::R_CovarianceInfluence, y, weights, subset, 0L)
a2 <- .Call(libcoin:::R_CovarianceInfluence, y, as.double(weights), as.double(subset), 0L)
a3 <- .Call(libcoin:::R_CovarianceInfluence, y, weights, as.double(subset), 0L)
a4 <- .Call(libcoin:::R_CovarianceInfluence, y, as.double(weights), subset, 0L)
a5 <- LinStatExpCov(x, y, weights = weights, subset = subset)$CovarianceInfluence

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4) &&
          isequal(a0, a5))

a0 <- vary
a1 <- .Call(libcoin:::R_CovarianceInfluence, y, weights, subset, 1L)
a2 <- .Call(libcoin:::R_CovarianceInfluence, y, as.double(weights), as.double(subset), 1L)
a3 <- .Call(libcoin:::R_CovarianceInfluence, y, weights, as.double(subset), 1L)
a4 <- .Call(libcoin:::R_CovarianceInfluence, y, as.double(weights), subset, 1L)
a5 <- LinStatExpCov(x, y, weights = weights, subset = subset, varonly = TRUE)$VarianceInfluence

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4) &&
          isequal(a0, a5))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap149}\raggedright\small
\NWtarget{nuweb82}{} $\langle\,${\itshape R_CovarianceInfluence Prototype}\nobreak\ {\footnotesize {82}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_CovarianceInfluence@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP varonly@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb83a}{, 83a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_CovarianceInfluence@\nobreak\ \NWlink{nuweb83a}{83a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap150}\raggedright\small
\NWtarget{nuweb83a}{} $\langle\,${\itshape R_CovarianceInfluence}\nobreak\ {\footnotesize {83a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_CovarianceInfluence Prototype}\nobreak\ {\footnotesize \NWlink{nuweb82}{82}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    SEXP ExpInf;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    double sumweights;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    Q = NCOL(y);@\\
\mbox{}\verb@    N = XLENGTH(y) / Q;@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ExpInf = R_ExpectationInfluence(y, weights, subset));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    sumweights = RC_Sums(N, weights, subset, Offset0, Nsubset);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (INTEGER(varonly)[0]) {@\\
\mbox{}\verb@        PROTECT(ans = allocVector(REALSXP, Q));@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PROTECT(ans = allocVector(REALSXP, Q * (Q + 1) / 2));@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    RC_CovarianceInfluence(N, y, Q, weights, subset, Offset0, Nsubset, REAL(ExpInf), sumweights,@\\
\mbox{}\verb@                           INTEGER(varonly)[0], REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_CovarianceInfluence@\nobreak\ \NWlink{nuweb82}{82}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_CovarianceInfluence@\nobreak\ \NWlink{nuweb84a}{84a}, \verb@RC_Sums@\nobreak\ \NWlink{nuweb91a}{91a}, \verb@R_ExpectationInfluence@\nobreak\ \NWlink{nuweb81a}{81a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap151}\raggedright\small
\NWtarget{nuweb83b}{} $\langle\,${\itshape RC_CovarianceInfluence Prototype}\nobreak\ {\footnotesize {83b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_CovarianceInfluence@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    double *ExpInf,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C sumweights Input}\nobreak\ {\footnotesize \NWlink{nuweb25e}{25e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    int VARONLY,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb84a}{84a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_CovarianceInfluence@\nobreak\ \NWlink{nuweb84a}{84a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap152}\raggedright\small
\NWtarget{nuweb84a}{} $\langle\,${\itshape RC_CovarianceInfluence}\nobreak\ {\footnotesize {84a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_CovarianceInfluence Prototype}\nobreak\ {\footnotesize \NWlink{nuweb83b}{83b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (VARONLY) {@\\
\mbox{}\verb@        RC_colSums(REAL(y), N, Q, Power2, ExpInf, DoCenter, weights,@\\
\mbox{}\verb@                   subset, offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@        for (int q = 0; q < Q; q++)@\\
\mbox{}\verb@            PQ_ans[q] = PQ_ans[q] / sumweights;@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        RC_KronSums(y, N, Q, REAL(y), Q, DoSymmetric, ExpInf, ExpInf, DoCenter, weights,@\\
\mbox{}\verb@                    subset, offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@        for (int q = 0; q < Q * (Q + 1) / 2; q++)@\\
\mbox{}\verb@            PQ_ans[q] = PQ_ans[q] / sumweights;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_CovarianceInfluence@\nobreak\ \NWlink{nuweb35b}{35b}\NWlink{nuweb44}{, 44}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb83b}{b}.\item \NWtxtIdentsUsed\nobreak\  \verb@DoCenter@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@DoSymmetric@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@Power2@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_colSums@\nobreak\ \NWlink{nuweb107b}{107b}, \verb@RC_KronSums@\nobreak\ \NWlink{nuweb95b}{95b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{X}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap153}\raggedright\small
\NWtarget{nuweb84b}{} $\langle\,${\itshape R_ExpectationX Prototype}\nobreak\ {\footnotesize {84b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_ExpectationX@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP P,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb84c}{, 84c}.
\item \NWtxtIdentsUsed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@R_ExpectationX@\nobreak\ \NWlink{nuweb84c}{84c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap154}\raggedright\small
\NWtarget{nuweb84c}{} $\langle\,${\itshape R_ExpectationX}\nobreak\ {\footnotesize {84c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_ExpectationX Prototype}\nobreak\ {\footnotesize \NWlink{nuweb84b}{84b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    N = XLENGTH(x) / INTEGER(P)[0];@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, INTEGER(P)[0]));@\\
\mbox{}\verb@    RC_ExpectationX(x, N, INTEGER(P)[0], weights, subset,@\\
\mbox{}\verb@                    Offset0, Nsubset, REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_ExpectationX@\nobreak\ \NWlink{nuweb84b}{84b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@RC_ExpectationX@\nobreak\ \NWlink{nuweb85b}{85b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap155}\raggedright\small
\NWtarget{nuweb85a}{} $\langle\,${\itshape RC_ExpectationX Prototype}\nobreak\ {\footnotesize {85a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_ExpectationX@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb112c}{112c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb85b}{85b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_ExpectationX@\nobreak\ \NWlink{nuweb85b}{85b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap156}\raggedright\small
\NWtarget{nuweb85b}{} $\langle\,${\itshape RC_ExpectationX}\nobreak\ {\footnotesize {85b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_ExpectationX Prototype}\nobreak\ {\footnotesize \NWlink{nuweb85a}{85a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    double center;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (TYPEOF(x) == INTSXP) {@\\
\mbox{}\verb@        double* Pp1tmp = R_Calloc(P + 1, double);@\\
\mbox{}\verb@        RC_OneTableSums(INTEGER(x), N, P + 1, weights, subset, offset, Nsubset, Pp1tmp);@\\
\mbox{}\verb@        for (int p = 0; p < P; p++) P_ans[p] = Pp1tmp[p + 1];@\\
\mbox{}\verb@        R_Free(Pp1tmp);@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        RC_colSums(REAL(x), N, P, Power1, &center, !DoCenter, weights, subset, offset, Nsubset, P_ans);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_ExpectationX@\nobreak\ \NWlink{nuweb35a}{35a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb85a}{, 85a}.\item \NWtxtIdentsUsed\nobreak\  \verb@DoCenter@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Power1@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@RC_colSums@\nobreak\ \NWlink{nuweb107b}{107b}, \verb@RC_OneTableSums@\nobreak\ \NWlink{nuweb112a}{112a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<ExpectationCovarianceX>>=
a0 <- colSums(x[subset, ] * weights[subset])
a1 <- .Call(libcoin:::R_ExpectationX, x, P, weights, subset);
a2 <- .Call(libcoin:::R_ExpectationX, x, P, as.double(weights), as.double(subset))
a3 <- .Call(libcoin:::R_ExpectationX, x, P, weights, as.double(subset))
a4 <- .Call(libcoin:::R_ExpectationX, x, P, as.double(weights), subset)

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4) &&
          isequal(a0, LECVxyws$ExpectationX))

a0 <- colSums(x[subset, ]^2 * weights[subset])
a1 <- .Call(libcoin:::R_CovarianceX, x, P, weights, subset, 1L)
a2 <- .Call(libcoin:::R_CovarianceX, x, P, as.double(weights), as.double(subset), 1L)
a3 <- .Call(libcoin:::R_CovarianceX, x, P, weights, as.double(subset), 1L)
a4 <- .Call(libcoin:::R_CovarianceX, x, P, as.double(weights), subset, 1L)

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))

a0 <- as.vector(colSums(Xfactor[subset, ] * weights[subset]))
a1 <- .Call(libcoin:::R_ExpectationX, ix, Lx, weights, subset)
a2 <- .Call(libcoin:::R_ExpectationX, ix, Lx, as.double(weights), as.double(subset))
a3 <- .Call(libcoin:::R_ExpectationX, ix, Lx, weights, as.double(subset))
a4 <- .Call(libcoin:::R_ExpectationX, ix, Lx, as.double(weights), subset)

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))

a1 <- .Call(libcoin:::R_CovarianceX, ix, Lx, weights, subset, 1L)
a2 <- .Call(libcoin:::R_CovarianceX, ix, Lx, as.double(weights), as.double(subset), 1L)
a3 <- .Call(libcoin:::R_CovarianceX, ix, Lx, weights, as.double(subset), 1L)
a4 <- .Call(libcoin:::R_CovarianceX, ix, Lx, as.double(weights), subset, 1L)

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))

r1x <- rep(1:ncol(Xfactor), ncol(Xfactor))
r2x <- rep(1:ncol(Xfactor), each = ncol(Xfactor))
a0 <- colSums(Xfactor[subset, r1x] * Xfactor[subset, r2x] * weights[subset])
a0 <- matrix(a0, ncol = ncol(Xfactor))
vary <- diag(a0)

a0 <- a0[lower.tri(a0, diag = TRUE)]
a1 <- .Call(libcoin:::R_CovarianceX, ix, Lx, weights, subset, 0L)
a2 <- .Call(libcoin:::R_CovarianceX, ix, Lx, as.double(weights), as.double(subset), 0L)
a3 <- .Call(libcoin:::R_CovarianceX, ix, Lx, weights, as.double(subset), 0L)
a4 <- .Call(libcoin:::R_CovarianceX, ix, Lx, as.double(weights), subset, 0L)

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap157}\raggedright\small
\NWtarget{nuweb86}{} $\langle\,${\itshape R_CovarianceX Prototype}\nobreak\ {\footnotesize {86}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_CovarianceX@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP P,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP varonly@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb87a}{, 87a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@R_CovarianceX@\nobreak\ \NWlink{nuweb87a}{87a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap158}\raggedright\small
\NWtarget{nuweb87a}{} $\langle\,${\itshape R_CovarianceX}\nobreak\ {\footnotesize {87a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_CovarianceX Prototype}\nobreak\ {\footnotesize \NWlink{nuweb86}{86}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    SEXP ExpX;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    N = XLENGTH(x) / INTEGER(P)[0];@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ExpX = R_ExpectationX(x, P, weights, subset));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (INTEGER(varonly)[0]) {@\\
\mbox{}\verb@        PROTECT(ans = allocVector(REALSXP, INTEGER(P)[0]));@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PROTECT(ans = allocVector(REALSXP, INTEGER(P)[0] * (INTEGER(P)[0] + 1) / 2));@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    RC_CovarianceX(x, N, INTEGER(P)[0], weights, subset, Offset0, Nsubset, REAL(ExpX),@\\
\mbox{}\verb@                   INTEGER(varonly)[0], REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_CovarianceX@\nobreak\ \NWlink{nuweb86}{86}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@RC_CovarianceX@\nobreak\ \NWlink{nuweb88a}{88a}, \verb@R_ExpectationX@\nobreak\ \NWlink{nuweb84c}{84c}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap159}\raggedright\small
\NWtarget{nuweb87b}{} $\langle\,${\itshape RC_CovarianceX Prototype}\nobreak\ {\footnotesize {87b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_CovarianceX@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    double *ExpX,@\\
\mbox{}\verb@    int VARONLY,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb88a}{88a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_CovarianceX@\nobreak\ \NWlink{nuweb88a}{88a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap160}\raggedright\small
\NWtarget{nuweb88a}{} $\langle\,${\itshape RC_CovarianceX}\nobreak\ {\footnotesize {88a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_CovarianceX Prototype}\nobreak\ {\footnotesize \NWlink{nuweb87b}{87b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    double center;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (TYPEOF(x) == INTSXP) {@\\
\mbox{}\verb@        if (VARONLY) {@\\
\mbox{}\verb@            for (int p = 0; p < P; p++) PQ_ans[p] = ExpX[p];@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            for (int p = 0; p < PP12(P); p++)@\\
\mbox{}\verb@                PQ_ans[p] = 0.0;@\\
\mbox{}\verb@            for (int p = 0; p < P; p++)@\\
\mbox{}\verb@                PQ_ans[S(p, p, P)] = ExpX[p];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (VARONLY) {@\\
\mbox{}\verb@            RC_colSums(REAL(x), N, P, Power2, &center, !DoCenter, weights,@\\
\mbox{}\verb@                       subset, offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            RC_KronSums(x, N, P, REAL(x), P, DoSymmetric, &center, &center, !DoCenter, weights,@\\
\mbox{}\verb@                        subset, offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb78a}{78a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_CovarianceX@\nobreak\ \NWlink{nuweb35c}{35c}\NWlink{nuweb35d}{d}\NWlink{nuweb44}{, 44}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb87b}{b}.\item \NWtxtIdentsUsed\nobreak\  \verb@DoCenter@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@DoSymmetric@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Power2@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@PP12@\nobreak\ \NWlink{nuweb132a}{132a}, \verb@RC_colSums@\nobreak\ \NWlink{nuweb107b}{107b}, \verb@RC_KronSums@\nobreak\ \NWlink{nuweb95b}{95b}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\section{Computing Sums}

The core concept of all functions in the section is the computation of
various sums over observations, case weights, or blocks. We start with an
initialisation of the loop over all observations

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap161}\raggedright\small
\NWtarget{nuweb88b}{} $\langle\,${\itshape init subset loop}\nobreak\ {\footnotesize {88b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@R_xlen_t diff = 0;@\\
\mbox{}\verb@s = subset + offset;@\\
\mbox{}\verb@w = weights;@\\
\mbox{}\verb@/* subset is R-style index in 1:N */@\\
\mbox{}\verb@if (Nsubset > 0)@\\
\mbox{}\verb@    diff = (R_xlen_t) s[0] - 1;@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93a}{93a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb122b}{, 122b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
and loop over $i = 1, \dots, N$ when no subset was specified or
over the subset of the subset given by \code{offset} and \code{Nsubset},
allowing for number of observations larger than \code{INT_MAX}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap162}\raggedright\small
\NWtarget{nuweb88c}{} $\langle\,${\itshape start subset loop}\nobreak\ {\footnotesize {88c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@for (R_xlen_t i = 0; i < (Nsubset == 0 ? N : Nsubset) - 1; i++)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93a}{93a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb122b}{, 122b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
After computations in the loop, we compute the next element

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap163}\raggedright\small
\NWtarget{nuweb89a}{} $\langle\,${\itshape continue subset loop}\nobreak\ {\footnotesize {89a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (Nsubset > 0) {@\\
\mbox{}\verb@    /* NB: diff also works with R style index */@\\
\mbox{}\verb@    diff = (R_xlen_t) s[1] - s[0];@\\
\mbox{}\verb@    if (diff < 0)@\\
\mbox{}\verb@        error("subset not sorted");@\\
\mbox{}\verb@    s++;@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    diff = 1;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93a}{93a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb122b}{, 122b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{Simple Sums}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap164}\raggedright\small
\NWtarget{nuweb89b}{} $\langle\,${\itshape SimpleSums}\nobreak\ {\footnotesize {89b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_Sums_dweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb91b}{91b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_Sums_iweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb92a}{92a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_Sums_iweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb92b}{92b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_Sums_dweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb92c}{92c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_Sums}\nobreak\ {\footnotesize \NWlink{nuweb91a}{91a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_Sums}\nobreak\ {\footnotesize \NWlink{nuweb90a}{90a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<SimpleSums>>=
a0 <- sum(weights[subset])
a1 <- .Call(libcoin:::R_Sums, N, weights, subset)
a2 <- .Call(libcoin:::R_Sums, N, as.double(weights), as.double(subset))
a3 <- .Call(libcoin:::R_Sums, N, weights, as.double(subset))
a4 <- .Call(libcoin:::R_Sums, N, as.double(weights), subset)

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap165}\raggedright\small
\NWtarget{nuweb89c}{} $\langle\,${\itshape R_Sums Prototype}\nobreak\ {\footnotesize {89c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_Sums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R N Input}\nobreak\ {\footnotesize \NWlink{nuweb23b}{23b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb90a}{, 90a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_Sums@\nobreak\ \NWlink{nuweb90a}{90a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap166}\raggedright\small
\NWtarget{nuweb90a}{} $\langle\,${\itshape R_Sums}\nobreak\ {\footnotesize {90a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_Sums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb89c}{89c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, 1));@\\
\mbox{}\verb@    REAL(ans)[0] = RC_Sums(INTEGER(N)[0], weights, subset, Offset0, Nsubset);@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb89b}{89b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_Sums@\nobreak\ \NWlink{nuweb89c}{89c}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@RC_Sums@\nobreak\ \NWlink{nuweb91a}{91a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap167}\raggedright\small
\NWtarget{nuweb90b}{} $\langle\,${\itshape RC_Sums Prototype}\nobreak\ {\footnotesize {90b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double RC_Sums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb91a}{91a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_Sums@\nobreak\ \NWlink{nuweb91a}{91a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap168}\raggedright\small
\NWtarget{nuweb91a}{} $\langle\,${\itshape RC_Sums}\nobreak\ {\footnotesize {91a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_Sums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb90b}{90b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (XLENGTH(weights) == 0) {@\\
\mbox{}\verb@        if (XLENGTH(subset) == 0) {@\\
\mbox{}\verb@            return((double) N);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            return((double) Nsubset);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    if (TYPEOF(weights) == INTSXP) {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            return(C_Sums_iweights_isubset(N, INTEGER(weights), XLENGTH(weights),@\\
\mbox{}\verb@                                           INTEGER(subset), offset, Nsubset));@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            return(C_Sums_iweights_dsubset(N, INTEGER(weights), XLENGTH(weights),@\\
\mbox{}\verb@                                           REAL(subset), offset, Nsubset));@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            return(C_Sums_dweights_isubset(N, REAL(weights), XLENGTH(weights),@\\
\mbox{}\verb@                                           INTEGER(subset), offset, Nsubset));@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            return(C_Sums_dweights_dsubset(N, REAL(weights), XLENGTH(weights),@\\
\mbox{}\verb@                                           REAL(subset), offset, Nsubset));@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb89b}{89b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_Sums@\nobreak\ \NWlink{nuweb34a}{34a}\NWlink{nuweb34b}{b}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb90b}{b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb127a}{, 127a}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_Sums_dweights_dsubset@\nobreak\ \NWlink{nuweb91b}{91b}, \verb@C_Sums_dweights_isubset@\nobreak\ \NWlink{nuweb92c}{92c}, \verb@C_Sums_iweights_dsubset@\nobreak\ \NWlink{nuweb92a}{92a}, \verb@C_Sums_iweights_isubset@\nobreak\ \NWlink{nuweb92b}{92b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap169}\raggedright\small
\NWtarget{nuweb91b}{} $\langle\,${\itshape C_Sums_dweights_dsubset}\nobreak\ {\footnotesize {91b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_Sums_dweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Sums Body}\nobreak\ {\footnotesize \NWlink{nuweb93a}{93a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb89b}{89b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_Sums_dweights_dsubset@\nobreak\ \NWlink{nuweb91a}{91a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap170}\raggedright\small
\NWtarget{nuweb92a}{} $\langle\,${\itshape C_Sums_iweights_dsubset}\nobreak\ {\footnotesize {92a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_Sums_iweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s;@\\
\mbox{}\verb@    int *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Sums Body}\nobreak\ {\footnotesize \NWlink{nuweb93a}{93a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb89b}{89b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_Sums_iweights_dsubset@\nobreak\ \NWlink{nuweb91a}{91a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap171}\raggedright\small
\NWtarget{nuweb92b}{} $\langle\,${\itshape C_Sums_iweights_isubset}\nobreak\ {\footnotesize {92b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_Sums_iweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Sums Body}\nobreak\ {\footnotesize \NWlink{nuweb93a}{93a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb89b}{89b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_Sums_iweights_isubset@\nobreak\ \NWlink{nuweb91a}{91a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap172}\raggedright\small
\NWtarget{nuweb92c}{} $\langle\,${\itshape C_Sums_dweights_isubset}\nobreak\ {\footnotesize {92c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_Sums_dweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s;@\\
\mbox{}\verb@    double *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape Sums Body}\nobreak\ {\footnotesize \NWlink{nuweb93a}{93a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb89b}{89b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_Sums_dweights_isubset@\nobreak\ \NWlink{nuweb91a}{91a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap173}\raggedright\small
\NWtarget{nuweb93a}{} $\langle\,${\itshape Sums Body}\nobreak\ {\footnotesize {93a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double ans = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (Nsubset > 0) {@\\
\mbox{}\verb@    if (!HAS_WEIGHTS) return((double) Nsubset);@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    if (!HAS_WEIGHTS) return((double) N);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape init subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88b}{88b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape start subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88c}{88c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    w = w + diff;@\\
\mbox{}\verb@    ans += w[0];@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape continue subset loop}\nobreak\ {\footnotesize \NWlink{nuweb89a}{89a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@w = w + diff;@\\
\mbox{}\verb@ans += w[0];@\\
\mbox{}\verb@@\\
\mbox{}\verb@return(ans);@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb91b}{91b}\NWlink{nuweb92a}{, 92a}\NWlink{nuweb92b}{b}\NWlink{nuweb92c}{c}.
\item \NWtxtIdentsUsed\nobreak\  \verb@HAS_WEIGHTS@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{Kronecker Sums}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap174}\raggedright\small
\NWtarget{nuweb93b}{} $\langle\,${\itshape KronSums}\nobreak\ {\footnotesize {93b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_KronSums_dweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb97b}{97b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_KronSums_iweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb97c}{97c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_KronSums_iweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb98a}{98a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_KronSums_dweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb98b}{98b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_XfactorKronSums_dweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb100b}{100b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_XfactorKronSums_iweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb100c}{100c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_XfactorKronSums_iweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb100d}{100d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_XfactorKronSums_dweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb101a}{101a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_KronSums}\nobreak\ {\footnotesize \NWlink{nuweb95b}{95b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_KronSums}\nobreak\ {\footnotesize \NWlink{nuweb94b}{94b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_KronSums_Permutation_isubset}\nobreak\ {\footnotesize \NWlink{nuweb104b}{104b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_KronSums_Permutation_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb104a}{104a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_XfactorKronSums_Permutation_isubset}\nobreak\ {\footnotesize \NWlink{nuweb105b}{105b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_XfactorKronSums_Permutation_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb105a}{105a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_KronSums_Permutation}\nobreak\ {\footnotesize \NWlink{nuweb103b}{103b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_KronSums_Permutation}\nobreak\ {\footnotesize \NWlink{nuweb102b}{102b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<KronSums>>=
a0 <- colSums(x[subset, r1] * y[subset, r2] * weights[subset])
a1 <- .Call(libcoin:::R_KronSums, x, P, y, weights, subset, 0L)
a2 <- .Call(libcoin:::R_KronSums, x, P, y, as.double(weights), as.double(subset), 0L)
a3 <- .Call(libcoin:::R_KronSums, x, P, y, weights, as.double(subset), 0L)
a4 <- .Call(libcoin:::R_KronSums, x, P, y, as.double(weights), subset, 0L)

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))

a0 <- as.vector(colSums(Xfactor[subset, r1Xfactor] *
                        y[subset, r2Xfactor] * weights[subset]))
a1 <- .Call(libcoin:::R_KronSums, ix, Lx, y, weights, subset, 0L)
a2 <- .Call(libcoin:::R_KronSums, ix, Lx, y, as.double(weights), as.double(subset), 0L)
a3 <- .Call(libcoin:::R_KronSums, ix, Lx, y, weights, as.double(subset), 0L)
a4 <- .Call(libcoin:::R_KronSums, ix, Lx, y, as.double(weights), subset, 0L)

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap175}\raggedright\small
\NWtarget{nuweb94a}{} $\langle\,${\itshape R_KronSums Prototype}\nobreak\ {\footnotesize {94a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_KronSums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP P,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP symmetric@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb94b}{, 94b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@R_KronSums@\nobreak\ \NWlink{nuweb94b}{94b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap176}\raggedright\small
\NWtarget{nuweb94b}{} $\langle\,${\itshape R_KronSums}\nobreak\ {\footnotesize {94b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_KronSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb94a}{94a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    double center;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    Q = NCOL(y);@\\
\mbox{}\verb@    N = XLENGTH(y) / Q;@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (INTEGER(symmetric)[0]) {@\\
\mbox{}\verb@        PROTECT(ans = allocVector(REALSXP, INTEGER(P)[0] * (INTEGER(P)[0] + 1) / 2));@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PROTECT(ans = allocVector(REALSXP, INTEGER(P)[0] * Q));@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    RC_KronSums(x, N, INTEGER(P)[0], REAL(y), Q, INTEGER(symmetric)[0], &center, &center,@\\
\mbox{}\verb@                !DoCenter, weights, subset, Offset0, Nsubset, REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_KronSums@\nobreak\ \NWlink{nuweb94a}{94a}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@DoCenter@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_KronSums@\nobreak\ \NWlink{nuweb95b}{95b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap177}\raggedright\small
\NWtarget{nuweb95a}{} $\langle\,${\itshape RC_KronSums Prototype}\nobreak\ {\footnotesize {95a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_KronSums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape RC KronSums Input}\nobreak\ {\footnotesize \NWlink{nuweb95c}{95c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb95b}{95b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_KronSums@\nobreak\ \NWlink{nuweb95b}{95b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap178}\raggedright\small
\NWtarget{nuweb95b}{} $\langle\,${\itshape RC_KronSums}\nobreak\ {\footnotesize {95b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_KronSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb95a}{95a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (TYPEOF(x) == INTSXP) {@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape KronSums Integer x}\nobreak\ {\footnotesize \NWlink{nuweb96b}{96b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape KronSums Double x}\nobreak\ {\footnotesize \NWlink{nuweb97a}{97a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_KronSums@\nobreak\ \NWlink{nuweb77d}{77d}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb95a}{, 95a}.\item \NWtxtIdentsUsed\nobreak\  \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap179}\raggedright\small
\NWtarget{nuweb95c}{} $\langle\,${\itshape RC KronSums Input}\nobreak\ {\footnotesize {95c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C real y Input}\nobreak\ {\footnotesize \NWlink{nuweb24f}{24f}}$\,\rangle$}\verb@@\\
\mbox{}\verb@const int SYMMETRIC,@\\
\mbox{}\verb@double *centerx,@\\
\mbox{}\verb@double *centery,@\\
\mbox{}\verb@const int CENTER,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb95a}{95a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap180}\raggedright\small
\NWtarget{nuweb95d}{} $\langle\,${\itshape C KronSums Input}\nobreak\ {\footnotesize {95d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C real x Input}\nobreak\ {\footnotesize \NWlink{nuweb24b}{24b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C real y Input}\nobreak\ {\footnotesize \NWlink{nuweb24f}{24f}}$\,\rangle$}\verb@@\\
\mbox{}\verb@const int SYMMETRIC,@\\
\mbox{}\verb@double *centerx,@\\
\mbox{}\verb@double *centery,@\\
\mbox{}\verb@const int CENTER,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb97b}{97b}\NWlink{nuweb97c}{c}\NWlink{nuweb98a}{, 98a}\NWlink{nuweb98b}{b}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap181}\raggedright\small
\NWtarget{nuweb96a}{} $\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize {96a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *PQ_ans@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb77c}{77c}\NWlink{nuweb83b}{, 83b}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb95a}{, 95a}\NWlink{nuweb97b}{, 97b}\NWlink{nuweb97c}{c}\NWlink{nuweb98a}{, 98a}\NWlink{nuweb98b}{b}\NWlink{nuweb100b}{, 100b}\NWlink{nuweb100c}{c}\NWlink{nuweb100d}{d}\NWlink{nuweb101a}{, 101a}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb104a}{, 104a}\NWlink{nuweb104b}{b}\NWlink{nuweb105a}{, 105a}\NWlink{nuweb105b}{b}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap182}\raggedright\small
\NWtarget{nuweb96b}{} $\langle\,${\itshape KronSums Integer x}\nobreak\ {\footnotesize {96b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (SYMMETRIC) error("not implemented");@\\
\mbox{}\verb@if (CENTER) error("not implemented");@\\
\mbox{}\verb@if (TYPEOF(weights) == INTSXP) {@\\
\mbox{}\verb@    if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@        C_XfactorKronSums_iweights_isubset(INTEGER(x), N, P, y, Q,@\\
\mbox{}\verb@            INTEGER(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@            offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        C_XfactorKronSums_iweights_dsubset(INTEGER(x), N, P, y, Q,@\\
\mbox{}\verb@            INTEGER(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@            offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@        C_XfactorKronSums_dweights_isubset(INTEGER(x), N, P, y, Q,@\\
\mbox{}\verb@            REAL(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@            offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        C_XfactorKronSums_dweights_dsubset(INTEGER(x), N, P, y, Q,@\\
\mbox{}\verb@            REAL(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@            offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb95b}{95b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_XfactorKronSums_dweights_dsubset@\nobreak\ \NWlink{nuweb100b}{100b}, \verb@C_XfactorKronSums_dweights_isubset@\nobreak\ \NWlink{nuweb101a}{101a}, \verb@C_XfactorKronSums_iweights_dsubset@\nobreak\ \NWlink{nuweb100c}{100c}, \verb@C_XfactorKronSums_iweights_isubset@\nobreak\ \NWlink{nuweb100d}{100d}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap183}\raggedright\small
\NWtarget{nuweb97a}{} $\langle\,${\itshape KronSums Double x}\nobreak\ {\footnotesize {97a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (TYPEOF(weights) == INTSXP) {@\\
\mbox{}\verb@    if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@        C_KronSums_iweights_isubset(REAL(x), N, P, y, Q, SYMMETRIC, centerx, centery, CENTER,@\\
\mbox{}\verb@            INTEGER(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@            offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        C_KronSums_iweights_dsubset(REAL(x), N, P, y, Q, SYMMETRIC, centerx, centery, CENTER,@\\
\mbox{}\verb@            INTEGER(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@            offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@        C_KronSums_dweights_isubset(REAL(x), N, P, y, Q, SYMMETRIC, centerx, centery, CENTER,@\\
\mbox{}\verb@            REAL(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@            offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        C_KronSums_dweights_dsubset(REAL(x), N, P, y, Q, SYMMETRIC, centerx, centery, CENTER,@\\
\mbox{}\verb@            REAL(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@            offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb95b}{95b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_KronSums_dweights_dsubset@\nobreak\ \NWlink{nuweb97b}{97b}, \verb@C_KronSums_dweights_isubset@\nobreak\ \NWlink{nuweb98b}{98b}, \verb@C_KronSums_iweights_dsubset@\nobreak\ \NWlink{nuweb97c}{97c}, \verb@C_KronSums_iweights_isubset@\nobreak\ \NWlink{nuweb98a}{98a}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap184}\raggedright\small
\NWtarget{nuweb97b}{} $\langle\,${\itshape C_KronSums_dweights_dsubset}\nobreak\ {\footnotesize {97b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_KronSums_dweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Input}\nobreak\ {\footnotesize \NWlink{nuweb95d}{95d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape KronSums Body}\nobreak\ {\footnotesize \NWlink{nuweb99}{99}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_KronSums_dweights_dsubset@\nobreak\ \NWlink{nuweb97a}{97a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap185}\raggedright\small
\NWtarget{nuweb97c}{} $\langle\,${\itshape C_KronSums_iweights_dsubset}\nobreak\ {\footnotesize {97c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_KronSums_iweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Input}\nobreak\ {\footnotesize \NWlink{nuweb95d}{95d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s;@\\
\mbox{}\verb@    int *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape KronSums Body}\nobreak\ {\footnotesize \NWlink{nuweb99}{99}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_KronSums_iweights_dsubset@\nobreak\ \NWlink{nuweb97a}{97a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap186}\raggedright\small
\NWtarget{nuweb98a}{} $\langle\,${\itshape C_KronSums_iweights_isubset}\nobreak\ {\footnotesize {98a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_KronSums_iweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Input}\nobreak\ {\footnotesize \NWlink{nuweb95d}{95d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape KronSums Body}\nobreak\ {\footnotesize \NWlink{nuweb99}{99}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_KronSums_iweights_isubset@\nobreak\ \NWlink{nuweb97a}{97a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap187}\raggedright\small
\NWtarget{nuweb98b}{} $\langle\,${\itshape C_KronSums_dweights_isubset}\nobreak\ {\footnotesize {98b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_KronSums_dweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Input}\nobreak\ {\footnotesize \NWlink{nuweb95d}{95d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s;@\\
\mbox{}\verb@    double *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape KronSums Body}\nobreak\ {\footnotesize \NWlink{nuweb99}{99}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_KronSums_dweights_isubset@\nobreak\ \NWlink{nuweb97a}{97a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap188}\raggedright\small
\NWtarget{nuweb99}{} $\langle\,${\itshape KronSums Body}\nobreak\ {\footnotesize {99}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@    double *xx, *yy, cx = 0.0, cy = 0.0, *thisPQ_ans;@\\
\mbox{}\verb@    int idx;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@        for (int q = (SYMMETRIC ? p : 0); q < Q; q++) {@\\
\mbox{}\verb@            /* SYMMETRIC is column-wise, default@\\
\mbox{}\verb@               is row-wise (maybe need to change this) */@\\
\mbox{}\verb@            if (SYMMETRIC) {@\\
\mbox{}\verb@                idx = S(p, q, P);@\\
\mbox{}\verb@            } else {@\\
\mbox{}\verb@                idx = q * P + p;@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@            PQ_ans[idx] = 0.0;@\\
\mbox{}\verb@            thisPQ_ans = PQ_ans + idx;@\\
\mbox{}\verb@            yy = y + N * q;@\\
\mbox{}\verb@            xx = x + N * p;@\\
\mbox{}\verb@@\\
\mbox{}\verb@            if (CENTER) {@\\
\mbox{}\verb@                cx = centerx[p];@\\
\mbox{}\verb@                cy = centery[q];@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape init subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88b}{88b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            @\hbox{$\langle\,${\itshape start subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88c}{88c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            {@\\
\mbox{}\verb@                xx = xx + diff;@\\
\mbox{}\verb@                yy = yy + diff;@\\
\mbox{}\verb@                if (HAS_WEIGHTS) {@\\
\mbox{}\verb@                    w = w + diff;@\\
\mbox{}\verb@                    if (CENTER) {@\\
\mbox{}\verb@                        thisPQ_ans[0] += (xx[0] - cx) * (yy[0] - cy) * w[0];@\\
\mbox{}\verb@                    } else {@\\
\mbox{}\verb@                        thisPQ_ans[0] += xx[0] * yy[0] * w[0];@\\
\mbox{}\verb@                    }@\\
\mbox{}\verb@                } else {@\\
\mbox{}\verb@                    if (CENTER) {@\\
\mbox{}\verb@                        thisPQ_ans[0] += (xx[0] - cx) * (yy[0] - cy);@\\
\mbox{}\verb@                    } else {@\\
\mbox{}\verb@                        thisPQ_ans[0] += xx[0] * yy[0];@\\
\mbox{}\verb@                    }@\\
\mbox{}\verb@                }@\\
\mbox{}\verb@                @\hbox{$\langle\,${\itshape continue subset loop}\nobreak\ {\footnotesize \NWlink{nuweb89a}{89a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@            xx = xx + diff;@\\
\mbox{}\verb@            yy = yy + diff;@\\
\mbox{}\verb@            if (HAS_WEIGHTS) {@\\
\mbox{}\verb@                w = w + diff;@\\
\mbox{}\verb@                thisPQ_ans[0] += (xx[0] - cx) * (yy[0] - cy) * w[0];@\\
\mbox{}\verb@            } else {@\\
\mbox{}\verb@                thisPQ_ans[0] += (xx[0] - cx) * (yy[0] - cy);@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb97b}{97b}\NWlink{nuweb97c}{c}\NWlink{nuweb98a}{, 98a}\NWlink{nuweb98b}{b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@HAS_WEIGHTS@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsubsection{Xfactor Kronecker Sums}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap189}\raggedright\small
\NWtarget{nuweb100a}{} $\langle\,${\itshape C XfactorKronSums Input}\nobreak\ {\footnotesize {100a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer x Input}\nobreak\ {\footnotesize \NWlink{nuweb24c}{24c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C real y Input}\nobreak\ {\footnotesize \NWlink{nuweb24f}{24f}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb100b}{100b}\NWlink{nuweb100c}{c}\NWlink{nuweb100d}{d}\NWlink{nuweb101a}{, 101a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap190}\raggedright\small
\NWtarget{nuweb100b}{} $\langle\,${\itshape C_XfactorKronSums_dweights_dsubset}\nobreak\ {\footnotesize {100b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_XfactorKronSums_dweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C XfactorKronSums Input}\nobreak\ {\footnotesize \NWlink{nuweb100a}{100a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape XfactorKronSums Body}\nobreak\ {\footnotesize \NWlink{nuweb101b}{101b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_XfactorKronSums_dweights_dsubset@\nobreak\ \NWlink{nuweb96b}{96b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap191}\raggedright\small
\NWtarget{nuweb100c}{} $\langle\,${\itshape C_XfactorKronSums_iweights_dsubset}\nobreak\ {\footnotesize {100c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_XfactorKronSums_iweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C XfactorKronSums Input}\nobreak\ {\footnotesize \NWlink{nuweb100a}{100a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s;@\\
\mbox{}\verb@    int *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape XfactorKronSums Body}\nobreak\ {\footnotesize \NWlink{nuweb101b}{101b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_XfactorKronSums_iweights_dsubset@\nobreak\ \NWlink{nuweb96b}{96b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap192}\raggedright\small
\NWtarget{nuweb100d}{} $\langle\,${\itshape C_XfactorKronSums_iweights_isubset}\nobreak\ {\footnotesize {100d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_XfactorKronSums_iweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C XfactorKronSums Input}\nobreak\ {\footnotesize \NWlink{nuweb100a}{100a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape XfactorKronSums Body}\nobreak\ {\footnotesize \NWlink{nuweb101b}{101b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_XfactorKronSums_iweights_isubset@\nobreak\ \NWlink{nuweb96b}{96b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap193}\raggedright\small
\NWtarget{nuweb101a}{} $\langle\,${\itshape C_XfactorKronSums_dweights_isubset}\nobreak\ {\footnotesize {101a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_XfactorKronSums_dweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C XfactorKronSums Input}\nobreak\ {\footnotesize \NWlink{nuweb100a}{100a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s;@\\
\mbox{}\verb@    double *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape XfactorKronSums Body}\nobreak\ {\footnotesize \NWlink{nuweb101b}{101b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_XfactorKronSums_dweights_isubset@\nobreak\ \NWlink{nuweb96b}{96b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap194}\raggedright\small
\NWtarget{nuweb101b}{} $\langle\,${\itshape XfactorKronSums Body}\nobreak\ {\footnotesize {101b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int *xx, ixi;@\\
\mbox{}\verb@double *yy;@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int p = 0; p < mPQB(P, Q, 1); p++) PQ_ans[p] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int q = 0; q < Q; q++) {@\\
\mbox{}\verb@    yy = y + N * q;@\\
\mbox{}\verb@    xx = x;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape init subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88b}{88b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape start subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88c}{88c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    {@\\
\mbox{}\verb@        xx = xx + diff;@\\
\mbox{}\verb@        yy = yy + diff;@\\
\mbox{}\verb@        ixi = xx[0] - 1;@\\
\mbox{}\verb@        if (HAS_WEIGHTS) {@\\
\mbox{}\verb@            w = w + diff;@\\
\mbox{}\verb@            if (ixi >= 0)@\\
\mbox{}\verb@                PQ_ans[ixi + q * P] += yy[0] * w[0];@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            if (ixi >= 0)@\\
\mbox{}\verb@                PQ_ans[ixi + q * P] += yy[0];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape continue subset loop}\nobreak\ {\footnotesize \NWlink{nuweb89a}{89a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    xx = xx + diff;@\\
\mbox{}\verb@    yy = yy + diff;@\\
\mbox{}\verb@    ixi = xx[0] - 1;@\\
\mbox{}\verb@    if (HAS_WEIGHTS) {@\\
\mbox{}\verb@        w = w + diff;@\\
\mbox{}\verb@        if (ixi >= 0)@\\
\mbox{}\verb@            PQ_ans[ixi + q * P] += yy[0] * w[0];@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (ixi >= 0)@\\
\mbox{}\verb@            PQ_ans[ixi + q * P] += yy[0];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb100b}{100b}\NWlink{nuweb100c}{c}\NWlink{nuweb100d}{d}\NWlink{nuweb101a}{, 101a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@HAS_WEIGHTS@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsubsection{Permuted Kronecker Sums}

<<KronSums-Permutation>>=
a0 <- colSums(x[subset, r1] * y[subsety, r2])
a1 <- .Call(libcoin:::R_KronSums_Permutation, x, P, y, subset, subsety)
a2 <- .Call(libcoin:::R_KronSums_Permutation, x, P, y, as.double(subset), as.double(subsety))

stopifnot(isequal(a0, a1) && isequal(a0, a2))

a0 <- as.vector(colSums(Xfactor[subset, r1Xfactor] * y[subsety, r2Xfactor]))
a1 <- .Call(libcoin:::R_KronSums_Permutation, ix, Lx, y, subset, subsety)
a2 <- .Call(libcoin:::R_KronSums_Permutation, ix, Lx, y, as.double(subset), as.double(subsety))

stopifnot(isequal(a0, a1) && isequal(a0, a2))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap195}\raggedright\small
\NWtarget{nuweb102a}{} $\langle\,${\itshape R_KronSums_Permutation Prototype}\nobreak\ {\footnotesize {102a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_KronSums_Permutation@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    SEXP P,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP subsety@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb102b}{, 102b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@R_KronSums_Permutation@\nobreak\ \NWlink{nuweb102b}{102b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap196}\raggedright\small
\NWtarget{nuweb102b}{} $\langle\,${\itshape R_KronSums_Permutation}\nobreak\ {\footnotesize {102b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_KronSums_Permutation Prototype}\nobreak\ {\footnotesize \NWlink{nuweb102a}{102a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    Q = NCOL(y);@\\
\mbox{}\verb@    N = XLENGTH(y) / Q;@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, INTEGER(P)[0] * Q));@\\
\mbox{}\verb@    RC_KronSums_Permutation(x, N, INTEGER(P)[0], REAL(y), Q, subset, Offset0, Nsubset,@\\
\mbox{}\verb@                            subsety, REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_KronSums_Permutation@\nobreak\ \NWlink{nuweb102a}{102a}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_KronSums_Permutation@\nobreak\ \NWlink{nuweb103b}{103b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap197}\raggedright\small
\NWtarget{nuweb103a}{} $\langle\,${\itshape RC_KronSums_Permutation Prototype}\nobreak\ {\footnotesize {103a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_KronSums_Permutation@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real y Input}\nobreak\ {\footnotesize \NWlink{nuweb24f}{24f}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP subsety,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb103b}{103b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_KronSums_Permutation@\nobreak\ \NWlink{nuweb103b}{103b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap198}\raggedright\small
\NWtarget{nuweb103b}{} $\langle\,${\itshape RC_KronSums_Permutation}\nobreak\ {\footnotesize {103b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_KronSums_Permutation Prototype}\nobreak\ {\footnotesize \NWlink{nuweb103a}{103a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (TYPEOF(x) == INTSXP) {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            C_XfactorKronSums_Permutation_isubset(INTEGER(x), N, P, y, Q,@\\
\mbox{}\verb@                                                  INTEGER(subset), offset, Nsubset,@\\
\mbox{}\verb@                                                  INTEGER(subsety), PQ_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_XfactorKronSums_Permutation_dsubset(INTEGER(x), N, P, y, Q,@\\
\mbox{}\verb@                                                  REAL(subset), offset, Nsubset,@\\
\mbox{}\verb@                                                  REAL(subsety), PQ_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            C_KronSums_Permutation_isubset(REAL(x), N, P, y, Q,@\\
\mbox{}\verb@                                           INTEGER(subset), offset, Nsubset,@\\
\mbox{}\verb@                                           INTEGER(subsety), PQ_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_KronSums_Permutation_dsubset(REAL(x), N, P, y, Q,@\\
\mbox{}\verb@                                           REAL(subset), offset, Nsubset,@\\
\mbox{}\verb@                                           REAL(subsety), PQ_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_KronSums_Permutation@\nobreak\ \NWlink{nuweb37}{37}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103a}{, 103a}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_KronSums_Permutation_dsubset@\nobreak\ \NWlink{nuweb104a}{104a}, \verb@C_KronSums_Permutation_isubset@\nobreak\ \NWlink{nuweb104b}{104b}, \verb@C_XfactorKronSums_Permutation_dsubset@\nobreak\ \NWlink{nuweb105a}{105a}, \verb@C_XfactorKronSums_Permutation_isubset@\nobreak\ \NWlink{nuweb105b}{105b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap199}\raggedright\small
\NWtarget{nuweb104a}{} $\langle\,${\itshape C_KronSums_Permutation_dsubset}\nobreak\ {\footnotesize {104a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_KronSums_Permutation_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real x Input}\nobreak\ {\footnotesize \NWlink{nuweb24b}{24b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real y Input}\nobreak\ {\footnotesize \NWlink{nuweb24f}{24f}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    double *subsety,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape KronSums Permutation Body}\nobreak\ {\footnotesize \NWlink{nuweb104c}{104c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_KronSums_Permutation_dsubset@\nobreak\ \NWlink{nuweb103b}{103b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap200}\raggedright\small
\NWtarget{nuweb104b}{} $\langle\,${\itshape C_KronSums_Permutation_isubset}\nobreak\ {\footnotesize {104b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_KronSums_Permutation_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real x Input}\nobreak\ {\footnotesize \NWlink{nuweb24b}{24b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real y Input}\nobreak\ {\footnotesize \NWlink{nuweb24f}{24f}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    int *subsety,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape KronSums Permutation Body}\nobreak\ {\footnotesize \NWlink{nuweb104c}{104c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_KronSums_Permutation_isubset@\nobreak\ \NWlink{nuweb103b}{103b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Because \code{subset} might not be ordered (in the presence of blocks) we
have to go through all elements explicitly here.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap201}\raggedright\small
\NWtarget{nuweb104c}{} $\langle\,${\itshape KronSums Permutation Body}\nobreak\ {\footnotesize {104c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@R_xlen_t qP, qN, pN, qPp;@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int q = 0; q < Q; q++) {@\\
\mbox{}\verb@    qN = q * N;@\\
\mbox{}\verb@    qP = q * P;@\\
\mbox{}\verb@    for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@        qPp = qP + p;@\\
\mbox{}\verb@        PQ_ans[qPp] = 0.0;@\\
\mbox{}\verb@        pN = p * N;@\\
\mbox{}\verb@        for (R_xlen_t i = offset; i < Nsubset; i++)@\\
\mbox{}\verb@            PQ_ans[qPp] += y[qN + (R_xlen_t) subsety[i] - 1] *@\\
\mbox{}\verb@                           x[pN + (R_xlen_t) subset[i] - 1];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb104a}{104a}\NWlink{nuweb104b}{b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsubsection{Xfactor Permuted Kronecker Sums}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap202}\raggedright\small
\NWtarget{nuweb105a}{} $\langle\,${\itshape C_XfactorKronSums_Permutation_dsubset}\nobreak\ {\footnotesize {105a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_XfactorKronSums_Permutation_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer x Input}\nobreak\ {\footnotesize \NWlink{nuweb24c}{24c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real y Input}\nobreak\ {\footnotesize \NWlink{nuweb24f}{24f}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    double *subsety,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape XfactorKronSums Permutation Body}\nobreak\ {\footnotesize \NWlink{nuweb105c}{105c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_XfactorKronSums_Permutation_dsubset@\nobreak\ \NWlink{nuweb103b}{103b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap203}\raggedright\small
\NWtarget{nuweb105b}{} $\langle\,${\itshape C_XfactorKronSums_Permutation_isubset}\nobreak\ {\footnotesize {105b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_XfactorKronSums_Permutation_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer x Input}\nobreak\ {\footnotesize \NWlink{nuweb24c}{24c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real y Input}\nobreak\ {\footnotesize \NWlink{nuweb24f}{24f}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    int *subsety,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C KronSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape XfactorKronSums Permutation Body}\nobreak\ {\footnotesize \NWlink{nuweb105c}{105c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb93b}{93b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_XfactorKronSums_Permutation_isubset@\nobreak\ \NWlink{nuweb103b}{103b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap204}\raggedright\small
\NWtarget{nuweb105c}{} $\langle\,${\itshape XfactorKronSums Permutation Body}\nobreak\ {\footnotesize {105c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@R_xlen_t qP, qN;@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int p = 0; p < mPQB(P, Q, 1); p++) PQ_ans[p] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int q = 0; q < Q; q++) {@\\
\mbox{}\verb@    qP = q * P;@\\
\mbox{}\verb@    qN = q * N;@\\
\mbox{}\verb@    for (R_xlen_t i = offset; i < Nsubset; i++)@\\
\mbox{}\verb@        PQ_ans[x[(R_xlen_t) subset[i] - 1] - 1 + qP] += y[qN + (R_xlen_t) subsety[i] - 1];@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb105a}{105a}\NWlink{nuweb105b}{b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{Column Sums}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap205}\raggedright\small
\NWtarget{nuweb106a}{} $\langle\,${\itshape colSums}\nobreak\ {\footnotesize {106a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_colSums_dweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb108b}{108b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_colSums_iweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb108c}{108c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_colSums_iweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb108d}{108d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_colSums_dweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb109a}{109a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_colSums}\nobreak\ {\footnotesize \NWlink{nuweb107b}{107b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_colSums}\nobreak\ {\footnotesize \NWlink{nuweb106c}{106c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<colSums>>=
a0 <- colSums(x[subset, ] * weights[subset])
a1 <- .Call(libcoin:::R_colSums, x, weights, subset)
a2 <- .Call(libcoin:::R_colSums, x, as.double(weights), as.double(subset))
a3 <- .Call(libcoin:::R_colSums, x, weights, as.double(subset))
a4 <- .Call(libcoin:::R_colSums, x, as.double(weights), subset)

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap206}\raggedright\small
\NWtarget{nuweb106b}{} $\langle\,${\itshape R_colSums Prototype}\nobreak\ {\footnotesize {106b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_colSums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb106c}{, 106c}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_colSums@\nobreak\ \NWlink{nuweb106c}{106c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap207}\raggedright\small
\NWtarget{nuweb106c}{} $\langle\,${\itshape R_colSums}\nobreak\ {\footnotesize {106c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_colSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb106b}{106b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    int P;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    double center;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    P = NCOL(x);@\\
\mbox{}\verb@    N = XLENGTH(x) / P;@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, P));@\\
\mbox{}\verb@    RC_colSums(REAL(x), N, P, Power1, &center, !DoCenter, weights, subset, Offset0,@\\
\mbox{}\verb@               Nsubset, REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb106a}{106a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_colSums@\nobreak\ \NWlink{nuweb106b}{106b}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@DoCenter@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Power1@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@RC_colSums@\nobreak\ \NWlink{nuweb107b}{107b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap208}\raggedright\small
\NWtarget{nuweb107a}{} $\langle\,${\itshape RC_colSums Prototype}\nobreak\ {\footnotesize {107a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_colSums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Input}\nobreak\ {\footnotesize \NWlink{nuweb107c}{107c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb108a}{108a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb107b}{107b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_colSums@\nobreak\ \NWlink{nuweb107b}{107b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap209}\raggedright\small
\NWtarget{nuweb107b}{} $\langle\,${\itshape RC_colSums}\nobreak\ {\footnotesize {107b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_colSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb107a}{107a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (TYPEOF(weights) == INTSXP) {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            C_colSums_iweights_isubset(x, N, P, power, centerx, CENTER,@\\
\mbox{}\verb@                                       INTEGER(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@                                       offset, Nsubset, P_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_colSums_iweights_dsubset(x, N, P, power, centerx, CENTER,@\\
\mbox{}\verb@                                       INTEGER(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@                                       offset, Nsubset, P_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            C_colSums_dweights_isubset(x, N, P, power, centerx, CENTER,@\\
\mbox{}\verb@                                       REAL(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@                                       offset, Nsubset, P_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_colSums_dweights_dsubset(x, N, P, power, centerx, CENTER,@\\
\mbox{}\verb@                                       REAL(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@                                       offset, Nsubset, P_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb106a}{106a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_colSums@\nobreak\ \NWlink{nuweb81c}{81c}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107a}{, 107a}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_colSums_dweights_dsubset@\nobreak\ \NWlink{nuweb108b}{108b}, \verb@C_colSums_dweights_isubset@\nobreak\ \NWlink{nuweb109a}{109a}, \verb@C_colSums_iweights_dsubset@\nobreak\ \NWlink{nuweb108c}{108c}, \verb@C_colSums_iweights_isubset@\nobreak\ \NWlink{nuweb108d}{108d}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap210}\raggedright\small
\NWtarget{nuweb107c}{} $\langle\,${\itshape C colSums Input}\nobreak\ {\footnotesize {107c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C real x Input}\nobreak\ {\footnotesize \NWlink{nuweb24b}{24b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@const int power,@\\
\mbox{}\verb@double *centerx,@\\
\mbox{}\verb@const int CENTER,@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb107a}{107a}\NWlink{nuweb108b}{, 108b}\NWlink{nuweb108c}{c}\NWlink{nuweb108d}{d}\NWlink{nuweb109a}{, 109a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap211}\raggedright\small
\NWtarget{nuweb108a}{} $\langle\,${\itshape C colSums Answer}\nobreak\ {\footnotesize {108a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *P_ans@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb81b}{81b}\NWlink{nuweb107a}{, 107a}\NWlink{nuweb108b}{, 108b}\NWlink{nuweb108c}{c}\NWlink{nuweb108d}{d}\NWlink{nuweb109a}{, 109a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap212}\raggedright\small
\NWtarget{nuweb108b}{} $\langle\,${\itshape C_colSums_dweights_dsubset}\nobreak\ {\footnotesize {108b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_colSums_dweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Input}\nobreak\ {\footnotesize \NWlink{nuweb107c}{107c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb108a}{108a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape colSums Body}\nobreak\ {\footnotesize \NWlink{nuweb109b}{109b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb106a}{106a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_colSums_dweights_dsubset@\nobreak\ \NWlink{nuweb107b}{107b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap213}\raggedright\small
\NWtarget{nuweb108c}{} $\langle\,${\itshape C_colSums_iweights_dsubset}\nobreak\ {\footnotesize {108c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_colSums_iweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Input}\nobreak\ {\footnotesize \NWlink{nuweb107c}{107c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb108a}{108a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s;@\\
\mbox{}\verb@    int *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape colSums Body}\nobreak\ {\footnotesize \NWlink{nuweb109b}{109b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb106a}{106a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_colSums_iweights_dsubset@\nobreak\ \NWlink{nuweb107b}{107b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap214}\raggedright\small
\NWtarget{nuweb108d}{} $\langle\,${\itshape C_colSums_iweights_isubset}\nobreak\ {\footnotesize {108d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_colSums_iweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Input}\nobreak\ {\footnotesize \NWlink{nuweb107c}{107c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb108a}{108a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape colSums Body}\nobreak\ {\footnotesize \NWlink{nuweb109b}{109b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb106a}{106a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_colSums_iweights_isubset@\nobreak\ \NWlink{nuweb107b}{107b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap215}\raggedright\small
\NWtarget{nuweb109a}{} $\langle\,${\itshape C_colSums_dweights_isubset}\nobreak\ {\footnotesize {109a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_colSums_dweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Input}\nobreak\ {\footnotesize \NWlink{nuweb107c}{107c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C colSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb108a}{108a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s;@\\
\mbox{}\verb@    double *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape colSums Body}\nobreak\ {\footnotesize \NWlink{nuweb109b}{109b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb106a}{106a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_colSums_dweights_isubset@\nobreak\ \NWlink{nuweb107b}{107b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap216}\raggedright\small
\NWtarget{nuweb109b}{} $\langle\,${\itshape colSums Body}\nobreak\ {\footnotesize {109b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *xx, cx = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int p = 0; p < P; p++) {@\\
\mbox{}\verb@    P_ans[0] = 0.0;@\\
\mbox{}\verb@    xx = x + N * p;@\\
\mbox{}\verb@    if (CENTER) {@\\
\mbox{}\verb@        cx = centerx[p];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape init subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88b}{88b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape start subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88c}{88c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    {@\\
\mbox{}\verb@        xx = xx + diff;@\\
\mbox{}\verb@        if (HAS_WEIGHTS) {@\\
\mbox{}\verb@            w = w + diff;@\\
\mbox{}\verb@            P_ans[0] += pow(xx[0] - cx, power) * w[0];@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            P_ans[0] += pow(xx[0] - cx, power);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        @\hbox{$\langle\,${\itshape continue subset loop}\nobreak\ {\footnotesize \NWlink{nuweb89a}{89a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    xx = xx + diff;@\\
\mbox{}\verb@    if (HAS_WEIGHTS) {@\\
\mbox{}\verb@        w = w + diff;@\\
\mbox{}\verb@        P_ans[0] += pow(xx[0] - cx, power) * w[0];@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        P_ans[0] += pow(xx[0] - cx, power);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    P_ans++;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb108b}{108b}\NWlink{nuweb108c}{c}\NWlink{nuweb108d}{d}\NWlink{nuweb109a}{, 109a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@HAS_WEIGHTS@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{Tables}

\subsubsection{OneTable Sums}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap217}\raggedright\small
\NWtarget{nuweb110a}{} $\langle\,${\itshape Tables}\nobreak\ {\footnotesize {110a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_OneTableSums_dweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb112d}{112d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_OneTableSums_iweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb113a}{113a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_OneTableSums_iweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb113b}{113b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_OneTableSums_dweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb113c}{113c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_OneTableSums}\nobreak\ {\footnotesize \NWlink{nuweb112a}{112a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_OneTableSums}\nobreak\ {\footnotesize \NWlink{nuweb111a}{111a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_TwoTableSums_dweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb117a}{117a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_TwoTableSums_iweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb117b}{117b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_TwoTableSums_iweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb117c}{117c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_TwoTableSums_dweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb118a}{118a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_TwoTableSums}\nobreak\ {\footnotesize \NWlink{nuweb116a}{116a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_TwoTableSums}\nobreak\ {\footnotesize \NWlink{nuweb115a}{115a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_ThreeTableSums_dweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb121b}{121b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_ThreeTableSums_iweights_dsubset}\nobreak\ {\footnotesize \NWlink{nuweb121c}{121c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_ThreeTableSums_iweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb121d}{121d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_ThreeTableSums_dweights_isubset}\nobreak\ {\footnotesize \NWlink{nuweb122a}{122a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_ThreeTableSums}\nobreak\ {\footnotesize \NWlink{nuweb120b}{120b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_ThreeTableSums}\nobreak\ {\footnotesize \NWlink{nuweb119b}{119b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<OneTableSum>>=
a0 <- as.vector(xtabs(weights ~ ixf, subset = subset))
a1 <- ctabs(ix, weights = weights, subset = subset)[-1]
a2 <- ctabs(ix, weights = as.double(weights), subset = as.double(subset))[-1]
a3 <- ctabs(ix, weights = weights, subset = as.double(subset))[-1]
a4 <- ctabs(ix, weights = as.double(weights), subset = subset)[-1]

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap218}\raggedright\small
\NWtarget{nuweb110b}{} $\langle\,${\itshape R_OneTableSums Prototype}\nobreak\ {\footnotesize {110b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_OneTableSums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb111a}{, 111a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_OneTableSums@\nobreak\ \NWlink{nuweb111a}{111a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap219}\raggedright\small
\NWtarget{nuweb111a}{} $\langle\,${\itshape R_OneTableSums}\nobreak\ {\footnotesize {111a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_OneTableSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb110b}{110b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    int P;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    N = XLENGTH(x);@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@    P = NLEVELS(x) + 1;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, P));@\\
\mbox{}\verb@    RC_OneTableSums(INTEGER(x), N, P, weights, subset,@\\
\mbox{}\verb@                    Offset0, Nsubset, REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_OneTableSums@\nobreak\ \NWlink{nuweb15b}{15b}\NWlink{nuweb110b}{, 110b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NLEVELS@\nobreak\ \NWlink{nuweb131b}{131b}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@RC_OneTableSums@\nobreak\ \NWlink{nuweb112a}{112a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap220}\raggedright\small
\NWtarget{nuweb111b}{} $\langle\,${\itshape RC_OneTableSums Prototype}\nobreak\ {\footnotesize {111b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_OneTableSums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb112b}{112b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb112c}{112c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb112a}{112a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_OneTableSums@\nobreak\ \NWlink{nuweb112a}{112a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap221}\raggedright\small
\NWtarget{nuweb112a}{} $\langle\,${\itshape RC_OneTableSums}\nobreak\ {\footnotesize {112a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_OneTableSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb111b}{111b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (TYPEOF(weights) == INTSXP) {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            C_OneTableSums_iweights_isubset(x, N, P,@\\
\mbox{}\verb@                                        INTEGER(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, P_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_OneTableSums_iweights_dsubset(x, N, P,@\\
\mbox{}\verb@                                        INTEGER(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, P_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            C_OneTableSums_dweights_isubset(x, N, P,@\\
\mbox{}\verb@                                        REAL(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, P_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_OneTableSums_dweights_dsubset(x, N, P,@\\
\mbox{}\verb@                                        REAL(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, P_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_OneTableSums@\nobreak\ \NWlink{nuweb34a}{34a}\NWlink{nuweb37}{, 37}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb111b}{b}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_OneTableSums_dweights_dsubset@\nobreak\ \NWlink{nuweb112d}{112d}, \verb@C_OneTableSums_dweights_isubset@\nobreak\ \NWlink{nuweb113c}{113c}, \verb@C_OneTableSums_iweights_dsubset@\nobreak\ \NWlink{nuweb113a}{113a}, \verb@C_OneTableSums_iweights_isubset@\nobreak\ \NWlink{nuweb113b}{113b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap222}\raggedright\small
\NWtarget{nuweb112b}{} $\langle\,${\itshape C OneTableSums Input}\nobreak\ {\footnotesize {112b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer x Input}\nobreak\ {\footnotesize \NWlink{nuweb24c}{24c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb111b}{111b}\NWlink{nuweb112d}{, 112d}\NWlink{nuweb113a}{, 113a}\NWlink{nuweb113b}{b}\NWlink{nuweb113c}{c}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap223}\raggedright\small
\NWtarget{nuweb112c}{} $\langle\,${\itshape C OneTableSums Answer}\nobreak\ {\footnotesize {112c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *P_ans@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb85a}{85a}\NWlink{nuweb111b}{, 111b}\NWlink{nuweb112d}{, 112d}\NWlink{nuweb113a}{, 113a}\NWlink{nuweb113b}{b}\NWlink{nuweb113c}{c}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap224}\raggedright\small
\NWtarget{nuweb112d}{} $\langle\,${\itshape C_OneTableSums_dweights_dsubset}\nobreak\ {\footnotesize {112d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_OneTableSums_dweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb112b}{112b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb112c}{112c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape OneTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb114a}{114a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_OneTableSums_dweights_dsubset@\nobreak\ \NWlink{nuweb112a}{112a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap225}\raggedright\small
\NWtarget{nuweb113a}{} $\langle\,${\itshape C_OneTableSums_iweights_dsubset}\nobreak\ {\footnotesize {113a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_OneTableSums_iweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb112b}{112b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb112c}{112c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s;@\\
\mbox{}\verb@    int *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape OneTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb114a}{114a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_OneTableSums_iweights_dsubset@\nobreak\ \NWlink{nuweb112a}{112a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap226}\raggedright\small
\NWtarget{nuweb113b}{} $\langle\,${\itshape C_OneTableSums_iweights_isubset}\nobreak\ {\footnotesize {113b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_OneTableSums_iweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb112b}{112b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb112c}{112c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape OneTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb114a}{114a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_OneTableSums_iweights_isubset@\nobreak\ \NWlink{nuweb112a}{112a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap227}\raggedright\small
\NWtarget{nuweb113c}{} $\langle\,${\itshape C_OneTableSums_dweights_isubset}\nobreak\ {\footnotesize {113c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_OneTableSums_dweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb112b}{112b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C OneTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb112c}{112c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s;@\\
\mbox{}\verb@    double *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape OneTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb114a}{114a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_OneTableSums_dweights_isubset@\nobreak\ \NWlink{nuweb112a}{112a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap228}\raggedright\small
\NWtarget{nuweb114a}{} $\langle\,${\itshape OneTableSums Body}\nobreak\ {\footnotesize {114a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int *xx;@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int p = 0; p < P; p++) P_ans[p] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@xx = x;@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape init subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88b}{88b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape start subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88c}{88c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    xx = xx + diff;@\\
\mbox{}\verb@    if (HAS_WEIGHTS) {@\\
\mbox{}\verb@        w = w + diff;@\\
\mbox{}\verb@        P_ans[xx[0]] += (double) w[0];@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        P_ans[xx[0]]++;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape continue subset loop}\nobreak\ {\footnotesize \NWlink{nuweb89a}{89a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@xx = xx + diff;@\\
\mbox{}\verb@if (HAS_WEIGHTS) {@\\
\mbox{}\verb@    w = w + diff;@\\
\mbox{}\verb@    P_ans[xx[0]] += w[0];@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    P_ans[xx[0]]++;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb112d}{112d}\NWlink{nuweb113a}{, 113a}\NWlink{nuweb113b}{b}\NWlink{nuweb113c}{c}.
\item \NWtxtIdentsUsed\nobreak\  \verb@HAS_WEIGHTS@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsubsection{TwoTable Sums}

<<TwoTableSum>>=
a0 <- xtabs(weights ~ ixf + iyf, subset = subset)
class(a0) <- "matrix"
dimnames(a0) <- NULL
attributes(a0)$call <- NULL
a1 <- ctabs(ix, iy, weights = weights, subset = subset)[-1, -1]
a2 <- ctabs(ix, iy, weights = as.double(weights),
            subset = as.double(subset))[-1, -1]
a3 <- ctabs(ix, iy, weights = weights, subset = as.double(subset))[-1, -1]
a4 <- ctabs(ix, iy, weights = as.double(weights), subset = subset)[-1, -1]

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap229}\raggedright\small
\NWtarget{nuweb114b}{} $\langle\,${\itshape R_TwoTableSums Prototype}\nobreak\ {\footnotesize {114b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_TwoTableSums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb115a}{, 115a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_TwoTableSums@\nobreak\ \NWlink{nuweb115a}{115a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap230}\raggedright\small
\NWtarget{nuweb115a}{} $\langle\,${\itshape R_TwoTableSums}\nobreak\ {\footnotesize {115a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_TwoTableSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb114b}{114b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans, dim;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    int P, Q;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    N = XLENGTH(x);@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@    P = NLEVELS(x) + 1;@\\
\mbox{}\verb@    Q = NLEVELS(y) + 1;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, mPQB(P, Q, 1)));@\\
\mbox{}\verb@    PROTECT(dim = allocVector(INTSXP, 2));@\\
\mbox{}\verb@    INTEGER(dim)[0] = P;@\\
\mbox{}\verb@    INTEGER(dim)[1] = Q;@\\
\mbox{}\verb@    dimgets(ans, dim);@\\
\mbox{}\verb@    RC_TwoTableSums(INTEGER(x), N, P, INTEGER(y), Q,@\\
\mbox{}\verb@                    weights, subset, Offset0, Nsubset, REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_TwoTableSums@\nobreak\ \NWlink{nuweb15b}{15b}\NWlink{nuweb114b}{, 114b}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NLEVELS@\nobreak\ \NWlink{nuweb131b}{131b}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_TwoTableSums@\nobreak\ \NWlink{nuweb116a}{116a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap231}\raggedright\small
\NWtarget{nuweb115b}{} $\langle\,${\itshape RC_TwoTableSums Prototype}\nobreak\ {\footnotesize {115b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_TwoTableSums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C TwoTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb116b}{116b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C TwoTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb116c}{116c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb116a}{116a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_TwoTableSums@\nobreak\ \NWlink{nuweb116a}{116a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap232}\raggedright\small
\NWtarget{nuweb116a}{} $\langle\,${\itshape RC_TwoTableSums}\nobreak\ {\footnotesize {116a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_TwoTableSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb115b}{115b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (TYPEOF(weights) == INTSXP) {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            C_TwoTableSums_iweights_isubset(x, N, P, y, Q,@\\
\mbox{}\verb@                                        INTEGER(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_TwoTableSums_iweights_dsubset(x, N, P, y, Q,@\\
\mbox{}\verb@                                        INTEGER(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            C_TwoTableSums_dweights_isubset(x, N, P, y, Q,@\\
\mbox{}\verb@                                        REAL(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_TwoTableSums_dweights_dsubset(x, N, P, y, Q,@\\
\mbox{}\verb@                                        REAL(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, PQ_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_TwoTableSums@\nobreak\ \NWlink{nuweb41a}{41a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb115b}{b}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_TwoTableSums_dweights_dsubset@\nobreak\ \NWlink{nuweb117a}{117a}, \verb@C_TwoTableSums_dweights_isubset@\nobreak\ \NWlink{nuweb118a}{118a}, \verb@C_TwoTableSums_iweights_dsubset@\nobreak\ \NWlink{nuweb117b}{117b}, \verb@C_TwoTableSums_iweights_isubset@\nobreak\ \NWlink{nuweb117c}{117c}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap233}\raggedright\small
\NWtarget{nuweb116b}{} $\langle\,${\itshape C TwoTableSums Input}\nobreak\ {\footnotesize {116b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer x Input}\nobreak\ {\footnotesize \NWlink{nuweb24c}{24c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer y Input}\nobreak\ {\footnotesize \NWlink{nuweb25a}{25a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb115b}{115b}\NWlink{nuweb117a}{, 117a}\NWlink{nuweb117b}{b}\NWlink{nuweb117c}{c}\NWlink{nuweb118a}{, 118a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap234}\raggedright\small
\NWtarget{nuweb116c}{} $\langle\,${\itshape C TwoTableSums Answer}\nobreak\ {\footnotesize {116c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *PQ_ans@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb115b}{115b}\NWlink{nuweb117a}{, 117a}\NWlink{nuweb117b}{b}\NWlink{nuweb117c}{c}\NWlink{nuweb118a}{, 118a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap235}\raggedright\small
\NWtarget{nuweb117a}{} $\langle\,${\itshape C_TwoTableSums_dweights_dsubset}\nobreak\ {\footnotesize {117a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_TwoTableSums_dweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C TwoTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb116b}{116b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C TwoTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb116c}{116c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape TwoTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb118b}{118b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_TwoTableSums_dweights_dsubset@\nobreak\ \NWlink{nuweb116a}{116a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap236}\raggedright\small
\NWtarget{nuweb117b}{} $\langle\,${\itshape C_TwoTableSums_iweights_dsubset}\nobreak\ {\footnotesize {117b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_TwoTableSums_iweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C TwoTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb116b}{116b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C TwoTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb116c}{116c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s;@\\
\mbox{}\verb@    int *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape TwoTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb118b}{118b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_TwoTableSums_iweights_dsubset@\nobreak\ \NWlink{nuweb116a}{116a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap237}\raggedright\small
\NWtarget{nuweb117c}{} $\langle\,${\itshape C_TwoTableSums_iweights_isubset}\nobreak\ {\footnotesize {117c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_TwoTableSums_iweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C TwoTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb116b}{116b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C TwoTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb116c}{116c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape TwoTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb118b}{118b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_TwoTableSums_iweights_isubset@\nobreak\ \NWlink{nuweb116a}{116a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap238}\raggedright\small
\NWtarget{nuweb118a}{} $\langle\,${\itshape C_TwoTableSums_dweights_isubset}\nobreak\ {\footnotesize {118a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_TwoTableSums_dweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C TwoTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb116b}{116b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C TwoTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb116c}{116c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s;@\\
\mbox{}\verb@    double *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape TwoTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb118b}{118b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_TwoTableSums_dweights_isubset@\nobreak\ \NWlink{nuweb116a}{116a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap239}\raggedright\small
\NWtarget{nuweb118b}{} $\langle\,${\itshape TwoTableSums Body}\nobreak\ {\footnotesize {118b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int *xx, *yy;@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int p = 0; p < Q * P; p++) PQ_ans[p] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@yy = y;@\\
\mbox{}\verb@xx = x;@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape init subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88b}{88b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape start subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88c}{88c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    xx = xx + diff;@\\
\mbox{}\verb@    yy = yy + diff;@\\
\mbox{}\verb@    if (HAS_WEIGHTS) {@\\
\mbox{}\verb@        w = w + diff;@\\
\mbox{}\verb@        PQ_ans[yy[0] * P + xx[0]] += (double) w[0];@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PQ_ans[yy[0] * P + xx[0]]++;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape continue subset loop}\nobreak\ {\footnotesize \NWlink{nuweb89a}{89a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@xx = xx + diff;@\\
\mbox{}\verb@yy = yy + diff;@\\
\mbox{}\verb@if (HAS_WEIGHTS) {@\\
\mbox{}\verb@    w = w + diff;@\\
\mbox{}\verb@    PQ_ans[yy[0] * P + xx[0]] += w[0];@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    PQ_ans[yy[0] * P + xx[0]]++;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb117a}{117a}\NWlink{nuweb117b}{b}\NWlink{nuweb117c}{c}\NWlink{nuweb118a}{, 118a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@HAS_WEIGHTS@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsubsection{ThreeTable Sums}

<<ThreeTableSum>>=
a0 <- xtabs(weights ~ ixf + iyf + block, subset = subset)
class(a0) <- "array"
dimnames(a0) <- NULL
attributes(a0)$call <- NULL
a1 <- ctabs(ix, iy, block, weights, subset)[-1, -1,]
a2 <- ctabs(ix, iy, block, as.double(weights), as.double(subset))[-1,-1,]
a3 <- ctabs(ix, iy, block, weights, as.double(subset))[-1,-1,]
a4 <- ctabs(ix, iy, block, as.double(weights), subset)[-1,-1,]

stopifnot(isequal(a0, a1) && isequal(a0, a2) &&
          isequal(a0, a3) && isequal(a0, a4))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap240}\raggedright\small
\NWtarget{nuweb119a}{} $\langle\,${\itshape R_ThreeTableSums Prototype}\nobreak\ {\footnotesize {119a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_ThreeTableSums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R x Input}\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R block Input}\nobreak\ {\footnotesize \NWlink{nuweb26f}{26f}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb119b}{, 119b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_ThreeTableSums@\nobreak\ \NWlink{nuweb119b}{119b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap241}\raggedright\small
\NWtarget{nuweb119b}{} $\langle\,${\itshape R_ThreeTableSums}\nobreak\ {\footnotesize {119b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_ThreeTableSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb119a}{119a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans, dim;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    int P, Q, B;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    N = XLENGTH(x);@\\
\mbox{}\verb@    Nsubset = XLENGTH(subset);@\\
\mbox{}\verb@    P = NLEVELS(x) + 1;@\\
\mbox{}\verb@    Q = NLEVELS(y) + 1;@\\
\mbox{}\verb@    B = NLEVELS(block);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, mPQB(P, Q, B)));@\\
\mbox{}\verb@    PROTECT(dim = allocVector(INTSXP, 3));@\\
\mbox{}\verb@    INTEGER(dim)[0] = P;@\\
\mbox{}\verb@    INTEGER(dim)[1] = Q;@\\
\mbox{}\verb@    INTEGER(dim)[2] = B;@\\
\mbox{}\verb@    dimgets(ans, dim);@\\
\mbox{}\verb@    RC_ThreeTableSums(INTEGER(x), N, P, INTEGER(y), Q,@\\
\mbox{}\verb@                      INTEGER(block), B,@\\
\mbox{}\verb@                      weights, subset, Offset0, Nsubset, REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_ThreeTableSums@\nobreak\ \NWlink{nuweb15b}{15b}\NWlink{nuweb119a}{, 119a}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NLEVELS@\nobreak\ \NWlink{nuweb131b}{131b}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@RC_ThreeTableSums@\nobreak\ \NWlink{nuweb120b}{120b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap242}\raggedright\small
\NWtarget{nuweb120a}{} $\langle\,${\itshape RC_ThreeTableSums Prototype}\nobreak\ {\footnotesize {120a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void RC_ThreeTableSums@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C ThreeTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb120c}{120c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C subset range Input}\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C ThreeTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb121a}{121a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb120b}{120b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_ThreeTableSums@\nobreak\ \NWlink{nuweb120b}{120b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap243}\raggedright\small
\NWtarget{nuweb120b}{} $\langle\,${\itshape RC_ThreeTableSums}\nobreak\ {\footnotesize {120b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_ThreeTableSums Prototype}\nobreak\ {\footnotesize \NWlink{nuweb120a}{120a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    if (TYPEOF(weights) == INTSXP) {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            C_ThreeTableSums_iweights_isubset(x, N, P, y, Q, block, B,@\\
\mbox{}\verb@                                        INTEGER(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, PQL_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_ThreeTableSums_iweights_dsubset(x, N, P, y, Q, block, B,@\\
\mbox{}\verb@                                        INTEGER(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, PQL_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@            C_ThreeTableSums_dweights_isubset(x, N, P, y, Q, block, B,@\\
\mbox{}\verb@                                        REAL(weights), XLENGTH(weights) > 0, INTEGER(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, PQL_ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_ThreeTableSums_dweights_dsubset(x, N, P, y, Q, block, B,@\\
\mbox{}\verb@                                        REAL(weights), XLENGTH(weights) > 0, REAL(subset),@\\
\mbox{}\verb@                                        offset, Nsubset, PQL_ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_ThreeTableSums@\nobreak\ \NWlink{nuweb41a}{41a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120a}{, 120a}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@C_ThreeTableSums_dweights_dsubset@\nobreak\ \NWlink{nuweb121b}{121b}, \verb@C_ThreeTableSums_dweights_isubset@\nobreak\ \NWlink{nuweb122a}{122a}, \verb@C_ThreeTableSums_iweights_dsubset@\nobreak\ \NWlink{nuweb121c}{121c}, \verb@C_ThreeTableSums_iweights_isubset@\nobreak\ \NWlink{nuweb121d}{121d}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@offset@\nobreak\ \NWlink{nuweb26c}{26c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap244}\raggedright\small
\NWtarget{nuweb120c}{} $\langle\,${\itshape C ThreeTableSums Input}\nobreak\ {\footnotesize {120c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer x Input}\nobreak\ {\footnotesize \NWlink{nuweb24c}{24c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer y Input}\nobreak\ {\footnotesize \NWlink{nuweb25a}{25a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C integer block Input}\nobreak\ {\footnotesize \NWlink{nuweb27b}{27b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb120a}{120a}\NWlink{nuweb121b}{, 121b}\NWlink{nuweb121c}{c}\NWlink{nuweb121d}{d}\NWlink{nuweb122a}{, 122a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap245}\raggedright\small
\NWtarget{nuweb121a}{} $\langle\,${\itshape C ThreeTableSums Answer}\nobreak\ {\footnotesize {121a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double *PQL_ans@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb120a}{120a}\NWlink{nuweb121b}{, 121b}\NWlink{nuweb121c}{c}\NWlink{nuweb121d}{d}\NWlink{nuweb122a}{, 122a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap246}\raggedright\small
\NWtarget{nuweb121b}{} $\langle\,${\itshape C_ThreeTableSums_dweights_dsubset}\nobreak\ {\footnotesize {121b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_ThreeTableSums_dweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C ThreeTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb120c}{120c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C ThreeTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb121a}{121a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape ThreeTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb122b}{122b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_ThreeTableSums_dweights_dsubset@\nobreak\ \NWlink{nuweb120b}{120b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap247}\raggedright\small
\NWtarget{nuweb121c}{} $\langle\,${\itshape C_ThreeTableSums_iweights_dsubset}\nobreak\ {\footnotesize {121c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_ThreeTableSums_iweights_dsubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C ThreeTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb120c}{120c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C ThreeTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb121a}{121a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *s;@\\
\mbox{}\verb@    int *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape ThreeTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb122b}{122b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_ThreeTableSums_iweights_dsubset@\nobreak\ \NWlink{nuweb120b}{120b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap248}\raggedright\small
\NWtarget{nuweb121d}{} $\langle\,${\itshape C_ThreeTableSums_iweights_isubset}\nobreak\ {\footnotesize {121d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_ThreeTableSums_iweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C ThreeTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb120c}{120c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C ThreeTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb121a}{121a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s, *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape ThreeTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb122b}{122b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_ThreeTableSums_iweights_isubset@\nobreak\ \NWlink{nuweb120b}{120b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap249}\raggedright\small
\NWtarget{nuweb122a}{} $\langle\,${\itshape C_ThreeTableSums_dweights_isubset}\nobreak\ {\footnotesize {122a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_ThreeTableSums_dweights_isubset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C ThreeTableSums Input}\nobreak\ {\footnotesize \NWlink{nuweb120c}{120c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C ThreeTableSums Answer}\nobreak\ {\footnotesize \NWlink{nuweb121a}{121a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int *s;@\\
\mbox{}\verb@    double *w;@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape ThreeTableSums Body}\nobreak\ {\footnotesize \NWlink{nuweb122b}{122b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb110a}{110a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_ThreeTableSums_dweights_isubset@\nobreak\ \NWlink{nuweb120b}{120b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap250}\raggedright\small
\NWtarget{nuweb122b}{} $\langle\,${\itshape ThreeTableSums Body}\nobreak\ {\footnotesize {122b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int *xx, *yy, *bb, PQ = mPQB(P, Q, 1);@\\
\mbox{}\verb@@\\
\mbox{}\verb@for (int p = 0; p < PQ * B; p++) PQL_ans[p] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@yy = y;@\\
\mbox{}\verb@xx = x;@\\
\mbox{}\verb@bb = block;@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape init subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88b}{88b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape start subset loop}\nobreak\ {\footnotesize \NWlink{nuweb88c}{88c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    xx = xx + diff;@\\
\mbox{}\verb@    yy = yy + diff;@\\
\mbox{}\verb@    bb = bb + diff;@\\
\mbox{}\verb@    if (HAS_WEIGHTS) {@\\
\mbox{}\verb@        w = w + diff;@\\
\mbox{}\verb@        PQL_ans[(bb[0] - 1) * PQ + yy[0] * P + xx[0]] += (double) w[0];@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PQL_ans[(bb[0] - 1) * PQ + yy[0] * P + xx[0]]++;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape continue subset loop}\nobreak\ {\footnotesize \NWlink{nuweb89a}{89a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@xx = xx + diff;@\\
\mbox{}\verb@yy = yy + diff;@\\
\mbox{}\verb@bb = bb + diff;@\\
\mbox{}\verb@if (HAS_WEIGHTS) {@\\
\mbox{}\verb@    w = w + diff;@\\
\mbox{}\verb@    PQL_ans[(bb[0] - 1) * PQ + yy[0] * P + xx[0]] += w[0];@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    PQL_ans[(bb[0] - 1) * PQ + yy[0] * P + xx[0]]++;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb121b}{121b}\NWlink{nuweb121c}{c}\NWlink{nuweb121d}{d}\NWlink{nuweb122a}{, 122a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@HAS_WEIGHTS@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\section{Utilities}

\subsection{Blocks}

<<blocks>>=
sb <- sample(block)

ns1 <- do.call(c, tapply(subset, sb[subset], function(i) i))
ns2 <- .Call(libcoin:::R_order_subset_wrt_block, y, integer(0), subset, sb)

stopifnot(isequal(ns1, ns2))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap251}\raggedright\small
\NWtarget{nuweb123a}{} $\langle\,${\itshape Utils}\nobreak\ {\footnotesize {123a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_setup_subset}\nobreak\ {\footnotesize \NWlink{nuweb125a}{125a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_setup_subset_block}\nobreak\ {\footnotesize \NWlink{nuweb125b}{125b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_order_subset_wrt_block}\nobreak\ {\footnotesize \NWlink{nuweb126a}{126a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_order_subset_wrt_block}\nobreak\ {\footnotesize \NWlink{nuweb124b}{124b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_order_subset_wrt_block}\nobreak\ {\footnotesize \NWlink{nuweb123c}{123c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap252}\raggedright\small
\NWtarget{nuweb123b}{} $\langle\,${\itshape R_order_subset_wrt_block Prototype}\nobreak\ {\footnotesize {123b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_order_subset_wrt_block@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R y Input}\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R block Input}\nobreak\ {\footnotesize \NWlink{nuweb26f}{26f}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb123c}{, 123c}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_order_subset_wrt_block@\nobreak\ \NWlink{nuweb123c}{123c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap253}\raggedright\small
\NWtarget{nuweb123c}{} $\langle\,${\itshape R_order_subset_wrt_block}\nobreak\ {\footnotesize {123c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_order_subset_wrt_block Prototype}\nobreak\ {\footnotesize \NWlink{nuweb123b}{123b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@;@\\
\mbox{}\verb@    SEXP blockTable, ans;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    N = XLENGTH(y) / NCOL(y);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (XLENGTH(weights) > 0)@\\
\mbox{}\verb@        error("cannot deal with weights here");@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (NLEVELS(block) > 1) {@\\
\mbox{}\verb@        PROTECT(blockTable = R_OneTableSums(block, weights, subset));@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PROTECT(blockTable = allocVector(REALSXP, 2));@\\
\mbox{}\verb@        REAL(blockTable)[0] = 0.0;@\\
\mbox{}\verb@        REAL(blockTable)[1] = RC_Sums(N, weights, subset, Offset0, XLENGTH(subset));@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = RC_order_subset_wrt_block(N, subset, block, blockTable));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb123a}{123a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_order_subset_wrt_block@\nobreak\ \NWlink{nuweb123b}{123b}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@blockTable@\nobreak\ \NWlink{nuweb27c}{27c}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}, \verb@NLEVELS@\nobreak\ \NWlink{nuweb131b}{131b}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@RC_order_subset_wrt_block@\nobreak\ \NWlink{nuweb124b}{124b}, \verb@RC_Sums@\nobreak\ \NWlink{nuweb91a}{91a}, \verb@R_OneTableSums@\nobreak\ \NWlink{nuweb111a}{111a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap254}\raggedright\small
\NWtarget{nuweb124a}{} $\langle\,${\itshape RC_order_subset_wrt_block Prototype}\nobreak\ {\footnotesize {124a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP RC_order_subset_wrt_block@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R block Input}\nobreak\ {\footnotesize \NWlink{nuweb26f}{26f}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R blockTable Input}\nobreak\ {\footnotesize \NWlink{nuweb27c}{27c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb124b}{124b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_order_subset_wrt_block@\nobreak\ \NWlink{nuweb124b}{124b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap255}\raggedright\small
\NWtarget{nuweb124b}{} $\langle\,${\itshape RC_order_subset_wrt_block}\nobreak\ {\footnotesize {124b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_order_subset_wrt_block Prototype}\nobreak\ {\footnotesize \NWlink{nuweb124a}{124a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    int NOBLOCK = (XLENGTH(block) == 0 || XLENGTH(blockTable) == 2);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (XLENGTH(subset) > 0) {@\\
\mbox{}\verb@        if (NOBLOCK) {@\\
\mbox{}\verb@            return(subset);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            PROTECT(ans = allocVector(TYPEOF(subset), XLENGTH(subset)));@\\
\mbox{}\verb@            C_order_subset_wrt_block(subset, block, blockTable, ans);@\\
\mbox{}\verb@            UNPROTECT(1);@\\
\mbox{}\verb@            return(ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PROTECT(ans = allocVector(TYPEOF(subset), N));@\\
\mbox{}\verb@        if (NOBLOCK) {@\\
\mbox{}\verb@            C_setup_subset(N, ans);@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            C_setup_subset_block(N, block, blockTable, ans);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        UNPROTECT(1);@\\
\mbox{}\verb@        return(ans);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb123a}{123a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_order_subset_wrt_block@\nobreak\ \NWlink{nuweb34a}{34a}\NWlink{nuweb37}{, 37}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124a}{, 124a}.\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@blockTable@\nobreak\ \NWlink{nuweb27c}{27c}, \verb@C_order_subset_wrt_block@\nobreak\ \NWlink{nuweb126a}{126a}, \verb@C_setup_subset@\nobreak\ \NWlink{nuweb125a}{125a}, \verb@C_setup_subset_block@\nobreak\ \NWlink{nuweb125b}{125b}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap256}\raggedright\small
\NWtarget{nuweb125a}{} $\langle\,${\itshape C_setup_subset}\nobreak\ {\footnotesize {125a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_setup_subset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    for (R_xlen_t i = 0; i < N; i++) {@\\
\mbox{}\verb@        /* ans is R style index in 1:N */@\\
\mbox{}\verb@        if (TYPEOF(ans) == INTSXP) {@\\
\mbox{}\verb@            INTEGER(ans)[i] = i + 1;@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            REAL(ans)[i] = (double) i + 1;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb123a}{123a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_setup_subset@\nobreak\ \NWlink{nuweb124b}{124b}\NWlink{nuweb127a}{, 127a}.\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap257}\raggedright\small
\NWtarget{nuweb125b}{} $\langle\,${\itshape C_setup_subset_block}\nobreak\ {\footnotesize {125b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_setup_subset_block@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R block Input}\nobreak\ {\footnotesize \NWlink{nuweb26f}{26f}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R blockTable Input}\nobreak\ {\footnotesize \NWlink{nuweb27c}{27c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *cumtable;@\\
\mbox{}\verb@    int Nlevels = LENGTH(blockTable);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    cumtable = R_Calloc(Nlevels, double);@\\
\mbox{}\verb@    for (int k = 0; k < Nlevels; k++) cumtable[k] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* table[0] are missings, i.e. block == 0 ! */@\\
\mbox{}\verb@    for (int k = 1; k < Nlevels; k++)@\\
\mbox{}\verb@        cumtable[k] = cumtable[k - 1] + REAL(blockTable)[k - 1];@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (R_xlen_t i = 0; i < N; i++) {@\\
\mbox{}\verb@        /* ans is R style index in 1:N */@\\
\mbox{}\verb@        if (TYPEOF(ans) == INTSXP) {@\\
\mbox{}\verb@            INTEGER(ans)[(int) cumtable[INTEGER(block)[i]]++] = i + 1;@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            REAL(ans)[(R_xlen_t) cumtable[INTEGER(block)[i]]++] = (double) i + 1;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    R_Free(cumtable);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb123a}{123a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_setup_subset_block@\nobreak\ \NWlink{nuweb124b}{124b}.\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@blockTable@\nobreak\ \NWlink{nuweb27c}{27c}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap258}\raggedright\small
\NWtarget{nuweb126a}{} $\langle\,${\itshape C_order_subset_wrt_block}\nobreak\ {\footnotesize {126a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_order_subset_wrt_block@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R block Input}\nobreak\ {\footnotesize \NWlink{nuweb26f}{26f}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R blockTable Input}\nobreak\ {\footnotesize \NWlink{nuweb27c}{27c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    SEXP ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *cumtable;@\\
\mbox{}\verb@    int Nlevels = LENGTH(blockTable);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    cumtable = R_Calloc(Nlevels, double);@\\
\mbox{}\verb@    for (int k = 0; k < Nlevels; k++) cumtable[k] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* table[0] are missings, ie block == 0 ! */@\\
\mbox{}\verb@    for (int k = 1; k < Nlevels; k++)@\\
\mbox{}\verb@        cumtable[k] = cumtable[k - 1] + REAL(blockTable)[k - 1];@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* subset is R style index in 1:N */@\\
\mbox{}\verb@    if (TYPEOF(subset) == INTSXP) {@\\
\mbox{}\verb@        for (R_xlen_t i = 0; i < XLENGTH(subset); i++)@\\
\mbox{}\verb@            INTEGER(ans)[(int) cumtable[INTEGER(block)[INTEGER(subset)[i] - 1]]++] = INTEGER(subset)[i];@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        for (R_xlen_t i = 0; i < XLENGTH(subset); i++)@\\
\mbox{}\verb@            REAL(ans)[(R_xlen_t) cumtable[INTEGER(block)[(R_xlen_t) REAL(subset)[i] - 1]]++] = REAL(subset)[i];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    R_Free(cumtable);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb123a}{123a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_order_subset_wrt_block@\nobreak\ \NWlink{nuweb124b}{124b}.\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@blockTable@\nobreak\ \NWlink{nuweb27c}{27c}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap259}\raggedright\small
\NWtarget{nuweb126b}{} $\langle\,${\itshape RC_setup_subset Prototype}\nobreak\ {\footnotesize {126b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP RC_setup_subset@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer N Input}\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R weights Input}\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R subset Input}\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb127a}{127a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@RC_setup_subset@\nobreak\ \NWlink{nuweb127a}{127a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Because this will only be used when really needed (in Permutations) we can
be a little bit more generous with memory here. The return value is always
\code{REALSXP}.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap260}\raggedright\small
\NWtarget{nuweb127a}{} $\langle\,${\itshape RC_setup_subset}\nobreak\ {\footnotesize {127a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_setup_subset Prototype}\nobreak\ {\footnotesize \NWlink{nuweb126b}{126b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    SEXP ans, mysubset;@\\
\mbox{}\verb@    R_xlen_t sumweights;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (XLENGTH(subset) == 0) {@\\
\mbox{}\verb@        PROTECT(mysubset = allocVector(REALSXP, N));@\\
\mbox{}\verb@        C_setup_subset(N, mysubset);@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PROTECT(mysubset = coerceVector(subset, REALSXP));@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (XLENGTH(weights) == 0) {@\\
\mbox{}\verb@        UNPROTECT(1);@\\
\mbox{}\verb@        return(mysubset);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    sumweights = (R_xlen_t) RC_Sums(N, weights, mysubset, Offset0, XLENGTH(subset));@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, sumweights));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    R_xlen_t itmp = 0;@\\
\mbox{}\verb@    for (R_xlen_t i = 0; i < XLENGTH(mysubset); i++) {@\\
\mbox{}\verb@        if (TYPEOF(weights) == REALSXP) {@\\
\mbox{}\verb@            for (R_xlen_t j = 0; j < REAL(weights)[(R_xlen_t) REAL(mysubset)[i] - 1]; j++)@\\
\mbox{}\verb@                REAL(ans)[itmp++] = REAL(mysubset)[i];@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            for (R_xlen_t j = 0; j < INTEGER(weights)[(R_xlen_t) REAL(mysubset)[i] - 1]; j++)@\\
\mbox{}\verb@                REAL(ans)[itmp++] = REAL(mysubset)[i];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb127b}{127b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_setup_subset@\nobreak\ \NWlink{nuweb37}{37}\NWlink{nuweb126b}{, 126b}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_setup_subset@\nobreak\ \NWlink{nuweb125a}{125a}, \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@Offset0@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@RC_Sums@\nobreak\ \NWlink{nuweb91a}{91a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@weights@\nobreak\ \NWlink{nuweb25b}{25b}, \verb@weights,@\nobreak\ \NWlink{nuweb25c}{25c}\NWlink{nuweb25d}{d}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{Permutation Helpers}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap261}\raggedright\small
\NWtarget{nuweb127b}{} $\langle\,${\itshape Permutations}\nobreak\ {\footnotesize {127b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_setup_subset}\nobreak\ {\footnotesize \NWlink{nuweb127a}{127a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_Permute}\nobreak\ {\footnotesize \NWlink{nuweb128a}{128a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_doPermute}\nobreak\ {\footnotesize \NWlink{nuweb128b}{128b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_PermuteBlock}\nobreak\ {\footnotesize \NWlink{nuweb129a}{129a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_doPermuteBlock}\nobreak\ {\footnotesize \NWlink{nuweb129b}{129b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap262}\raggedright\small
\NWtarget{nuweb128a}{} $\langle\,${\itshape C_Permute}\nobreak\ {\footnotesize {128a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_Permute@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    double *subset,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    double *ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    R_xlen_t n = Nsubset, j;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (R_xlen_t i = 0; i < Nsubset; i++) {@\\
\mbox{}\verb@        j = n * unif_rand();@\\
\mbox{}\verb@        ans[i] = subset[j];@\\
\mbox{}\verb@        subset[j] = subset[--n];@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb127b}{127b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_Permute@\nobreak\ \NWlink{nuweb128b}{128b}\NWlink{nuweb129a}{, 129a}.\item \NWtxtIdentsUsed\nobreak\  \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap263}\raggedright\small
\NWtarget{nuweb128b}{} $\langle\,${\itshape C_doPermute}\nobreak\ {\footnotesize {128b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_doPermute@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    double *subset,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    double *Nsubset_tmp,@\\
\mbox{}\verb@    double *perm@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    Memcpy(Nsubset_tmp, subset, Nsubset);@\\
\mbox{}\verb@    C_Permute(Nsubset_tmp, Nsubset, perm);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb127b}{127b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_doPermute@\nobreak\ \NWlink{nuweb37}{37}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_Permute@\nobreak\ \NWlink{nuweb128a}{128a}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap264}\raggedright\small
\NWtarget{nuweb129a}{} $\langle\,${\itshape C_PermuteBlock}\nobreak\ {\footnotesize {129a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_PermuteBlock@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    double *subset,@\\
\mbox{}\verb@    double *table,@\\
\mbox{}\verb@    int Nlevels,@\\
\mbox{}\verb@    double *ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *px, *pans;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    px = subset;@\\
\mbox{}\verb@    pans = ans;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (R_xlen_t j = 0; j < Nlevels; j++) {@\\
\mbox{}\verb@        if (table[j] > 0) {@\\
\mbox{}\verb@            C_Permute(px, (R_xlen_t) table[j], pans);@\\
\mbox{}\verb@            px += (R_xlen_t) table[j];@\\
\mbox{}\verb@            pans += (R_xlen_t) table[j];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb127b}{127b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_PermuteBlock@\nobreak\ \NWlink{nuweb129b}{129b}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_Permute@\nobreak\ \NWlink{nuweb128a}{128a}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap265}\raggedright\small
\NWtarget{nuweb129b}{} $\langle\,${\itshape C_doPermuteBlock}\nobreak\ {\footnotesize {129b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_doPermuteBlock@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    double *subset,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Nsubset Input}\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    double *table,@\\
\mbox{}\verb@    int Nlevels,@\\
\mbox{}\verb@    double *Nsubset_tmp,@\\
\mbox{}\verb@    double *perm@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    Memcpy(Nsubset_tmp, subset, Nsubset);@\\
\mbox{}\verb@    C_PermuteBlock(Nsubset_tmp, table, Nlevels, perm);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb127b}{127b}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_doPermuteBlock@\nobreak\ \NWlink{nuweb37}{37}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_PermuteBlock@\nobreak\ \NWlink{nuweb129a}{129a}, \verb@Nsubset@\nobreak\ \NWlink{nuweb26b}{26b}, \verb@subset@\nobreak\ \NWlink{nuweb26a}{26a}\NWlink{nuweb26d}{d}\NWlink{nuweb26e}{e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\subsection{Other Utils}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap266}\raggedright\small
\NWtarget{nuweb130a}{} $\langle\,${\itshape MoreUtils}\nobreak\ {\footnotesize {130a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape NROW}\nobreak\ {\footnotesize \NWlink{nuweb130b}{130b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape NCOL}\nobreak\ {\footnotesize \NWlink{nuweb131a}{131a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape NLEVELS}\nobreak\ {\footnotesize \NWlink{nuweb131b}{131b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_kronecker}\nobreak\ {\footnotesize \NWlink{nuweb134}{134}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_kronecker}\nobreak\ {\footnotesize \NWlink{nuweb133b}{133b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_kronecker_sym}\nobreak\ {\footnotesize \NWlink{nuweb135}{135}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_KronSums_sym}\nobreak\ {\footnotesize \NWlink{nuweb136a}{136a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_MPinv_sym}\nobreak\ {\footnotesize \NWlink{nuweb138}{138}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_MPinv_sym}\nobreak\ {\footnotesize \NWlink{nuweb137b}{137b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_unpack_sym}\nobreak\ {\footnotesize \NWlink{nuweb140}{140}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_pack_sym}\nobreak\ {\footnotesize \NWlink{nuweb141c}{141c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap267}\raggedright\small
\NWtarget{nuweb130b}{} $\langle\,${\itshape NROW}\nobreak\ {\footnotesize {130b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@R_xlen_t NROW@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    SEXP x@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    SEXP a;@\\
\mbox{}\verb@    R_xlen_t ret;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(a = getAttrib(x, R_DimSymbol)); // rchk warning@\\
\mbox{}\verb@    if (a == R_NilValue) {@\\
\mbox{}\verb@        UNPROTECT(1);@\\
\mbox{}\verb@        return(XLENGTH(x));@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    if (TYPEOF(a) == REALSXP) {@\\
\mbox{}\verb@        ret = (R_xlen_t) REAL(a)[0];@\\
\mbox{}\verb@        UNPROTECT(1);@\\
\mbox{}\verb@        return(ret);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    ret = (R_xlen_t) INTEGER(a)[0];@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ret);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@NROW@\nobreak\ \NWlink{nuweb6}{6}\NWlink{nuweb8}{, 8}\NWlink{nuweb9a}{, 9a}\NWlink{nuweb9b}{b}\NWlink{nuweb14}{, 14}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb37}{, 37}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb61b}{, 61b}\NWlink{nuweb131b}{, 131b}\NWlink{nuweb133b}{, 133b}\NWlink{nuweb141c}{, 141c}.\item \NWtxtIdentsUsed\nobreak\  \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap268}\raggedright\small
\NWtarget{nuweb131a}{} $\langle\,${\itshape NCOL}\nobreak\ {\footnotesize {131a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int NCOL@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    SEXP x@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    SEXP a;@\\
\mbox{}\verb@    int ret;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(a = getAttrib(x, R_DimSymbol));  // rchk warning@\\
\mbox{}\verb@    if (a == R_NilValue) {@\\
\mbox{}\verb@        UNPROTECT(1);@\\
\mbox{}\verb@        return(1);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    if (TYPEOF(a) == REALSXP) {@\\
\mbox{}\verb@        ret = (int) REAL(a)[1];@\\
\mbox{}\verb@        UNPROTECT(1);@\\
\mbox{}\verb@        return(ret);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    ret = INTEGER(a)[1];@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ret);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@NCOL@\nobreak\ \NWlink{nuweb12}{12}\NWlink{nuweb31b}{, 31b}\NWlink{nuweb41b}{, 41b}\NWlink{nuweb61b}{, 61b}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb133b}{, 133b}.\item \NWtxtIdentsUsed\nobreak\  \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap269}\raggedright\small
\NWtarget{nuweb131b}{} $\langle\,${\itshape NLEVELS}\nobreak\ {\footnotesize {131b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int NLEVELS@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    SEXP x@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    SEXP a;@\\
\mbox{}\verb@    int maxlev = 0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(a = getAttrib(x, R_LevelsSymbol));@\\
\mbox{}\verb@    if (a == R_NilValue) {@\\
\mbox{}\verb@        if (TYPEOF(x) != INTSXP)@\\
\mbox{}\verb@            error("cannot determine number of levels");@\\
\mbox{}\verb@        for (R_xlen_t i = 0; i < XLENGTH(x); i++) {@\\
\mbox{}\verb@            if (INTEGER(x)[i] > maxlev)@\\
\mbox{}\verb@                maxlev = INTEGER(x)[i];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        UNPROTECT(1);@\\
\mbox{}\verb@        return(maxlev);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    maxlev = NROW(a);@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(maxlev);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@NLEVELS@\nobreak\ \NWlink{nuweb31b}{31b}\NWlink{nuweb41b}{, 41b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb123c}{, 123c}.\item \NWtxtIdentsUsed\nobreak\  \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Check for integer overflow when computing $P (P + 1) / 2$ and $P Q$.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap270}\raggedright\small
\NWtarget{nuweb132a}{} $\langle\,${\itshape PP12}\nobreak\ {\footnotesize {132a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int PP12@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    int P@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double dP = (double) P;@\\
\mbox{}\verb@    double ans;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    ans = dP * (dP + 1) / 2;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (ans > INT_MAX)@\\
\mbox{}\verb@        error("cannot allocate memory: number of levels too large");@\\
\mbox{}\verb@@\\
\mbox{}\verb@    return((int) ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@PP12@\nobreak\ \NWlink{nuweb34a}{34a}\NWlink{nuweb44}{, 44}\NWlink{nuweb46}{, 46}\NWlink{nuweb51}{, 51}\NWlink{nuweb79}{, 79}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb149}{, 149}\NWlink{nuweb150a}{, 150a}.\item \NWtxtIdentsUsed\nobreak\  \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap271}\raggedright\small
\NWtarget{nuweb132b}{} $\langle\,${\itshape mPQB}\nobreak\ {\footnotesize {132b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int mPQB@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    int P,@\\
\mbox{}\verb@    int Q,@\\
\mbox{}\verb@    int B@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double ans = P * Q * B;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (ans > INT_MAX)@\\
\mbox{}\verb@        error("cannot allocate memory: number of levels too large");@\\
\mbox{}\verb@@\\
\mbox{}\verb@    return((int) ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@mPQB@\nobreak\ \NWlink{nuweb36a}{36a}\NWlink{nuweb37}{, 37}\NWlink{nuweb45}{, 45}\NWlink{nuweb48}{, 48}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb71}{, 71}\NWlink{nuweb73a}{, 73a}\NWlink{nuweb76b}{, 76b}\NWlink{nuweb78b}{, 78b}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb149}{, 149}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<kronecker>>=
A <- matrix(runif(12), ncol = 3)
B <- matrix(runif(10), ncol = 2)

K1 <- kronecker(A, B)
K2 <- .Call(libcoin:::R_kronecker, A, B)

stopifnot(isequal(K1, K2))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap272}\raggedright\small
\NWtarget{nuweb132c}{} $\langle\,${\itshape R_kronecker Prototype}\nobreak\ {\footnotesize {132c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_kronecker@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    SEXP A,@\\
\mbox{}\verb@    SEXP B@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb133b}{, 133b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap273}\raggedright\small
\NWtarget{nuweb133a}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {133a}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_kronecker(@\\
\mbox{}\verb@    SEXP A, SEXP B@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_kronecker");@\\
\mbox{}\verb@    return fun(A, B);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap274}\raggedright\small
\NWtarget{nuweb133b}{} $\langle\,${\itshape R_kronecker}\nobreak\ {\footnotesize {133b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_kronecker Prototype}\nobreak\ {\footnotesize \NWlink{nuweb132c}{132c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    int m, n, r, s;@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (!isReal(A) || !isReal(B))@\\
\mbox{}\verb@        error("R_kronecker: A and / or B are not of type REALSXP");@\\
\mbox{}\verb@@\\
\mbox{}\verb@    m = NROW(A);@\\
\mbox{}\verb@    n = NCOL(A);@\\
\mbox{}\verb@    r = NROW(B);@\\
\mbox{}\verb@    s = NCOL(B);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocMatrix(REALSXP, m * n, r * s));@\\
\mbox{}\verb@    C_kronecker(REAL(A), m, n, REAL(B), r, s, 1, REAL(ans));@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@C_kronecker@\nobreak\ \NWlink{nuweb134}{134}, \verb@NCOL@\nobreak\ \NWlink{nuweb131a}{131a}, \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap275}\raggedright\small
\NWtarget{nuweb134}{} $\langle\,${\itshape C_kronecker}\nobreak\ {\footnotesize {134}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_kronecker@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const double *A,@\\
\mbox{}\verb@    const int m,@\\
\mbox{}\verb@    const int n,@\\
\mbox{}\verb@    const double *B,@\\
\mbox{}\verb@    const int r,@\\
\mbox{}\verb@    const int s,@\\
\mbox{}\verb@    const int overwrite,@\\
\mbox{}\verb@    double *ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int mr, js, ir;@\\
\mbox{}\verb@    double y;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (overwrite) {@\\
\mbox{}\verb@        for (int i = 0; i < m * r * n * s; i++) ans[i] = 0.0;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    mr = m * r;@\\
\mbox{}\verb@    for (int i = 0; i < m; i++) {@\\
\mbox{}\verb@        ir = i * r;@\\
\mbox{}\verb@        for (int j = 0; j < n; j++) {@\\
\mbox{}\verb@            js = j * s;@\\
\mbox{}\verb@            y = A[j*m + i];@\\
\mbox{}\verb@            for (int k = 0; k < r; k++) {@\\
\mbox{}\verb@                for (int l = 0; l < s; l++)@\\
\mbox{}\verb@                    ans[(js + l) * mr + ir + k] += y * B[l * r + k];@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_kronecker@\nobreak\ \NWlink{nuweb80a}{80a}\NWlink{nuweb133b}{, 133b}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap276}\raggedright\small
\NWtarget{nuweb135}{} $\langle\,${\itshape C_kronecker_sym}\nobreak\ {\footnotesize {135}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_kronecker_sym@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const double *A,@\\
\mbox{}\verb@    const int m,@\\
\mbox{}\verb@    const double *B,@\\
\mbox{}\verb@    const int r,@\\
\mbox{}\verb@    const int overwrite,@\\
\mbox{}\verb@    double *ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int mr, js, ir, s;@\\
\mbox{}\verb@    double y;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    mr = m * r;@\\
\mbox{}\verb@    s = r;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (overwrite) {@\\
\mbox{}\verb@        for (int i = 0; i < mr * (mr + 1) / 2; i++) ans[i] = 0.0;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int i = 0; i < m; i++) {@\\
\mbox{}\verb@        ir = i * r;@\\
\mbox{}\verb@        for (int j = 0; j <= i; j++) {@\\
\mbox{}\verb@            js = j * s;@\\
\mbox{}\verb@            y = A[S(i, j, m)];@\\
\mbox{}\verb@            for (int k = 0; k < r; k++) {@\\
\mbox{}\verb@                for (int l = 0; l < (j < i ? s : k + 1); l++) {@\\
\mbox{}\verb@                    ans[S(ir + k, js + l, mr)] += y * B[S(k, l, r)];@\\
\mbox{}\verb@                }@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_kronecker_sym@\nobreak\ \NWlink{nuweb79}{79}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@y@\nobreak\ \NWlink{nuweb24d}{24d}\NWlink{nuweb24f}{f}\NWlink{nuweb25a}{, 25a}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap277}\raggedright\small
\NWtarget{nuweb136a}{} $\langle\,${\itshape C_KronSums_sym}\nobreak\ {\footnotesize {136a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/* sum_i (t(x[i,]) %*% x[i,]) */@\\
\mbox{}\verb@void C_KronSums_sym_@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C real x Input}\nobreak\ {\footnotesize \NWlink{nuweb24b}{24b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@    double *PP_sym_ans@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int pN, qN, SpqP;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (int q = 0; q < P; q++) {@\\
\mbox{}\verb@        qN = q * N;@\\
\mbox{}\verb@        for (int p = 0; p <= q; p++) {@\\
\mbox{}\verb@            PP_sym_ans[S(p, q, P)] = 0.0;@\\
\mbox{}\verb@            pN = p * N;@\\
\mbox{}\verb@            SpqP = S(p, q, P);@\\
\mbox{}\verb@            for (int i = 0; i < N; i++)@\\
\mbox{}\verb@                 PP_sym_ans[SpqP] += x[qN + i] * x[pN + i];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_KronSums_sym@\nobreak\ \NWtxtIdentsNotUsed.\item \NWtxtIdentsUsed\nobreak\  \verb@N@\nobreak\ \NWlink{nuweb23b}{23b}\NWlink{nuweb23c}{c}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<MPinv>>=
covar <- vcov(ls1)
covar_sym <- ls1$Covariance
n <- (sqrt(1 + 8 * length(covar_sym)) - 1) / 2

tol <- sqrt(.Machine$double.eps)
MP1 <- MPinverse(covar, tol)
MP2 <- .Call(libcoin:::R_MPinv_sym, covar_sym, as.integer(n), tol)

lt <- lower.tri(covar, diag = TRUE)
stopifnot(isequal(MP1$MPinv[lt], MP2$MPinv) &&
          isequal(MP1$rank, MP2$rank))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap278}\raggedright\small
\NWtarget{nuweb136b}{} $\langle\,${\itshape R_MPinv_sym Prototype}\nobreak\ {\footnotesize {136b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_MPinv_sym@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    SEXP x,@\\
\mbox{}\verb@    SEXP n,@\\
\mbox{}\verb@    SEXP tol@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb137b}{, 137b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_MPinv_sym@\nobreak\ \NWlink{nuweb137b}{137b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap279}\raggedright\small
\NWtarget{nuweb137a}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {137a}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_MPinv_sym(@\\
\mbox{}\verb@    SEXP x, SEXP n, SEXP tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP, SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_MPinv_sym");@\\
\mbox{}\verb@    return fun(x, n, tol);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_MPinv_sym@\nobreak\ \NWlink{nuweb137b}{137b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap280}\raggedright\small
\NWtarget{nuweb137b}{} $\langle\,${\itshape R_MPinv_sym}\nobreak\ {\footnotesize {137b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_MPinv_sym Prototype}\nobreak\ {\footnotesize \NWlink{nuweb136b}{136b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    int m;@\\
\mbox{}\verb@    SEXP ans, names, MPinv, rank;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    m = INTEGER(n)[0];@\\
\mbox{}\verb@    if (m == 0)@\\
\mbox{}\verb@        m = (int) (sqrt(0.25 + 2 * LENGTH(x)) - 0.5);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(ans = allocVector(VECSXP, 2));@\\
\mbox{}\verb@    PROTECT(names = allocVector(STRSXP, 2));@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, 0, MPinv = allocVector(REALSXP, LENGTH(x)));@\\
\mbox{}\verb@    SET_STRING_ELT(names, 0, mkChar("MPinv"));@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, 1, rank = allocVector(INTSXP, 1));@\\
\mbox{}\verb@    SET_STRING_ELT(names, 1, mkChar("rank"));@\\
\mbox{}\verb@    namesgets(ans, names);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    C_MPinv_sym(REAL(x), m, REAL(tol)[0], REAL(MPinv), INTEGER(rank));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_MPinv_sym@\nobreak\ \NWlink{nuweb136b}{136b}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap281}\raggedright\small
\NWtarget{nuweb138}{} $\langle\,${\itshape C_MPinv_sym}\nobreak\ {\footnotesize {138}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@void C_MPinv_sym@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    const double *x,@\\
\mbox{}\verb@    const int n,@\\
\mbox{}\verb@    const double tol,@\\
\mbox{}\verb@    double *dMP,@\\
\mbox{}\verb@    int *rank@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    double *val, *vec, dtol, *rx, *work, valinv;@\\
\mbox{}\verb@    int valzero = 0, info = 0, kn;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (n == 1) {@\\
\mbox{}\verb@        if (x[0] > tol) {@\\
\mbox{}\verb@            dMP[0] = 1 / x[0];@\\
\mbox{}\verb@            rank[0] = 1;@\\
\mbox{}\verb@        } else {@\\
\mbox{}\verb@            dMP[0] = 0;@\\
\mbox{}\verb@            rank[0] = 0;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        rx = R_Calloc(n * (n + 1) / 2, double);@\\
\mbox{}\verb@        Memcpy(rx, x, n * (n + 1) / 2);@\\
\mbox{}\verb@        work = R_Calloc(3 * n, double);@\\
\mbox{}\verb@        val = R_Calloc(n, double);@\\
\mbox{}\verb@        vec = R_Calloc(n * n, double);@\\
\mbox{}\verb@@\\
\mbox{}\verb@        F77_CALL(dspev)("V", "L", &n, rx, val, vec, &n, work,@\\
\mbox{}\verb@                        &info FCONE FCONE);@\\
\mbox{}\verb@@\\
\mbox{}\verb@        dtol = val[n - 1] * tol;@\\
\mbox{}\verb@@\\
\mbox{}\verb@        for (int k = 0; k < n; k++)@\\
\mbox{}\verb@            valzero += (val[k] < dtol);@\\
\mbox{}\verb@        rank[0] = n - valzero;@\\
\mbox{}\verb@@\\
\mbox{}\verb@        for (int k = 0; k < n * (n + 1) / 2; k++) dMP[k] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@        for (int k = valzero; k < n; k++) {@\\
\mbox{}\verb@            valinv = 1 / val[k];@\\
\mbox{}\verb@            kn = k * n;@\\
\mbox{}\verb@            for (int i = 0; i < n; i++) {@\\
\mbox{}\verb@                for (int j = 0; j <= i; j++) {@\\
\mbox{}\verb@                    /* MP is symmetric */@\\
\mbox{}\verb@                    dMP[S(i, j, n)] += valinv * vec[kn + i] * vec[kn + j];@\\
\mbox{}\verb@                }@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        R_Free(rx); R_Free(work); R_Free(val); R_Free(vec);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsUsed\nobreak\  \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<unpack>>=
m <- matrix(c(3, 2, 1,
              2, 4, 2,
              1, 2, 5),
            ncol = 3)

s <- m[lower.tri(m, diag = TRUE)]
u1 <- .Call(libcoin:::R_unpack_sym, s, NULL, 0L)
u2 <- .Call(libcoin:::R_unpack_sym, s, NULL, 1L)

stopifnot(isequal(m, u1) && isequal(diag(m), u2))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap282}\raggedright\small
\NWtarget{nuweb139a}{} $\langle\,${\itshape R_unpack_sym Prototype}\nobreak\ {\footnotesize {139a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_unpack_sym@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    SEXP x,@\\
\mbox{}\verb@    SEXP names,@\\
\mbox{}\verb@    SEXP diagonly@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb140}{, 140}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_unpack_sym@\nobreak\ \NWlink{nuweb140}{140}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap283}\raggedright\small
\NWtarget{nuweb139b}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {139b}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_unpack_sym(@\\
\mbox{}\verb@    SEXP x, SEXP names, SEXP diagonly@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP, SEXP, SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP, SEXP, SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_unpack_sym");@\\
\mbox{}\verb@    return fun(x, names, diagonly);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_unpack_sym@\nobreak\ \NWlink{nuweb140}{140}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap284}\raggedright\small
\NWtarget{nuweb140}{} $\langle\,${\itshape R_unpack_sym}\nobreak\ {\footnotesize {140}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_unpack_sym Prototype}\nobreak\ {\footnotesize \NWlink{nuweb139a}{139a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    R_xlen_t n, k = 0;@\\
\mbox{}\verb@    SEXP ans, dimnames;@\\
\mbox{}\verb@    double *dx, *dans;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    /* m = n * (n + 1)/2 <=> n^2 + n - 2 * m = 0 */@\\
\mbox{}\verb@    n = sqrt(0.25 + 2 * XLENGTH(x)) - 0.5;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    dx = REAL(x);@\\
\mbox{}\verb@    if (INTEGER(diagonly)[0]) {@\\
\mbox{}\verb@        PROTECT(ans = allocVector(REALSXP, n));@\\
\mbox{}\verb@        if (names != R_NilValue) {@\\
\mbox{}\verb@            namesgets(ans, names);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        dans = REAL(ans);@\\
\mbox{}\verb@        for (R_xlen_t i = 0; i < n; i++) {@\\
\mbox{}\verb@            dans[i] = dx[k];@\\
\mbox{}\verb@            k += n - i;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    } else {@\\
\mbox{}\verb@        PROTECT(ans = allocMatrix(REALSXP, n, n));@\\
\mbox{}\verb@        if (names != R_NilValue) {@\\
\mbox{}\verb@            PROTECT(dimnames = allocVector(VECSXP, 2));@\\
\mbox{}\verb@            SET_VECTOR_ELT(dimnames, 0, names);@\\
\mbox{}\verb@            SET_VECTOR_ELT(dimnames, 1, names);@\\
\mbox{}\verb@            dimnamesgets(ans, dimnames);@\\
\mbox{}\verb@            UNPROTECT(1);@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        dans = REAL(ans);@\\
\mbox{}\verb@        for (R_xlen_t i = 0; i < n; i++) {@\\
\mbox{}\verb@            dans[i * n + i] = dx[k];     /* diagonal */@\\
\mbox{}\verb@            k++;@\\
\mbox{}\verb@            for (R_xlen_t j = i + 1; j < n; j++) {@\\
\mbox{}\verb@                dans[i * n + j] = dx[k]; /* lower triangular */@\\
\mbox{}\verb@                dans[j * n + i] = dx[k]; /* upper triangular */@\\
\mbox{}\verb@                k++;@\\
\mbox{}\verb@            }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return ans;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_unpack_sym@\nobreak\ \NWlink{nuweb10}{10}\NWlink{nuweb139a}{, 139a}\NWlink{nuweb139b}{b}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
<<pack>>=
m <- matrix(c(4, 3, 2, 1,
              3, 5, 4, 2,
              2, 4, 6, 5,
              1, 2, 5, 7),
            ncol = 4)

s <- m[lower.tri(m, diag = TRUE)]
p <- .Call(libcoin:::R_pack_sym, m)

stopifnot(isequal(s, p))
@

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap285}\raggedright\small
\NWtarget{nuweb141a}{} $\langle\,${\itshape R_pack_sym Prototype}\nobreak\ {\footnotesize {141a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP R_pack_sym@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    SEXP x@\\
\mbox{}\verb@)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb22b}{22b}\NWlink{nuweb141c}{, 141c}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_pack_sym@\nobreak\ \NWlink{nuweb141c}{141c}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
This function can be called from other packages.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap286}\raggedright\small
\NWtarget{nuweb141b}{} \verb@"libcoinAPI.h"@\nobreak\ {\footnotesize {141b}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@extern SEXP libcoin_R_pack_sym(@\\
\mbox{}\verb@    SEXP x@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    static SEXP(*fun)(SEXP) = NULL;@\\
\mbox{}\verb@    if (fun == NULL)@\\
\mbox{}\verb@        fun = (SEXP(*)(SEXP))@\\
\mbox{}\verb@            R_GetCCallable("libcoin", "R_pack_sym");@\\
\mbox{}\verb@    return fun(x);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtFileDefBy\ \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
\item \NWtxtIdentsUsed\nobreak\  \verb@R_pack_sym@\nobreak\ \NWlink{nuweb141c}{141c}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap287}\raggedright\small
\NWtarget{nuweb141c}{} $\langle\,${\itshape R_pack_sym}\nobreak\ {\footnotesize {141c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R_pack_sym Prototype}\nobreak\ {\footnotesize \NWlink{nuweb141a}{141a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@{@\\
\mbox{}\verb@    R_xlen_t n, k = 0;@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@    double *dx, *dans;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    n = NROW(x);@\\
\mbox{}\verb@    dx = REAL(x);@\\
\mbox{}\verb@    PROTECT(ans = allocVector(REALSXP, n * (n + 1) / 2));@\\
\mbox{}\verb@    dans = REAL(ans);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    for (R_xlen_t i = 0; i < n; i++) {@\\
\mbox{}\verb@        for (R_xlen_t j = i; j < n; j++) {@\\
\mbox{}\verb@          dans[k] = dx[i * n + j];@\\
\mbox{}\verb@          k++;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(1);@\\
\mbox{}\verb@    return ans;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb130a}{130a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@R_pack_sym@\nobreak\ \NWlink{nuweb141a}{141a}\NWlink{nuweb141b}{b}\NWlink{nuweb154}{, 154}.\item \NWtxtIdentsUsed\nobreak\  \verb@NROW@\nobreak\ \NWlink{nuweb130b}{130b}, \verb@x@\nobreak\ \NWlink{nuweb23d}{23d}\NWlink{nuweb24b}{, 24b}\NWlink{nuweb24c}{c}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\section{Memory}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap288}\raggedright\small
\NWtarget{nuweb142a}{} $\langle\,${\itshape Memory}\nobreak\ {\footnotesize {142a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_P}\nobreak\ {\footnotesize \NWlink{nuweb142c}{142c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_Q}\nobreak\ {\footnotesize \NWlink{nuweb143a}{143a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape PP12}\nobreak\ {\footnotesize \NWlink{nuweb132a}{132a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape mPQB}\nobreak\ {\footnotesize \NWlink{nuweb132b}{132b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_varonly}\nobreak\ {\footnotesize \NWlink{nuweb143b}{143b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_Xfactor}\nobreak\ {\footnotesize \NWlink{nuweb143c}{143c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_LinearStatistic}\nobreak\ {\footnotesize \NWlink{nuweb143d}{143d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_Expectation}\nobreak\ {\footnotesize \NWlink{nuweb144a}{144a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_Variance}\nobreak\ {\footnotesize \NWlink{nuweb144b}{144b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_Covariance}\nobreak\ {\footnotesize \NWlink{nuweb144c}{144c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_ExpectationX}\nobreak\ {\footnotesize \NWlink{nuweb145a}{145a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_ExpectationInfluence}\nobreak\ {\footnotesize \NWlink{nuweb145b}{145b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_CovarianceInfluence}\nobreak\ {\footnotesize \NWlink{nuweb145c}{145c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_VarianceInfluence}\nobreak\ {\footnotesize \NWlink{nuweb145d}{145d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_TableBlock}\nobreak\ {\footnotesize \NWlink{nuweb146a}{146a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_Sumweights}\nobreak\ {\footnotesize \NWlink{nuweb146b}{146b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_Table}\nobreak\ {\footnotesize \NWlink{nuweb146c}{146c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_dimTable}\nobreak\ {\footnotesize \NWlink{nuweb146d}{146d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_B}\nobreak\ {\footnotesize \NWlink{nuweb147a}{147a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_nresample}\nobreak\ {\footnotesize \NWlink{nuweb147b}{147b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_PermutedLinearStatistic}\nobreak\ {\footnotesize \NWlink{nuweb147c}{147c}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C_get_tol}\nobreak\ {\footnotesize \NWlink{nuweb147d}{147d}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_init_LECV_1d}\nobreak\ {\footnotesize \NWlink{nuweb150b}{150b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape RC_init_LECV_2d}\nobreak\ {\footnotesize \NWlink{nuweb151}{151}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb23a}{23a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap289}\raggedright\small
\NWtarget{nuweb142b}{} $\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize {142b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP LECV@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb50b}{50b}\NWlink{nuweb52b}{, 52b}\NWlink{nuweb142c}{, 142c}\NWlink{nuweb143a}{, 143a}\NWlink{nuweb143b}{b}\NWlink{nuweb143c}{c}\NWlink{nuweb143d}{d}\NWlink{nuweb144a}{, 144a}\NWlink{nuweb144b}{b}\NWlink{nuweb144c}{c}\NWlink{nuweb145a}{, 145a}\NWlink{nuweb145b}{b}\NWlink{nuweb145c}{c}\NWlink{nuweb145d}{d}\NWlink{nuweb146a}{, 146a}\NWlink{nuweb146b}{b}\NWlink{nuweb146c}{c}\NWlink{nuweb146d}{d}\NWlink{nuweb147a}{, 147a}\NWlink{nuweb147b}{b}\NWlink{nuweb147c}{c}\NWlink{nuweb147d}{d}.
\item \NWtxtIdentsDefed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb38b}{38b}\NWlink{nuweb38c}{c}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb51}{, 51}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb53}{, 53}\NWlink{nuweb54}{, 54}\NWlink{nuweb55a}{, 55a}\NWlink{nuweb55b}{b}\NWlink{nuweb56}{, 56}\NWlink{nuweb69b}{, 69b}\NWlink{nuweb71}{, 71}\NWlink{nuweb142c}{, 142c}\NWlink{nuweb143a}{, 143a}\NWlink{nuweb143b}{b}\NWlink{nuweb143c}{c}\NWlink{nuweb143d}{d}\NWlink{nuweb144a}{, 144a}\NWlink{nuweb144b}{b}\NWlink{nuweb144c}{c}\NWlink{nuweb145a}{, 145a}\NWlink{nuweb145b}{b}\NWlink{nuweb145c}{c}\NWlink{nuweb145d}{d}\NWlink{nuweb146a}{, 146a}\NWlink{nuweb146b}{b}\NWlink{nuweb146c}{c}\NWlink{nuweb146d}{d}\NWlink{nuweb147a}{, 147a}\NWlink{nuweb147b}{b}\NWlink{nuweb147c}{c}\NWlink{nuweb147d}{d}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap290}\raggedright\small
\NWtarget{nuweb142c}{} $\langle\,${\itshape C_get_P}\nobreak\ {\footnotesize {142c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int C_get_P@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(INTEGER(VECTOR_ELT(LECV, dim_SLOT))[0]);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_P@\nobreak\ \NWlink{nuweb33a}{33a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb46}{, 46}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb56}{, 56}\NWlink{nuweb71}{, 71}\NWlink{nuweb144b}{, 144b}\NWlink{nuweb144c}{c}\NWlink{nuweb147b}{, 147b}.\item \NWtxtIdentsUsed\nobreak\  \verb@dim_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap291}\raggedright\small
\NWtarget{nuweb143a}{} $\langle\,${\itshape C_get_Q}\nobreak\ {\footnotesize {143a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int C_get_Q@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(INTEGER(VECTOR_ELT(LECV, dim_SLOT))[1]);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_Q@\nobreak\ \NWlink{nuweb33a}{33a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb46}{, 46}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb71}{, 71}\NWlink{nuweb144b}{, 144b}\NWlink{nuweb144c}{c}\NWlink{nuweb147b}{, 147b}.\item \NWtxtIdentsUsed\nobreak\  \verb@dim_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap292}\raggedright\small
\NWtarget{nuweb143b}{} $\langle\,${\itshape C_get_varonly}\nobreak\ {\footnotesize {143b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int C_get_varonly@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(INTEGER(VECTOR_ELT(LECV, varonly_SLOT))[0]);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_varonly@\nobreak\ \NWlink{nuweb32}{32}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb46}{, 46}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}\NWlink{nuweb144c}{, 144c}.\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@varonly_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap293}\raggedright\small
\NWtarget{nuweb143c}{} $\langle\,${\itshape C_get_Xfactor}\nobreak\ {\footnotesize {143c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int C_get_Xfactor@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(INTEGER(VECTOR_ELT(LECV, Xfactor_SLOT))[0]);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_Xfactor@\nobreak\ \NWlink{nuweb46}{46}.\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@Xfactor_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap294}\raggedright\small
\NWtarget{nuweb143d}{} $\langle\,${\itshape C_get_LinearStatistic}\nobreak\ {\footnotesize {143d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_LinearStatistic@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, LinearStatistic_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_LinearStatistic@\nobreak\ \NWlink{nuweb33b}{33b}\NWlink{nuweb45}{, 45}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}\NWlink{nuweb150a}{, 150a}.\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@LinearStatistic_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap295}\raggedright\small
\NWtarget{nuweb144a}{} $\langle\,${\itshape C_get_Expectation}\nobreak\ {\footnotesize {144a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_Expectation@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, Expectation_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_Expectation@\nobreak\ \NWlink{nuweb35a}{35a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}\NWlink{nuweb150a}{, 150a}.\item \NWtxtIdentsUsed\nobreak\  \verb@Expectation_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap296}\raggedright\small
\NWtarget{nuweb144b}{} $\langle\,${\itshape C_get_Variance}\nobreak\ {\footnotesize {144b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_Variance@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int PQ = C_get_P(LECV) * C_get_Q(LECV);@\\
\mbox{}\verb@    double *var, *covar;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (isNull(VECTOR_ELT(LECV, Variance_SLOT))) {@\\
\mbox{}\verb@        SET_VECTOR_ELT(LECV, Variance_SLOT,@\\
\mbox{}\verb@                       allocVector(REALSXP, PQ));@\\
\mbox{}\verb@        if (!isNull(VECTOR_ELT(LECV, Covariance_SLOT))) {@\\
\mbox{}\verb@            covar = REAL(VECTOR_ELT(LECV, Covariance_SLOT));@\\
\mbox{}\verb@            var = REAL(VECTOR_ELT(LECV, Variance_SLOT));@\\
\mbox{}\verb@            for (int p = 0; p < PQ; p++)@\\
\mbox{}\verb@                var[p] = covar[S(p, p, PQ)];@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, Variance_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_Variance@\nobreak\ \NWlink{nuweb35c}{35c}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}\NWlink{nuweb144c}{, 144c}\NWlink{nuweb150a}{, 150a}.\item \NWtxtIdentsUsed\nobreak\  \verb@Covariance_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@C_get_P@\nobreak\ \NWlink{nuweb142c}{142c}, \verb@C_get_Q@\nobreak\ \NWlink{nuweb143a}{143a}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@S@\nobreak\ \NWlink{nuweb21a}{21a}, \verb@Variance_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap297}\raggedright\small
\NWtarget{nuweb144c}{} $\langle\,${\itshape C_get_Covariance}\nobreak\ {\footnotesize {144c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_Covariance@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int PQ = C_get_P(LECV) * C_get_Q(LECV);@\\
\mbox{}\verb@    if (C_get_varonly(LECV) && PQ > 1)@\\
\mbox{}\verb@        error("Cannot extract covariance from variance only object");@\\
\mbox{}\verb@    if (C_get_varonly(LECV) && PQ == 1)@\\
\mbox{}\verb@        return(C_get_Variance(LECV));@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, Covariance_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_Covariance@\nobreak\ \NWlink{nuweb35d}{35d}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}\NWlink{nuweb150a}{, 150a}.\item \NWtxtIdentsUsed\nobreak\  \verb@Covariance_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@C_get_P@\nobreak\ \NWlink{nuweb142c}{142c}, \verb@C_get_Q@\nobreak\ \NWlink{nuweb143a}{143a}, \verb@C_get_Variance@\nobreak\ \NWlink{nuweb144b}{144b}, \verb@C_get_varonly@\nobreak\ \NWlink{nuweb143b}{143b}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap298}\raggedright\small
\NWtarget{nuweb145a}{} $\langle\,${\itshape C_get_ExpectationX}\nobreak\ {\footnotesize {145a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_ExpectationX@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, ExpectationX_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_ExpectationX@\nobreak\ \NWlink{nuweb34a}{34a}\NWlink{nuweb46}{, 46}\NWlink{nuweb71}{, 71}.\item \NWtxtIdentsUsed\nobreak\  \verb@ExpectationX_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap299}\raggedright\small
\NWtarget{nuweb145b}{} $\langle\,${\itshape C_get_ExpectationInfluence}\nobreak\ {\footnotesize {145b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_ExpectationInfluence@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, ExpectationInfluence_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_ExpectationInfluence@\nobreak\ \NWlink{nuweb34a}{34a}\NWlink{nuweb46}{, 46}\NWlink{nuweb150a}{, 150a}.\item \NWtxtIdentsUsed\nobreak\  \verb@ExpectationInfluence_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap300}\raggedright\small
\NWtarget{nuweb145c}{} $\langle\,${\itshape C_get_CovarianceInfluence}\nobreak\ {\footnotesize {145c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_CovarianceInfluence@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, CovarianceInfluence_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_CovarianceInfluence@\nobreak\ \NWlink{nuweb34a}{34a}\NWlink{nuweb44}{, 44}\NWlink{nuweb71}{, 71}\NWlink{nuweb150a}{, 150a}.\item \NWtxtIdentsUsed\nobreak\  \verb@CovarianceInfluence_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap301}\raggedright\small
\NWtarget{nuweb145d}{} $\langle\,${\itshape C_get_VarianceInfluence}\nobreak\ {\footnotesize {145d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_VarianceInfluence@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, VarianceInfluence_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_VarianceInfluence@\nobreak\ \NWlink{nuweb34a}{34a}\NWlink{nuweb44}{, 44}\NWlink{nuweb71}{, 71}\NWlink{nuweb150a}{, 150a}.\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@VarianceInfluence_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap302}\raggedright\small
\NWtarget{nuweb146a}{} $\langle\,${\itshape C_get_TableBlock}\nobreak\ {\footnotesize {146a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_TableBlock@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    if (VECTOR_ELT(LECV, TableBlock_SLOT) == R_NilValue)@\\
\mbox{}\verb@        error("object does not contain table block slot");@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, TableBlock_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_TableBlock@\nobreak\ \NWlink{nuweb34a}{34a}.\item \NWtxtIdentsUsed\nobreak\  \verb@block@\nobreak\ \NWlink{nuweb26f}{26f}\NWlink{nuweb27b}{, 27b}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@TableBlock_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap303}\raggedright\small
\NWtarget{nuweb146b}{} $\langle\,${\itshape C_get_Sumweights}\nobreak\ {\footnotesize {146b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_Sumweights@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    if (VECTOR_ELT(LECV, Sumweights_SLOT) == R_NilValue)@\\
\mbox{}\verb@        error("object does not contain sumweights slot");@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, Sumweights_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_Sumweights@\nobreak\ \NWlink{nuweb34a}{34a}\NWlink{nuweb46}{, 46}.\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@sumweights@\nobreak\ \NWlink{nuweb25e}{25e}, \verb@Sumweights_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap304}\raggedright\small
\NWtarget{nuweb146c}{} $\langle\,${\itshape C_get_Table}\nobreak\ {\footnotesize {146c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_Table@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    if (LENGTH(LECV) <= Table_SLOT)@\\
\mbox{}\verb@        error("Cannot extract table from object");@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, Table_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_Table@\nobreak\ \NWlink{nuweb41a}{41a}\NWlink{nuweb46}{, 46}.\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@Table_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap305}\raggedright\small
\NWtarget{nuweb146d}{} $\langle\,${\itshape C_get_dimTable}\nobreak\ {\footnotesize {146d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int* C_get_dimTable@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    if (LENGTH(LECV) <= Table_SLOT)@\\
\mbox{}\verb@        error("Cannot extract table from object");@\\
\mbox{}\verb@    return(INTEGER(getAttrib(VECTOR_ELT(LECV, Table_SLOT),@\\
\mbox{}\verb@                             R_DimSymbol)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_dimTable@\nobreak\ \NWlink{nuweb46}{46}\NWlink{nuweb147a}{, 147a}.\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@Table_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap306}\raggedright\small
\NWtarget{nuweb147a}{} $\langle\,${\itshape C_get_B}\nobreak\ {\footnotesize {147a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@int C_get_B@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    if (VECTOR_ELT(LECV, TableBlock_SLOT) != R_NilValue)@\\
\mbox{}\verb@        return(LENGTH(VECTOR_ELT(LECV, Sumweights_SLOT)));@\\
\mbox{}\verb@    return(C_get_dimTable(LECV)[2]);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_B@\nobreak\ \NWlink{nuweb33a}{33a}\NWlink{nuweb46}{, 46}\NWlink{nuweb71}{, 71}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_get_dimTable@\nobreak\ \NWlink{nuweb146d}{146d}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@Sumweights_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@TableBlock_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap307}\raggedright\small
\NWtarget{nuweb147b}{} $\langle\,${\itshape C_get_nresample}\nobreak\ {\footnotesize {147b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@R_xlen_t C_get_nresample@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    int PQ = C_get_P(LECV) * C_get_Q(LECV);@\\
\mbox{}\verb@    return(XLENGTH(VECTOR_ELT(LECV, PermutedLinearStatistic_SLOT)) / PQ);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_nresample@\nobreak\ \NWlink{nuweb39a}{39a}\NWlink{nuweb51}{, 51}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb54}{, 54}\NWlink{nuweb56}{, 56}\NWlink{nuweb71}{, 71}.\item \NWtxtIdentsUsed\nobreak\  \verb@C_get_P@\nobreak\ \NWlink{nuweb142c}{142c}, \verb@C_get_Q@\nobreak\ \NWlink{nuweb143a}{143a}, \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@PermutedLinearStatistic_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap308}\raggedright\small
\NWtarget{nuweb147c}{} $\langle\,${\itshape C_get_PermutedLinearStatistic}\nobreak\ {\footnotesize {147c}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double* C_get_PermutedLinearStatistic@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, PermutedLinearStatistic_SLOT)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_PermutedLinearStatistic@\nobreak\ \NWlink{nuweb39a}{39a}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}.\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@PermutedLinearStatistic_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap309}\raggedright\small
\NWtarget{nuweb147d}{} $\langle\,${\itshape C_get_tol}\nobreak\ {\footnotesize {147d}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@double C_get_tol@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R LECV Input}\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    return(REAL(VECTOR_ELT(LECV, tol_SLOT))[0]);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@C_get_tol@\nobreak\ \NWlink{nuweb39a}{39a}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}.\item \NWtxtIdentsUsed\nobreak\  \verb@LECV@\nobreak\ \NWlink{nuweb142b}{142b}, \verb@tol_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap310}\raggedright\small
\NWtarget{nuweb148a}{} $\langle\,${\itshape Memory Input Checks}\nobreak\ {\footnotesize {148a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@if (P <= 0)@\\
\mbox{}\verb@    error("P is not positive");@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (Q <= 0)@\\
\mbox{}\verb@    error("Q is not positive");@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (B <= 0)@\\
\mbox{}\verb@    error("B is not positive");@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (varonly < 0 || varonly > 1)@\\
\mbox{}\verb@    error("varonly is not 0 or 1");@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (Xfactor < 0 || Xfactor > 1)@\\
\mbox{}\verb@    error("Xfactor is not 0 or 1");@\\
\mbox{}\verb@@\\
\mbox{}\verb@if (tol <= DBL_MIN)@\\
\mbox{}\verb@    error("tol is not positive");@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb149}{149}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap311}\raggedright\small
\NWtarget{nuweb148b}{} $\langle\,${\itshape Memory Names}\nobreak\ {\footnotesize {148b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@PROTECT(names = allocVector(STRSXP, Table_SLOT + 1));@\\
\mbox{}\verb@SET_STRING_ELT(names, LinearStatistic_SLOT, mkChar("LinearStatistic"));@\\
\mbox{}\verb@SET_STRING_ELT(names, Expectation_SLOT, mkChar("Expectation"));@\\
\mbox{}\verb@SET_STRING_ELT(names, varonly_SLOT, mkChar("varonly"));@\\
\mbox{}\verb@SET_STRING_ELT(names, Variance_SLOT, mkChar("Variance"));@\\
\mbox{}\verb@SET_STRING_ELT(names, Covariance_SLOT, mkChar("Covariance"));@\\
\mbox{}\verb@SET_STRING_ELT(names, ExpectationX_SLOT, mkChar("ExpectationX"));@\\
\mbox{}\verb@SET_STRING_ELT(names, dim_SLOT, mkChar("dimension"));@\\
\mbox{}\verb@SET_STRING_ELT(names, ExpectationInfluence_SLOT,@\\
\mbox{}\verb@               mkChar("ExpectationInfluence"));@\\
\mbox{}\verb@SET_STRING_ELT(names, Xfactor_SLOT, mkChar("Xfactor"));@\\
\mbox{}\verb@SET_STRING_ELT(names, CovarianceInfluence_SLOT,@\\
\mbox{}\verb@               mkChar("CovarianceInfluence"));@\\
\mbox{}\verb@SET_STRING_ELT(names, VarianceInfluence_SLOT,@\\
\mbox{}\verb@               mkChar("VarianceInfluence"));@\\
\mbox{}\verb@SET_STRING_ELT(names, TableBlock_SLOT, mkChar("TableBlock"));@\\
\mbox{}\verb@SET_STRING_ELT(names, Sumweights_SLOT, mkChar("Sumweights"));@\\
\mbox{}\verb@SET_STRING_ELT(names, PermutedLinearStatistic_SLOT,@\\
\mbox{}\verb@               mkChar("PermutedLinearStatistic"));@\\
\mbox{}\verb@SET_STRING_ELT(names, StandardisedPermutedLinearStatistic_SLOT,@\\
\mbox{}\verb@               mkChar("StandardisedPermutedLinearStatistic"));@\\
\mbox{}\verb@SET_STRING_ELT(names, tol_SLOT, mkChar("tol"));@\\
\mbox{}\verb@SET_STRING_ELT(names, Table_SLOT, mkChar("Table"));@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb149}{149}.
\item \NWtxtIdentsUsed\nobreak\  \verb@CovarianceInfluence_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Covariance_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@dim_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@ExpectationInfluence_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@ExpectationX_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Expectation_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@LinearStatistic_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@PermutedLinearStatistic_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@StandardisedPermutedLinearStatistic_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Sumweights_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@TableBlock_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Table_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@tol_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@VarianceInfluence_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Variance_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@varonly_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Xfactor_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap312}\raggedright\small
\NWtarget{nuweb149}{} $\langle\,${\itshape R_init_LECV}\nobreak\ {\footnotesize {149}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP vo, d, names, tolerance, tmp;@\\
\mbox{}\verb@int PQ;@\\
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Memory Input Checks}\nobreak\ {\footnotesize \NWlink{nuweb148a}{148a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@PQ = mPQB(P, Q, 1);@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Memory Names}\nobreak\ {\footnotesize \NWlink{nuweb148b}{148b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@/* Table_SLOT is always last and only used in 2d case, ie omitted here */@\\
\mbox{}\verb@PROTECT(ans = allocVector(VECSXP, Table_SLOT + 1));@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, LinearStatistic_SLOT, allocVector(REALSXP, PQ));@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, Expectation_SLOT, allocVector(REALSXP, PQ));@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, varonly_SLOT, vo = allocVector(INTSXP, 1));@\\
\mbox{}\verb@INTEGER(vo)[0] = varonly;@\\
\mbox{}\verb@if (varonly) {@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, Variance_SLOT, tmp = allocVector(REALSXP, PQ));@\\
\mbox{}\verb@} else {@\\
\mbox{}\verb@    /* always return variance */@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, Variance_SLOT, tmp = allocVector(REALSXP, PQ));@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, Covariance_SLOT,@\\
\mbox{}\verb@                   tmp = allocVector(REALSXP, PP12(PQ)));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, ExpectationX_SLOT, allocVector(REALSXP, P));@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, dim_SLOT, d = allocVector(INTSXP, 2));@\\
\mbox{}\verb@INTEGER(d)[0] = P;@\\
\mbox{}\verb@INTEGER(d)[1] = Q;@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, ExpectationInfluence_SLOT,@\\
\mbox{}\verb@               tmp = allocVector(REALSXP, B * Q));@\\
\mbox{}\verb@for (int q = 0; q < B * Q; q++) REAL(tmp)[q] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@/* should always _both_ be there */@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, VarianceInfluence_SLOT,@\\
\mbox{}\verb@               tmp = allocVector(REALSXP, B * Q));@\\
\mbox{}\verb@for (int q = 0; q < B * Q; q++) REAL(tmp)[q] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, CovarianceInfluence_SLOT,@\\
\mbox{}\verb@               tmp = allocVector(REALSXP, B * Q * (Q + 1) / 2));@\\
\mbox{}\verb@for (int q = 0; q < B * Q * (Q + 1) / 2; q++) REAL(tmp)[q] = 0.0;@\\
\mbox{}\verb@@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, Xfactor_SLOT, allocVector(INTSXP, 1));@\\
\mbox{}\verb@INTEGER(VECTOR_ELT(ans, Xfactor_SLOT))[0] = Xfactor;@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, TableBlock_SLOT, tmp = allocVector(REALSXP, B + 1));@\\
\mbox{}\verb@for (int q = 0; q < B + 1; q++) REAL(tmp)[q] = 0.0;@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, Sumweights_SLOT, allocVector(REALSXP, B));@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, PermutedLinearStatistic_SLOT,@\\
\mbox{}\verb@               allocMatrix(REALSXP, 0, 0));@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, StandardisedPermutedLinearStatistic_SLOT,@\\
\mbox{}\verb@               allocMatrix(REALSXP, 0, 0));@\\
\mbox{}\verb@SET_VECTOR_ELT(ans, tol_SLOT, tolerance = allocVector(REALSXP, 1));@\\
\mbox{}\verb@REAL(tolerance)[0] = tol;@\\
\mbox{}\verb@namesgets(ans, names);@\\
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape Initialise Zero}\nobreak\ {\footnotesize \NWlink{nuweb150a}{150a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb150b}{150b}\NWlink{nuweb151}{, 151}.
\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@CovarianceInfluence_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Covariance_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@dim_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@ExpectationInfluence_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@ExpectationX_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Expectation_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@LinearStatistic_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@mPQB@\nobreak\ \NWlink{nuweb132b}{132b}, \verb@P@\nobreak\ \NWlink{nuweb24a}{24a}, \verb@PermutedLinearStatistic_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@PP12@\nobreak\ \NWlink{nuweb132a}{132a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}, \verb@StandardisedPermutedLinearStatistic_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Sumweights_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@TableBlock_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Table_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@tol_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@VarianceInfluence_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Variance_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@varonly_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@Xfactor_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap313}\raggedright\small
\NWtarget{nuweb150a}{} $\langle\,${\itshape Initialise Zero}\nobreak\ {\footnotesize {150a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/* set initial zeros */@\\
\mbox{}\verb@for (int p = 0; p < PQ; p++) {@\\
\mbox{}\verb@    C_get_LinearStatistic(ans)[p] = 0.0;@\\
\mbox{}\verb@    C_get_Expectation(ans)[p] = 0.0;@\\
\mbox{}\verb@    if (varonly)@\\
\mbox{}\verb@        C_get_Variance(ans)[p] = 0.0;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@if (!varonly) {@\\
\mbox{}\verb@    for (int p = 0; p < PP12(PQ); p++)@\\
\mbox{}\verb@        C_get_Covariance(ans)[p] = 0.0;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@for (int q = 0; q < Q; q++) {@\\
\mbox{}\verb@    C_get_ExpectationInfluence(ans)[q] = 0.0;@\\
\mbox{}\verb@    C_get_VarianceInfluence(ans)[q] = 0.0;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@for (int q = 0; q < Q * (Q + 1) / 2; q++)@\\
\mbox{}\verb@    C_get_CovarianceInfluence(ans)[q] = 0.0;@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb149}{149}.
\item \NWtxtIdentsUsed\nobreak\  \verb@C_get_Covariance@\nobreak\ \NWlink{nuweb144c}{144c}, \verb@C_get_CovarianceInfluence@\nobreak\ \NWlink{nuweb145c}{145c}, \verb@C_get_Expectation@\nobreak\ \NWlink{nuweb144a}{144a}, \verb@C_get_ExpectationInfluence@\nobreak\ \NWlink{nuweb145b}{145b}, \verb@C_get_LinearStatistic@\nobreak\ \NWlink{nuweb143d}{143d}, \verb@C_get_Variance@\nobreak\ \NWlink{nuweb144b}{144b}, \verb@C_get_VarianceInfluence@\nobreak\ \NWlink{nuweb145d}{145d}, \verb@PP12@\nobreak\ \NWlink{nuweb132a}{132a}, \verb@Q@\nobreak\ \NWlink{nuweb24e}{24e}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap314}\raggedright\small
\NWtarget{nuweb150b}{} $\langle\,${\itshape RC_init_LECV_1d}\nobreak\ {\footnotesize {150b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP RC_init_LECV_1d@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    int varonly,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer B Input}\nobreak\ {\footnotesize \NWlink{nuweb27a}{27a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    int Xfactor,@\\
\mbox{}\verb@    double tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    SEXP ans;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R_init_LECV}\nobreak\ {\footnotesize \NWlink{nuweb149}{149}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, TableBlock_SLOT,@\\
\mbox{}\verb@                   allocVector(REALSXP, B + 1));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, Sumweights_SLOT,@\\
\mbox{}\verb@                   allocVector(REALSXP, B));@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(2);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_init_LECV_1d@\nobreak\ \NWlink{nuweb31a}{31a}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@Sumweights_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}, \verb@TableBlock_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap315}\raggedright\small
\NWtarget{nuweb151}{} $\langle\,${\itshape RC_init_LECV_2d}\nobreak\ {\footnotesize {151}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@SEXP RC_init_LECV_2d@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer P Input}\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer Q Input}\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    int varonly,@\\
\mbox{}\verb@    int Lx,@\\
\mbox{}\verb@    int Ly,@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape C integer B Input}\nobreak\ {\footnotesize \NWlink{nuweb27a}{27a}}$\,\rangle$}\verb@,@\\
\mbox{}\verb@    int Xfactor,@\\
\mbox{}\verb@    double tol@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    SEXP ans, tabdim, tab;@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (Lx <= 0)@\\
\mbox{}\verb@        error("Lx is not positive");@\\
\mbox{}\verb@@\\
\mbox{}\verb@    if (Ly <= 0)@\\
\mbox{}\verb@        error("Ly is not positive");@\\
\mbox{}\verb@@\\
\mbox{}\verb@    @\hbox{$\langle\,${\itshape R_init_LECV}\nobreak\ {\footnotesize \NWlink{nuweb149}{149}}$\,\rangle$}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    PROTECT(tabdim = allocVector(INTSXP, 3));@\\
\mbox{}\verb@    INTEGER(tabdim)[0] = Lx + 1;@\\
\mbox{}\verb@    INTEGER(tabdim)[1] = Ly + 1;@\\
\mbox{}\verb@    INTEGER(tabdim)[2] = B;@\\
\mbox{}\verb@    SET_VECTOR_ELT(ans, Table_SLOT,@\\
\mbox{}\verb@                   tab = allocVector(REALSXP,@\\
\mbox{}\verb@                       INTEGER(tabdim)[0] *@\\
\mbox{}\verb@                       INTEGER(tabdim)[1] *@\\
\mbox{}\verb@                       INTEGER(tabdim)[2]));@\\
\mbox{}\verb@    dimgets(tab, tabdim);@\\
\mbox{}\verb@@\\
\mbox{}\verb@    UNPROTECT(3);@\\
\mbox{}\verb@    return(ans);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb142a}{142a}.
\item \NWtxtIdentsDefed\nobreak\  \verb@RC_init_LECV_2d@\nobreak\ \NWlink{nuweb41a}{41a}.\item \NWtxtIdentsUsed\nobreak\  \verb@B@\nobreak\ \NWlink{nuweb27a}{27a}, \verb@Table_SLOT@\nobreak\ \NWlink{nuweb21b}{21b}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\chapter{Package Infrastructure}

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap316}\raggedright\small
\NWtarget{nuweb152a}{} \verb@"AAA.R"@\nobreak\ {\footnotesize {152a}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape R Header}\nobreak\ {\footnotesize \NWlink{nuweb155a}{155a}}$\,\rangle$}\verb@@\\
\mbox{}\verb@.onUnload <-@\\
\mbox{}\verb@function(libpath)@\\
\mbox{}\verb@    library.dynam.unload("libcoin", libpath)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap317}\raggedright\small
\NWtarget{nuweb152b}{} \verb@"DESCRIPTION"@\nobreak\ {\footnotesize {152b}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@Package: libcoin@\\
\mbox{}\verb@Title: Linear Test Statistics for Permutation Inference@\\
\mbox{}\verb@Date: 20YY-MM-DD@\\
\mbox{}\verb@Version: 1.0-13@\\
\mbox{}\verb@Authors@{\tt @}\verb@R: c(person("Torsten", "Hothorn", role = c("aut", "cre"),@\\
\mbox{}\verb@                    email = "Torsten.Hothorn@{\tt @}\verb@R-project.org",@\\
\mbox{}\verb@                    comment = c(ORCID = "0000-0001-8301-0471")),@\\
\mbox{}\verb@             person("Henric", "Winell", role = "aut",@\\
\mbox{}\verb@                    comment = c(ORCID = "0000-0001-7995-3047")))@\\
\mbox{}\verb@Description: Basic infrastructure for linear test statistics and permutation@\\
\mbox{}\verb@  inference in the framework of Strasser and Weber (1999) <https://epub.wu.ac.at/102/>.@\\
\mbox{}\verb@  This package must not be used by end-users. CRAN package 'coin' implements all@\\
\mbox{}\verb@  user interfaces and is ready to be used by anyone.@\\
\mbox{}\verb@Depends: R (>= 3.4.0)@\\
\mbox{}\verb@Suggests: coin, bibtex@\\
\mbox{}\verb@Imports: stats, mvtnorm@\\
\mbox{}\verb@LinkingTo: mvtnorm@\\
\mbox{}\verb@NeedsCompilation: yes@\\
\mbox{}\verb@License: GPL-2@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap318}\raggedright\small
\NWtarget{nuweb152c}{} \verb@"NAMESPACE"@\nobreak\ {\footnotesize {152c}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@useDynLib(libcoin, .registration = TRUE)@\\
\mbox{}\verb@@\\
\mbox{}\verb@importFrom("stats", complete.cases, vcov)@\\
\mbox{}\verb@importFrom("mvtnorm", GenzBretz)@\\
\mbox{}\verb@@\\
\mbox{}\verb@export(LinStatExpCov, doTest, ctabs, lmult)@\\
\mbox{}\verb@@\\
\mbox{}\verb@S3method(vcov, LinStatExpCov)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Add flag \code{-g} to \code{PKG_CFLAGS} for \code{operf} profiling (this is
not portable).
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap319}\raggedright\small
\NWtarget{nuweb153a}{} \verb@"Makevars"@\nobreak\ {\footnotesize {153a}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@PKG_CFLAGS=$(C_VISIBILITY)@\\
\mbox{}\verb@PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap320}\raggedright\small
\NWtarget{nuweb153b}{} \verb@"libcoin-win.def"@\nobreak\ {\footnotesize {153b}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@LIBRARY libcoin.dll@\\
\mbox{}\verb@EXPORTS@\\
\mbox{}\verb@  R_init_libcoin@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
Other packages can link against \pkg{libcoin}. A small example package
is contained in \texttt{libcoin/inst/C_API_example}.

\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap321}\raggedright\small
\NWtarget{nuweb154}{} \verb@"libcoin-init.c"@\nobreak\ {\footnotesize {154}}$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@@\hbox{$\langle\,${\itshape C Header}\nobreak\ {\footnotesize \NWlink{nuweb155b}{155b}}$\,\rangle$}\verb@@\\
\mbox{}\verb@#include "libcoin.h"@\\
\mbox{}\verb@#include <R_ext/Rdynload.h>@\\
\mbox{}\verb@#include <R_ext/Visibility.h>@\\
\mbox{}\verb@@\\
\mbox{}\verb@#define CALLDEF(name, n) {#name, (DL_FUNC) &name, n}@\\
\mbox{}\verb@#define REGCALL(name) R_RegisterCCallable("libcoin", #name, (DL_FUNC) &name)@\\
\mbox{}\verb@@\\
\mbox{}\verb@static const R_CallMethodDef callMethods[] = {@\\
\mbox{}\verb@    CALLDEF(R_ExpectationCovarianceStatistic, 7),@\\
\mbox{}\verb@    CALLDEF(R_PermutedLinearStatistic, 6),@\\
\mbox{}\verb@    CALLDEF(R_StandardisePermutedLinearStatistic, 1),@\\
\mbox{}\verb@    CALLDEF(R_ExpectationCovarianceStatistic_2d, 9),@\\
\mbox{}\verb@    CALLDEF(R_PermutedLinearStatistic_2d, 7),@\\
\mbox{}\verb@    CALLDEF(R_QuadraticTest, 5),@\\
\mbox{}\verb@    CALLDEF(R_MaximumTest, 9),@\\
\mbox{}\verb@    CALLDEF(R_MaximallySelectedTest, 6),@\\
\mbox{}\verb@    CALLDEF(R_ExpectationInfluence, 3),@\\
\mbox{}\verb@    CALLDEF(R_CovarianceInfluence, 4),@\\
\mbox{}\verb@    CALLDEF(R_ExpectationX, 4),@\\
\mbox{}\verb@    CALLDEF(R_CovarianceX, 5),@\\
\mbox{}\verb@    CALLDEF(R_Sums, 3),@\\
\mbox{}\verb@    CALLDEF(R_KronSums, 6),@\\
\mbox{}\verb@    CALLDEF(R_KronSums_Permutation, 5),@\\
\mbox{}\verb@    CALLDEF(R_colSums, 3),@\\
\mbox{}\verb@    CALLDEF(R_OneTableSums, 3),@\\
\mbox{}\verb@    CALLDEF(R_TwoTableSums, 4),@\\
\mbox{}\verb@    CALLDEF(R_ThreeTableSums, 5),@\\
\mbox{}\verb@    CALLDEF(R_order_subset_wrt_block, 4),@\\
\mbox{}\verb@    CALLDEF(R_quadform, 3),@\\
\mbox{}\verb@    CALLDEF(R_kronecker, 2),@\\
\mbox{}\verb@    CALLDEF(R_MPinv_sym, 3),@\\
\mbox{}\verb@    CALLDEF(R_unpack_sym, 3),@\\
\mbox{}\verb@    CALLDEF(R_pack_sym, 1),@\\
\mbox{}\verb@    {NULL, NULL, 0}@\\
\mbox{}\verb@};@\\
\mbox{}\verb@@\\
\mbox{}\verb@void attribute_visible R_init_libcoin@\\
\mbox{}\verb@(@\\
\mbox{}\verb@    DllInfo *dll@\\
\mbox{}\verb@) {@\\
\mbox{}\verb@    R_registerRoutines(dll, NULL, callMethods, NULL, NULL);@\\
\mbox{}\verb@    R_useDynamicSymbols(dll, FALSE);@\\
\mbox{}\verb@    R_forceSymbols(dll, TRUE);@\\
\mbox{}\verb@    REGCALL(R_ExpectationCovarianceStatistic);@\\
\mbox{}\verb@    REGCALL(R_PermutedLinearStatistic);@\\
\mbox{}\verb@    REGCALL(R_StandardisePermutedLinearStatistic);@\\
\mbox{}\verb@    REGCALL(R_ExpectationCovarianceStatistic_2d);@\\
\mbox{}\verb@    REGCALL(R_PermutedLinearStatistic_2d);@\\
\mbox{}\verb@    REGCALL(R_QuadraticTest);@\\
\mbox{}\verb@    REGCALL(R_MaximumTest);@\\
\mbox{}\verb@    REGCALL(R_MaximallySelectedTest);@\\
\mbox{}\verb@    REGCALL(R_ExpectationInfluence);@\\
\mbox{}\verb@    REGCALL(R_CovarianceInfluence);@\\
\mbox{}\verb@    REGCALL(R_ExpectationX);@\\
\mbox{}\verb@    REGCALL(R_CovarianceX);@\\
\mbox{}\verb@    REGCALL(R_Sums);@\\
\mbox{}\verb@    REGCALL(R_KronSums);@\\
\mbox{}\verb@    REGCALL(R_KronSums_Permutation);@\\
\mbox{}\verb@    REGCALL(R_colSums);@\\
\mbox{}\verb@    REGCALL(R_OneTableSums);@\\
\mbox{}\verb@    REGCALL(R_TwoTableSums);@\\
\mbox{}\verb@    REGCALL(R_ThreeTableSums);@\\
\mbox{}\verb@    REGCALL(R_order_subset_wrt_block);@\\
\mbox{}\verb@    REGCALL(R_quadform);@\\
\mbox{}\verb@    REGCALL(R_kronecker);@\\
\mbox{}\verb@    REGCALL(R_MPinv_sym);@\\
\mbox{}\verb@    REGCALL(R_unpack_sym);@\\
\mbox{}\verb@    REGCALL(R_pack_sym);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtIdentsUsed\nobreak\  \verb@R_colSums@\nobreak\ \NWlink{nuweb106c}{106c}, \verb@R_CovarianceInfluence@\nobreak\ \NWlink{nuweb83a}{83a}, \verb@R_CovarianceX@\nobreak\ \NWlink{nuweb87a}{87a}, \verb@R_ExpectationCovarianceStatistic@\nobreak\ \NWlink{nuweb31a}{31a}, \verb@R_ExpectationCovarianceStatistic_2d@\nobreak\ \NWlink{nuweb41a}{41a}, \verb@R_ExpectationInfluence@\nobreak\ \NWlink{nuweb81a}{81a}, \verb@R_ExpectationX@\nobreak\ \NWlink{nuweb84c}{84c}, \verb@R_KronSums@\nobreak\ \NWlink{nuweb94b}{94b}, \verb@R_KronSums_Permutation@\nobreak\ \NWlink{nuweb102b}{102b}, \verb@R_MPinv_sym@\nobreak\ \NWlink{nuweb137b}{137b}, \verb@R_OneTableSums@\nobreak\ \NWlink{nuweb111a}{111a}, \verb@R_order_subset_wrt_block@\nobreak\ \NWlink{nuweb123c}{123c}, \verb@R_pack_sym@\nobreak\ \NWlink{nuweb141c}{141c}, \verb@R_PermutedLinearStatistic@\nobreak\ \NWlink{nuweb37}{37}, \verb@R_PermutedLinearStatistic_2d@\nobreak\ \NWlink{nuweb48}{48}, \verb@R_quadform@\nobreak\ \NWlink{nuweb61b}{61b}, \verb@R_Sums@\nobreak\ \NWlink{nuweb90a}{90a}, \verb@R_ThreeTableSums@\nobreak\ \NWlink{nuweb119b}{119b}, \verb@R_TwoTableSums@\nobreak\ \NWlink{nuweb115a}{115a}, \verb@R_unpack_sym@\nobreak\ \NWlink{nuweb140}{140}.
\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap322}\raggedright\small
\NWtarget{nuweb155a}{} $\langle\,${\itshape R Header}\nobreak\ {\footnotesize {155a}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@###    Copyright (C) 2016-2026 Torsten Hothorn@\\
\mbox{}\verb@###@\\
\mbox{}\verb@###    This file is part of the 'libcoin' R add-on package.@\\
\mbox{}\verb@###@\\
\mbox{}\verb@###    'libcoin' is free software: you can redistribute it and/or modify@\\
\mbox{}\verb@###    it under the terms of the GNU General Public License as published by@\\
\mbox{}\verb@###    the Free Software Foundation, version 2.@\\
\mbox{}\verb@###@\\
\mbox{}\verb@###    'libcoin' is distributed in the hope that it will be useful,@\\
\mbox{}\verb@###    but WITHOUT ANY WARRANTY; without even the implied warranty of@\\
\mbox{}\verb@###    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the@\\
\mbox{}\verb@###    GNU General Public License for more details.@\\
\mbox{}\verb@###@\\
\mbox{}\verb@###    You should have received a copy of the GNU General Public License@\\
\mbox{}\verb@###    along with 'libcoin'.  If not, see <http://www.gnu.org/licenses/>.@\\
\mbox{}\verb@###@\\
\mbox{}\verb@###@\\
\mbox{}\verb@###    DO NOT EDIT THIS FILE@\\
\mbox{}\verb@###@\\
\mbox{}\verb@###    Edit 'libcoin.w' and run 'nuweb -r libcoin.w'@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb3a}{3a}\NWlink{nuweb15b}{, 15b}\NWlink{nuweb152a}{, 152a}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth}\label{scrap323}\raggedright\small
\NWtarget{nuweb155b}{} $\langle\,${\itshape C Header}\nobreak\ {\footnotesize {155b}}$\,\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/*@\\
\mbox{}\verb@    Copyright (C) 2016-2026 Torsten Hothorn@\\
\mbox{}\verb@@\\
\mbox{}\verb@    This file is part of the 'libcoin' R add-on package.@\\
\mbox{}\verb@@\\
\mbox{}\verb@    'libcoin' is free software: you can redistribute it and/or modify@\\
\mbox{}\verb@    it under the terms of the GNU General Public License as published by@\\
\mbox{}\verb@    the Free Software Foundation, version 2.@\\
\mbox{}\verb@@\\
\mbox{}\verb@    'libcoin' is distributed in the hope that it will be useful,@\\
\mbox{}\verb@    but WITHOUT ANY WARRANTY; without even the implied warranty of@\\
\mbox{}\verb@    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the@\\
\mbox{}\verb@    GNU General Public License for more details.@\\
\mbox{}\verb@@\\
\mbox{}\verb@    You should have received a copy of the GNU General Public License@\\
\mbox{}\verb@    along with 'libcoin'.  If not, see <http://www.gnu.org/licenses/>.@\\
\mbox{}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@    DO NOT EDIT THIS FILE@\\
\mbox{}\verb@@\\
\mbox{}\verb@    Edit 'libcoin.w' and run 'nuweb -r libcoin.w'@\\
\mbox{}\verb@*/@\\
\mbox{}\verb@@{\NWsep}
\end{list}
\vspace{-1.5ex}
\footnotesize
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \NWtxtMacroRefIn\ \NWlink{nuweb20a}{20a}\NWlink{nuweb22a}{, 22a}\NWlink{nuweb22c}{c}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb154}{, 154}.

\item{}
\end{list}
\end{minipage}\vspace{4ex}
\end{flushleft}
\chapter*{Index}

\section*{Files}


{\small\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \verb@"AAA.R"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb152a}{152a}.}
\item \verb@"ctabs.R"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb15b}{15b}.}
\item \verb@"ctabs.Rd"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb19}{19}.}
\item \verb@"DESCRIPTION"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb152b}{152b}.}
\item \verb@"doTest.Rd"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb18}{18}.}
\item \verb@"libcoin-init.c"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb154}{154}.}
\item \verb@"libcoin-win.def"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb153b}{153b}.}
\item \verb@"libcoin.c"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb22c}{22c}.}
\item \verb@"libcoin.h"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb22a}{22a}.}
\item \verb@"libcoin.R"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb3a}{3a}.}
\item \verb@"libcoinAPI.h"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb30d}{30d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb38c}{, 38c}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb53}{, 53}\NWlink{nuweb55b}{, 55b}\NWlink{nuweb61a}{, 61a}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb139b}{, 139b}\NWlink{nuweb141b}{, 141b}.
}
\item \verb@"libcoin_internal.h"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb20a}{20a}.}
\item \verb@"LinStatExpCov.Rd"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb17}{17}.}
\item \verb@"Makevars"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb153a}{153a}.}
\item \verb@"NAMESPACE"@ {\footnotesize {\NWtxtDefBy} \NWlink{nuweb152c}{152c}.}
\end{list}}

\section*{Fragments}


{\small\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item $\langle\,$2d Covariance\nobreak\ {\footnotesize \NWlink{nuweb44}{44}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb45}{45}.}
\item $\langle\,$2d Expectation\nobreak\ {\footnotesize \NWlink{nuweb43b}{43b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb45}{45}.}
\item $\langle\,$2d Memory\nobreak\ {\footnotesize \NWlink{nuweb46}{46}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb45}{45}.}
\item $\langle\,$2d Total Table\nobreak\ {\footnotesize \NWlink{nuweb42b}{42b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb45}{45}.}
\item $\langle\,$2d User Interface\nobreak\ {\footnotesize \NWlink{nuweb39b}{39b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$2d User Interface Input\nobreak\ {\footnotesize \NWlink{nuweb39c}{39c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb40a}{40a}\NWlink{nuweb45}{, 45}.
}
\item $\langle\,$C colSums Answer\nobreak\ {\footnotesize \NWlink{nuweb108a}{108a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb81b}{81b}\NWlink{nuweb107a}{, 107a}\NWlink{nuweb108b}{, 108b}\NWlink{nuweb108c}{c}\NWlink{nuweb108d}{d}\NWlink{nuweb109a}{, 109a}.
}
\item $\langle\,$C colSums Input\nobreak\ {\footnotesize \NWlink{nuweb107c}{107c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb107a}{107a}\NWlink{nuweb108b}{, 108b}\NWlink{nuweb108c}{c}\NWlink{nuweb108d}{d}\NWlink{nuweb109a}{, 109a}.
}
\item $\langle\,$C Global Variables\nobreak\ {\footnotesize \NWlink{nuweb21b}{21b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb20a}{20a}.}
\item $\langle\,$C Header\nobreak\ {\footnotesize \NWlink{nuweb155b}{155b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb20a}{20a}\NWlink{nuweb22a}{, 22a}\NWlink{nuweb22c}{c}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb154}{, 154}.
}
\item $\langle\,$C integer B Input\nobreak\ {\footnotesize \NWlink{nuweb27a}{27a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb27b}{27b}\NWlink{nuweb32}{, 32}\NWlink{nuweb150b}{, 150b}\NWlink{nuweb151}{, 151}.
}
\item $\langle\,$C integer block Input\nobreak\ {\footnotesize \NWlink{nuweb27b}{27b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb120c}{120c}.}
\item $\langle\,$C integer N Input\nobreak\ {\footnotesize \NWlink{nuweb23c}{23c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb24b}{24b}\NWlink{nuweb24c}{c}\NWlink{nuweb32}{, 32}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81b}{b}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb83b}{b}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb87b}{b}\NWlink{nuweb90b}{, 90b}\NWlink{nuweb91b}{, 91b}\NWlink{nuweb92a}{, 92a}\NWlink{nuweb92b}{b}\NWlink{nuweb92c}{c}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb95c}{, 95c}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124a}{, 124a}\NWlink{nuweb125a}{, 125a}\NWlink{nuweb125b}{b}\NWlink{nuweb126b}{, 126b}.
}
\item $\langle\,$C integer Nsubset Input\nobreak\ {\footnotesize \NWlink{nuweb26b}{26b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb26c}{26c}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb128a}{, 128a}\NWlink{nuweb128b}{b}\NWlink{nuweb129b}{, 129b}.
}
\item $\langle\,$C integer P Input\nobreak\ {\footnotesize \NWlink{nuweb24a}{24a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb24b}{24b}\NWlink{nuweb24c}{c}\NWlink{nuweb32}{, 32}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb78b}{, 78b}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb95c}{, 95c}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb150b}{, 150b}\NWlink{nuweb151}{, 151}.
}
\item $\langle\,$C integer Q Input\nobreak\ {\footnotesize \NWlink{nuweb24e}{24e}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb24f}{24f}\NWlink{nuweb25a}{, 25a}\NWlink{nuweb32}{, 32}\NWlink{nuweb78b}{, 78b}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81b}{b}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb83b}{b}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb150b}{, 150b}\NWlink{nuweb151}{, 151}.
}
\item $\langle\,$C integer subset Input\nobreak\ {\footnotesize \NWlink{nuweb26d}{26d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb92b}{92b}\NWlink{nuweb92c}{c}\NWlink{nuweb98a}{, 98a}\NWlink{nuweb98b}{b}\NWlink{nuweb100d}{, 100d}\NWlink{nuweb101a}{, 101a}\NWlink{nuweb104b}{, 104b}\NWlink{nuweb105b}{, 105b}\NWlink{nuweb108d}{, 108d}\NWlink{nuweb109a}{, 109a}\NWlink{nuweb113b}{, 113b}\NWlink{nuweb113c}{c}\NWlink{nuweb117c}{, 117c}\NWlink{nuweb118a}{, 118a}\NWlink{nuweb121d}{, 121d}\NWlink{nuweb122a}{, 122a}.
}
\item $\langle\,$C integer weights Input\nobreak\ {\footnotesize \NWlink{nuweb25c}{25c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb92a}{92a}\NWlink{nuweb92b}{b}\NWlink{nuweb97c}{, 97c}\NWlink{nuweb98a}{, 98a}\NWlink{nuweb100c}{, 100c}\NWlink{nuweb100d}{d}\NWlink{nuweb108c}{, 108c}\NWlink{nuweb108d}{d}\NWlink{nuweb113a}{, 113a}\NWlink{nuweb113b}{b}\NWlink{nuweb117b}{, 117b}\NWlink{nuweb117c}{c}\NWlink{nuweb121c}{, 121c}\NWlink{nuweb121d}{d}.
}
\item $\langle\,$C integer x Input\nobreak\ {\footnotesize \NWlink{nuweb24c}{24c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb100a}{100a}\NWlink{nuweb105a}{, 105a}\NWlink{nuweb105b}{b}\NWlink{nuweb112b}{, 112b}\NWlink{nuweb116b}{, 116b}\NWlink{nuweb120c}{, 120c}.
}
\item $\langle\,$C integer y Input\nobreak\ {\footnotesize \NWlink{nuweb25a}{25a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb116b}{116b}\NWlink{nuweb120c}{, 120c}.
}
\item $\langle\,$C KronSums Answer\nobreak\ {\footnotesize \NWlink{nuweb96a}{96a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb77c}{77c}\NWlink{nuweb83b}{, 83b}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb95a}{, 95a}\NWlink{nuweb97b}{, 97b}\NWlink{nuweb97c}{c}\NWlink{nuweb98a}{, 98a}\NWlink{nuweb98b}{b}\NWlink{nuweb100b}{, 100b}\NWlink{nuweb100c}{c}\NWlink{nuweb100d}{d}\NWlink{nuweb101a}{, 101a}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb104a}{, 104a}\NWlink{nuweb104b}{b}\NWlink{nuweb105a}{, 105a}\NWlink{nuweb105b}{b}.
}
\item $\langle\,$C KronSums Input\nobreak\ {\footnotesize \NWlink{nuweb95d}{95d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb97b}{97b}\NWlink{nuweb97c}{c}\NWlink{nuweb98a}{, 98a}\NWlink{nuweb98b}{b}.
}
\item $\langle\,$C Macros\nobreak\ {\footnotesize \NWlink{nuweb21a}{21a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb20a}{20a}.}
\item $\langle\,$C OneTableSums Answer\nobreak\ {\footnotesize \NWlink{nuweb112c}{112c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb85a}{85a}\NWlink{nuweb111b}{, 111b}\NWlink{nuweb112d}{, 112d}\NWlink{nuweb113a}{, 113a}\NWlink{nuweb113b}{b}\NWlink{nuweb113c}{c}.
}
\item $\langle\,$C OneTableSums Input\nobreak\ {\footnotesize \NWlink{nuweb112b}{112b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb111b}{111b}\NWlink{nuweb112d}{, 112d}\NWlink{nuweb113a}{, 113a}\NWlink{nuweb113b}{b}\NWlink{nuweb113c}{c}.
}
\item $\langle\,$C real subset Input\nobreak\ {\footnotesize \NWlink{nuweb26e}{26e}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb91b}{91b}\NWlink{nuweb92a}{, 92a}\NWlink{nuweb97b}{, 97b}\NWlink{nuweb97c}{c}\NWlink{nuweb100b}{, 100b}\NWlink{nuweb100c}{c}\NWlink{nuweb104a}{, 104a}\NWlink{nuweb105a}{, 105a}\NWlink{nuweb108b}{, 108b}\NWlink{nuweb108c}{c}\NWlink{nuweb112d}{, 112d}\NWlink{nuweb113a}{, 113a}\NWlink{nuweb117a}{, 117a}\NWlink{nuweb117b}{b}\NWlink{nuweb121b}{, 121b}\NWlink{nuweb121c}{c}.
}
\item $\langle\,$C real weights Input\nobreak\ {\footnotesize \NWlink{nuweb25d}{25d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb91b}{91b}\NWlink{nuweb92c}{, 92c}\NWlink{nuweb97b}{, 97b}\NWlink{nuweb98b}{, 98b}\NWlink{nuweb100b}{, 100b}\NWlink{nuweb101a}{, 101a}\NWlink{nuweb108b}{, 108b}\NWlink{nuweb109a}{, 109a}\NWlink{nuweb112d}{, 112d}\NWlink{nuweb113c}{, 113c}\NWlink{nuweb117a}{, 117a}\NWlink{nuweb118a}{, 118a}\NWlink{nuweb121b}{, 121b}\NWlink{nuweb122a}{, 122a}.
}
\item $\langle\,$C real x Input\nobreak\ {\footnotesize \NWlink{nuweb24b}{24b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb95d}{95d}\NWlink{nuweb104a}{, 104a}\NWlink{nuweb104b}{b}\NWlink{nuweb107c}{, 107c}\NWlink{nuweb136a}{, 136a}.
}
\item $\langle\,$C real y Input\nobreak\ {\footnotesize \NWlink{nuweb24f}{24f}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb77c}{77c}\NWlink{nuweb95c}{, 95c}\NWlink{nuweb95d}{d}\NWlink{nuweb100a}{, 100a}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb104a}{, 104a}\NWlink{nuweb104b}{b}\NWlink{nuweb105a}{, 105a}\NWlink{nuweb105b}{b}.
}
\item $\langle\,$C subset range Input\nobreak\ {\footnotesize \NWlink{nuweb26c}{26c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb26d}{26d}\NWlink{nuweb26e}{e}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb81b}{, 81b}\NWlink{nuweb83b}{, 83b}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb90b}{, 90b}\NWlink{nuweb95a}{, 95a}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb107a}{, 107a}\NWlink{nuweb111b}{, 111b}\NWlink{nuweb115b}{, 115b}\NWlink{nuweb120a}{, 120a}.
}
\item $\langle\,$C sumweights Input\nobreak\ {\footnotesize \NWlink{nuweb25e}{25e}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb79}{79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb81b}{, 81b}\NWlink{nuweb83b}{, 83b}.
}
\item $\langle\,$C ThreeTableSums Answer\nobreak\ {\footnotesize \NWlink{nuweb121a}{121a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb120a}{120a}\NWlink{nuweb121b}{, 121b}\NWlink{nuweb121c}{c}\NWlink{nuweb121d}{d}\NWlink{nuweb122a}{, 122a}.
}
\item $\langle\,$C ThreeTableSums Input\nobreak\ {\footnotesize \NWlink{nuweb120c}{120c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb120a}{120a}\NWlink{nuweb121b}{, 121b}\NWlink{nuweb121c}{c}\NWlink{nuweb121d}{d}\NWlink{nuweb122a}{, 122a}.
}
\item $\langle\,$C TwoTableSums Answer\nobreak\ {\footnotesize \NWlink{nuweb116c}{116c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb115b}{115b}\NWlink{nuweb117a}{, 117a}\NWlink{nuweb117b}{b}\NWlink{nuweb117c}{c}\NWlink{nuweb118a}{, 118a}.
}
\item $\langle\,$C TwoTableSums Input\nobreak\ {\footnotesize \NWlink{nuweb116b}{116b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb115b}{115b}\NWlink{nuweb117a}{, 117a}\NWlink{nuweb117b}{b}\NWlink{nuweb117c}{c}\NWlink{nuweb118a}{, 118a}.
}
\item $\langle\,$C XfactorKronSums Input\nobreak\ {\footnotesize \NWlink{nuweb100a}{100a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb100b}{100b}\NWlink{nuweb100c}{c}\NWlink{nuweb100d}{d}\NWlink{nuweb101a}{, 101a}.
}
\item $\langle\,$Check ix\nobreak\ {\footnotesize \NWlink{nuweb9a}{9a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb8}{8}\NWlink{nuweb15b}{, 15b}.
}
\item $\langle\,$Check iy\nobreak\ {\footnotesize \NWlink{nuweb9b}{9b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb8}{8}\NWlink{nuweb15b}{, 15b}.
}
\item $\langle\,$Check weights, subset, block\nobreak\ {\footnotesize \NWlink{nuweb5a}{5a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb6}{6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15b}{, 15b}.
}
\item $\langle\,$Col Row Total Sums\nobreak\ {\footnotesize \NWlink{nuweb43a}{43a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb45}{45}\NWlink{nuweb48}{, 48}.
}
\item $\langle\,$colSums\nobreak\ {\footnotesize \NWlink{nuweb106a}{106a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$colSums Body\nobreak\ {\footnotesize \NWlink{nuweb109b}{109b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb108b}{108b}\NWlink{nuweb108c}{c}\NWlink{nuweb108d}{d}\NWlink{nuweb109a}{, 109a}.
}
\item $\langle\,$Compute Covariance Influence\nobreak\ {\footnotesize \NWlink{nuweb35b}{35b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb32}{32}.}
\item $\langle\,$Compute Covariance Linear Statistic\nobreak\ {\footnotesize \NWlink{nuweb35d}{35d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb32}{32}.}
\item $\langle\,$Compute Expectation Linear Statistic\nobreak\ {\footnotesize \NWlink{nuweb35a}{35a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb32}{32}.}
\item $\langle\,$Compute Linear Statistic\nobreak\ {\footnotesize \NWlink{nuweb33b}{33b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb32}{32}.}
\item $\langle\,$Compute maxstat Permutation P-Value\nobreak\ {\footnotesize \NWlink{nuweb73d}{73d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb70}{70}\NWlink{nuweb74}{, 74}.
}
\item $\langle\,$Compute maxstat Test Statistic\nobreak\ {\footnotesize \NWlink{nuweb73c}{73c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb70}{70}\NWlink{nuweb74}{, 74}.
}
\item $\langle\,$Compute maxstat Variance / Covariance Directly\nobreak\ {\footnotesize \NWlink{nuweb73b}{73b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb70}{70}.}
\item $\langle\,$Compute maxstat Variance / Covariance from Total Covariance\nobreak\ {\footnotesize \NWlink{nuweb73a}{73a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb70}{70}.}
\item $\langle\,$Compute Permuted Linear Statistic 2d\nobreak\ {\footnotesize \NWlink{nuweb49d}{49d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb48}{48}.}
\item $\langle\,$Compute Sum of Weights in Block\nobreak\ {\footnotesize \NWlink{nuweb34b}{34b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb32}{32}.}
\item $\langle\,$Compute unordered maxstat Linear Statistic and Expectation\nobreak\ {\footnotesize \NWlink{nuweb76a}{76a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb74}{74}.}
\item $\langle\,$Compute unordered maxstat Variance / Covariance Directly\nobreak\ {\footnotesize \NWlink{nuweb77a}{77a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb74}{74}.}
\item $\langle\,$Compute unordered maxstat Variance / Covariance from Total Covariance\nobreak\ {\footnotesize \NWlink{nuweb76b}{76b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb74}{74}.}
\item $\langle\,$Compute Variance from Covariance\nobreak\ {\footnotesize \NWlink{nuweb36a}{36a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb32}{32}.}
\item $\langle\,$Compute Variance Linear Statistic\nobreak\ {\footnotesize \NWlink{nuweb35c}{35c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb32}{32}.}
\item $\langle\,$continue subset loop\nobreak\ {\footnotesize \NWlink{nuweb89a}{89a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93a}{93a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb122b}{, 122b}.
}
\item $\langle\,$Contrasts\nobreak\ {\footnotesize \NWlink{nuweb14}{14}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb3a}{3a}.}
\item $\langle\,$Convert Table to Integer\nobreak\ {\footnotesize \NWlink{nuweb49a}{49a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb48}{48}.}
\item $\langle\,$Count Levels\nobreak\ {\footnotesize \NWlink{nuweb75a}{75a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb74}{74}.}
\item $\langle\,$ctabs Prototype\nobreak\ {\footnotesize \NWlink{nuweb15a}{15a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb15b}{15b}\NWlink{nuweb19}{, 19}.
}
\item $\langle\,$C_chisq_pvalue\nobreak\ {\footnotesize \NWlink{nuweb64c}{64c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb64b}{64b}.}
\item $\langle\,$C_colSums_dweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb108b}{108b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb106a}{106a}.}
\item $\langle\,$C_colSums_dweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb109a}{109a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb106a}{106a}.}
\item $\langle\,$C_colSums_iweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb108c}{108c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb106a}{106a}.}
\item $\langle\,$C_colSums_iweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb108d}{108d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb106a}{106a}.}
\item $\langle\,$C_CovarianceLinearStatistic\nobreak\ {\footnotesize \NWlink{nuweb79}{79}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$C_doPermute\nobreak\ {\footnotesize \NWlink{nuweb128b}{128b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb127b}{127b}.}
\item $\langle\,$C_doPermuteBlock\nobreak\ {\footnotesize \NWlink{nuweb129b}{129b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb127b}{127b}.}
\item $\langle\,$C_ExpectationLinearStatistic\nobreak\ {\footnotesize \NWlink{nuweb78b}{78b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$C_get_B\nobreak\ {\footnotesize \NWlink{nuweb147a}{147a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_Covariance\nobreak\ {\footnotesize \NWlink{nuweb144c}{144c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_CovarianceInfluence\nobreak\ {\footnotesize \NWlink{nuweb145c}{145c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_dimTable\nobreak\ {\footnotesize \NWlink{nuweb146d}{146d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_Expectation\nobreak\ {\footnotesize \NWlink{nuweb144a}{144a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_ExpectationInfluence\nobreak\ {\footnotesize \NWlink{nuweb145b}{145b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_ExpectationX\nobreak\ {\footnotesize \NWlink{nuweb145a}{145a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_LinearStatistic\nobreak\ {\footnotesize \NWlink{nuweb143d}{143d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_nresample\nobreak\ {\footnotesize \NWlink{nuweb147b}{147b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_P\nobreak\ {\footnotesize \NWlink{nuweb142c}{142c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_PermutedLinearStatistic\nobreak\ {\footnotesize \NWlink{nuweb147c}{147c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_Q\nobreak\ {\footnotesize \NWlink{nuweb143a}{143a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_Sumweights\nobreak\ {\footnotesize \NWlink{nuweb146b}{146b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_Table\nobreak\ {\footnotesize \NWlink{nuweb146c}{146c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_TableBlock\nobreak\ {\footnotesize \NWlink{nuweb146a}{146a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_tol\nobreak\ {\footnotesize \NWlink{nuweb147d}{147d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_Variance\nobreak\ {\footnotesize \NWlink{nuweb144b}{144b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_VarianceInfluence\nobreak\ {\footnotesize \NWlink{nuweb145d}{145d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_varonly\nobreak\ {\footnotesize \NWlink{nuweb143b}{143b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_get_Xfactor\nobreak\ {\footnotesize \NWlink{nuweb143c}{143c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$C_kronecker\nobreak\ {\footnotesize \NWlink{nuweb134}{134}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$C_kronecker_sym\nobreak\ {\footnotesize \NWlink{nuweb135}{135}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$C_KronSums_dweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb97b}{97b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_KronSums_dweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb98b}{98b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_KronSums_iweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb97c}{97c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_KronSums_iweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb98a}{98a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_KronSums_Permutation_dsubset\nobreak\ {\footnotesize \NWlink{nuweb104a}{104a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_KronSums_Permutation_isubset\nobreak\ {\footnotesize \NWlink{nuweb104b}{104b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_KronSums_sym\nobreak\ {\footnotesize \NWlink{nuweb136a}{136a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$C_maxabsstand_Covariance\nobreak\ {\footnotesize \NWlink{nuweb59b}{59b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_maxabsstand_Variance\nobreak\ {\footnotesize \NWlink{nuweb60a}{60a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_maxstand_Covariance\nobreak\ {\footnotesize \NWlink{nuweb57b}{57b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_maxstand_Variance\nobreak\ {\footnotesize \NWlink{nuweb58a}{58a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_maxtype\nobreak\ {\footnotesize \NWlink{nuweb63}{63}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_maxtype_pvalue\nobreak\ {\footnotesize \NWlink{nuweb67}{67}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb64b}{64b}.}
\item $\langle\,$C_minstand_Covariance\nobreak\ {\footnotesize \NWlink{nuweb58b}{58b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_minstand_Variance\nobreak\ {\footnotesize \NWlink{nuweb59a}{59a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_MPinv_sym\nobreak\ {\footnotesize \NWlink{nuweb138}{138}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$C_norm_pvalue\nobreak\ {\footnotesize \NWlink{nuweb66}{66}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb64b}{64b}.}
\item $\langle\,$C_OneTableSums_dweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb112d}{112d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_OneTableSums_dweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb113c}{113c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_OneTableSums_iweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb113a}{113a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_OneTableSums_iweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb113b}{113b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_ordered_Xfactor\nobreak\ {\footnotesize \NWlink{nuweb70}{70}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_order_subset_wrt_block\nobreak\ {\footnotesize \NWlink{nuweb126a}{126a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb123a}{123a}.}
\item $\langle\,$C_Permute\nobreak\ {\footnotesize \NWlink{nuweb128a}{128a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb127b}{127b}.}
\item $\langle\,$C_PermuteBlock\nobreak\ {\footnotesize \NWlink{nuweb129a}{129a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb127b}{127b}.}
\item $\langle\,$C_perm_pvalue\nobreak\ {\footnotesize \NWlink{nuweb65}{65}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb64b}{64b}.}
\item $\langle\,$C_quadform\nobreak\ {\footnotesize \NWlink{nuweb62}{62}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_setup_subset\nobreak\ {\footnotesize \NWlink{nuweb125a}{125a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb123a}{123a}.}
\item $\langle\,$C_setup_subset_block\nobreak\ {\footnotesize \NWlink{nuweb125b}{125b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb123a}{123a}.}
\item $\langle\,$C_standardise\nobreak\ {\footnotesize \NWlink{nuweb64a}{64a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_Sums_dweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb91b}{91b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb89b}{89b}.}
\item $\langle\,$C_Sums_dweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb92c}{92c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb89b}{89b}.}
\item $\langle\,$C_Sums_iweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb92a}{92a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb89b}{89b}.}
\item $\langle\,$C_Sums_iweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb92b}{92b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb89b}{89b}.}
\item $\langle\,$C_ThreeTableSums_dweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb121b}{121b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_ThreeTableSums_dweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb122a}{122a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_ThreeTableSums_iweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb121c}{121c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_ThreeTableSums_iweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb121d}{121d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_TwoTableSums_dweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb117a}{117a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_TwoTableSums_dweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb118a}{118a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_TwoTableSums_iweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb117b}{117b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_TwoTableSums_iweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb117c}{117c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$C_unordered_Xfactor\nobreak\ {\footnotesize \NWlink{nuweb74}{74}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$C_VarianceLinearStatistic\nobreak\ {\footnotesize \NWlink{nuweb80a}{80a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$C_XfactorKronSums_dweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb100b}{100b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_XfactorKronSums_dweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb101a}{101a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_XfactorKronSums_iweights_dsubset\nobreak\ {\footnotesize \NWlink{nuweb100c}{100c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_XfactorKronSums_iweights_isubset\nobreak\ {\footnotesize \NWlink{nuweb100d}{100d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_XfactorKronSums_Permutation_dsubset\nobreak\ {\footnotesize \NWlink{nuweb105a}{105a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$C_XfactorKronSums_Permutation_isubset\nobreak\ {\footnotesize \NWlink{nuweb105b}{105b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$doTest\nobreak\ {\footnotesize \NWlink{nuweb12}{12}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb3a}{3a}.}
\item $\langle\,$doTest Prototype\nobreak\ {\footnotesize \NWlink{nuweb11}{11}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb12}{12}\NWlink{nuweb18}{, 18}.
}
\item $\langle\,$ExpectationCovariances\nobreak\ {\footnotesize \NWlink{nuweb78a}{78a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$Extract Dimensions\nobreak\ {\footnotesize \NWlink{nuweb33a}{33a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb32}{32}.}
\item $\langle\,$Function Definitions\nobreak\ {\footnotesize \NWlink{nuweb23a}{23a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22c}{22c}.}
\item $\langle\,$Function Prototypes\nobreak\ {\footnotesize \NWlink{nuweb22b}{22b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22a}{22a}.}
\item $\langle\,$Handle Missing Values\nobreak\ {\footnotesize \NWlink{nuweb5b}{5b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb6}{6}.}
\item $\langle\,$init subset loop\nobreak\ {\footnotesize \NWlink{nuweb88b}{88b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93a}{93a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb122b}{, 122b}.
}
\item $\langle\,$Initialise Zero\nobreak\ {\footnotesize \NWlink{nuweb150a}{150a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb149}{149}.}
\item $\langle\,$KronSums\nobreak\ {\footnotesize \NWlink{nuweb93b}{93b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$KronSums Body\nobreak\ {\footnotesize \NWlink{nuweb99}{99}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb97b}{97b}\NWlink{nuweb97c}{c}\NWlink{nuweb98a}{, 98a}\NWlink{nuweb98b}{b}.
}
\item $\langle\,$KronSums Double x\nobreak\ {\footnotesize \NWlink{nuweb97a}{97a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb95b}{95b}.}
\item $\langle\,$KronSums Integer x\nobreak\ {\footnotesize \NWlink{nuweb96b}{96b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb95b}{95b}.}
\item $\langle\,$KronSums Permutation Body\nobreak\ {\footnotesize \NWlink{nuweb104c}{104c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb104a}{104a}\NWlink{nuweb104b}{b}.
}
\item $\langle\,$Linear Statistic 2d\nobreak\ {\footnotesize \NWlink{nuweb42a}{42a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb45}{45}\NWlink{nuweb49d}{, 49d}.
}
\item $\langle\,$LinearStatistics\nobreak\ {\footnotesize \NWlink{nuweb77b}{77b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$LinStatExpCov\nobreak\ {\footnotesize \NWlink{nuweb4}{4}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb3a}{3a}.}
\item $\langle\,$LinStatExpCov Prototype\nobreak\ {\footnotesize \NWlink{nuweb3b}{3b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb4}{4}\NWlink{nuweb17}{, 17}.
}
\item $\langle\,$LinStatExpCov1d\nobreak\ {\footnotesize \NWlink{nuweb6}{6}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb3a}{3a}.}
\item $\langle\,$LinStatExpCov2d\nobreak\ {\footnotesize \NWlink{nuweb8}{8}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb3a}{3a}.}
\item $\langle\,$maxstat Xfactor Variables\nobreak\ {\footnotesize \NWlink{nuweb69b}{69b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb70}{70}\NWlink{nuweb74}{, 74}.
}
\item $\langle\,$Memory\nobreak\ {\footnotesize \NWlink{nuweb142a}{142a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$Memory Input Checks\nobreak\ {\footnotesize \NWlink{nuweb148a}{148a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb149}{149}.}
\item $\langle\,$Memory Names\nobreak\ {\footnotesize \NWlink{nuweb148b}{148b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb149}{149}.}
\item $\langle\,$MoreUtils\nobreak\ {\footnotesize \NWlink{nuweb130a}{130a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$mPQB\nobreak\ {\footnotesize \NWlink{nuweb132b}{132b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$NCOL\nobreak\ {\footnotesize \NWlink{nuweb131a}{131a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$NLEVELS\nobreak\ {\footnotesize \NWlink{nuweb131b}{131b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$NROW\nobreak\ {\footnotesize \NWlink{nuweb130b}{130b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$OneTableSums Body\nobreak\ {\footnotesize \NWlink{nuweb114a}{114a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb112d}{112d}\NWlink{nuweb113a}{, 113a}\NWlink{nuweb113b}{b}\NWlink{nuweb113c}{c}.
}
\item $\langle\,$P-Values\nobreak\ {\footnotesize \NWlink{nuweb64b}{64b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$Permutations\nobreak\ {\footnotesize \NWlink{nuweb127b}{127b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$PP12\nobreak\ {\footnotesize \NWlink{nuweb132a}{132a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$R block Input\nobreak\ {\footnotesize \NWlink{nuweb26f}{26f}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb30b}{30b}\NWlink{nuweb39c}{, 39c}\NWlink{nuweb47a}{, 47a}\NWlink{nuweb119a}{, 119a}\NWlink{nuweb123b}{, 123b}\NWlink{nuweb124a}{, 124a}\NWlink{nuweb125b}{, 125b}\NWlink{nuweb126a}{, 126a}.
}
\item $\langle\,$R blockTable Input\nobreak\ {\footnotesize \NWlink{nuweb27c}{27c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb124a}{124a}\NWlink{nuweb125b}{, 125b}\NWlink{nuweb126a}{, 126a}.
}
\item $\langle\,$R Header\nobreak\ {\footnotesize \NWlink{nuweb155a}{155a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb3a}{3a}\NWlink{nuweb15b}{, 15b}\NWlink{nuweb152a}{, 152a}.
}
\item $\langle\,$R Includes\nobreak\ {\footnotesize \NWlink{nuweb20b}{20b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb20a}{20a}.}
\item $\langle\,$R LECV Input\nobreak\ {\footnotesize \NWlink{nuweb142b}{142b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb50b}{50b}\NWlink{nuweb52b}{, 52b}\NWlink{nuweb142c}{, 142c}\NWlink{nuweb143a}{, 143a}\NWlink{nuweb143b}{b}\NWlink{nuweb143c}{c}\NWlink{nuweb143d}{d}\NWlink{nuweb144a}{, 144a}\NWlink{nuweb144b}{b}\NWlink{nuweb144c}{c}\NWlink{nuweb145a}{, 145a}\NWlink{nuweb145b}{b}\NWlink{nuweb145c}{c}\NWlink{nuweb145d}{d}\NWlink{nuweb146a}{, 146a}\NWlink{nuweb146b}{b}\NWlink{nuweb146c}{c}\NWlink{nuweb146d}{d}\NWlink{nuweb147a}{, 147a}\NWlink{nuweb147b}{b}\NWlink{nuweb147c}{c}\NWlink{nuweb147d}{d}.
}
\item $\langle\,$R N Input\nobreak\ {\footnotesize \NWlink{nuweb23b}{23b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb89c}{89c}.}
\item $\langle\,$R subset Input\nobreak\ {\footnotesize \NWlink{nuweb26a}{26a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb30b}{30b}\NWlink{nuweb39c}{, 39c}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb80b}{, 80b}\NWlink{nuweb81b}{, 81b}\NWlink{nuweb82}{, 82}\NWlink{nuweb83b}{, 83b}\NWlink{nuweb84b}{, 84b}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb86}{, 86}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb89c}{, 89c}\NWlink{nuweb90b}{, 90b}\NWlink{nuweb94a}{, 94a}\NWlink{nuweb95a}{, 95a}\NWlink{nuweb102a}{, 102a}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb106b}{, 106b}\NWlink{nuweb107a}{, 107a}\NWlink{nuweb110b}{, 110b}\NWlink{nuweb111b}{, 111b}\NWlink{nuweb114b}{, 114b}\NWlink{nuweb115b}{, 115b}\NWlink{nuweb119a}{, 119a}\NWlink{nuweb120a}{, 120a}\NWlink{nuweb123b}{, 123b}\NWlink{nuweb124a}{, 124a}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb126b}{b}.
}
\item $\langle\,$R weights Input\nobreak\ {\footnotesize \NWlink{nuweb25b}{25b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb30b}{30b}\NWlink{nuweb39c}{, 39c}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb80b}{, 80b}\NWlink{nuweb81b}{, 81b}\NWlink{nuweb82}{, 82}\NWlink{nuweb83b}{, 83b}\NWlink{nuweb84b}{, 84b}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb86}{, 86}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb89c}{, 89c}\NWlink{nuweb90b}{, 90b}\NWlink{nuweb94a}{, 94a}\NWlink{nuweb95a}{, 95a}\NWlink{nuweb106b}{, 106b}\NWlink{nuweb107a}{, 107a}\NWlink{nuweb110b}{, 110b}\NWlink{nuweb111b}{, 111b}\NWlink{nuweb114b}{, 114b}\NWlink{nuweb115b}{, 115b}\NWlink{nuweb119a}{, 119a}\NWlink{nuweb120a}{, 120a}\NWlink{nuweb123b}{, 123b}\NWlink{nuweb126b}{, 126b}.
}
\item $\langle\,$R x Input\nobreak\ {\footnotesize \NWlink{nuweb23d}{23d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb30b}{30b}\NWlink{nuweb39c}{, 39c}\NWlink{nuweb47a}{, 47a}\NWlink{nuweb77c}{, 77c}\NWlink{nuweb84b}{, 84b}\NWlink{nuweb85a}{, 85a}\NWlink{nuweb86}{, 86}\NWlink{nuweb87b}{, 87b}\NWlink{nuweb94a}{, 94a}\NWlink{nuweb95c}{, 95c}\NWlink{nuweb102a}{, 102a}\NWlink{nuweb103a}{, 103a}\NWlink{nuweb106b}{, 106b}\NWlink{nuweb110b}{, 110b}\NWlink{nuweb114b}{, 114b}\NWlink{nuweb119a}{, 119a}.
}
\item $\langle\,$R y Input\nobreak\ {\footnotesize \NWlink{nuweb24d}{24d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb30b}{30b}\NWlink{nuweb39c}{, 39c}\NWlink{nuweb47a}{, 47a}\NWlink{nuweb80b}{, 80b}\NWlink{nuweb81b}{, 81b}\NWlink{nuweb82}{, 82}\NWlink{nuweb83b}{, 83b}\NWlink{nuweb94a}{, 94a}\NWlink{nuweb102a}{, 102a}\NWlink{nuweb114b}{, 114b}\NWlink{nuweb119a}{, 119a}\NWlink{nuweb123b}{, 123b}.
}
\item $\langle\,$RC KronSums Input\nobreak\ {\footnotesize \NWlink{nuweb95c}{95c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb95a}{95a}.}
\item $\langle\,$RC_colSums\nobreak\ {\footnotesize \NWlink{nuweb107b}{107b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb106a}{106a}.}
\item $\langle\,$RC_colSums Prototype\nobreak\ {\footnotesize \NWlink{nuweb107a}{107a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb107b}{107b}.}
\item $\langle\,$RC_CovarianceInfluence\nobreak\ {\footnotesize \NWlink{nuweb84a}{84a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$RC_CovarianceInfluence Prototype\nobreak\ {\footnotesize \NWlink{nuweb83b}{83b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb84a}{84a}.}
\item $\langle\,$RC_CovarianceX\nobreak\ {\footnotesize \NWlink{nuweb88a}{88a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$RC_CovarianceX Prototype\nobreak\ {\footnotesize \NWlink{nuweb87b}{87b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb88a}{88a}.}
\item $\langle\,$RC_ExpectationCovarianceStatistic\nobreak\ {\footnotesize \NWlink{nuweb32}{32}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb30a}{30a}.}
\item $\langle\,$RC_ExpectationCovarianceStatistic_2d\nobreak\ {\footnotesize \NWlink{nuweb45}{45}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb39b}{39b}.}
\item $\langle\,$RC_ExpectationInfluence\nobreak\ {\footnotesize \NWlink{nuweb81c}{81c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$RC_ExpectationInfluence Prototype\nobreak\ {\footnotesize \NWlink{nuweb81b}{81b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb81c}{81c}.}
\item $\langle\,$RC_ExpectationX\nobreak\ {\footnotesize \NWlink{nuweb85b}{85b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$RC_ExpectationX Prototype\nobreak\ {\footnotesize \NWlink{nuweb85a}{85a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb85b}{85b}.}
\item $\langle\,$RC_init_LECV_1d\nobreak\ {\footnotesize \NWlink{nuweb150b}{150b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$RC_init_LECV_2d\nobreak\ {\footnotesize \NWlink{nuweb151}{151}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb142a}{142a}.}
\item $\langle\,$RC_KronSums\nobreak\ {\footnotesize \NWlink{nuweb95b}{95b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$RC_KronSums Prototype\nobreak\ {\footnotesize \NWlink{nuweb95a}{95a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb95b}{95b}.}
\item $\langle\,$RC_KronSums_Permutation\nobreak\ {\footnotesize \NWlink{nuweb103b}{103b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$RC_KronSums_Permutation Prototype\nobreak\ {\footnotesize \NWlink{nuweb103a}{103a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb103b}{103b}.}
\item $\langle\,$RC_LinearStatistic\nobreak\ {\footnotesize \NWlink{nuweb77d}{77d}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb77b}{77b}.}
\item $\langle\,$RC_LinearStatistic Prototype\nobreak\ {\footnotesize \NWlink{nuweb77c}{77c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb77d}{77d}.}
\item $\langle\,$RC_OneTableSums\nobreak\ {\footnotesize \NWlink{nuweb112a}{112a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$RC_OneTableSums Prototype\nobreak\ {\footnotesize \NWlink{nuweb111b}{111b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb112a}{112a}.}
\item $\langle\,$RC_order_subset_wrt_block\nobreak\ {\footnotesize \NWlink{nuweb124b}{124b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb123a}{123a}.}
\item $\langle\,$RC_order_subset_wrt_block Prototype\nobreak\ {\footnotesize \NWlink{nuweb124a}{124a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb124b}{124b}.}
\item $\langle\,$RC_setup_subset\nobreak\ {\footnotesize \NWlink{nuweb127a}{127a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb127b}{127b}.}
\item $\langle\,$RC_setup_subset Prototype\nobreak\ {\footnotesize \NWlink{nuweb126b}{126b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb127a}{127a}.}
\item $\langle\,$RC_Sums\nobreak\ {\footnotesize \NWlink{nuweb91a}{91a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb89b}{89b}.}
\item $\langle\,$RC_Sums Prototype\nobreak\ {\footnotesize \NWlink{nuweb90b}{90b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb91a}{91a}.}
\item $\langle\,$RC_ThreeTableSums\nobreak\ {\footnotesize \NWlink{nuweb120b}{120b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$RC_ThreeTableSums Prototype\nobreak\ {\footnotesize \NWlink{nuweb120a}{120a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb120b}{120b}.}
\item $\langle\,$RC_TwoTableSums\nobreak\ {\footnotesize \NWlink{nuweb116a}{116a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$RC_TwoTableSums Prototype\nobreak\ {\footnotesize \NWlink{nuweb115b}{115b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb116a}{116a}.}
\item $\langle\,$R_colSums\nobreak\ {\footnotesize \NWlink{nuweb106c}{106c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb106a}{106a}.}
\item $\langle\,$R_colSums Prototype\nobreak\ {\footnotesize \NWlink{nuweb106b}{106b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb106c}{, 106c}.
}
\item $\langle\,$R_CovarianceInfluence\nobreak\ {\footnotesize \NWlink{nuweb83a}{83a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$R_CovarianceInfluence Prototype\nobreak\ {\footnotesize \NWlink{nuweb82}{82}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb83a}{, 83a}.
}
\item $\langle\,$R_CovarianceX\nobreak\ {\footnotesize \NWlink{nuweb87a}{87a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$R_CovarianceX Prototype\nobreak\ {\footnotesize \NWlink{nuweb86}{86}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb87a}{, 87a}.
}
\item $\langle\,$R_ExpectationCovarianceStatistic\nobreak\ {\footnotesize \NWlink{nuweb31a}{31a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb30a}{30a}.}
\item $\langle\,$R_ExpectationCovarianceStatistic Prototype\nobreak\ {\footnotesize \NWlink{nuweb30c}{30c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb31a}{, 31a}.
}
\item $\langle\,$R_ExpectationCovarianceStatistic_2d\nobreak\ {\footnotesize \NWlink{nuweb41a}{41a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb39b}{39b}.}
\item $\langle\,$R_ExpectationCovarianceStatistic_2d Prototype\nobreak\ {\footnotesize \NWlink{nuweb40a}{40a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb41a}{, 41a}.
}
\item $\langle\,$R_ExpectationInfluence\nobreak\ {\footnotesize \NWlink{nuweb81a}{81a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$R_ExpectationInfluence Prototype\nobreak\ {\footnotesize \NWlink{nuweb80b}{80b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb81a}{, 81a}.
}
\item $\langle\,$R_ExpectationX\nobreak\ {\footnotesize \NWlink{nuweb84c}{84c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb78a}{78a}.}
\item $\langle\,$R_ExpectationX Prototype\nobreak\ {\footnotesize \NWlink{nuweb84b}{84b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb84c}{, 84c}.
}
\item $\langle\,$R_init_LECV\nobreak\ {\footnotesize \NWlink{nuweb149}{149}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb150b}{150b}\NWlink{nuweb151}{, 151}.
}
\item $\langle\,$R_kronecker\nobreak\ {\footnotesize \NWlink{nuweb133b}{133b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$R_kronecker Prototype\nobreak\ {\footnotesize \NWlink{nuweb132c}{132c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb133b}{, 133b}.
}
\item $\langle\,$R_KronSums\nobreak\ {\footnotesize \NWlink{nuweb94b}{94b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$R_KronSums Prototype\nobreak\ {\footnotesize \NWlink{nuweb94a}{94a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb94b}{, 94b}.
}
\item $\langle\,$R_KronSums_Permutation\nobreak\ {\footnotesize \NWlink{nuweb102b}{102b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93b}{93b}.}
\item $\langle\,$R_KronSums_Permutation Prototype\nobreak\ {\footnotesize \NWlink{nuweb102a}{102a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb102b}{, 102b}.
}
\item $\langle\,$R_MaximallySelectedTest\nobreak\ {\footnotesize \NWlink{nuweb56}{56}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb50a}{50a}.}
\item $\langle\,$R_MaximallySelectedTest Prototype\nobreak\ {\footnotesize \NWlink{nuweb55a}{55a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb56}{, 56}.
}
\item $\langle\,$R_MaximumTest\nobreak\ {\footnotesize \NWlink{nuweb54}{54}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb50a}{50a}.}
\item $\langle\,$R_MaximumTest Prototype\nobreak\ {\footnotesize \NWlink{nuweb52b}{52b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb54}{, 54}.
}
\item $\langle\,$R_MPinv_sym\nobreak\ {\footnotesize \NWlink{nuweb137b}{137b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$R_MPinv_sym Prototype\nobreak\ {\footnotesize \NWlink{nuweb136b}{136b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb137b}{, 137b}.
}
\item $\langle\,$R_OneTableSums\nobreak\ {\footnotesize \NWlink{nuweb111a}{111a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$R_OneTableSums Prototype\nobreak\ {\footnotesize \NWlink{nuweb110b}{110b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb111a}{, 111a}.
}
\item $\langle\,$R_order_subset_wrt_block\nobreak\ {\footnotesize \NWlink{nuweb123c}{123c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb123a}{123a}.}
\item $\langle\,$R_order_subset_wrt_block Prototype\nobreak\ {\footnotesize \NWlink{nuweb123b}{123b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb123c}{, 123c}.
}
\item $\langle\,$R_pack_sym\nobreak\ {\footnotesize \NWlink{nuweb141c}{141c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$R_pack_sym Prototype\nobreak\ {\footnotesize \NWlink{nuweb141a}{141a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb141c}{, 141c}.
}
\item $\langle\,$R_PermutedLinearStatistic\nobreak\ {\footnotesize \NWlink{nuweb37}{37}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb30a}{30a}.}
\item $\langle\,$R_PermutedLinearStatistic Prototype\nobreak\ {\footnotesize \NWlink{nuweb36b}{36b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb37}{, 37}.
}
\item $\langle\,$R_PermutedLinearStatistic_2d\nobreak\ {\footnotesize \NWlink{nuweb48}{48}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb39b}{39b}.}
\item $\langle\,$R_PermutedLinearStatistic_2d Prototype\nobreak\ {\footnotesize \NWlink{nuweb47a}{47a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb48}{, 48}.
}
\item $\langle\,$R_quadform\nobreak\ {\footnotesize \NWlink{nuweb61b}{61b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb57a}{57a}.}
\item $\langle\,$R_quadform Prototype\nobreak\ {\footnotesize \NWlink{nuweb60b}{60b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb61b}{, 61b}.
}
\item $\langle\,$R_QuadraticTest\nobreak\ {\footnotesize \NWlink{nuweb51}{51}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb50a}{50a}.}
\item $\langle\,$R_QuadraticTest Prototype\nobreak\ {\footnotesize \NWlink{nuweb50b}{50b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb51}{, 51}.
}
\item $\langle\,$R_StandardisePermutedLinearStatistic\nobreak\ {\footnotesize \NWlink{nuweb39a}{39a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb30a}{30a}.}
\item $\langle\,$R_StandardisePermutedLinearStatistic Prototype\nobreak\ {\footnotesize \NWlink{nuweb38b}{38b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb39a}{, 39a}.
}
\item $\langle\,$R_Sums\nobreak\ {\footnotesize \NWlink{nuweb90a}{90a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb89b}{89b}.}
\item $\langle\,$R_Sums Prototype\nobreak\ {\footnotesize \NWlink{nuweb89c}{89c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb90a}{, 90a}.
}
\item $\langle\,$R_ThreeTableSums\nobreak\ {\footnotesize \NWlink{nuweb119b}{119b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$R_ThreeTableSums Prototype\nobreak\ {\footnotesize \NWlink{nuweb119a}{119a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb119b}{, 119b}.
}
\item $\langle\,$R_TwoTableSums\nobreak\ {\footnotesize \NWlink{nuweb115a}{115a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb110a}{110a}.}
\item $\langle\,$R_TwoTableSums Prototype\nobreak\ {\footnotesize \NWlink{nuweb114b}{114b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb115a}{, 115a}.
}
\item $\langle\,$R_unpack_sym\nobreak\ {\footnotesize \NWlink{nuweb140}{140}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb130a}{130a}.}
\item $\langle\,$R_unpack_sym Prototype\nobreak\ {\footnotesize \NWlink{nuweb139a}{139a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb22b}{22b}\NWlink{nuweb140}{, 140}.
}
\item $\langle\,$Setup Dimensions\nobreak\ {\footnotesize \NWlink{nuweb31b}{31b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb31a}{31a}\NWlink{nuweb37}{, 37}.
}
\item $\langle\,$Setup Dimensions 2d\nobreak\ {\footnotesize \NWlink{nuweb41b}{41b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb41a}{41a}\NWlink{nuweb48}{, 48}.
}
\item $\langle\,$Setup Linear Statistic\nobreak\ {\footnotesize \NWlink{nuweb38a}{38a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb37}{37}\NWlink{nuweb48}{, 48}.
}
\item $\langle\,$Setup Log-Factorials\nobreak\ {\footnotesize \NWlink{nuweb49c}{49c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb48}{48}.}
\item $\langle\,$Setup maxstat Memory\nobreak\ {\footnotesize \NWlink{nuweb72}{72}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb70}{70}\NWlink{nuweb74}{, 74}.
}
\item $\langle\,$Setup maxstat Variables\nobreak\ {\footnotesize \NWlink{nuweb71}{71}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb70}{70}\NWlink{nuweb74}{, 74}.
}
\item $\langle\,$Setup Memory and Subsets in Blocks\nobreak\ {\footnotesize \NWlink{nuweb34a}{34a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb32}{32}.}
\item $\langle\,$Setup mvtnorm Correlation\nobreak\ {\footnotesize \NWlink{nuweb69a}{69a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb67}{67}.}
\item $\langle\,$Setup mvtnorm Memory\nobreak\ {\footnotesize \NWlink{nuweb68}{68}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb67}{67}.}
\item $\langle\,$Setup Test Memory\nobreak\ {\footnotesize \NWlink{nuweb52a}{52a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb51}{51}\NWlink{nuweb54}{, 54}.
}
\item $\langle\,$Setup unordered maxstat Contrasts\nobreak\ {\footnotesize \NWlink{nuweb75b}{75b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb74}{74}.}
\item $\langle\,$Setup Working Memory\nobreak\ {\footnotesize \NWlink{nuweb49b}{49b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb48}{48}.}
\item $\langle\,$SimpleSums\nobreak\ {\footnotesize \NWlink{nuweb89b}{89b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$start subset loop\nobreak\ {\footnotesize \NWlink{nuweb88c}{88c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb93a}{93a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb122b}{, 122b}.
}
\item $\langle\,$Sums Body\nobreak\ {\footnotesize \NWlink{nuweb93a}{93a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb91b}{91b}\NWlink{nuweb92a}{, 92a}\NWlink{nuweb92b}{b}\NWlink{nuweb92c}{c}.
}
\item $\langle\,$Tables\nobreak\ {\footnotesize \NWlink{nuweb110a}{110a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$Test Statistics\nobreak\ {\footnotesize \NWlink{nuweb57a}{57a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$Tests\nobreak\ {\footnotesize \NWlink{nuweb50a}{50a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$ThreeTableSums Body\nobreak\ {\footnotesize \NWlink{nuweb122b}{122b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb121b}{121b}\NWlink{nuweb121c}{c}\NWlink{nuweb121d}{d}\NWlink{nuweb122a}{, 122a}.
}
\item $\langle\,$TwoTableSums Body\nobreak\ {\footnotesize \NWlink{nuweb118b}{118b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb117a}{117a}\NWlink{nuweb117b}{b}\NWlink{nuweb117c}{c}\NWlink{nuweb118a}{, 118a}.
}
\item $\langle\,$User Interface\nobreak\ {\footnotesize \NWlink{nuweb30a}{30a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$User Interface Input\nobreak\ {\footnotesize \NWlink{nuweb30b}{30b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb30c}{30c}\NWlink{nuweb32}{, 32}\NWlink{nuweb36b}{, 36b}.
}
\item $\langle\,$Utils\nobreak\ {\footnotesize \NWlink{nuweb123a}{123a}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb23a}{23a}.}
\item $\langle\,$vcov LinStatExpCov\nobreak\ {\footnotesize \NWlink{nuweb10}{10}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb3a}{3a}.}
\item $\langle\,$XfactorKronSums Body\nobreak\ {\footnotesize \NWlink{nuweb101b}{101b}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb100b}{100b}\NWlink{nuweb100c}{c}\NWlink{nuweb100d}{d}\NWlink{nuweb101a}{, 101a}.
}
\item $\langle\,$XfactorKronSums Permutation Body\nobreak\ {\footnotesize \NWlink{nuweb105c}{105c}}$\,\rangle$ {\footnotesize {\NWtxtRefIn} \NWlink{nuweb105a}{105a}\NWlink{nuweb105b}{b}.
}
\end{list}}

\section*{Identifiers}


{\small\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \verb@B@: \underline{\NWlink{nuweb27a}{27a}}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb32}{, 32}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42b}{, 42b}\NWlink{nuweb45}{, 45}\NWlink{nuweb46}{, 46}\NWlink{nuweb48}{, 48}\NWlink{nuweb49b}{, 49b}\NWlink{nuweb70}{, 70}\NWlink{nuweb71}{, 71}\NWlink{nuweb74}{, 74}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb132b}{, 132b}\NWlink{nuweb132c}{c}\NWlink{nuweb133a}{, 133a}\NWlink{nuweb133b}{b}\NWlink{nuweb134}{, 134}\NWlink{nuweb135}{, 135}\NWlink{nuweb148a}{, 148a}\NWlink{nuweb149}{, 149}\NWlink{nuweb150b}{, 150b}\NWlink{nuweb151}{, 151}.
\item \verb@block@: \NWlink{nuweb3b}{3b}\NWlink{nuweb4}{, 4}\NWlink{nuweb5a}{, 5a}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15a}{, 15a}\NWlink{nuweb15b}{b}\NWlink{nuweb17}{, 17}\NWlink{nuweb19}{, 19}, \underline{\NWlink{nuweb26f}{26f}}, \underline{\NWlink{nuweb27b}{27b}}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb125b}{, 125b}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb146a}{, 146a}.
\item \verb@blockTable@: \underline{\NWlink{nuweb27c}{27c}}\NWlink{nuweb37}{, 37}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb125b}{, 125b}\NWlink{nuweb126a}{, 126a}.
\item \verb@CovarianceInfluence_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb145c}{, 145c}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@Covariance_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb144b}{, 144b}\NWlink{nuweb144c}{c}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@C_chisq_pvalue@: \NWlink{nuweb51}{51}, \underline{\NWlink{nuweb64c}{64c}}.
\item \verb@C_colSums_dweights_dsubset@: \NWlink{nuweb107b}{107b}, \underline{\NWlink{nuweb108b}{108b}}.
\item \verb@C_colSums_dweights_isubset@: \NWlink{nuweb107b}{107b}, \underline{\NWlink{nuweb109a}{109a}}.
\item \verb@C_colSums_iweights_dsubset@: \NWlink{nuweb107b}{107b}, \underline{\NWlink{nuweb108c}{108c}}.
\item \verb@C_colSums_iweights_isubset@: \NWlink{nuweb107b}{107b}, \underline{\NWlink{nuweb108d}{108d}}.
\item \verb@C_CovarianceLinearStatistic@: \NWlink{nuweb35d}{35d}\NWlink{nuweb44}{, 44}\NWlink{nuweb73b}{, 73b}\NWlink{nuweb77a}{, 77a}, \underline{\NWlink{nuweb79}{79}}\NWlink{nuweb80a}{, 80a}.
\item \verb@C_doPermute@: \NWlink{nuweb37}{37}, \underline{\NWlink{nuweb128b}{128b}}.
\item \verb@C_doPermuteBlock@: \NWlink{nuweb37}{37}, \underline{\NWlink{nuweb129b}{129b}}.
\item \verb@C_ExpectationLinearStatistic@: \NWlink{nuweb35a}{35a}\NWlink{nuweb43b}{, 43b}, \underline{\NWlink{nuweb78b}{78b}}.
\item \verb@C_get_B@: \NWlink{nuweb33a}{33a}\NWlink{nuweb46}{, 46}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb147a}{147a}}.
\item \verb@C_get_Covariance@: \NWlink{nuweb35d}{35d}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb144c}{144c}}\NWlink{nuweb150a}{, 150a}.
\item \verb@C_get_CovarianceInfluence@: \NWlink{nuweb34a}{34a}\NWlink{nuweb44}{, 44}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb145c}{145c}}\NWlink{nuweb150a}{, 150a}.
\item \verb@C_get_dimTable@: \NWlink{nuweb46}{46}, \underline{\NWlink{nuweb146d}{146d}}\NWlink{nuweb147a}{, 147a}.
\item \verb@C_get_Expectation@: \NWlink{nuweb35a}{35a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb144a}{144a}}\NWlink{nuweb150a}{, 150a}.
\item \verb@C_get_ExpectationInfluence@: \NWlink{nuweb34a}{34a}\NWlink{nuweb46}{, 46}, \underline{\NWlink{nuweb145b}{145b}}\NWlink{nuweb150a}{, 150a}.
\item \verb@C_get_ExpectationX@: \NWlink{nuweb34a}{34a}\NWlink{nuweb46}{, 46}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb145a}{145a}}.
\item \verb@C_get_LinearStatistic@: \NWlink{nuweb33b}{33b}\NWlink{nuweb45}{, 45}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb143d}{143d}}\NWlink{nuweb150a}{, 150a}.
\item \verb@C_get_nresample@: \NWlink{nuweb39a}{39a}\NWlink{nuweb51}{, 51}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb54}{, 54}\NWlink{nuweb56}{, 56}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb147b}{147b}}.
\item \verb@C_get_P@: \NWlink{nuweb33a}{33a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb46}{, 46}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb56}{, 56}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb142c}{142c}}\NWlink{nuweb144b}{, 144b}\NWlink{nuweb144c}{c}\NWlink{nuweb147b}{, 147b}.
\item \verb@C_get_PermutedLinearStatistic@: \NWlink{nuweb39a}{39a}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb147c}{147c}}.
\item \verb@C_get_Q@: \NWlink{nuweb33a}{33a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb46}{, 46}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb143a}{143a}}\NWlink{nuweb144b}{, 144b}\NWlink{nuweb144c}{c}\NWlink{nuweb147b}{, 147b}.
\item \verb@C_get_Sumweights@: \NWlink{nuweb34a}{34a}\NWlink{nuweb46}{, 46}, \underline{\NWlink{nuweb146b}{146b}}.
\item \verb@C_get_Table@: \NWlink{nuweb41a}{41a}\NWlink{nuweb46}{, 46}, \underline{\NWlink{nuweb146c}{146c}}.
\item \verb@C_get_TableBlock@: \NWlink{nuweb34a}{34a}, \underline{\NWlink{nuweb146a}{146a}}.
\item \verb@C_get_tol@: \NWlink{nuweb39a}{39a}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb147d}{147d}}.
\item \verb@C_get_Variance@: \NWlink{nuweb35c}{35c}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb144b}{144b}}\NWlink{nuweb144c}{, 144c}\NWlink{nuweb150a}{, 150a}.
\item \verb@C_get_VarianceInfluence@: \NWlink{nuweb34a}{34a}\NWlink{nuweb44}{, 44}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb145d}{145d}}\NWlink{nuweb150a}{, 150a}.
\item \verb@C_get_varonly@: \NWlink{nuweb32}{32}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb46}{, 46}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb54}{, 54}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb143b}{143b}}\NWlink{nuweb144c}{, 144c}.
\item \verb@C_get_Xfactor@: \NWlink{nuweb46}{46}, \underline{\NWlink{nuweb143c}{143c}}.
\item \verb@C_kronecker@: \NWlink{nuweb80a}{80a}\NWlink{nuweb133b}{, 133b}, \underline{\NWlink{nuweb134}{134}}.
\item \verb@C_kronecker_sym@: \NWlink{nuweb79}{79}, \underline{\NWlink{nuweb135}{135}}.
\item \verb@C_KronSums_dweights_dsubset@: \NWlink{nuweb97a}{97a}, \underline{\NWlink{nuweb97b}{97b}}.
\item \verb@C_KronSums_dweights_isubset@: \NWlink{nuweb97a}{97a}, \underline{\NWlink{nuweb98b}{98b}}.
\item \verb@C_KronSums_iweights_dsubset@: \NWlink{nuweb97a}{97a}, \underline{\NWlink{nuweb97c}{97c}}.
\item \verb@C_KronSums_iweights_isubset@: \NWlink{nuweb97a}{97a}, \underline{\NWlink{nuweb98a}{98a}}.
\item \verb@C_KronSums_Permutation_dsubset@: \NWlink{nuweb103b}{103b}, \underline{\NWlink{nuweb104a}{104a}}.
\item \verb@C_KronSums_Permutation_isubset@: \NWlink{nuweb103b}{103b}, \underline{\NWlink{nuweb104b}{104b}}.
\item \verb@C_maxabsstand_Covariance@: \underline{\NWlink{nuweb59b}{59b}}\NWlink{nuweb63}{, 63}.
\item \verb@C_maxabsstand_Variance@: \underline{\NWlink{nuweb60a}{60a}}\NWlink{nuweb63}{, 63}.
\item \verb@C_maxstand_Covariance@: \underline{\NWlink{nuweb57b}{57b}}\NWlink{nuweb63}{, 63}.
\item \verb@C_maxstand_Variance@: \underline{\NWlink{nuweb58a}{58a}}\NWlink{nuweb63}{, 63}.
\item \verb@C_maxtype@: \NWlink{nuweb54}{54}, \underline{\NWlink{nuweb63}{63}}\NWlink{nuweb73c}{, 73c}.
\item \verb@C_maxtype_pvalue@: \NWlink{nuweb54}{54}, \underline{\NWlink{nuweb67}{67}}.
\item \verb@C_minstand_Covariance@: \underline{\NWlink{nuweb58b}{58b}}\NWlink{nuweb63}{, 63}.
\item \verb@C_minstand_Variance@: \underline{\NWlink{nuweb59a}{59a}}\NWlink{nuweb63}{, 63}.
\item \verb@C_OneTableSums_dweights_dsubset@: \NWlink{nuweb112a}{112a}, \underline{\NWlink{nuweb112d}{112d}}.
\item \verb@C_OneTableSums_dweights_isubset@: \NWlink{nuweb112a}{112a}, \underline{\NWlink{nuweb113c}{113c}}.
\item \verb@C_OneTableSums_iweights_dsubset@: \NWlink{nuweb112a}{112a}, \underline{\NWlink{nuweb113a}{113a}}.
\item \verb@C_OneTableSums_iweights_isubset@: \NWlink{nuweb112a}{112a}, \underline{\NWlink{nuweb113b}{113b}}.
\item \verb@C_ordered_Xfactor@: \NWlink{nuweb35b}{35b}\NWlink{nuweb44}{, 44}\NWlink{nuweb56}{, 56}, \underline{\NWlink{nuweb70}{70}}.
\item \verb@C_order_subset_wrt_block@: \NWlink{nuweb124b}{124b}, \underline{\NWlink{nuweb126a}{126a}}.
\item \verb@C_Permute@: \underline{\NWlink{nuweb128a}{128a}}\NWlink{nuweb128b}{, 128b}\NWlink{nuweb129a}{, 129a}.
\item \verb@C_PermuteBlock@: \underline{\NWlink{nuweb129a}{129a}}\NWlink{nuweb129b}{, 129b}.
\item \verb@C_perm_pvalue@: \NWlink{nuweb51}{51}\NWlink{nuweb54}{, 54}, \underline{\NWlink{nuweb65}{65}}\NWlink{nuweb73d}{, 73d}.
\item \verb@C_quadform@: \NWlink{nuweb51}{51}\NWlink{nuweb61b}{, 61b}, \underline{\NWlink{nuweb62}{62}}\NWlink{nuweb73c}{, 73c}.
\item \verb@C_setup_subset@: \NWlink{nuweb124b}{124b}, \underline{\NWlink{nuweb125a}{125a}}\NWlink{nuweb127a}{, 127a}.
\item \verb@C_setup_subset_block@: \NWlink{nuweb124b}{124b}, \underline{\NWlink{nuweb125b}{125b}}.
\item \verb@C_standardise@: \NWlink{nuweb39a}{39a}, \underline{\NWlink{nuweb64a}{64a}}.
\item \verb@C_Sums_dweights_dsubset@: \NWlink{nuweb91a}{91a}, \underline{\NWlink{nuweb91b}{91b}}.
\item \verb@C_Sums_dweights_isubset@: \NWlink{nuweb91a}{91a}, \underline{\NWlink{nuweb92c}{92c}}.
\item \verb@C_Sums_iweights_dsubset@: \NWlink{nuweb91a}{91a}, \underline{\NWlink{nuweb92a}{92a}}.
\item \verb@C_Sums_iweights_isubset@: \NWlink{nuweb91a}{91a}, \underline{\NWlink{nuweb92b}{92b}}.
\item \verb@C_ThreeTableSums_dweights_dsubset@: \NWlink{nuweb120b}{120b}, \underline{\NWlink{nuweb121b}{121b}}.
\item \verb@C_ThreeTableSums_dweights_isubset@: \NWlink{nuweb120b}{120b}, \underline{\NWlink{nuweb122a}{122a}}.
\item \verb@C_ThreeTableSums_iweights_dsubset@: \NWlink{nuweb120b}{120b}, \underline{\NWlink{nuweb121c}{121c}}.
\item \verb@C_ThreeTableSums_iweights_isubset@: \NWlink{nuweb120b}{120b}, \underline{\NWlink{nuweb121d}{121d}}.
\item \verb@C_TwoTableSums_dweights_dsubset@: \NWlink{nuweb116a}{116a}, \underline{\NWlink{nuweb117a}{117a}}.
\item \verb@C_TwoTableSums_dweights_isubset@: \NWlink{nuweb116a}{116a}, \underline{\NWlink{nuweb118a}{118a}}.
\item \verb@C_TwoTableSums_iweights_dsubset@: \NWlink{nuweb116a}{116a}, \underline{\NWlink{nuweb117b}{117b}}.
\item \verb@C_TwoTableSums_iweights_isubset@: \NWlink{nuweb116a}{116a}, \underline{\NWlink{nuweb117c}{117c}}.
\item \verb@C_unordered_Xfactor@: \NWlink{nuweb35b}{35b}\NWlink{nuweb56}{, 56}, \underline{\NWlink{nuweb74}{74}}.
\item \verb@C_VarianceLinearStatistic@: \NWlink{nuweb35c}{35c}\NWlink{nuweb44}{, 44}\NWlink{nuweb73b}{, 73b}\NWlink{nuweb77a}{, 77a}, \underline{\NWlink{nuweb80a}{80a}}.
\item \verb@C_XfactorKronSums_dweights_dsubset@: \NWlink{nuweb96b}{96b}, \underline{\NWlink{nuweb100b}{100b}}.
\item \verb@C_XfactorKronSums_dweights_isubset@: \NWlink{nuweb96b}{96b}, \underline{\NWlink{nuweb101a}{101a}}.
\item \verb@C_XfactorKronSums_iweights_dsubset@: \NWlink{nuweb96b}{96b}, \underline{\NWlink{nuweb100c}{100c}}.
\item \verb@C_XfactorKronSums_iweights_isubset@: \NWlink{nuweb96b}{96b}, \underline{\NWlink{nuweb100d}{100d}}.
\item \verb@C_XfactorKronSums_Permutation_dsubset@: \NWlink{nuweb103b}{103b}, \underline{\NWlink{nuweb105a}{105a}}.
\item \verb@C_XfactorKronSums_Permutation_isubset@: \NWlink{nuweb103b}{103b}, \underline{\NWlink{nuweb105b}{105b}}.
\item \verb@dim_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb142c}{, 142c}\NWlink{nuweb143a}{, 143a}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@DoCenter@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81c}{, 81c}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb106c}{, 106c}.
\item \verb@DoSymmetric@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb88a}{, 88a}.
\item \verb@DoVarOnly@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb35b}{, 35b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb44}{, 44}.
\item \verb@ExpectationInfluence_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb145b}{, 145b}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@ExpectationX_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb145a}{, 145a}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@Expectation_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb144a}{, 144a}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@GE@: \underline{\NWlink{nuweb21a}{21a}}\NWlink{nuweb51}{, 51}\NWlink{nuweb54}{, 54}.
\item \verb@HAS_WEIGHTS@: \underline{\NWlink{nuweb25c}{25c}}, \underline{\NWlink{nuweb25d}{25d}}\NWlink{nuweb93a}{, 93a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb122b}{, 122b}.
\item \verb@LE@: \underline{\NWlink{nuweb21a}{21a}}\NWlink{nuweb54}{, 54}.
\item \verb@LECV@: \NWlink{nuweb38b}{38b}\NWlink{nuweb38c}{c}\NWlink{nuweb39a}{, 39a}\NWlink{nuweb50c}{, 50c}\NWlink{nuweb51}{, 51}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb53}{, 53}\NWlink{nuweb54}{, 54}\NWlink{nuweb55a}{, 55a}\NWlink{nuweb55b}{b}\NWlink{nuweb56}{, 56}\NWlink{nuweb69b}{, 69b}\NWlink{nuweb71}{, 71}, \underline{\NWlink{nuweb142b}{142b}}\NWlink{nuweb142c}{, 142c}\NWlink{nuweb143a}{, 143a}\NWlink{nuweb143b}{b}\NWlink{nuweb143c}{c}\NWlink{nuweb143d}{d}\NWlink{nuweb144a}{, 144a}\NWlink{nuweb144b}{b}\NWlink{nuweb144c}{c}\NWlink{nuweb145a}{, 145a}\NWlink{nuweb145b}{b}\NWlink{nuweb145c}{c}\NWlink{nuweb145d}{d}\NWlink{nuweb146a}{, 146a}\NWlink{nuweb146b}{b}\NWlink{nuweb146c}{c}\NWlink{nuweb146d}{d}\NWlink{nuweb147a}{, 147a}\NWlink{nuweb147b}{b}\NWlink{nuweb147c}{c}\NWlink{nuweb147d}{d}.
\item \verb@LinearStatistic_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb143d}{, 143d}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@mPQB@: \NWlink{nuweb36a}{36a}\NWlink{nuweb37}{, 37}\NWlink{nuweb45}{, 45}\NWlink{nuweb48}{, 48}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb71}{, 71}\NWlink{nuweb73a}{, 73a}\NWlink{nuweb76b}{, 76b}\NWlink{nuweb78b}{, 78b}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb122b}{, 122b}, \underline{\NWlink{nuweb132b}{132b}}\NWlink{nuweb149}{, 149}.
\item \verb@N@: \NWlink{nuweb5a}{5a}\NWlink{nuweb5b}{b}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15b}{, 15b}, \underline{\NWlink{nuweb23b}{23b}}, \underline{\NWlink{nuweb23c}{23c}}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb67}{, 67}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb88c}{c}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb93a}{, 93a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb125a}{, 125a}\NWlink{nuweb125b}{b}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb127a}{, 127a}\NWlink{nuweb136a}{, 136a}.
\item \verb@NCOL@: \NWlink{nuweb12}{12}\NWlink{nuweb31b}{, 31b}\NWlink{nuweb41b}{, 41b}\NWlink{nuweb61b}{, 61b}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb123c}{, 123c}, \underline{\NWlink{nuweb131a}{131a}}\NWlink{nuweb133b}{, 133b}.
\item \verb@NLEVELS@: \NWlink{nuweb31b}{31b}\NWlink{nuweb41b}{, 41b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb123c}{, 123c}, \underline{\NWlink{nuweb131b}{131b}}.
\item \verb@NROW@: \NWlink{nuweb6}{6}\NWlink{nuweb8}{, 8}\NWlink{nuweb9a}{, 9a}\NWlink{nuweb9b}{b}\NWlink{nuweb14}{, 14}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb37}{, 37}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb61b}{, 61b}, \underline{\NWlink{nuweb130b}{130b}}\NWlink{nuweb131b}{, 131b}\NWlink{nuweb133b}{, 133b}\NWlink{nuweb141c}{, 141c}.
\item \verb@Nsubset@: \underline{\NWlink{nuweb26b}{26b}}\NWlink{nuweb34b}{, 34b}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb88c}{c}\NWlink{nuweb89a}{, 89a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb93a}{, 93a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb128a}{, 128a}\NWlink{nuweb128b}{b}\NWlink{nuweb129b}{, 129b}.
\item \verb@offset@: \underline{\NWlink{nuweb26c}{26c}}\NWlink{nuweb32}{, 32}\NWlink{nuweb34b}{, 34b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81c}{, 81c}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb120b}{, 120b}.
\item \verb@Offset0@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb127a}{, 127a}.
\item \verb@P@: \NWlink{nuweb14}{14}, \underline{\NWlink{nuweb24a}{24a}}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb46}{, 46}\NWlink{nuweb48}{, 48}\NWlink{nuweb51}{, 51}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb54}{, 54}\NWlink{nuweb56}{, 56}\NWlink{nuweb70}{, 70}\NWlink{nuweb71}{, 71}\NWlink{nuweb72}{, 72}\NWlink{nuweb73a}{, 73a}\NWlink{nuweb74}{, 74}\NWlink{nuweb75a}{, 75a}\NWlink{nuweb75b}{b}\NWlink{nuweb76a}{, 76a}\NWlink{nuweb76b}{b}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb78b}{, 78b}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb84b}{, 84b}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb86}{, 86}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb94a}{, 94a}\NWlink{nuweb94b}{b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102a}{, 102a}\NWlink{nuweb102b}{b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb132a}{, 132a}\NWlink{nuweb132b}{b}\NWlink{nuweb136a}{, 136a}\NWlink{nuweb148a}{, 148a}\NWlink{nuweb149}{, 149}.
\item \verb@PermutedLinearStatistic_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb147b}{, 147b}\NWlink{nuweb147c}{c}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@Power1@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb81c}{, 81c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb106c}{, 106c}.
\item \verb@Power2@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb88a}{, 88a}.
\item \verb@PP12@: \NWlink{nuweb34a}{34a}\NWlink{nuweb44}{, 44}\NWlink{nuweb46}{, 46}\NWlink{nuweb51}{, 51}\NWlink{nuweb79}{, 79}\NWlink{nuweb88a}{, 88a}, \underline{\NWlink{nuweb132a}{132a}}\NWlink{nuweb149}{, 149}\NWlink{nuweb150a}{, 150a}.
\item \verb@Q@: \NWlink{nuweb14}{14}, \underline{\NWlink{nuweb24e}{24e}}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb37}{, 37}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb46}{, 46}\NWlink{nuweb48}{, 48}\NWlink{nuweb51}{, 51}\NWlink{nuweb52a}{, 52a}\NWlink{nuweb54}{, 54}\NWlink{nuweb70}{, 70}\NWlink{nuweb71}{, 71}\NWlink{nuweb72}{, 72}\NWlink{nuweb73a}{, 73a}\NWlink{nuweb73b}{b}\NWlink{nuweb73c}{c}\NWlink{nuweb74}{, 74}\NWlink{nuweb76a}{, 76a}\NWlink{nuweb76b}{b}\NWlink{nuweb77a}{, 77a}\NWlink{nuweb77d}{d}\NWlink{nuweb78b}{, 78b}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb132b}{, 132b}\NWlink{nuweb148a}{, 148a}\NWlink{nuweb149}{, 149}\NWlink{nuweb150a}{, 150a}.
\item \verb@RC_colSums@: \NWlink{nuweb81c}{81c}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107a}{, 107a}, \underline{\NWlink{nuweb107b}{107b}}.
\item \verb@RC_CovarianceInfluence@: \NWlink{nuweb35b}{35b}\NWlink{nuweb44}{, 44}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb83b}{b}, \underline{\NWlink{nuweb84a}{84a}}.
\item \verb@RC_CovarianceX@: \NWlink{nuweb35c}{35c}\NWlink{nuweb35d}{d}\NWlink{nuweb44}{, 44}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb87b}{b}, \underline{\NWlink{nuweb88a}{88a}}.
\item \verb@RC_ExpectationCovarianceStatistic@: \NWlink{nuweb31a}{31a}, \underline{\NWlink{nuweb32}{32}}, \underline{\NWlink{nuweb45}{45}}.
\item \verb@RC_ExpectationInfluence@: \NWlink{nuweb35a}{35a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81b}{b}, \underline{\NWlink{nuweb81c}{81c}}.
\item \verb@RC_ExpectationX@: \NWlink{nuweb35a}{35a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb85a}{, 85a}, \underline{\NWlink{nuweb85b}{85b}}.
\item \verb@RC_init_LECV_1d@: \NWlink{nuweb31a}{31a}, \underline{\NWlink{nuweb150b}{150b}}.
\item \verb@RC_init_LECV_2d@: \NWlink{nuweb41a}{41a}, \underline{\NWlink{nuweb151}{151}}.
\item \verb@RC_KronSums@: \NWlink{nuweb77d}{77d}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb95a}{, 95a}, \underline{\NWlink{nuweb95b}{95b}}.
\item \verb@RC_KronSums_Permutation@: \NWlink{nuweb37}{37}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103a}{, 103a}, \underline{\NWlink{nuweb103b}{103b}}.
\item \verb@RC_LinearStatistic@: \NWlink{nuweb33b}{33b}\NWlink{nuweb77c}{, 77c}, \underline{\NWlink{nuweb77d}{77d}}.
\item \verb@RC_OneTableSums@: \NWlink{nuweb34a}{34a}\NWlink{nuweb37}{, 37}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb111b}{b}, \underline{\NWlink{nuweb112a}{112a}}.
\item \verb@RC_order_subset_wrt_block@: \NWlink{nuweb34a}{34a}\NWlink{nuweb37}{, 37}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124a}{, 124a}, \underline{\NWlink{nuweb124b}{124b}}.
\item \verb@RC_setup_subset@: \NWlink{nuweb37}{37}\NWlink{nuweb126b}{, 126b}, \underline{\NWlink{nuweb127a}{127a}}.
\item \verb@RC_Sums@: \NWlink{nuweb34a}{34a}\NWlink{nuweb34b}{b}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb90b}{b}, \underline{\NWlink{nuweb91a}{91a}}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb127a}{, 127a}.
\item \verb@RC_ThreeTableSums@: \NWlink{nuweb41a}{41a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120a}{, 120a}, \underline{\NWlink{nuweb120b}{120b}}.
\item \verb@RC_TwoTableSums@: \NWlink{nuweb41a}{41a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb115b}{b}, \underline{\NWlink{nuweb116a}{116a}}.
\item \verb@R_colSums@: \NWlink{nuweb106b}{106b}, \underline{\NWlink{nuweb106c}{106c}}\NWlink{nuweb154}{, 154}.
\item \verb@R_CovarianceInfluence@: \NWlink{nuweb82}{82}, \underline{\NWlink{nuweb83a}{83a}}\NWlink{nuweb154}{, 154}.
\item \verb@R_CovarianceX@: \NWlink{nuweb86}{86}, \underline{\NWlink{nuweb87a}{87a}}\NWlink{nuweb154}{, 154}.
\item \verb@R_ExpectationCovarianceStatistic@: \NWlink{nuweb6}{6}\NWlink{nuweb30c}{, 30c}\NWlink{nuweb30d}{d}, \underline{\NWlink{nuweb31a}{31a}}\NWlink{nuweb154}{, 154}.
\item \verb@R_ExpectationCovarianceStatistic_2d@: \NWlink{nuweb8}{8}\NWlink{nuweb40a}{, 40a}\NWlink{nuweb40b}{b}, \underline{\NWlink{nuweb41a}{41a}}\NWlink{nuweb154}{, 154}.
\item \verb@R_ExpectationInfluence@: \NWlink{nuweb80b}{80b}, \underline{\NWlink{nuweb81a}{81a}}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb154}{, 154}.
\item \verb@R_ExpectationX@: \NWlink{nuweb84b}{84b}, \underline{\NWlink{nuweb84c}{84c}}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb154}{, 154}.
\item \verb@R_KronSums@: \NWlink{nuweb94a}{94a}, \underline{\NWlink{nuweb94b}{94b}}\NWlink{nuweb154}{, 154}.
\item \verb@R_KronSums_Permutation@: \NWlink{nuweb102a}{102a}, \underline{\NWlink{nuweb102b}{102b}}\NWlink{nuweb154}{, 154}.
\item \verb@R_MPinv_sym@: \NWlink{nuweb136b}{136b}\NWlink{nuweb137a}{, 137a}, \underline{\NWlink{nuweb137b}{137b}}\NWlink{nuweb154}{, 154}.
\item \verb@R_OneTableSums@: \NWlink{nuweb15b}{15b}\NWlink{nuweb110b}{, 110b}, \underline{\NWlink{nuweb111a}{111a}}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb154}{, 154}.
\item \verb@R_order_subset_wrt_block@: \NWlink{nuweb123b}{123b}, \underline{\NWlink{nuweb123c}{123c}}\NWlink{nuweb154}{, 154}.
\item \verb@R_pack_sym@: \NWlink{nuweb141a}{141a}\NWlink{nuweb141b}{b}, \underline{\NWlink{nuweb141c}{141c}}\NWlink{nuweb154}{, 154}.
\item \verb@R_PermutedLinearStatistic@: \NWlink{nuweb6}{6}\NWlink{nuweb36b}{, 36b}\NWlink{nuweb36c}{c}, \underline{\NWlink{nuweb37}{37}}\NWlink{nuweb154}{, 154}.
\item \verb@R_PermutedLinearStatistic_2d@: \NWlink{nuweb8}{8}\NWlink{nuweb47a}{, 47a}\NWlink{nuweb47b}{b}, \underline{\NWlink{nuweb48}{48}}\NWlink{nuweb49a}{, 49a}\NWlink{nuweb154}{, 154}.
\item \verb@R_quadform@: \NWlink{nuweb60b}{60b}\NWlink{nuweb61a}{, 61a}, \underline{\NWlink{nuweb61b}{61b}}\NWlink{nuweb154}{, 154}.
\item \verb@R_Sums@: \NWlink{nuweb89c}{89c}, \underline{\NWlink{nuweb90a}{90a}}\NWlink{nuweb154}{, 154}.
\item \verb@R_ThreeTableSums@: \NWlink{nuweb15b}{15b}\NWlink{nuweb119a}{, 119a}, \underline{\NWlink{nuweb119b}{119b}}\NWlink{nuweb154}{, 154}.
\item \verb@R_TwoTableSums@: \NWlink{nuweb15b}{15b}\NWlink{nuweb114b}{, 114b}, \underline{\NWlink{nuweb115a}{115a}}\NWlink{nuweb154}{, 154}.
\item \verb@R_unpack_sym@: \NWlink{nuweb10}{10}\NWlink{nuweb139a}{, 139a}\NWlink{nuweb139b}{b}, \underline{\NWlink{nuweb140}{140}}\NWlink{nuweb154}{, 154}.
\item \verb@S@: \underline{\NWlink{nuweb21a}{21a}}\NWlink{nuweb35b}{, 35b}\NWlink{nuweb36a}{, 36a}\NWlink{nuweb44}{, 44}\NWlink{nuweb45}{, 45}\NWlink{nuweb57b}{, 57b}\NWlink{nuweb58b}{, 58b}\NWlink{nuweb59b}{, 59b}\NWlink{nuweb62}{, 62}\NWlink{nuweb64a}{, 64a}\NWlink{nuweb68}{, 68}\NWlink{nuweb69a}{, 69a}\NWlink{nuweb73a}{, 73a}\NWlink{nuweb76b}{, 76b}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb99}{, 99}\NWlink{nuweb135}{, 135}\NWlink{nuweb136a}{, 136a}\NWlink{nuweb138}{, 138}\NWlink{nuweb144b}{, 144b}.
\item \verb@StandardisedPermutedLinearStatistic_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@subset@: \NWlink{nuweb3b}{3b}\NWlink{nuweb4}{, 4}\NWlink{nuweb5a}{, 5a}\NWlink{nuweb5b}{b}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15a}{, 15a}\NWlink{nuweb15b}{b}\NWlink{nuweb17}{, 17}\NWlink{nuweb19}{, 19}, \underline{\NWlink{nuweb26a}{26a}}, \underline{\NWlink{nuweb26d}{26d}}, \underline{\NWlink{nuweb26e}{26e}}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb32}{, 32}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb89a}{, 89a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb124b}{, 124b}\NWlink{nuweb126a}{, 126a}\NWlink{nuweb127a}{, 127a}\NWlink{nuweb128a}{, 128a}\NWlink{nuweb128b}{b}\NWlink{nuweb129a}{, 129a}\NWlink{nuweb129b}{b}.
\item \verb@sumweights@: \underline{\NWlink{nuweb25e}{25e}}\NWlink{nuweb32}{, 32}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb34b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb43a}{, 43a}\NWlink{nuweb43b}{b}\NWlink{nuweb44}{, 44}\NWlink{nuweb46}{, 46}\NWlink{nuweb48}{, 48}\NWlink{nuweb49b}{, 49b}\NWlink{nuweb49d}{d}\NWlink{nuweb71}{, 71}\NWlink{nuweb72}{, 72}\NWlink{nuweb73b}{, 73b}\NWlink{nuweb77a}{, 77a}\NWlink{nuweb79}{, 79}\NWlink{nuweb80a}{, 80a}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb127a}{, 127a}\NWlink{nuweb146b}{, 146b}.
\item \verb@Sumweights_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb146b}{, 146b}\NWlink{nuweb147a}{, 147a}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}\NWlink{nuweb150b}{, 150b}.
\item \verb@TableBlock_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb34a}{, 34a}\NWlink{nuweb146a}{, 146a}\NWlink{nuweb147a}{, 147a}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}\NWlink{nuweb150b}{, 150b}.
\item \verb@Table_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb146c}{, 146c}\NWlink{nuweb146d}{d}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}\NWlink{nuweb151}{, 151}.
\item \verb@tol_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb147d}{, 147d}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@VarianceInfluence_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb145d}{, 145d}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@Variance_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb144b}{, 144b}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@varonly_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb143b}{, 143b}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@weights@: \NWlink{nuweb3b}{3b}\NWlink{nuweb4}{, 4}\NWlink{nuweb5a}{, 5a}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15a}{, 15a}\NWlink{nuweb15b}{b}\NWlink{nuweb17}{, 17}\NWlink{nuweb19}{, 19}, \underline{\NWlink{nuweb25b}{25b}}\NWlink{nuweb25c}{, 25c}\NWlink{nuweb25d}{d}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb34b}{, 34b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb49a}{, 49a}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb88b}{b}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb91a}{, 91a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb127a}{, 127a}.
\item \verb@weights,@: \NWlink{nuweb4}{4}\NWlink{nuweb6}{, 6}\NWlink{nuweb8}{, 8}\NWlink{nuweb15b}{, 15b}\NWlink{nuweb19}{, 19}, \underline{\NWlink{nuweb25c}{25c}}, \underline{\NWlink{nuweb25d}{25d}}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb34b}{, 34b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb84c}{c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb90a}{, 90a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb127a}{, 127a}.
\item \verb@x@: \NWlink{nuweb8}{8}\NWlink{nuweb14}{, 14}\NWlink{nuweb17}{, 17}\NWlink{nuweb21a}{, 21a}, \underline{\NWlink{nuweb23d}{23d}}, \underline{\NWlink{nuweb24b}{24b}}, \underline{\NWlink{nuweb24c}{24c}}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33a}{, 33a}\NWlink{nuweb33b}{b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35c}{c}\NWlink{nuweb35d}{d}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb48}{, 48}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb84c}{, 84c}\NWlink{nuweb85b}{, 85b}\NWlink{nuweb87a}{, 87a}\NWlink{nuweb88a}{, 88a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb95b}{, 95b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb106c}{, 106c}\NWlink{nuweb107b}{, 107b}\NWlink{nuweb109b}{, 109b}\NWlink{nuweb111a}{, 111a}\NWlink{nuweb112a}{, 112a}\NWlink{nuweb114a}{, 114a}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb130b}{, 130b}\NWlink{nuweb131a}{, 131a}\NWlink{nuweb131b}{b}\NWlink{nuweb136a}{, 136a}\NWlink{nuweb136b}{b}\NWlink{nuweb137a}{, 137a}\NWlink{nuweb137b}{b}\NWlink{nuweb138}{, 138}\NWlink{nuweb139a}{, 139a}\NWlink{nuweb139b}{b}\NWlink{nuweb140}{, 140}\NWlink{nuweb141a}{, 141a}\NWlink{nuweb141b}{b}\NWlink{nuweb141c}{c}.
\item \verb@Xfactor_SLOT@: \underline{\NWlink{nuweb21b}{21b}}\NWlink{nuweb143c}{, 143c}\NWlink{nuweb148b}{, 148b}\NWlink{nuweb149}{, 149}.
\item \verb@y@: \NWlink{nuweb14}{14}\NWlink{nuweb21a}{, 21a}, \underline{\NWlink{nuweb24d}{24d}}, \underline{\NWlink{nuweb24f}{24f}}, \underline{\NWlink{nuweb25a}{25a}}\NWlink{nuweb30d}{, 30d}\NWlink{nuweb31a}{, 31a}\NWlink{nuweb31b}{b}\NWlink{nuweb33b}{, 33b}\NWlink{nuweb35a}{, 35a}\NWlink{nuweb35b}{b}\NWlink{nuweb36c}{, 36c}\NWlink{nuweb37}{, 37}\NWlink{nuweb40b}{, 40b}\NWlink{nuweb41a}{, 41a}\NWlink{nuweb41b}{b}\NWlink{nuweb42a}{, 42a}\NWlink{nuweb43b}{, 43b}\NWlink{nuweb44}{, 44}\NWlink{nuweb47b}{, 47b}\NWlink{nuweb77d}{, 77d}\NWlink{nuweb81a}{, 81a}\NWlink{nuweb81c}{c}\NWlink{nuweb83a}{, 83a}\NWlink{nuweb84a}{, 84a}\NWlink{nuweb94b}{, 94b}\NWlink{nuweb96b}{, 96b}\NWlink{nuweb97a}{, 97a}\NWlink{nuweb99}{, 99}\NWlink{nuweb101b}{, 101b}\NWlink{nuweb102b}{, 102b}\NWlink{nuweb103b}{, 103b}\NWlink{nuweb104c}{, 104c}\NWlink{nuweb105c}{, 105c}\NWlink{nuweb115a}{, 115a}\NWlink{nuweb116a}{, 116a}\NWlink{nuweb118b}{, 118b}\NWlink{nuweb119b}{, 119b}\NWlink{nuweb120b}{, 120b}\NWlink{nuweb122b}{, 122b}\NWlink{nuweb123c}{, 123c}\NWlink{nuweb134}{, 134}\NWlink{nuweb135}{, 135}.
\end{list}}

\bibliographystyle{plainnat}
\bibliography{\Sexpr{gsub("\\.bib", "", system.file("REFERENCES.bib", package = "libcoin"))}}

\end{document}
