[latex3-commits] [l3svn] r6973 - Add new "fpu" package

noreply at latex-project.org noreply at latex-project.org
Tue Feb 21 22:38:53 CET 2017


Author: joseph
Date: 2017-02-21 22:38:53 +0100 (Tue, 21 Feb 2017)
New Revision: 6973

Added:
   trunk/l3packages/fpu/
   trunk/l3packages/fpu/build.lua
   trunk/l3packages/fpu/fpu.dtx
   trunk/l3packages/fpu/fpu.ins
Modified:
   trunk/l3packages/README.md
Log:
Add new "fpu" package

The name is probably not stable yet, but hopefully the core idea
is. Documentation is largely a copy-paste from l3fp.dtx but with
'not yet' stuff, etc., removed.


Modified: trunk/l3packages/README.md
===================================================================
--- trunk/l3packages/README.md	2017-02-21 14:17:48 UTC (rev 6972)
+++ trunk/l3packages/README.md	2017-02-21 21:38:53 UTC (rev 6973)
@@ -20,11 +20,21 @@
 
 Currently included in the CTAN release of `l3packages` are the following
 bundles:
+* `fpu`
 * `l3keys2e`
 * `xfrac`
 * `xparse`
 * `xtemplate`
 
+`fpu`
+-----
+
+The `fpu` package provides a document-level interface for the LaTeX3
+FPU. As such, it is a wrapper around the core `\fp_eval:n` function
+but does not require code syntax. It provides the expandable command
+`\fpeval`, which can be used inside for example `\edef` or contexts
+where TeX requires a number.
+
 `l3keys2e`
 ----------
 

Added: trunk/l3packages/fpu/build.lua
===================================================================
--- trunk/l3packages/fpu/build.lua	                        (rev 0)
+++ trunk/l3packages/fpu/build.lua	2017-02-21 21:38:53 UTC (rev 6973)
@@ -0,0 +1,18 @@
+#!/usr/bin/env texlua
+
+-- Build script for LaTeX3 "fpu" files
+
+-- Identify the bundle and module: the module may be empty in the case where
+-- there is no subdivision
+bundle = "l3packages"
+module = "fpu"
+
+-- Location of main directory: use Unix-style path separators
+maindir = "../.."
+
+-- Load the common build code: this is the one place that a path needs to be
+-- hard-coded
+-- As the build system is 'self-contained' there is no module set up here: just
+--load the file in a similar way to a TeX \input
+dofile (maindir .. "/build-config.lua")
+dofile (maindir .. "/l3build/l3build.lua")

