  We present a generic technique, automated by computer-algebra systems and
available as open-source software \cite{scuff-em}, for efficient numerical
evaluation of a large family of singular and nonsingular 4-dimensional
integrals over triangle-product domains, such as those arising in the
boundary-element method (BEM) of computational electromagnetism. To date,
practical implementation of BEM solvers has often required the aggregation of
multiple disparate integral-evaluation schemes to treat all of the distinct
types of integrals needed for a given BEM formulation; in contrast, our
technique allows many different types of integrals to be handled by the
\emph{same} algorithm and the same code implementation. Our method is a
significant generalization of the Taylor--Duffy approach
\cite{Taylor2003,Duffy1982}, which was originally presented for just a single
type of integrand; in addition to generalizing this technique to a broad class
of integrands, we also achieve a significant improvement in its efficiency by
showing how the \emph{dimension} of the final numerical integral may often be
reduced by one. In particular, if $n$ is the number of common vertices between
the two triangles, in many cases we can reduce the dimension of the integral
from $4-n$ to $3-n$, obtaining a closed-form analytical result for $n=3$ (the
common-triangle case).