Added: trunk/l3packages/fpu/fpu.dtx
===================================================================
--- trunk/l3packages/fpu/fpu.dtx	                        (rev 0)
+++ trunk/l3packages/fpu/fpu.dtx	2017-02-21 21:38:53 UTC (rev 6973)
@@ -0,0 +1,167 @@
+% \iffalse meta-comment
+%
+%% File: fpu.dtx (C) Copyright 2017 The LaTeX3 Project
+%
+% It may be distributed and/or modified under the conditions of the
+% LaTeX Project Public License (LPPL), either version 1.3c of this
+% license or (at your option) any later version.  The latest version
+% of this license is in the file
+%
+%    http://www.latex-project.org/lppl.txt
+%
+% This file is part of the "l3packages bundle" (The Work in LPPL)
+% and all files in that bundle must be distributed together.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/latex3/latex3
+%
+% for those people who are interested.
+%
+%<*driver|package>
+% The version of expl3 required is tested as early as possible, as
+% some really old versions do not define \ProvidesExplPackage.
+\RequirePackage{xparse}[2017/02/10]
+%<package>\@ifpackagelater{xparse}{2017/02/10}
+%<package>  {}
+%<package>  {%
+%<package>    \PackageError{fpu}{Support package xparse too old}
+%<package>      {%
+%<package>        Please install an up to date version of xparse\MessageBreak
+%<package>        using your TeX package manager or from CTAN.\MessageBreak
+%<package>        \MessageBreak
+%<package>        Loading fpu will abort!%
+%<package>      }%
+%<package>    \endinput
+%<package>  }
+\def\ExplFileName{fpu}
+\def\ExplFileDescription{LaTeX Floating Point Unit}
+\def\ExplFileDate{2017/02/10}
+\def\ExplFileVersion{6878}
+%</driver|package>
+%<*driver>
+\documentclass[full]{l3doc}
+\usepackage{amstext}
+\begin{document}
+  \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \providecommand\nan{\texttt{NaN}}
+%
+% \title{^^A
+%   The \textsf{fpu} package\\Floating Point Unit^^A
+%   \thanks{This file describes v\ExplFileVersion,
+%     last revised \ExplFileDate.}^^A
+% }
+%
+% \author{^^A
+%  The \LaTeX3 Project\thanks
+%    {^^A
+%      E-mail:
+%        \href{mailto:latex-team at latex-project.org}
+%          {latex-team at latex-project.org}^^A
+%    }^^A
+% }
+%
+% \date{Released \ExplFileDate}
+%
+% \maketitle
+%
+% \begin{documentation}
+%
+% This package provides a \LaTeXe{} document-level interface to the \LaTeX{}3
+% floating point unit (part of \pkg{expl3}).
+% 
+% \begin{function}[EXP]{\fpeval}
+%   The expandable command \cs{fpeval} takes as it's argument a floating
+%   point expression and will produce a result using the normal rules of
+%   mathematics. As this command is expandable it can be used where \TeX{}
+%   requires a number and for example within a low-level \cs{edef} operation
+%   to give a purely numerical result.
+% \end{function}
+% 
+% Briefly, the floating point expressions may comprise:
+% \begin{itemize}
+%   \item Basic arithmetic: addition $x+y$, subtraction $x-y$,
+%     multiplication $x*y$, division $x/y$, square root~$\sqrt{x}$,
+%     and parentheses.
+%   \item Comparison operators: $x\mathop{\mathtt{<}}y$,
+%     $x\mathop{\mathtt{<=}}y$, $x\mathop{\mathtt{>?}}y$,
+%     $x\mathop{\mathtt{!=}}y$ \emph{etc.}
+%   \item Boolean logic: negation $\mathop{!}x$, conjunction
+%     $x\mathop{\&\&}y$, disjunction $x\mathop{\vert\vert}y$, ternary
+%     operator $x\mathop{?}y\mathop{:}z$.
+%   \item Exponentials: $\exp x$, $\ln x$, $x^y$.
+%   \item Trigonometry: $\sin x$, $\cos x$, $\tan x$, $\cot x$, $\sec
+%     x$, $\csc x$ expecting their arguments in radians, and
+%     $\operatorname{sind} x$, $\operatorname{cosd} x$,
+%     $\operatorname{tand} x$, $\operatorname{cotd} x$,
+%     $\operatorname{secd} x$, $\operatorname{cscd} x$ expecting their
+%     arguments in degrees.
+%   \item Inverse trigonometric functions: $\operatorname{asin} x$,
+%     $\operatorname{acos} x$, $\operatorname{atan} x$,
+%     $\operatorname{acot} x$, $\operatorname{asec} x$,
+%     $\operatorname{acsc} x$ giving a result in radians, and
+%     $\operatorname{asind} x$, $\operatorname{acosd} x$,
+%     $\operatorname{atand} x$, $\operatorname{acotd} x$,
+%     $\operatorname{asecd} x$, $\operatorname{acscd} x$ giving a result
+%     in degrees.
+%   \item Extrema: $\max(x,y,\ldots)$, $\min(x,y,\ldots)$,
+%     $\operatorname{abs}(x)$.
+%   \item Rounding functions ($n=0$ by default, $t=\nan$ by default):
+%     $\operatorname{trunc}(x,n)$ rounds towards zero,
+%     $\operatorname{floor}(x,n)$ rounds towards~$-\infty$,
+%     $\operatorname{ceil}(x,n)$ rounds towards~$+\infty$,
+%     $\operatorname{round}(x,n,t)$ rounds to the closest value, with
+%     ties rounded to an even value by default, towards zero if $t=0$,
+%     towards $+\infty$ if $t>0$ and towards $-\infty$ if $t<0$.
+%   \item Random numbers: $\mathop{rand}()$, $\mathop{randint}(m,n)$ (requires
+%     \pdfTeX{} or \LuaTeX{}).
+%   \item Constants: \texttt{pi}, \texttt{deg} (one degree in radians).
+%   \item Dimensions, automatically expressed in points, \emph{e.g.},
+%     \texttt{pc} is~$12$.
+%   \item Automatic conversion (no need for \cs{number} of
+%     integer, dimension, and skip variables to floating points,
+%     expressing dimensions in points and ignoring the stretch and
+%     shrink components of skips.
+% \end{itemize}
+%
+% An example of use could be the following.
+% \begin{verbatim}
+%   \LaTeX{} can now compute: $ \frac{\sin (3.5)}{2} + 2\cdot 10^{-3}
+%   = \fpeval{sin 3.5 /2 + 2e-3} $.
+% \end{verbatim}
+%
+% \end{documentation}
+%
+% \begin{implementation}
+%
+% \section{\pkg{fpu} implementation}
+%
+%    \begin{macrocode}
+%<*package>
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\ProvidesExplPackage
+  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
+%    \end{macrocode}
+%
+% \begin{macro}{\fpeval}
+%   A document level wrapper around the code level function.
+%    \begin{macrocode}
+\NewExpandableDocumentCommand \fpeval { m } { \fp_eval:n {#1} }
+%    \end{macrocode}
+% \end{macro}
+%
+%    \begin{macrocode}
+%</package>
+%    \end{macrocode}
+%
+% \end{implementation}
+%
+% \PrintIndex

Added: trunk/l3packages/fpu/fpu.ins
===================================================================
--- trunk/l3packages/fpu/fpu.ins	                        (rev 0)
+++ trunk/l3packages/fpu/fpu.ins	2017-02-21 21:38:53 UTC (rev 6973)
@@ -0,0 +1,45 @@
+\iffalse meta-comment
+
+File xparse.ins Copyright (C) 2017 The LaTeX3 Project
+
+It may be distributed and/or modified under the conditions of the
+LaTeX Project Public License (LPPL), either version 1.3c of this
+license or (at your option) any later version.  The latest version
+of this license is in the file
+
+   http://www.latex-project.org/lppl.txt
+
+This file is part of the "l3packages bundle" (The Work in LPPL)
+and all files in that bundle must be distributed together.
+
+The released version of this bundle is available from CTAN.
+
+\fi
+
+\input l3docstrip.tex
+\askforoverwritefalse
+
+\preamble
+
+Copyright (C) 2017 The LaTeX3 Project
+
+It may be distributed and/or modified under the conditions of
+the LaTeX Project Public License (LPPL), either version 1.3c of
+this license or (at your option) any later version.  The latest
+version of this license is in the file:
+
+   http://www.latex-project.org/lppl.txt
+
+This file is part of the "l3packages bundle" (The Work in LPPL)
+and all files in that bundle must be distributed together.
+
+\endpreamble
+% stop docstrip adding \endinput
+\postamble
+\endpostamble
+
+\keepsilent
+
+\generate{\file{fpu.sty} {\from{fpu.dtx} {package}}}
+
+\endbatchfile



More information about the latex3-commits mailing list