% -*- coding: utf-8; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z" -*- % This file: xint.dtx. Proudly produced by xint-dtxbuild.sh. % Extract all files via "etex xint.dtx" and do "make help" % or follow instructions from extracted README.md. %<*dtx> \def\xintdtxtimestamp {Time-stamp: <25-02-2020 at 23:06:44 CET>} % %<*drv> %% --------------------------------------------------------------- \def\xintdocdate {2020/02/25} \def\xintbndldate{2020/02/25} \def\xintbndlversion {1.4b} % %% README %% CHANGE LOG %% xint 1.4b %% 2020/02/25 % % Source: xint.dtx 1.4b 2020/02/25 (doc 2020/02/25) % Author: Jean-Francois Burnol % Info: Expandable operations on big integers, decimals, fractions % License: LPPL 1.3c % %<*!readme&!changes&!dohtmlsh&!makefile> %% --------------------------------------------------------------- %% The xint bundle 1.4b 2020/02/25 %% Copyright (C) 2013-2020 by Jean-Francois Burnol %%% xintkernel: Paraphernalia for the xint packages %%% xinttools: Expandable and non-expandable utilities %%% xintcore: Expandable arithmetic on big integers %%% xint: Expandable operations on big integers %%% xintfrac: Expandable operations on fractions %%% xintexpr: Expandable expression parser %%% xintbinhex: Expandable binary and hexadecimal conversions %%% xintgcd: Euclidean algorithm with xint package %%% xintseries: Expandable partial sums with xint package %%% xintcfrac: Expandable continued fractions with xint package %%% xinttrig: Trigonometry for the xintexpr package %%% xintlog: Logarithms and exponentials for xintexpr %% --------------------------------------------------------------- % %<*dtx> \bgroup\catcode2 0 \catcode`\\ 12 ^^Biffalse % %<*readme>-------------------------------------------------------- Aim and usage ============= It is possible to use the package both with Plain (`\input xintexpr.sty`) or with the LaTeX macro format (`\usepackage{xintexpr}`). The basic aim is provide *expandable* computations on (arbitrily big) integers, fractions, and floating point numbers (at a user chosen precision). The four operations and the square-root extraction achieve so-called *correct rounding* for the given arbitrary precision. The syntax knows dummy variables, as in this example: \xinteval{reduce(add(x/(x+7), x = 1000..1010))} which expands to: 108959959329292321880648657/9974444716475301992902544 Trigonometrical functions are available: \xintDigits*:=48\relax \xintfloateval{[-2] sind(37)} expands to: 0.6018150231520482799179770004414898414256377098 The [-2] means to round the result to 2 digits less than float precision: currently trigonometrical functions are mostly implemented at high level via the user interface for declaring functions and variables and have no way to use guard digits, hence the last two digits are often not accurate. Release `1.4` adds support for nested structures. For example: \xintthealign\xintexpr ndseq(1/(i+j), i=1..5; j=1..5)\relax will print on the page (this is customizable, e.g. to use a pmatrix environnement rather): [[ 1/2, 1/3, 1/4, 1/5, 1/6 ], [ 1/3, 1/4, 1/5, 1/6, 1/7 ], [ 1/4, 1/5, 1/6, 1/7, 1/8 ], [ 1/5, 1/6, 1/7, 1/8, 1/9 ], [ 1/6, 1/7, 1/8, 1/9, 1/10 ]] It is possible to declare "universal functions" (à la NumPy) which will act itemwise on all leaves of such "arrays". More features are planned such as providing an interface to algebra of matrices in this framework. Installation ============ `xint` is included in [TeXLive](http://tug.org/texlive/) (hence [MacTeX](http://tug.org/mactex/) also) and in [MikTeX](http://www.miktex.org/). Thus, use the package manager to update your distribution. Alternatives: - download [`xint.tds.zip`](http://mirror.ctan.org/install/macros/generic/xint.tds.zip) and install in a suitable TDS-compliant repertory via `unzip`. "admin" privilges might be needed, as well as a file database rebuild (`texhash`). For example, on macos x, installation into user home folder (no `sudo`, and no `texhash` as it is recommended to not have a ls-R file there) unzip xint.tds.zip -d ~/Library/texmf - all files can be extracted using `etex xint.dtx`, or `make` if the `Makefile` included in the CTAN upload is present; see the file `INSTALL`, if present, else read the help in extracted file `Makefile.mk`. Documentation ============= `README.md`: this file `CHANGES.html`: change log as relevant to end users (`texdoc --list xint`) `xint.pdf`: user manual `sourcexint.pdf`: commented source code (`texdoc --list xint` or `texdoc sourcexint`) Requirements ============ Since release `1.4`, `xintexpr` requires the `\expanded` primitive. This is a functionality of all major TeX engines since TeXLive 2019. License ======= Copyright (C) 2013-2020 by Jean-Francois Burnol This Work may be distributed and/or modified under the conditions of the LaTeX Project Public License version 1.3c. This version of this license is in > and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later. This Work has the LPPL maintenance status `author-maintained`. The Author of this Work is `Jean-Francois Burnol`. This Work consists of the files `Makefile`, `INSTALL`, and `xint.dtx` and its extracted and derived files inclusive of the documentation files `xint.pdf`, `sourcexint.pdf` and `CHANGES.html`. See `xint.pdf` for contact information. %-------------------------------------------------------- %<*changes>------------------------------------------------------- `1.4b (2020/02/25)` ---- All changes regard the **xintexpr** module. ### Future - `&`, `|`, (as Boolean operators) and `=` (as equality test) have long been deprecated in favour of `&&`, `||` and `==`. They will be removed at next major release. - At next major release the power operators `**` and `^` will turn from left to right associative. I.e. `2**2**3` will give `256`, not `64`. This is to match with Python and l3fp. - `\thexintexpr` et al. (introduced at `1.2h` but not documented anymore for some time) will be removed at next major release. The original `\xinttheexpr` et al. have always been so much better names. Besides, since `1.4`, `\xintexpr` can be used directly in typesetting flow. ### New features - Function `zip()` is modeled on Python's function of the same name. - Function `flat()` removes all nesting to produce a "one-dimensional" list having the exact same leaves (some possibly empty) as the original (in the same order). - Chaining of comparison operators (e.g. `x1` and the scientific part is dropped if the exponent vanishes. In this way the output of `\xinteval` can be pasted to alternative software. - The output format of `\xinthe\xintboolexpr` also has changed. It uses `True` and `False` (which are accepted on input), and this can easily be configured otherwise (also `true` and `false` are accepted on input). - The "broadcasting" (as it turned out, à la `NumPy`) of scalar operations on one-dimensional "lists", e.g `3*[1,3,5,7]+10` acting itemwise is **dropped**. It is hoped to implement such operations again in stronger form in future releases. Pre-existing alternative syntax is available, also to produce the bracketed (cf. next item) `[13,19,25,31]` which will be the output in future. - The `divmod()` function now produces on output such a bracketed pair, but simultaneous assignment such as `\xintdefvar xq, xr = divmod(a,b);` will work transparently. - The syntax for using conditionals in function declarations has changed. Now, one *must* use the `?` and `??` short-circuit boolean branching operators whereas in the past it was explained that the syntax had to use the `if()` and `ifsgn()` functions. - Macros `\xintGCD`, `\xintLCM`, `\xintGCDof` and `\xintLCMof` formerly provided by **xintgcd** got moved to **xintfrac** (which is not loaded by **xintgcd**). Moreover, they were extended to handle general fractions on input but this also means that their output is now obiding by the raw **xintfrac** format. The integer only `\xintiiGCD`, `\xintiiLCM` also got moved out of **xintgcd**, but to **xint** which is now loaded automatically by **xintgcd**. The few remaining macros of **xintgcd** at least do not need other imports as **xintgcd** now loads also automatically **xinttools** which is a dependency for two of them. ### Improvements and new features Please note that this list is currently incomplete. For more information look at the user manual and the documented source code `sourcexint.pdf`. Unless otherwise specified all changes commented upon here regard **xintexpr**. Important: all the new syntax is to be considered experimental. The author may change some names in future release, or even the interface (whether to use semi-colons or colons etc...). - The `\csname` encapsulation technique used since **xintexpr** initial release (`1.07 2013/05/25`) to move around possibly large data during expansion-only operations is replaced with methods based on the `\expanded` engine primitive. The latter is available in all major engines since TeXLive 2019. Formerly, and with default memory settings, one would typically saturate the string pool memory after about of the order of 50,000 independent floating point evaluations of expressions of average complexity on 16-digits numbers. There is thus no string pool memory impact at all but one can now hit TeX's main memory limit (which typically stands at 5,000,000 words) from defining large variables or generating on the fly large data. TeX distributions have a configuration file allowing to enlarge TeX memory parameters and regenerate the (eTeX based) formats. - The package supports input and output of arbitrarily *nested lists*, a.k.a. *oples* or *nlists*, with `[...]` as the constructor of *bracketed lists*, a.k.a *nut-ples*. Operations on these objects (as briefly surveyed in later items) are inspired from syntax and functionalities of `NumPy`'s *ndarrays*. Our *oples* (hence also their packaged form *nut-ples*) may have *leaves* at varying depths rather than obeying an N-dimensional hyperrectangular shape. But the syntax does provide specific constructors for *ndlists* (i.e. hyperrectangular *oples* or *nut-ples*). In a (distant?) future, perhaps **xintexpr** itself or a third-party package will provide an interface, say `\xintstorearray`, `\xintgetarray`, to store (which can not be expandable) and retrieve (which can be expandable and thus be embedded inside expressions parsed by `\xintexpr`, `\xintiiexpr` or `\xintfloatexpr`) such *ndlists* from TeX memory. This is why the package does not use the word *ndarray* and reserves it for such memory stored objects. - The `*` serves as *unpacking* operator on *nut-ples*, i.e. reversing the `[]` bracketing of an *ople*. - *oples* have no exact equivalent in `Python`. For example **xintexpr** allows `foo(Var1, x)` if `foo` is a function of 4 variables and `Var1` is a variable producing a length 3 *ople*, or `foo(Var2)` if `Var2` is a variable producing a length 4 *ople*. Python would require here to use explicitly the `*`-unpacking notation on some "packed" objects. Variable and function values may be *oples* (even *nil*), but in function declarations variables must stand for *one-ples*, i.e. either *numbers* or *nut-ples* (as there is no non-ambiguous way to split e.g. 5 arguments into two separate *oples*). - Simultaneous assignment to at least two variables via `\xintdefvar` et al. automatically unpacks the assigned value if it is a *one-ple*. If this value was in fact a *number*, low-level errors will result shortly afterwards as no check is done if the unpacking was illicit. (Such checks exist in the codebase, but have not yet been integrated into `\xintdefvar` by laziness). - The `NumPy` concept and syntax for nested slicing and item selection are implemented. Currently *stepping* and the *Ellipsis object* are not yet available. Only so-called basic slicing is currently supported. (The author has not yet read the section of `NumPy` documentation on so-called *advanced indexing*). - The *broadcasting* of scalar operations, such as itemwise addition or multiplication of *nut-ples* of the same shape is **not yet implemented**. - Slicing and indexing apply also at top level to the *oples* with behaviour conforming to intuitive expectations (see user manual); if it turns out the *ople* is in fact a *nut-ple*, the top-level slicing/indexing switches to the `Python/NumPy` conventions, i.e. it operates inside the brackets for slicing and removes brackets if indexing. - The syntax `ndseq(expression in x, y, ..., x = values; y = values; ...)` constructs a (bracketed) *ndlist* by evaluation the expression on all possible Cartesian n-uples, where the first variable indexes the first axis, the second the next, etc... - The `ndmap(foo, values1; values2; ...; valuesN)` syntax constructs a (bracketed) *ndlist* by evaluating the function `foo` on all elements of the cartesian product of the given (one-dimensional) value lists. - The two concepts of `\xintdeffunc` (for recursive definitions) and `\xintdefefunc` (for functions which expand immediately in other function declarations) have been merged. The `\xintdefefunc` et al. are deprecated and kept as aliases for `\xintdeffunc` et al. - `\xintdefufunc` allows to define so-called *universal functions*, i.e. functions `foo` such that `foo(myople)` will apply itemwise at arbitrary depth in the nested structure. The function `foo` is allowed to produce from a scalar an *ople*... - The variables in function declarations can now be multi-letter words. - The last positional variable in a function declaration can be prefixed with a `*` meaning exactly as in Python (*variadic* function argument) that it stands for a one-dimensional *nut-ple* receiving all remaining arguments from the function call beyond the first positional ones. It is thus an optional argument, but syntax for named optional arguments with default values is not yet implemented. - Dummy variables used in constructors can also be multi-letter words, if they have been declared as such. - In variable and function declarations, if the expression contains inner semi-colons, it is not needed anymore to brace them to avoid mis-interpretation as the final semi-colon which is mandated by the syntax to serve as expression terminator. - `subsm(expression, var1 = value1; var2 = value2; ...)` provides a leaner syntax for multiple substitutions; they must be independent, though. - `subsn(expression, var1 = value1; var2 = value2; ...)` provides a leaner syntax for nested substitutions, i.e., each `valueJ` may be an expression using the dummy variables `varK` with `K>J`. And finally of course the evaluated expression can refer to all variables. - `\xintthealign\xintexpr...\relax` (or with `\xintfloatexpr` or `\xintiiexpr` or `\xintboolexpr`...) will use a TeX alignment to display *oples*. The output (for regular N-dimensional lists) looks very similar to what `Python/NumPy` produces in interactive session. This is entirely configurable and can also be set-up to be used for writing into external files. Attention that `\xintthealign` only works if followed by `\xintexpr` et al., not by `\xinteval{}`. - It is now possible to use `\xintexpr...\relax` directly for typesetting. The syntax `\xinteval{...}` or `\xintthe\xintexpr...\relax` is needed only if one wants the expansion to give the explicit digits, but `\xintexpr...\relax` by itself will typeset as would have the other ones. Further it can be used in so-called moving arguments, because when output to an external file it uses only characters with standard catcodes (and produces the same protected and re-tokenizable result it would in an `\edef`.) As formerly, `\xintexpr...\relax` is the preferred way to include an expression into another one. Using `\xinteval` is a waste because it forces the outer parser to re-digest all the digits (or now also the square brackets). - The output format of `\xintfloateval` with scientific notation has not changed (apart from possible presence of bracketed lists), but the author hesitates because the *prettifying* it does by default is not really adapted to display of arrays (see `\xintthealign`). Anyway, this is configurable by the user. It is possible to specify whether to use `e` or `E`. - Function declarations are able to parse a much wider part of the syntax, but some severe limitations remain. Refer to the user manual for related information. - We have made an effort on some error messages, and when working interactively in a shell it may even be sometimes possible to insert for example a correct variable or function name in place of the not recognized one. But don't expect miracles when trying to intervene in the midst of a purely expandable expansion... ### Bug fixes Bugs? Those identified in `1.3f` were almost features. As per `1.4` the code base of **xintexpr** received multiple successive core refactorings and added numerous new features, and our test suite although significantly enlarged is not yet extensive enough. Please report bugs by mail. ### TODO - The long delayed overhaul of how floating point numbers are handled is delayed again. It has remained basically identical to its initial provisory version from `1.07 2013/05/25` (which was based upon what was originally only a set of expandable macros for computations with big integers), and suffers from the author lack of knowledge of the notion of "data type" in modern programming. Indeed, he never took a CS class, and disables JavaScript in his browser (or allows only select non-tracking scripts, a rare beast in modern days). - Prior to integrating all of `NumPy`, it is envisioned to start with matrix algebra first. `1.3f (2019/09/10)` ---- ### Improvements and new features - **xintfrac**: `\xintDigits = P;` syntax (i.e. without a colon) is now accepted in addition to `\xintDigits := P;`. Document that the ending semi-colon can not be an active character and that it has always been allowed to use in its place a non-expanding token e.g. `\xintDigits := 32\relax`. Add `\xintSetDigits`. - **xintexpr**: add starred variants `\xintDigits*` and `\xintSetDigits*` which execute `\xintreloadxinttrig`. Revert 1.3e ban on usage of `\xinteval` et al. inside expressions by `\xintdeffunc`. And make them usable also inside macro definitions via `\xintNewExpr`. ### Bug fixes - **xintexpr**: fix bug preventing usage of `\xintdefefunc` to define a function without variables. Fix some issue with `\xintfloatexpr[D]..\relax` if used inside an expression parsed by `\xintdeffunc` et al. `1.3e (2019/04/05)` ---- ### Breaking changes - (_reverted at 1.3f_) When defining functions, sub-expressions can only use the `\xint(float)expr...\relax` syntax. One can not use there the `\xint(float)eval` wrappers. ### Improvements and new features - The **xinttrig** library is automatically loaded by **xintexpr**. It provides direct and inverse trigonometrical functions using either degrees or radians with a precision of up to (a bit less than) 60 digits. It is for the most part implemented using high level user interface, but will probably get some optimizations in future (and perhaps extension to more digits). - The **xintlog** library is automatically loaded by **xintexpr**. It uses [poormanlog](http://ctan.org/pkg/poormanlog) to provide logarithms and exponentials with almost 9 digits of precision. Extended precision is for a future release. - **xintexpr**: `\xintdefefunc`, `\xintdeffloatefunc`, `\xintdefiiefunc` define functions which are not protected against expansion in the definition of other functions; refer to `xint.pdf` for the related explanations. Notice that whole area of `\xintdef(e)func`, `\xintNewExpr`, `\xintNewFunction` is complex and to be considered still as work in progress as it has a number of shortcomings. - **xintexpr**: `inv()`, `ilog10()`, `sfloat()`, behaviour of `qfloat()` slightly modified. - **xintexpr**: `\xintensuredummy`, `\xintrestorelettervar`. - The optional argument of `\xintfloatexpr` or `\xintfloateval` (it must be at start of braced argument) can be negative; it then means to trim (and round) from the output at float precision that many least significant digits. ### Bug fixes - Some bugfixes related to user functions with no variables at all; they were dysfunctional. `1.3d (2019/01/06)` ---- ### Breaking changes - **xintexpr**: the `gcd()` and `lcm()` functions formerly converted their arguments to integers via `\xintNum`. They now handle general input with no such modification. - **xintexpr**: former `\xinteval`, `\xintieval`, `\xintiieval`, and `\xintfloateval` renamed to `\xintexpro`, `\xintiexpro`, `\xintiiexpro`, and `\xintfloatexpro`. ### Improvements and new features - **xintexpr**: the `gcd()` and `lcm()` multi-arguments functions have been refactored to handle general fractions. The dependency on **xintgcd** is removed. - **xintexpr**: three-way branching `\xintifsgnexpr`, `\xintifsgnfloatexpr`, `\xintifsgniiexpr` conditional macros. - **xintexpr**: `\xintunassignexprfunc`, `\xintunassigniiexprfunc`, `\xintunassignfloatexprfunc` to "undefine" functions. - **xintexpr**: `\xintunassignvar` really makes the (multi-letter) variable unknown (formerly, it only gave it value zero), - **xintexpr**: functions `isone()` and `isint()`. - **xintexpr**: `\xinteval`, `\xintieval`, `\xintiieval`, and `\xintfloateval` as synonyms to `\xinttheexpr...\relax` etc..., but with the (comma-separated) expression as a usual braced macro argument. ### Bug fixes - **xintcore**, **xintexpr** : division in `\xintiiexpr` was broken for a zero dividend and a one-digit divisor (e.g. ``0//7``) since `1.2p` due to a bug in `\xintiiDivMod` for such arguments. The bug was signaled (thanks to Kpym for report) and fixed shortly after `1.3c` release but I then completely forgot to upload a bugfix release to CTAN at that time, apologies for that. `1.3c (2018/06/17)` ---- ### Improvements and new features - **xintexpr**: with `\xintglobaldefstrue`, `\xintdefvar`, `\xintdeffunc`, `\xintNewExpr` et al. make definitions with global scope. - **xintexpr**: `qraw()` for fast input of (very many) comma separated numbers (in suitable raw format). - **xintexpr**: the colon in the `:=` part of the syntax for `\xintdefvar` and variants is now optional; and if present it may be an active character or have any (reasonable) catcode. - **xintexpr**: `\xintdefvar`, `\xintdeffunc` and their variants try to set the catcode of the semi-colon which delimits their arguments; of course this will not work if that catcode is already frozen. - `\xintUniformDeviate` is better documented and `sourcexint.pdf` is better hyperlinked and includes indices for the macros defined by each package. ### Bug fixes - **xintfrac**: since `1.3` release, it loaded **xintgcd** in contradiction to what the documentation says (hence also **xintexpr** loaded **xintgcd** automatically). There is no actual dependency so the loading is removed for now. `1.3b (2018/05/18)` ---- ### Improvements and new features All additions related to randomness are marked as work-in-progress. They require an engine providing the `\(pdf)uniformdeviate` primitive. - **xintkernel**: `\xintUniformDeviate`. - **xint**: `\xintRandomDigits`, `\xintXRandomDigits`, `\xintiiRandRange`, `\xintiiRandRangeAtoB`. - **xintfrac**: support macros (not public, mainly because internal format for floats is surely not final) for `random()` and `qrand()`. - **xintexpr**: `random()`, `qrand()`, and `randrange(A[, B])`. - **xintexpr**: when a function `foo()` is declared via `\xintdeffunc` (et al.) to be parameter-less, it can be used as `foo()`; formerly `foo(nil)` syntax was required. - The usual provision of user manual "improvements". `1.3a (2018/03/07)` ---- ### Removed - **xintcore**, **xint**, **xintfrac**: removal of the internal macros which were used at `1.2o` to add a deprecation mechanism; all deprecated macros have been removed at `1.3` so there was no reason to keep the code used for deprecating them. ### Improvements and new features - **xintexpr**: new conditionals `ifone()` and `ifint()`. - **xintfrac**: `\xintREZ` is faster on inputs having one hundred digits or more. - Added to the user manual mention of macros such as `\xintDivFloor`, `\xintMod`, `\xintModTrunc`, which had been left out so far. ### Bug fixes - **xintexpr**: the mechanism for adjunction to the expression parsers of user defined functions was refactored and improved at previous release `1.3`: in particular recursive definitions became possible. But an oversight made these recursive functions quite inefficient (to remain polite.) This release fixes the problem. `1.3 (2018/03/01)` ---- ### Breaking changes - **xintcore**, **xint**, **xintfrac**: all macros deprecated at `1.2o` got removed. - **xintfrac**: addition and subtraction of `a/b` and `c/d` now use the l.c.m. of the denominators. Similarly the macro supporting the modulo operator `/:` uses a l.c.m. for the denominator of the result. - **xintexpr**: the addition, subtraction, modulo `/:`, and the `mod()` and `divmod()` functions produce generally smaller denominators (see previous item). - **xintexpr**: formerly, the internal macros which are internally associated to user-declared functions were using comma separated parameter texts. They now do not use such commas (their meanings, which may again change in future, are written for information to the log under `\xintverbosetrue`). ### Improvements and new features - **xintexpr**: user-defined functions may now be of a recursive nature. This was made possible by a refactoring of the `\xintNewExpr` mechanism. It became both leaner and more extensive than formerly. - **xintfrac**: new macros `\xintPIrr` and `\xintDecToString`. The latter is a backport of a `polexpr 0.4` utility, and it is to be considered unstable. - **xintexpr**: new function `preduce()` associated with `\xintPIrr`. `1.2q (2018/02/06)` ---- ### Improvements and new features - **xintexpr**: tacit multiplication extended to cases such as `3!4!5!` or `(1+2)3`. ### Bug fixes - **xintcore**: sadly, refactoring at `1.2l` of subtraction left an extra character in an inner macro causing breakage in some rare circumstances. This should not have escaped our test suite! `1.2p (2017/12/05)` ---- ### Breaking changes - **xintgcd**: `\xintBezout{a}{b}`'s output consists of `{u}{v}{d}` with `u*a+v*b==d`, with `d` the GCD. Formerly it was `{a}{b}{u}{v}{d}`, and with `u*a-v*b==d`. - **xintgcd**: `\xintBezout{0}{0}` expands to `{0}{0}{0}`. Formerly (since `1.2l`) it raised `InvalidOperation`. - **xintcore**: `\xintiiMod` is now associated with floored division. The former meaning (associated with truncated division) is available as `\xintiiModTrunc`. - **xintfrac**: `\xintMod` is now associated with floored division. The former meaning is available as `\xintModTrunc`. - **xintexpr**: the ``//`` operator and its associated modulo ``'mod'`` (or ``/:``) now correspond to floored division, like the Python language `//`, `%`, and `divmod(x, y)`. Formerly they had been associated to truncated division. This is breaking change for operands of opposite signs. ### Improvements and new features - **xinttools**: `\xintListWithSep`, which had remained unchanged since its introduction at `1.04 (2013/04/25)`, was rewritten for increased speed. - **xintexpr**: `\xintdefvar`'s syntax is extended to allow simultaneous assignments. Examples: `\xintdefvar x1, x2, x3 := 1, 3**10, 3**20;` or `\xintdefiivar A, B := B, A 'mod' B;` for already defined variables `A` and `B`. - **xintexpr**: added `divmod()` to the built-in functions. It is associated with floored division, like the Python language `divmod()`. Related support macros added to **xintcore**, and **xintfrac**. ### Bug fixes - **xintgcd**: `\xintBezout{6}{3}` (for example) expanded to `{6}{3}{-0}{-1}{3}`, but the `-0` should have been `0`. - **xintgcd**: it still used macro `\xintiAbs` although the latter had been deprecated from **xintcore**. - **xintexpr**: in float expressions the `//` and `/:` (aka `'mod'`) operators did not round their operands to the float precision prior to computing with them, contrarily to other infix arithmetic operators and to the `mod(f,g)` function; thus, `mod(f,g)` and `f 'mod' g` were not completely equivalent. - various documentation fixes; in particular, the partial dependency of **xintcfrac** on **xinttools** had not been mentioned. `1.2o (2017/08/29)` ---- ### Breaking changes - **xint**: `\xintAND`, `\xintOR`, ... and similar Boolean logic macros do not apply anymore `\xintNum` (or `\xintRaw` if **xintfrac** is loaded), to their arguments (often, from internal usage of `\xintSgn`), but only f-expand them (using e.g. `\xintiiSgn`). This is kept un-modified even if loading **xintfrac**. ### Deprecated Deprecated macros raise an error but, generally, then expand as in former releases. They will all get removed at some future release. - **xintcore**: `\xintiOpp`, `\xintiAbs`, `\xintiAdd`, `\xintiSub`, `\xintiMul`, `\xintiDivision`, `\xintiQuo`, `\xintiRem`, `\xintiDivRound`, `\xintiDivTrunc`, `\xintiMod`, `\xintiSqr`, `\xintiPow`, and `\xintiFac` are deprecated. Only the `ii`-named variants get defined. - **xintcore**: `\xintCmp` and `\xintSgn` are deprecated from **xintcore** (which only defines `\xintiiCmp` and `\xintiiSgn`) as they actually belong to **xintfrac**. - **xintcore**: `\xintiiFDg`, resp. `\xintiiLDg`, are renamed `\xintFDg`, resp. `\xintLDg`. Former denominations are deprecated. - **xint**: `\xintMON`, `\xintMMON`, `\xintiMax`, `\xintiMin`, `\xintiMaxof`, `\xintiMinof`, `\xintiSquareRoot`, `\xintiSqrt`, `\xintiSqrtR`, `\xintiBinomial`, and `\xintiPFactorial` are deprecated. Only `ii`-named variants get defined. - **xint**: `\xintEq`, `\xintGeq`, `\xintGt`, `\xintLt`, `\xintGtorEq`, `\xintLtorEq`, `\xintIsZero`, `\xintIsNotZero`, `\xintIsOne`, `\xintOdd`, `\xintEven`, `\xintifSgn`, `\xintifCmp`, `\xintifEq`, `\xintifGt`, `\xintifLt`, `\xintifZero`, `\xintifNotZero`, `\xintifOne`, `\xintifOdd`, are deprecated. These macros belong to **xintfrac**. Package **xint** defines only the `ii`-named variants. - **xint**: `\xintNeq` was renamed to `\xintNotEq` which however is only provided by **xintfrac**. Package **xint** defines `\xintiiNotEq`, and `\xintNeq` is deprecated. - **xint**: `\xintNot` was renamed to `\xintNOT`, former denomination is deprecated. See also item about Boolean logic macros in the *Incompatible Changes* section. `1.2n (2017/08/06)` ---- ### Breaking changes - **xintbinhex** does not load package **xintcore** anymore, but only **xintkernel**. ### Improvements and new features - **xintbinhex** has only **xintkernel** as dependency. - Macros of **xintbinhex** have been improved for speed and increased maximal sizes of allowable inputs. `1.2m (2017/07/31)` ---- ### Breaking changes - **xintbinhex**: the length of the input is now limited. The maximum size depends on the macro and ranges from about `4000` to about `19900` digits. - **xintbinhex**: `\xintCHexToBin` is now the variant of `\xintHexToBin` which does not remove leading binary zeroes: `N` hex-digits give on output exactly `4N` binary digits. ### Improvements and new features - **xintbinhex**: all macros have been rewritten using techniques from the 1.2 release (they had remained unmodified since `1.08` of `2013/06/07`.) The new macros are faster but limited to a few thousand digits. The `1.08` routines could handle tens of thousands of digits, but not in a reasonable time. ### Bug fixes - user manual: the `Changes` section wrongly stated at `1.2l` that the macros of **xintbinhex** had been made robust against non terminated input such as ``\number\mathcode`\-``. Unfortunately the author fell into the trap of believing his own documentation and he forgot to actually implement the change. Now done. - user manual: the PDF bookmarks were messed up. - **xint**, **xintfrac**: `\xintGeq`, `\xintMax`, `\xintMin`, suffered from some extra overhead. This was caused by use of some auxiliaries from the very early days which got redefined at some stage. This is fixed here with some additional efficiency improvements and pruning of old code. `1.2l (2017/07/26)` ---- ### Removed - `\xintiiSumExpr`, `\xintiiPrdExpr` (**xint**) and `\xintSumExpr`, `\xintPrdExpr` (**xintfrac**). They had not been formally deprecated, but had been left un-documented since `1.09d (2013/10/22)`. - internal macro `\xint_gob_til_xint_relax` removed. ### Improvements and new features - the underscore character `_` is accepted by the **xintexpr** parsers as a digit separator (the space character already could be used for improved readability of big numbers). It is not allowed as *first* character of a number, as it would then be mis-interpreted as the start of a possible variable name. - some refactoring in **xintcore** auxiliary routines and in `\xintiiSub` and `\xintiiCmp` for some small efficiency gains. - code comments in **xintcore** are better formatted, but remain sparse. - **xintcore**, **xint**, **xintfrac**, ... : some macros were not robust against arguments whose expansion looks forward for some termination (e.g. ``\number\mathcode`\-``), and particularly, most were fragile against inputs using non-terminated ``\numexpr`` (such as `\xintiiAdd{\the\numexpr1}{2}` or `\xintRaw{\numexpr1}`). This was not a bug per se, as the user manual did not claim such inputs were legal, but it was slightly inconvenient. Most macros (particularly those of **xintfrac**) have now been made robust against such inputs. Some macros from **xintcore** primarily destined to internal usage still accept only properly terminated arguments such as ``\the\mathcode`\-`` or ``\the\numexpr1\relax``. The situation with expressions is unchanged: syntax such as `\xintexpr \numexpr1+2\relax` is illegal as the ending `\relax` token will get swallowed by the `\numexpr`; but it is needed by the ``xintexpr``-ession parser, hence the parser will expand forward and presumably end with in an "illegal token" error, or provoke some low-level TeX error (N.B.: a closing brace `}` for example can not terminate an ``xintexpr``-ession, the parser must find a `\relax` token at some point). Thus there must be in this example a second `\relax`. - experimental code for error conditions; there is no complete user interface yet, it is done in preparation for next major release and is completely unstable and undocumented. ### Bug fixes - **xintbinhex**: since `1.2 (2015/10/10)`, `\xintHexToDec` was broken due to an undefined macro (it was in `xint.sty`, but the module by itself is supposedly dependent only upon `xintcore.sty`). - **xintgcd**: macro `\xintBezout` produced partially wrong output if one of its two arguments was zero. - **xintfrac**: the manual said one could use directly `\numexpr` compatible expressions in arithmetic macros (without even a `\numexpr` encapsulation) if they were expressed with up to 8 tokens. There was a bug if these 8 tokens evaluated to zero. The bug has been fixed, and up to 9 tokens are now accepted. But it is simpler to use `\the\numexpr` prefix and not to worry about the token count... The ending `\relax` is now un-needed. `1.2k (2017/01/06)` ---- ### Breaking changes - macro `\xintFloat` which rounds its input to a floating point number does _not_ print anymore `10.0...0eN` to signal an upwards rounding to the next power of ten. The mantissa has in all cases except the zero input exactly one digit before the decimal mark. - some floating point computations may differ in the least significant digits, due to a change in the rounding algorithm applied to macro arguments expressed as fractions and to an improvement in precision regarding half-integer powers in expressions. See next. ### Improvements and new features - the initial rounding to the target precision `P` which is applied by the floating point macros from **xintfrac** to their arguments achieves the _exact (aka correct) rounding_ even for inputs which are fractions with more than `P+2` digits in their numerators and denominators (`>1`.) Hence the computed values depend only on the arguments as rational numbers and not upon their representatives. This is not relevant to _expressions_ (**xintexpr**), because the `\xintfloatexpr` parser sees there `/` as an operator and does not (apart from special constructs) get to manipulate fractions as such. - `\xintnewdummy` is public interface to a `1.2e` macro which serves to declare any given catcode 11 character as a dummy variable for expressions (**xintexpr**). This is useful for Unicode engines (the Latin letters being already all pre-declared as dummy variables.) - added `\xintiSqrtR`, there was only `\xintiiSqrtR` alongside `\xintiSqrt` and `\xintiiSqrt` (**xint**). - added non public `\xintLastItem:f:csv` to **xinttools** for faster `last()` function, and improved `\xintNewExpr` compatibility. Also `\xintFirstItem:f:csv`. ### Bug fixes - the `1.2f` half-integer powers computed within `\xintfloatexpr` had a silly rounding to the target precision just _before_ the final square-root extraction, thus possibly losing some precision. The `1.2k` implementation keeps guard digits for this final square root extraction. As for integer exponents, it is guaranteed that the computed value differs from the exact one by less than `0.52 ulp` (for inputs having at most `\xinttheDigits` digits.) - more regressions from `1.2i` were fixed: `\xintLen` (**xint**, **xintfrac**) and `\xintDouble` (**xintcore**) had forgotten that their argument was allowed to be negative. A regression test suite is now in place and is being slowly expanded to cover more macros. - `\xintiiSquareRoot{0}` now produces `{1}{1}`, which fits better the general documented behaviour of this macro than `11`. `1.2j (2016/12/22)` ---- ### Improvements and new features - **xinttools** and **xintexpr**: 1. slightly improves the speed of `\xintTrim`. 2. speed gains for the handlers of comma separated lists implementing Python-like slicing and item extraction. Relevant non (user) documented macros better documented in `sourcexint.pdf`. - significant documentations tweaks (inclusive of suppressing things!), and among them two beautiful hyperlinked tables with both horizontal and vertical rules which bring the documentation of the **xintexpr** syntax to a kind of awe-inspiring perfection... except that implementation of some math functions is still lacking. ### Bug fixes - fix two `1.2i` regressions caused by undefined macros (`\xintNthElt` in certain branches and `[list][N]` item extraction in certain cases.) The test files existed but were not executed prior to release. Automation in progress. `1.2i (2016/12/13)` ---- ### Breaking changes - `\xintDecSplit` second argument must have no sign (former code replaced it with its absolute value, a sign now may cause an error.) ### Removed - deprecated macros `\xintifTrue`, `\xintifTrueFalse`, `\xintQuo`, `\xintRem`, `\xintquo`, `\xintrem`. ### Improvements and new features - **xintkernel**: `\xintLength` is faster. New macros: - `\xintLastItem` to fetch the last item from its argument, - `\romannumeral\xintgobble` for gobbling many (up to 531440) upstream braced items or tokens. - `\romannumeral\xintreplicate` which is copied over from the expl3 `\prg_replicate:nn` with some minor changes. - **xinttools**: general token list handling routines `\xintKeep`, `\xintTrim` and `\xintNthElt` are faster; but the novel `\xintTrim` can only remove up to a maximum of 531440 items. Also, `\xintFor` partially improves on some issues which are reported upon in the documentation. - some old macros have been rewritten entirely or partially using techniques which **xint** started using in release `1.2`: - **xintcore**: `\xintDouble`, `\xintHalf`, `\xintInc`, `\xintDec`, `\xintiiLDg`, `\xintDSR` (originally from **xint**), a novel `\xintDSRr`. - **xint**: `\xintDSH`, `\xintDSx`, `\xintDecSplit`, `\xintiiE`. - **xintfrac**: as a result of the above `\xintTrunc`, `\xintRound` and `\xintXTrunc` got faster. But the main improvement for them is with decimal inputs which formerly had not been treated separately from the general fraction case. Also, `\xintXTrunc` does not anymore create a dependency of **xintfrac** on **xinttools**. - the documentation has again been (slightly) re-organized; it has a new sub-section on the Miller-Rabin primality test, to illustrate some use of `\xintNewFunction` for recursive definitions. - the documentation has dropped the LaTeX "command" terminology (which had been used initially in 2013 for some forgotten reasons and should have been removed long ago) and uses only the more apt "macro", as after all, all of **xint** is about expansion of macros (plus the use of `\numexpr`). ### Bug fixes - `\xintDecSplitL` and `\xintDecSplitR` from **xint** produced their output in a spurious brace pair (bug introduced in `1.2f`). `1.2h (2016/11/20)` ---- ### Improvements and new features - new macro `\xintNewFunction` in **xintexpr** which allows to extend the parser syntax with functions in situations where `\xintdeffunc` is not usable (typically, because dummy variables are used over a not yet determined range of values because it depends on the variables). - after three years of strict obedience to `xint` prefix, now `\thexintexpr`, `\thexintiexpr`, `\thexintfloatexpr`, and `\thexintiiexpr` are provided as synonyms to `\xinttheexpr`, etc... ### Bug fixes - the `(cond)?{foo}{bar}` operator from **xintexpr** mis-behaved in certain circumstances (such as an empty `foo`). - the **xintexpr** `1.2f` `binomial` function (which uses `\xintiiBinomial` from **xint.sty** or `\xintFloatBinomial` from **xintfrac.sty**) deliberately raised an error for `binomial(x,y)` with `y<0` or `x:= expression ;` is now accepted. - documentation enhancements: the _Quick Sort_ section with its included code samples has been entirely re-written; the _Commands of the xintexpr package_ section has been extended and reviewed entirely. ### Bug fixes - in **xintfrac**: the `\xintFloatFac` from release `1.2` parsed its argument only through `\numexpr` but it should have used `\xintNum`. - in **xintexpr**: release `1.2d` had broken the recognition of sub-expressions immediately after variable names (with tacit multiplication). - in **xintexpr**: contrarily to what `1.2d` documentation said, tacit multiplication was not yet always done with enhanced precedence. Now yes. `1.2d (2015/11/18)` ---- ### Improvements and new features - the function definitions done by `\xintdeffunc` et al., as well as the macro declarations by `\xintNewExpr` et al. now have only local scope. - tacit multiplication applies to more cases, for example (x+y)z, and always ties more than standard * infix operator, e.g. x/2y is like x/(2*y). - some documentation enhancements, particularly in the chapter on xintexpr.sty, and also in the code source comments. ### Bug fixes - in **xintcore**: release `1.2c` had inadvertently broken the `\xintiiDivRound` macro. `1.2c (2015/11/16)` ---- ### Improvements and new features - macros `\xintdeffunc`, `\xintdefiifunc`, `\xintdeffloatfunc` and boolean `\ifxintverbose`. - on-going code improvements and documentation enhancements, but stopped in order to issue this bugfix release. ### Bug fixes - in **xintcore**: recent release `1.2` introduced a bug in the subtraction (happened when 00000001 was found under certain circumstances at certain mod 8 locations). `1.2b (2015/10/29)` ---- ### Bug fixes - in **xintcore**: recent release `1.2` introduced a bug in the division macros, causing a crash when the divisor started with 99999999 (it was attempted to use with 1+99999999 a subroutine expecting only 8-digits numbers). `1.2a (2015/10/19)` ---- ### Improvements and new features - added `\xintKeepUnbraced`, `\xintTrimUnbraced` (**xinttools**) and fixed documentation of `\xintKeep` and `\xintTrim` regarding brace stripping. - added `\xintiiMaxof/\xintiiMinof` (**xint**). - TeX hackers only: replaced all code uses of ``\romannumeral-`0`` by the quicker ``\romannumeral`&&@`` (`^` being used as letter, had to find another character usable with catcode 7). ### Bug fixes - in **xintexpr**: recent release `1.2` introduced a bad bug in the parsing of decimal numbers and as a result `\xinttheexpr 0.01\relax` expanded to `0` ! (sigh...) `1.2 (2015/10/10)` ---- ### Removed - the macros `\xintAdd`, `\xintSub`, `\xintMul`, `\xintMax`, `\xintMin`, `\xintMaxof`, `\xintMinof` are removed from package **xint**, and only exist in the versions from **xintfrac**. With only **xintcore** or **xint** loaded, one _must_ use `\xintiiAdd`, `\xintiiSub`, ..., or `\xintiAdd`, `\xintiSub`, etc... ### Improvements and new features - the basic arithmetic implemented in **xintcore** has been entirely rewritten. The mathematics remains the elementary school one, but the `TeX` implementation achieves higher speed (except, regarding addition/subtraction, for numbers up to about thirty digits), the gains becoming quite significant for numbers with hundreds of digits. - the inputs must have less than 19959 digits. But computations with thousands of digits take time. - a previously standing limitation of `\xintexpr`, `\xintiiexpr`, and of `\xintfloatexpr` to numbers of less than 5000 digits has been lifted. - a *qint* function is provided to help the parser gather huge integers in one-go, as an exception to its normal mode of operation which expands token by token. - `\xintFloatFac` macro for computing the factorials of integers as floating point numbers to a given precision. The `!` postfix operator inside `\xintfloatexpr` maps to this new macro rather than to the exact factorial as used by `\xintexpr` and `\xintiiexpr`. - there is more flexibility in the parsing done by the macros from **xintfrac** on fractional input: the decimal parts of both the numerator and the denominator may arise from a separate expansion via ``\romannumeral-`0``. Also the strict `A/B[N]` format is a bit relaxed: `N` may be anything understood by `\numexpr` (it could even be empty but that possibility has been removed by later `1.2f` release.) - on the other hand an isolated dot `.` is not legal syntax anymore inside the expression parsers: there must be digits either before or after. It remains legal input for the macros of **xintfrac**. - added `\ht`, `\dp`, `\wd`, `\fontcharht`, etc... to the tokens recognized by the parsers and expanded by `\number`. - an obscure bug in package **xintkernel** has been fixed, regarding the sanitization of catcodes: under certain circumstances (which could not occur in a normal `LaTeX` context), unusual catcodes could end up being propagated to the external world. - an effort at randomly shuffling around various pieces of the documentation has been done. `1.1c (2015/09/12)` ---- - bugfix regarding macro `\xintAssign` from **xinttools** which did not behave correctly in some circumstances (if there was a space before `\to`, in particular). - very minor code improvements, and correction of some issues regarding the source code formatting in `sourcexint.pdf`, and minor issues in `Makefile.mk`. `1.1b (2015/08/31)` ---- - bugfix: some macros needed by the integer division routine from **xintcore** had been left in **xint.sty** since release `1.1`. This for example broke the `\xintGCD` from **xintgcd** if package **xint** was not loaded. - Slight enhancements to the documentation, particularly in the `Read this first` section. `1.1a (2014/11/07)` ---- - fixed a bug which prevented `\xintNewExpr` from producing correctly working macros from a comma separated replacement text. - `\xintiiSqrtR` for rounded integer square root; former `\xintiiSqrt` already produced truncated integer square root; corresponding function `sqrtr` added to `\xintiiexpr..\relax` syntax. - use of straight quotes in the documentation for better legibility. - added `\xintiiIsOne`, `\xintiiifOne`, `\xintiiifCmp`, `\xintiiifEq`, `\xintiiifGt`, `\xintiiifLt`, `\xintiiifOdd`, `\xintiiCmp`, `\xintiiEq`, `\xintiiGt`, `\xintiiLt`, `\xintiiLtorEq`, `\xintiiGtorEq`, `\xintiiNeq`, mainly for efficiency of `\xintiiexpr`. - for the same reason, added `\xintiiGCD` and `\xintiiLCM`. - added the previously mentioned `ii` macros, and some others from `1.1`, to the user manual. But their main usage is internal to `\xintiiexpr`, to skip unnecessary overheads. - various typographical fixes throughout the documentation, and a bit of clean up of the code comments. Improved `\Factors` example of nested `subs`, `rseq`, `iter` in `\xintiiexpr`. `1.1 (2014/10/28)` ---- ### Breaking changes - in `\xintiiexpr`, `/` does _rounded_ division, rather than the Euclidean division (for positive arguments, this is truncated division). The `//` operator does truncated division, - the `:` operator for three-way branching is gone, replaced with `??`, - `1e(3+5)` is now illegal. The number parser identifies `e` and `E` in the same way it does for the decimal mark, earlier versions treated `e` as `E` rather as infix operators of highest precedence, - the `add` and `mul` have a new syntax, old syntax is with `` `+` `` and `` `*` `` (left quotes mandatory), `sum` and `prd` are gone, - no more special treatment for encountered brace pairs `{..}` by the number scanner, `a/b[N]` notation can be used without use of braces (the `N` will end up as is in a `\numexpr`, it is not parsed by the `\xintexpr`-ession scanner), - in earlier releases, place holders for `\xintNewExpr` could either be denoted `#1`, `#2`, ... or also `$1`, `$2`, ... Only the usual `#` form is now accepted and the special cases previously treated via the second form are now managed via a `protect(...)` function. - **xintfrac**: `\xintFloor` and `\xintCeil` add a trailing `/1[0]` to their (integer) output. New `\xintiFloor` and `\xintiCeil` do not. ### Removed - `\xintnumexpr`, `\xintthenumexpr`, `\xintNewNumExpr`: use `\xintiexpr`, `\xinttheiexpr`, `\xintNewIExpr`. ### Deprecated - `\xintDivision`, `\xintQuo`, `\xintRem`: use `\xintiDivision`, `\xintiQuo`, `\xintiRem`. - `\xintMax`, `\xintMin`, `\xintAdd`, `\xintSub`, `\xintMul` (**xint**): their usage without **xintfrac** is deprecated; use `\xintiMax`, `\xintiMin`, `\xintiAdd`, `\xintiSub`, `\xintiMul`. - the `&` and `|` as Boolean operators in `xintexpr`-essions are deprecated in favour of `&&` and `||`. The single letter operators might be assigned some other meaning in some later release (bitwise operations, perhaps). Do not use them. ### Improvements and new features * new package **xintcore** has been split off **xint**. It contains the core arithmetic macros (it is loaded by LaTeX package **bnumexpr**), * neither **xint** nor **xintfrac** load **xinttools**. Only **xintexpr** does, * whenever some portion of code has been revised, often use has been made of the `\xint_dothis` and `\xint_orthat` pair of macros for expandably branching, * these tiny helpful macros, and a few others are in package **xintkernel** which contains also the catcode and loading order management code, initially inspired by code found in Heiko Oberdiek's packages, * the source code, which was suppressed from `xint.pdf` in release `1.09n`, is now compiled into a separate file `sourcexint.pdf`, * faster handling by `\xintAdd`, `\xintSub`, `\xintMul`, ... of the case where one of the arguments is zero, * the `\xintAdd` and `\xintSub` macros from package **xintfrac** check if one of the denominators is a multiple of the other, and only if this is not the case do they multiply the denominators. But systematic reduction would be too costly, * this naturally will be also the case for the `+` and `-` operations in `\xintexpr`, * **xint** added `\xintiiDivRound`, `\xintiiDivTrunc`, `\xintiiMod` for rounded and truncated division of big integers (next to `\xintiiQuo` and `\xintiiRem`), * with **xintfrac** loaded, the `\xintNum` macro does `\xintTTrunc` (which is truncation to an integer, same as `\xintiTrunc {0}`), * added `\xintMod` to **xintfrac** for modulo operation with fractional numbers, * added `\xintiFloor` and `\xintiCeil` to **xintfrac**, * `\xintiexpr`, `\xinttheiexpr` admit an optional argument within brackets `[d]`, they round the computation result (or results, if comma separated) to `d` digits after decimal mark, (the whole computation is done exactly, as in `xintexpr`), * `\xintfloatexpr`, `\xintthefloatexpr` similarly admit an optional argument which serves to keep only `d` digits of precision, getting rid of cumulated uncertainties in the last digits (the whole computation is done according to the precision set via `\xintDigits`), * `\xinttheexpr` and `\xintthefloatexpr` _pretty-print_ if possible, the former removing unit denominator or `[0]` brackets, the latter avoiding scientific notation if decimal notation is practical, * the `//` does truncated division and `/:` is the associated modulo, * multi-character operators `&&`, `||`, `==`, `<=`, `>=`, `!=`, `**`, * multi-letter infix binary words `'and'`, `'or'`, `'xor'`, `'mod'` (straight quotes mandatory), * functions `even`, `odd`, * `\xintdefvar A3:=3.1415;` for variable definitions (non expandable, naturally), usable in subsequent expressions; variable names may contain letters, digits, underscores. They should not start with a digit, the `@` is reserved, and single lowercase and uppercase Latin letters are predefined to work as dummy variables (see next), * generation of comma separated lists `a..b`, `a..[d]..b`, * Python syntax-like list extractors `[list][n:]`, `[list][:n]`, `[list][a:b]` allowing negative indices, but no optional step argument, and `[list][n]` (`n=0` for the number of items in the list), * functions `first`, `last`, `reversed`, * itemwise operations on comma separated lists `a*[list]`, etc.., possible on both sides `a*[list]^b`, and obeying the same precedence rules as with numbers, * `add` and `mul` must use a dummy variable: `add(x(x+1)(x-1), x=-10..10)`, * variable substitutions with `subs`: `subs(subs(add(x^2+y^2,x=1..y),y=t),t=20)`, * sequence generation using `seq` with a dummy variable: `seq(x^3, x=-10..10)`, * simple recursive lists with `rseq`, with `@` given the last value, `rseq(1;2@+1,i=1..10)`, * higher recursion with `rrseq`, `@1`, `@2`, `@3`, `@4`, and `@@(n)` for earlier values, up to `n=K` where `K` is the number of terms of the initial stretch `rrseq(0,1;@1+@2,i=2..100)`, * iteration with `iter` which is like `rrseq` but outputs only the last `K` terms, where `K` was the number of initial terms, * inside `seq`, `rseq`, `rrseq`, `iter`, possibility to use `omit`, `abort` and `break` to control termination, * `n++` potentially infinite index generation for `seq`, `rseq`, `rrseq`, and `iter`, it is advised to use `abort` or `break(..)` at some point, * the `add`, `mul`, `seq`, ... are nestable, * `\xintthecoords` converts a comma separated list of an even number of items to the format expected by the `TikZ` `coordinates` syntax, * completely new version `\xintNewExpr`, `protect` function to handle external macros. The dollar sign `$` for place holders is not accepted anymore, only the standard macro parameter `#`. Not all constructs are compatible with `\xintNewExpr`. % $ this docstripped line for emacs buffer fontification issues in doctex-mode ### Bug fixes - `\xintZapFirstSpaces` hence also `\xintZapSpaces` from package **xinttools** were buggy when used with an argument either empty or containing only space tokens. - `\xintiiexpr` did not strip leading zeroes, hence `\xinttheiiexpr 001+1\relax` did not obtain the expected result ... - `\xinttheexpr \xintiexpr 1.23\relax\relax` should have produced `1`, but it produced `1.23` - the catcode of `;` was not set at package launching time. - the `\XINTinFloatPrd:csv` macro name had a typo, hence `prd` was non-functional in `\xintfloatexpr`. `1.09n (2014/04/01)` ---- * the user manual does not include by default the source code anymore: the `\NoSourceCode` toggle in file `xint.tex` has to be set to 0 before compilation to get source code inclusion (later release `1.1` made source code available as `sourcexint.pdf`). * bug fix (**xinttools**) in `\XINT_nthelt_finish` (this bug was introduced in `1.09i` of `2013/12/18` and showed up when the index `N` was larger than the number of elements of the list). `1.09m (2014/02/26)` ---- * new in **xinttools**: `\xintKeep` keeps the first `N` or last `N` elements of a list (sequence of braced items); `\xintTrim` cuts out either the first `N` or the last `N` elements from a list. * new in **xintcfrac**: `\xintFGtoC` finds the initial partial quotients common to two numbers or fractions `f` and `g`; `\xintGGCFrac` is a clone of `\xintGCFrac` which however does not assume that the coefficients of the generalized continued fraction are numeric quantities. Some other minor changes. `1.09kb (2014/02/13)` ---- * bug fix (**xintexpr**): an aloof modification done by `1.09i` to `\xintNewExpr` had resulted in a spurious trailing space present in the outputs of all macros created by `\xintNewExpr`, making nesting of such macros impossible. * bug fix (**xinttools**): `\xintBreakFor` and `\xintBreakForAndDo` were buggy when used in the last iteration of an `\xintFor` loop. * bug fix (**xinttools**): `\xintSeq` from `1.09k` needed a `\chardef` which was missing from `xinttools.sty`, it was in `xint.sty`. `1.09k (2014/01/21)` ---- * inside `\xintexpr..\relax` (and its variants) tacit multiplication is implied when a number or operand is followed directly with an opening parenthesis, * the `"` for denoting (arbitrarily big) hexadecimal numbers is recognized by `\xintexpr` and its variants (package **xintbinhex** is required); a fractional hexadecimal part introduced by a dot `.` is allowed. * re-organization of the first sections of the user manual. * bug fix (**xinttools**, **xint**, ...): forgotten catcode check of `"` at loading time has been added. `1.09j (2014/01/09)` ---- * (**xint**) the core division routines have been re-written for some (limited) efficiency gain, more pronounced for small divisors. As a result the *computation of one thousand digits of $\pi$* is close to three times faster than with earlier releases. * some various other small improvements, particularly in the power routines. * (**xintfrac**) a macro `\xintXTrunc` is designed to produce thousands or even tens of thousands of digits of the decimal expansion of a fraction. Although completely expandable it has its use limited to inside an `\edef`, `\write`, `\message`, \dots. It can thus not be nested as argument to another package macro. * (**xintexpr**) the tacit multiplication done in `\xintexpr..\relax` on encountering a count register or variable, or a `\numexpr`, while scanning a (decimal) number, is extended to the case of a sub `\xintexpr`-ession. * `\xintexpr` can now be used in an `\edef` with no `\xintthe` prefix; it will execute completely the computation, and the error message about a missing `\xintthe` will be inhibited. Previously, in the absence of `\xintthe`, expansion could only be a full one (with ``\romannumeral-`0``), not a complete one (with `\edef`). Note that this differs from the behavior of the non-expandable `\numexpr`: `\the` or `\number` (or `\romannumeral`) are needed not only to print but also to trigger the computation, whereas `\xintthe` is mandatory only for the printing step. * the default behavior of `\xintAssign` is changed, it now does not do any further expansion beyond the initial full-expansion which provided the list of items to be assigned to macros. * bug fix (**xintfrac**): `1.09i` did an unexplainable change to `\XINT_infloat_zero` which broke the floating point routines for vanishing operands =:((( * bug fix: the `1.09i` `xint.ins` file produced a buggy `xint.tex` file. `1.09i (2013/12/18)` ---- * (**xintexpr**) `\xintiiexpr` is a variant of `\xintexpr` which is optimized to deal only with (long) integers, `/` does a euclidean quotient. * *deprecated*: `\xintnumexpr`, `\xintthenumexpr`, `\xintNewNumExpr` are renamed, respectively, `\xintiexpr`, `\xinttheiexpr`, `\xintNewIExpr`. The earlier denominations are kept but are to be removed at some point. * it is now possible within `\xintexpr...\relax` and its variants to use count, dimen, and skip registers or variables without explicit `\the/\number`: the parser inserts automatically `\number` and a tacit multiplication is implied when a register or variable immediately follows a number or fraction. Regarding dimensions and `\number`, see the further discussion in *Dimensions*. * (**xintfrac**) conditional `\xintifOne`; `\xintifTrueFalse` renamed to `\xintifTrueAelseB`; macros `\xintTFrac` (`fractional part`, mapped to function `frac` in `\xintexpr`-essions), `\xintFloatE`. * (**xinttools**) `\xintAssign` admits an optional argument to specify the expansion type to be used: `[]` (none, default), `[o]` (once), `[oo]` (twice), `[f]` (full), `[e]` (`\edef`),... to define the macros * **xinttools** defines `\odef`, `\oodef`, `\fdef` (if the names have already been assigned, it uses `\xintoodef` etc...). These tools are provided for the case one uses the package macros in a non-expandable context. `\oodef` expands twice the macro replacement text, and `\fdef` applies full expansion. They are useful in situations where one does not want a full `\edef`. `\fdef` appears to be faster than `\oodef` in almost all cases (with less than thousand digits in the result), and even faster than `\edef` for expanding the package macros when the result has a few dozens of digits. `\oodef` needs that expansion ends up in thousands of digits to become competitive with the other two. * some across the board slight efficiency improvement as a result of modifications of various types to *fork macros* and *branching conditionals* which are used internally. * bug fix (**xint**): `\xintAND` and `\xintOR` inserted a space token in some cases and did not expand as promised in two steps `:-((` (bug dating back to `1.09a` I think; this bug was without consequences when using `&` and `|` in `\xintexpr-essions`, it affected only the macro form). * bug fix (**xintcfrac**): `\xintFtoCCv` still ended fractions with the `[0]`'s which were supposed to have been removed since release `1.09b`. * *deprecated*: `\xintifTrueFalse`, `\xintifTrue`; use `\xintifTrueAelseB`. `1.09h (2013/11/28)` ---- * parts of the documentation have been re-written or re-organized, particularly the discussion of expansion issues and of input and output formats. * the expansion types of macro arguments are documented in the margin of the macro descriptions, with conventions mainly taken over from those in the `LaTeX3` documentation. * a dependency of **xinttools** on **xint** (inside `\xintSeq`) has been removed. * (**xintgcd**) `\xintTypesetEuclideAlgorithm` and `\xintTypesetBezoutAlgorithm` have been slightly modified (regarding indentation). * (**xint**) macros `xintiSum` and `xintiPrd` are renamed to `\xintiiSum` and `\xintiiPrd`. * (**xinttools**) a count register used in `1.09g` in the `\xintFor` loops for parsing purposes has been removed and replaced by use of a `\numexpr`. * the few uses of `\loop` have been replaced by `\xintloop/\xintiloop`. * all macros of **xinttools** for which it makes sense are now declared `\long`. `1.09g (2013/11/22)` ---- * a package **xinttools** is detached from **xint**, to make tools such as `\xintFor`, `\xintApplyUnbraced`, and `\xintiloop` available without the **xint** overhead. * expandable nestable loops `\xintloop` and `\xintiloop`. * bugfix: `\xintFor` and `\xintFor*` do not modify anymore the value of `\count 255`. `1.09f (2013/11/04)` ---- * (**xint**) `\xintZapFirstSpaces`, `\xintZapLastSpaces`, `\xintZapSpaces`, `\xintZapSpacesB`, for expandably stripping away leading and/or ending spaces. * `\xintCSVtoList` by default uses `\xintZapSpacesB` to strip away spaces around commas (or at the start and end of the comma separated list). * also the `\xintFor` loop will strip out all spaces around commas and at the start and the end of its list argument; and similarly for `\xintForpair`, `\xintForthree`, `\xintForfour`. * `\xintFor` *et al.* accept all macro parameters from `#1` to `#9`. * for reasons of inner coherence some macros previously with one extra `i` in their names (e.g. `\xintiMON`) now have a doubled `ii` (`\xintiiMON`) to indicate that they skip the overhead of parsing their inputs via `\xintNum`. Macros with a *single* `i` such as `\xintiAdd` are those which maintain the non-**xintfrac** output format for big integers, but do parse their inputs via `\xintNum` (since release `1.09a`). They too may have doubled-`i` variants for matters of programming optimization when working only with (big) integers and not fractions or decimal numbers. `1.09e (2013/10/29)` ---- * (**xint**) `\xintintegers`, `\xintdimensions`, `\xintrationals` for infinite `\xintFor` loops, interrupted with `\xintBreakFor` and `\xintBreakForAndDo`. * `\xintifForFirst`, `\xintifForLast` for the `\xintFor` and `\xintFor*` loops, * the `\xintFor` and `xintFor*` loops are now `\long`, the replacement text and the items may contain explicit `\par`'s. * conditionals `\xintifCmp`, `\xintifInt`, `\xintifOdd`. * bug fix (**xint**): the `\xintFor` loop (not `\xintFor*`) did not correctly detect an empty list. * bug fix (**xint**): `\xintiSqrt {0}` crashed. `:-((` * the documentation has been enriched with various additional examples, such as the *the quick sort algorithm illustrated* or the various ways of *computing prime numbers*. * the documentation explains with more details various expansion related issues, particularly in relation to conditionals. `1.09d (2013/10/22)` ---- * bug fix (**xint**): `\xintFor*` is modified to gracefully handle a space token (or more than one) located at the very end of its list argument (as the space before `\do` in `\xintFor* #1 in {{a}{b}{c}} \do {stuff}`; spaces at other locations were already harmless). Furthermore this new version _f-expands_ the un-braced list items. After `\def\x{{1}{2}}` and `\def\y{{a}\x {b}{c}\x }`, `\y` will appear to `\xintFor*` exactly as if it had been defined as `\def\y{{a}{1}{2}{b}{c}{1}{2}}`. * same bug fix for `\xintApplyInline`. `1.09c (2013/10/09)` ---- * (**xintexpr**) added `bool` and `togl` to the `\xintexpr` syntax; also added `\xintboolexpr` and `\xintifboolexpr`. * added `\xintNewNumExpr`. * the factorial `!` and branching `?`, `:`, operators (in `\xintexpr...\relax`) have now less precedence than a function name located just before, * (**xint**) `\xintFor` is a new type of loop, whose replacement text inserts the comma separated values or list items via macro parameters, rather than encapsulated in macros; the loops are nestable up to four levels (nine levels since `1.09f`) and their replacement texts are allowed to close groups as happens with the tabulation in alignments, * `\xintForpair`, `\xintForthree`, `\xintForfour` are experimental variants of `\xintFor`, * `\xintApplyInline` has been enhanced in order to be usable for generating rows (partially or completely) in an alignment, * command `\xintSeq` to generate (expandably) arithmetic sequences of (short) integers, * again various improvements and changes in the documentation. `1.09b (2013/10/03)` ---- * various improvements in the documentation, * more economical catcode management and re-loading handling, * removal of all those `[0]`'s previously forcefully added at the end of fractions by various macros of **xintcfrac**, * `\xintNthElt` with a negative index returns from the tail of the list, * macro `\xintPRaw` to have something like what `\xintFrac` does in math mode; i.e. a `\xintRaw` which does not print the denominator if it is one. `1.09a (2013/09/24)` ---- * (**xintexpr**) `\xintexpr..\relax` and `\xintfloatexpr..\relax` admit functions in their syntax, with comma separated values as arguments, among them `reduce, sqr, sqrt, abs, sgn, floor, ceil, quo, rem, round, trunc, float, gcd, lcm, max, min, sum, prd, add, mul, not, all, any, xor`. * comparison (`<`, `>`, `=`) and logical (`|`, `&`) operators. * the command `\xintthe` which converts `\xintexpr`essions into printable format (like `\the` with `\numexpr`) is more efficient, for example one can do `\xintthe\x` if `\x` was defined to be an `\xintexpr..\relax`: \def\x{\xintexpr 3^57\relax} \def\y{\xintexpr \x^(-2)\relax} \def\z{\xintexpr \y-3^-114\relax} \xintthe\z * `\xintnumexpr .. \relax` (now renamed `\xintiexpr`) is `\xintexpr round( .. ) \relax`. * `\xintNewExpr` now works with the standard macro parameter character `#`. * both regular `\xintexpr`-essions and commands defined by `\xintNewExpr` will work with comma separated lists of expressions, * commands `\xintFloor`, `\xintCeil`, `\xintMaxof`, `\xintMinof` (package **xintfrac**), `\xintGCDof`, `\xintLCM`, `\xintLCMof` (package **xintgcd**), `\xintifLt`, `\xintifGt`, `\xintifSgn`, `\xintANDof`, ... * The arithmetic macros from package **xint** now filter their operands via `\xintNum` which means that they may use directly count registers and `\numexpr`-essions without having to prefix them by `\the`. This is thus similar to the situation holding previously already when **xintfrac** was loaded. * a bug (**xintfrac**) introduced in `1.08b` made `\xintCmp` crash when one of its arguments was zero. `:-((` `1.08b (2013/06/14)` ---- * (**xintexpr**) Correction of a problem with spaces inside `\xintexpr`-essions. * (**xintfrac**) Additional improvements to the handling of floating point numbers. * section *Use of count registers* documenting how count registers may be directly used in arguments to the macros of **xintfrac**. `1.08a (2013/06/11)` ---- * (**xintfrac**) Improved efficiency of the basic conversion from exact fractions to floating point numbers, with ensuing speed gains especially for the power function macros `\xintFloatPow` and `\xintFloatPower`, * Better management by `\xintCmp`, `\xintMax`, `\xintMin` and `\xintGeq` of inputs having big powers of ten in them. * Macros for floating point numbers added to the **xintseries** package. `1.08 (2013/06/07)` ---- * (**xint** and **xintfrac**) Macros for extraction of square roots, for floating point numbers (`\xintFloatSqrt`), and integers (`\xintiSqrt`). * new package **xintbinhex** providing *conversion routines* to and from binary and hexadecimal bases. `1.07 (2013/05/25)` ---- * The **xintexpr** package is a new core constituent (which loads automatically **xintfrac** and **xint**) and implements the expandable expanding parser \xintexpr . . . \relax, and its variant \xintfloatexpr . . . \relax allowing on input formulas using the infix operators `+`, `-`, `*`, `/`, and `^`, and arbitrary levels of parenthesizing. Within a float expression the operations are executed according to the current value set by `\xintDigits`. Within an `\xintexpr`-ession the binary operators are computed exactly. To write the `\xintexpr` parser I benefited from the commented source of the `l3fp` parser; the `\xintexpr` parser has its own features and peculiarities. *See its documentation*. * The floating point precision `D` is set (this is a local assignment to a `\mathchar` variable) with `\xintDigits := D;` and queried with `\xinttheDigits`. It may be set to anything up to `32767`.[^1] The macro incarnations of the binary operations admit an optional argument which will replace pointwise `D`; this argument may exceed the `32767` bound. * The **xintfrac** macros now accept numbers written in scientific notation, the `\xintFloat` command serves to output its argument with a given number `D` of significant figures. The value of `D` is either given as optional argument to `\xintFloat` or set with `\xintDigits := D;`. The default value is `16`. [^1]: but values higher than 100 or 200 will presumably give too slow evaluations. `1.06b (2013/05/14)` ---- * Minor code and documentation improvements. Everywhere in the source code, a more modern underscore has replaced the @ sign. `1.06 (2013/05/07)` ---- * Some code improvements, particularly for macros of **xint** doing loops. * New utilities in **xint** for expandable manipulations of lists: \xintNthElt, \xintCSVtoList, \xintRevWithBraces * The macros did only a double expansion of their arguments. They now fully expand them (using ``\romannumeral-`0``). Furthermore, in the case of arguments constrained to obey the TeX bounds they will be inserted inside a `\numexpr..\relax`, hence completely expanded, one may use count registers, even infix arithmetic operations, etc... `1.05 (2013/05/01)` ---- Minor changes and additions to **xintfrac** and **xintcfrac**. `1.04 (2013/04/25)` ---- * New component **xintcfrac** devoted to continued fractions. * **xint**: faster division. * **xint**: added expandable macros `\xintListWithSep` and `\xintApply` to handle token lists. * **xintfrac**: added `\xintRound`. * **xintseries** has a new implementation of `\xintPowerSeries` based on a Horner scheme, and new macro `\xintRationalSeries`. Both to help deal with the *denominator buildup* plague. * `tex xint.dtx` extracts style files (no need for a `xint.ins`). * Bug fix (**xintfrac**): `\xintIrr {0}` crashed. `1.03 (2013/04/14)` ---- * New modules **xintfrac** (expandable operations on fractions) and **xintseries** (expandable partial sums with xint package). * Slightly improved division and faster multiplication (the best ordering of the arguments is chosen automatically). * Added illustration of Machin algorithm to the documentation. `1.0 (2013/03/28)` ---- Initial announcement: > The **xint** package implements with expandable TeX macros the basic arithmetic operations of addition, subtraction, multiplication and division, as applied to arbitrarily long numbers represented as chains of digits with an optional minus sign. > The **xintgcd** package provides implementations of the Euclidean algorithm and of its typesetting. > The packages may be used with Plain and with LaTeX. %------------------------------------------------------ %<*makefile>------------------------------------------------------ # This file: Makefile.mk (generated from xint.dtx) # "make --file=Makefile.mk help" # Starting with xint 1.3c, Latexmk is used for easier compilation of # sourcexint.pdf as the latter then included indices. These indices # got removed at 1.3e but usage of Latexmk is maintained for the build. # Originally tested on Mac OS X Mavericks with GNU Make 3.81, # TeXLive 2014 and Pandoc 1.13.1. # Note to myself: I wanted to use .RECIPEPREFIX = > but it is # supported only with GNU Make 3.82 and later. # this crazyness is to circumvent a problem with docstrip generation # of the Makefile; we do not want two empty lines becoming only one nullstring := define newline $(nullstring) endef # will speed-up a little, I think. newline := $(newline) define helptext ==== INSTRUCTIONS It is recommended to work with xint.dtx and Makefile moved to some otherwise empty temporary repertory. make help prints this help using more. And it will extract all files inclusive of README.md, CHANGES.md, and TeX macro files. make helpless prints this help using less. make doc produces all documentation, requires Latexmk and Pandoc. make all produces all documentation, then creates xint.tds.zip. make xint.tds.zip same as "make all" make xint.pdf extracts files and produces xint.pdf, using latex and dvipdfmx. Requires Latexmk. make sourcexint.pdf extracts files and produces sourcexint.pdf, using latex, makeindex and dvipdfmx. Requires Latexmk. make CHANGES.html requires Pandoc. make clean removes auxiliary files and repertories. make cleanall removes all files, leaving only xint.dtx (and Makefile). ==== INSTALLING The following has been tested on a TeXLive installation: make installhome creates xint.tds.zip, and unzips it in make installlocal creates xint.tds.zip, unzips it in and then does texhash Depending on access rights "sudo make installlocal" might be needed. In case of doubt run first "make doc" then "make installlocal". If the latter fails, then try "sudo make installlocal". make uninstallhome removes all xint files and repertories from make uninstalllocal removes all xint files and repertories from and then does texhash Might need "sudo". endef .PHONY: help helpless all doc clean cleanall\ installhome uninstallhome installlocal uninstalllocal # for printf with subst and \n, got it from # http://stackoverflow.com/a/5887751 # I could do the trick with := here, for \n substitution, but this would add # tiny overhead to all other operations of make help: @printf '$(subst $(newline),\n,$(helptext))' | more helpless: @printf '$(subst $(newline),\n,$(helptext))' | less # RM = rm -f JF_tmpdir := $(shell mktemp -d TEMP_XINT_XXX) TEXMF_local = $(shell kpsewhich -var-value TEXMFLOCAL) TEXMF_home = $(shell kpsewhich -var-value TEXMFHOME) packages = xintkernel.sty xintcore.sty xint.sty xintfrac.sty xintexpr.sty\ xintgcd.sty xintbinhex.sty xintseries.sty xintcfrac.sty\ xinttools.sty xinttrig.sty xintlog.sty # Makefile.mk is not included in $(extracted). Its extraction rule is in # master Makefile file. We can not extract Makefile from xint.dtx via # docstrip, as .tex is always appended if a filename with no extension is # specified. If "make -f Makefile.mk" is run, Makefile.mk will not be # overwritten because tex xint.dtx does not extract it (etex xint.dtx does). extracted = $(packages) xint.tex xint.ins README.md CHANGES.md doHTMLs.sh filesfortex = $(packages) filesforsource = xint.dtx Makefile filesfordoc = xint.pdf sourcexint.pdf README.md CHANGES.html auxiliaryfiles = xint.dvi xint.aux xint.toc xint.log\ sourcexint.dvi sourcexint.aux sourcexint.toc sourcexint.log xint_cmd = latexmk xint sourcexint_cmd = latexmk -jobname=sourcexint\ -latex='latex %O "\chardef\dosourcexint=1 \input{%S}"' xint.tex all: $(extracted) doc xint.tds.zip @echo 'make all done.' $(extracted): xint.dtx tex xint.dtx doc: xint.pdf sourcexint.pdf CHANGES.html @echo 'make doc done.' xint.pdf: xint.dtx xint.tex $(xint_cmd) dvipdfmx xint.dvi sourcexint.pdf: xint.dtx xint.tex $(sourcexint_cmd) dvipdfmx sourcexint.dvi CHANGES.html: CHANGES.md doHTMLs.sh chmod u+x doHTMLs.sh && ./doHTMLs.sh xint.tds.zip: $(filesfordoc) $(filesforsource) $(filesfortex) rm -fr $(JF_tmpdir) mkdir -p $(JF_tmpdir)/doc/generic/xint mkdir -p $(JF_tmpdir)/source/generic/xint mkdir -p $(JF_tmpdir)/tex/generic/xint chmod -R ugo+rwx $(JF_tmpdir) cp -a $(filesfordoc) $(JF_tmpdir)/doc/generic/xint cp -a $(filesforsource) $(JF_tmpdir)/source/generic/xint cp -a $(filesfortex) $(JF_tmpdir)/tex/generic/xint cd $(JF_tmpdir); chmod -R ugo+r doc source tex umask 0022 && cd $(JF_tmpdir) &&\ zip -r xint.tds.zip doc source tex &&\ mv -f xint.tds.zip ../ rm -fr $(JF_tmpdir) @echo 'make xint.tds.zip done.' xint.zip: $(filesfordoc) $(filesforsource) $(filesfortex) xint.tds.zip mkdir -p $(JF_tmpdir)/xint chmod ugo+rwx $(JF_tmpdir)/xint cp -a $(filesfordoc) $(JF_tmpdir)/xint cp -a $(filesforsource) $(JF_tmpdir)/xint chmod -R ugo+r $(JF_tmpdir)/xint mv xint.tds.zip $(JF_tmpdir)/ umask 0022 && cd $(JF_tmpdir) && zip -r xint.zip xint.tds.zip xint mv $(JF_tmpdir)/xint.tds.zip ./ mv -f $(JF_tmpdir)/xint.zip ./ rm -fr $(JF_tmpdir) @echo 'make xint.zip done.' installhome: xint.tds.zip unzip xint.tds.zip -d $(TEXMF_home) uninstallhome: cd $(TEXMF_home) && rm -fr doc/generic/xint \ source/generic/xint \ tex/generic/xint # cf http://stackoverflow.com/a/1909390 # as kpsewhich is very slow (.5s) I want to evaluate once only. installlocal: xint.tds.zip $(eval $@_tmp := $(TEXMF_local)) unzip xint.tds.zip -d $($@_tmp) && texhash $($@_tmp) uninstalllocal: cd $(TEXMF_local) && rm -fr doc/generic/xint \ source/generic/xint \ tex/generic/xint && texhash . clean: rm -fr auto/ TEMP*/ rm -f $(auxiliaryfiles)\ sourcexint.fls sourcexint.fdb_latexmk\ xint.fls xint.fdb_latexmk cleanall: clean rm -f $(extracted) CHANGES.html \ xint.pdf sourcexint.pdf xint.tds.zip xint.zip Makefile.mk %$----------------------------------------------------- %<*dohtmlsh>------------------------------------------------------ #! /bin/sh # README.html and CHANGES.html from README.md and CHANGES.md # tested with pandoc 1.13.1 # pandoc -o README.html -s --toc -V highlighting-css=' body{margin-left : 10%; margin-right : 15%; margin-top: 4ex; font-size: 12pt;} # pre {white-space: pre-wrap; } # code {white-space: pre-wrap; } # .mono {font-family: monospace;}' README.md pandoc -o CHANGES.html -s --toc -V highlighting-css=' body{margin-left : 10%; margin-right : 15%; margin-top: 4ex; font-size: 12pt;} pre {white-space: pre-wrap;} code {white-space: pre-wrap;} #TOC {float: right; position: relative; top: 100px; margin-bottom: 100px;}' CHANGES.md %------------------------------------------------------ %<*drv>----------------------------------------------------------- %% %% To produce manually xint.pdf from xint.tex: %% - latex (thrice) then dvipdfmx, %% - or xelatex/pdflatex thrice. %% %% To produce manually sourcexint.pdf from xint.tex: %% (latexmk argument quoting may need shell-dependant changes) %% latexmk -jobname=sourcexint\ %% -latex="latex %O \\\\chardef\\\\dosourcexint=1 \\\\input{%S}"\ %% xint.tex %% dvipdfmx sourcexint.dvi %% %% To get xint.pdf to include the source code and indices: %% - etex xint.dtx (this will regenerate this file), %% - replace 1 by 0 in \chardef line below, %% - make clean %% - make xint.pdf %% This will use latexmk. Without it execute latex thrice then dvipdfmx. \NeedsTeXFormat{LaTeX2e} \ProvidesFile{xint.tex}% [\xintbndldate\space v\xintbndlversion\space driver file for xint documentation (JFB)]% \PassOptionsToClass{a4paper,fontsize=10pt}{scrdoc} \chardef\NoSourceCode 1 % set it to 0 if source code inclusion desired \input xint.dtx %%% Local Variables: %%% mode: latex %%% TeX-PDF-from-DVI: "Dvipdfmx" %%% End: %----------------------------------------------------------- %<*dtx>----------------------------------------------------------- ^^Bfi^^Begroup \chardef\noetex 0 \ifx\numexpr\undefined\chardef\noetex 1 \fi \ifnum\noetex=1 \chardef\extractfiles 0 % extract files, then stop \else \ifx\ProvidesFile\undefined \chardef\extractfiles 0 % no LaTeX2e: etex, xetex, ... on xint.dtx \else \ifx\NoSourceCode\undefined % latex/pdflatex/xelatex on xint.dtx, we will extract all files \chardef\extractfiles 1 % 1 = extract and typeset, 2 = only typeset \chardef\NoSourceCode 0 % 0 = include source code, 1 = do not \NeedsTeXFormat{LaTeX2e}% \PassOptionsToClass{a4paper,fontsize=10pt}{scrdoc}% \else % latex/pdflatex/xelatex on xint.tex \chardef\extractfiles 2 % no extractions, but typeset % \NoSourceCode is set-up in xint.tex \fi \ProvidesFile{xint.dtx}[bundle source (\xintbndlversion, \xintbndldate) % and documentation (\xintdocdate)]% \fi \fi \ifnum\extractfiles<2 % extract files \def\MessageDeFin{\newlinechar10 \let\Msg\message \Msg{^^J}% \Msg{********************************************************************^^J}% \Msg{*^^J}% \Msg{* To finish the installation you have to move the following^^J}% \Msg{* files into a directory searched by TeX:^^J}% \Msg{*^^J}% \Msg{* \space\space\space\space xintkernel.sty^^J}% \Msg{* \space\space\space\space xintcore.sty^^J}% \Msg{* \space\space\space\space xint.sty^^J}% \Msg{* \space\space\space\space xintbinhex.sty^^J}% \Msg{* \space\space\space\space xintgcd.sty^^J}% \Msg{* \space\space\space\space xintfrac.sty^^J}% \Msg{* \space\space\space\space xintseries.sty^^J}% \Msg{* \space\space\space\space xintcfrac.sty^^J}% \Msg{* \space\space\space\space xintexpr.sty^^J}% \Msg{* \space\space\space\space xinttools.sty^^J}% \Msg{* \space\space\space\space xinttrig.sty^^J}% \Msg{* \space\space\space\space xintlog.sty^^J}% \Msg{*^^J}% \Msg{* Rename Makefile.mk to Makefile if the latter is absent^^J}% \Msg{* (or use --file=Makefile.mk option to "make") then "make help"^^J}% \Msg{* provides information on targets. In particular:^^J}% \Msg{* - the "doc" target builds all documentation,^^J}% \Msg{* - the "xint.tds.zip" target additionally prepares a TDS-compliant^^J}% \Msg{*\space\space\space archive.^^J}% \Msg{* This requires Latexmk (for xint.pdf and sourcexint.pdf) and Pandoc^^J}% \Msg{* (for CHANGES.html).^^J}% \Msg{*^^J}% \Msg{* Or check instructions in xint.tex for manual compilation.^^J}% \Msg{*^^J}% \Msg{* Happy TeXing!^^J}% \Msg{*^^J}% \Msg{********************************************************************^^J}% }% \begingroup \input docstrip.tex \askforoverwritefalse \catcode9 11 % do not kill TAB in producing Makefile.mk \generate{\nopreamble\nopostamble \file{README.md}{\from{xint.dtx}{readme}} \file{CHANGES.md}{\from{xint.dtx}{changes}} % pure tex will use ^^I notation for TAB character, don't want that. % there is a problem with xelatex, as it generates ^^I also. \ifnum\noetex=1 \else\ifx\XeTeXinterchartoks\undefined \file{Makefile.mk}{\from{xint.dtx}{makefile}}\fi\fi \file{doHTMLs.sh}{\from{xint.dtx}{dohtmlsh}} \usepreamble\defaultpreamble \usepostamble\defaultpostamble \file{xint.tex}{\from{xint.dtx}{drv}} \file{xintkernel.sty}{\from{xint.dtx}{xintkernel}} \file{xinttools.sty}{\from{xint.dtx}{xinttools}} \file{xintcore.sty}{\from{xint.dtx}{xintcore}} \file{xint.sty}{\from{xint.dtx}{xint}} \file{xintbinhex.sty}{\from{xint.dtx}{xintbinhex}} \file{xintgcd.sty}{\from{xint.dtx}{xintgcd}} \file{xintfrac.sty}{\from{xint.dtx}{xintfrac}} \file{xintseries.sty}{\from{xint.dtx}{xintseries}} \file{xintcfrac.sty}{\from{xint.dtx}{xintcfrac}} \file{xintexpr.sty}{\from{xint.dtx}{xintexpr}} \file{xinttrig.sty}{\from{xint.dtx}{xinttrig}} \file{xintlog.sty}{\from{xint.dtx}{xintlog}}} \endgroup \fi % end of file extraction (from etex/latex/pdflatex/... run on xint.dtx) \ifnum\extractfiles=0 % no LaTeX, files now extracted. Stop. \MessageDeFin\expandafter\end \fi % From this point on, run is necessarily with e-TeX. % Check if \MessageDeFin got defined, if yes put it at end of run. \ifdefined\MessageDeFin\AtEndDocument{\MessageDeFin}\fi %----------------------------------------------------------------- % -*- coding: utf-8; mode: latex, fill-column: 78; -*- % \ifdefined\dosourcexint % this toggle is set from make sourcexint.pdf rule \chardef\NoSourceCode 0 \else \chardef\dosourcexint 0 \fi % default is to assume latex + dvipdfmx \chardef\Withdvipdfmx 1 \RequirePackage{ifpdf} \RequirePackage{ifxetex} \ifpdf \chardef\Withdvipdfmx 0 \fi \ifxetex\chardef\Withdvipdfmx 0 \fi % Get rid of HARASSMENT by KOMA-Script \makeatletter \def\class@shoulddisablepackagewarning@list{tocloft.} \makeatother \ifnum\Withdvipdfmx=1 \def\pgfsysdriver{pgfsys-dvipdfm.def} \documentclass [dvipdfm, dvipdfmx, dvipdfmx-outline-open]{scrdoc} \else \documentclass {scrdoc} \fi % Remove from sectioning commands insertion of marks, because we % will do it ourself. \usepackage{etoolbox} \makeatletter \patchcmd{\@sect}% {\expandafter\csname#1mark\expandafter\endcsname\expandafter{\@currentheadentry}}% {}{}{} \patchcmd{\@sect}% {\expandafter\csname#1mark\expandafter\endcsname\expandafter{\@currentheadentry}}% {}{}{} % This one now needed too, Jeudi 30 janvier 2020 % \expandafter \ifx \csname #1mark\endcsname \@gobble \@mkboth {}{}\else % \csname #1mark\expandafter \endcsname \expandafter {\@currentheadentry }\fi % \@gobble est long donc simplement \def\partmark #1{}% \makeatother \makeatletter \PassOptionsToPackage{bookmarks=true}{hyperref} \ifnum\NoSourceCode=1 \OnlyDescription \fi % counts used in particular in the samples from the documentation of the % xintseries.sty package \newcount\cnta \newcount\cntb \newcount\cntc \pagestyle{headings} \ifxetex \else \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \DeclareUnicodeCharacter{03B4}{\ensuremath{\delta}}%δ \DeclareUnicodeCharacter{03BE}{\ensuremath{\xi}}%ξ \DeclareUnicodeCharacter{03C0}{\ensuremath{\pi}}%π \fi \usepackage{multicol} \usepackage{geometry} \AtBeginDocument {\ttzfamily % package newtxtt loaded in preamble \newgeometry{textwidth=\dimexpr92\fontcharwd\font`X\relax, vscale=0.75}} \unless\ifnum\dosourcexint=1 \usepackage{xintexpr} \usepackage{xintbinhex} \usepackage{xintgcd} \usepackage{xintseries} \usepackage{xintcfrac} \usepackage{amsmath}% for \cfrac usage \DeclareMathOperator{\sinc}{sinc} \fi \usepackage{pifont}% for \ding{73} (hollow star) \usepackage{xinttools} \usepackage{enumitem} \usepackage{varioref} \usepackage{xspace} \usepackage[para]{footmisc} \usepackage{picture} \usepackage{graphicx} \usepackage[english]{babel} \usepackage[autolanguage,np]{numprint} \AtBeginDocument{\npthousandsep{,\hskip .5pt plus .1pt minus .1pt}} \usepackage[dvipsnames]{xcolor} \definecolor{joli}{RGB}{225,95,0} \definecolor{JOLI}{RGB}{225,95,0} \definecolor{BLUE}{RGB}{0,0,255} \definecolor{niceone}{RGB}{38,128,192} \definecolor{sedate}{RGB}{193,132,1} \definecolor{saddlebrown}{rgb}{.545,.27,.075} \definecolor{jfbrown}{RGB}{165,100,10}% \usepackage{eso-pic}% après xcolor sinon Option clash for package xcolor. \ifnum\dosourcexint=1 \else % Dependency graph done using TikZ (manually) \usepackage{tikz} \usetikzlibrary{shapes,arrows.meta} \fi \usepackage{framed} % SNUGFRAMED % ========== \makeatletter \newenvironment{snugframed}{% \fboxsep \dimexpr2\fontcharwd\font`X\relax \advance\linewidth-2\fboxsep \advance\csname @totalleftmargin\endcsname \fboxsep \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep \fbox{##1}\hskip-\fboxsep % There is no \@totalrightmargin, so: \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}% \MakeFramed {\advance\hsize-\width \@totalleftmargin\z@ \linewidth\hsize \@setminipage}% }{\par\unskip\@minipagefalse\endMakeFramed} \makeatother % HYPERREF % ======== \usepackage[pdfencoding=unicode]{hyperref} \hypersetup{% linktoc=all,% breaklinks=true,% colorlinks=true,% urlcolor=niceone,% linkcolor=blue,% pdfauthor={Jean-Fran\c cois Burnol},% pdftitle={The xintexpr and allied packages},% pdfsubject={Arithmetic with TeX},% pdfkeywords={Expansion, arithmetic, TeX},% pdfstartview=FitH,% pdfpagemode=UseNone,% } \usepackage{hypcap} \ifnum\dosourcexint=1 \hypersetup{pdftitle={The xint packages source code}} \fi \usepackage{bookmark} % FONTS % ===== \usepackage[zerostyle=a,straightquotes,scaled=0.95]{newtxtt} \usepackage{newtxmath} \makeatletter \DeclareFontFamily{T1}{newtxttb}{\hyphenchar\font\m@ne} \DeclareFontShape{T1}{newtxttb}{m}{n}{ <-> s*[\newtxtt@scale]newtxttbq }{} \DeclareFontShape{T1}{newtxttb}{b}{n}{ <-> s*[\newtxtt@scale]newtxbttbq }{} \DeclareFontShape{T1}{newtxttb}{bx}{n}{ <-> ssub * newtxttb/b/n }{} \DeclareFontShape{T1}{newtxttb}{m}{sl}{ <-> s*[\newtxtt@scale]newtxttslbq }{} \DeclareFontShape{T1}{newtxttb}{m}{it}{ <-> ssub * newtxttb/m/sl }{} % Ajouté le 9 mars 2016 \DeclareFontShape{T1}{newtxttb}{m}{sc}{%cap & small cap <-> s*[\newtxtt@scale]newtxttscbq }{} \DeclareFontShape{T1}{newtxttb}{b}{sc}{%bold cap & small cap <-> s*[\newtxtt@scale]newtxbttscbq }{} \DeclareFontShape{T1}{newtxttb}{b}{sl}{%bold slanted <-> s*[\newtxtt@scale]newtxbttslbq }{} \DeclareFontShape{T1}{newtxttb}{b}{it}{%bold italic <-> ssub * newtxttb/b/sl% }{} \DeclareFontShape{T1}{newtxttb}{bx}{sc}{%bold extended cap & small cap <-> ssub * newtxttb/b/sc% }{} \DeclareFontShape{T1}{newtxttb}{bx}{sl}{%bold extended slanted <-> ssub * newtxttb/b/sl% }{} \DeclareFontShape{T1}{newtxttb}{bx}{it}{%bold extended italic <-> ssub * newtxttb/b/sl% }{} % Ajouté le 9 mars 2016 \DeclareEncodingSubset{TS1}{newtxttb}{0} \DeclareFontFamily{TS1}{newtxttb}{\hyphenchar\font\m@ne} \DeclareFontShape{TS1}{newtxttb}{m}{n}{%medium <-> s*[\newtxtt@scale]tcxtt% }{} \DeclareFontShape{TS1}{newtxttb}{m}{sc}{%cap & small cap <->ssub * newtxttb/m/n% }{} \DeclareFontShape{TS1}{newtxttb}{m}{sl}{%slanted <-> s*[\newtxtt@scale]tcxttsl% }{} \DeclareFontShape{TS1}{newtxttb}{m}{it}{%italic <->ssub * newtxttb/m/sl% }{} \DeclareFontShape{TS1}{newtxttb}{b}{n}{%bold <-> s*[\newtxtt@scale]tcxbtt% }{} \DeclareFontShape{TS1}{newtxttb}{b}{sc}{%bold cap & small cap <->ssub * newtxttb/b/n% }{} \DeclareFontShape{TS1}{newtxttb}{b}{sl}{%bold slanted <-> s*[\newtxtt@scale]tcxbttsl% }{} \DeclareFontShape{TS1}{newtxttb}{b}{it}{%bold italic <->ssub * newtxttb/b/sl% }{} \DeclareFontShape{TS1}{newtxttb}{bx}{n}{%bold extended <->ssub * newtxttb/b/n% }{} \DeclareFontShape{TS1}{newtxttb}{bx}{sc}{ %bold extended cap & small cap <->ssub * newtxttb/b/sc% }{} \DeclareFontShape{TS1}{newtxttb}{bx}{sl}{%bold extended slanted <->ssub * newtxttb/b/sl% }{} \DeclareFontShape{TS1}{newtxttb}{bx}{it}{%bold extended italic <->ssub * newtxttb/b/it% }{} \makeatother % This is with a slashed 0 like the original txtt. \newcommand\ttbfamily {\fontfamily{newtxttb}\selectfont } \ifnum\dosourcexint=1 \else \renewcommand\familydefault\ttdefault \usepackage[noendash]{mathastext}% pas de endash dans newtxtt \fi \frenchspacing % sans-serif in footnotes, TOC, titles, etc... \renewcommand\familydefault\sfdefault % TABLES OF CONTENTS % ================== \usepackage{tocloft} \usepackage{etoc} \def\gobbletodot #1.{} \newif\ifinmanualmaintoc \ifnum\dosourcexint=0 \inmanualmaintoctrue \fi \def\sectioncouleur{{cyan}} \def\MARGEPAGENO {1.5em}% changera pour la partie implémentation \def\SKIPSECTIONINTERSPACE{\vskip\bigskipamount} \etocsetstyle{section}{} {\normalfont} {\etociffirst{}{\SKIPSECTIONINTERSPACE}% \rightskip \MARGEPAGENO\relax \parfillskip -\MARGEPAGENO\relax \bfseries \leftskip \leftmarginii \noindent\llap % \llap {\makebox[\leftmarginii][l]% et \leftmargini le 12/10/2014 {\expandafter\textcolor\sectioncouleur {\etocnumber}}}% \strut\etocname \mdseries\nobreak\leaders\etoctoclineleaders\hfill\nobreak\strut \makebox[\MARGEPAGENO][r]{\etocpage}\par \let\ETOCsectionnumber\etocthenumber }% {}% \newdimen\margegauchetoc \AtBeginDocument{\margegauchetoc \dimexpr 5\fontcharwd\font`X\relax} \makeatletter \etocsetstyle{subsection} {\begingroup\normalfont \setlength{\premulticols}{0pt}% \setlength{\multicolsep}{0pt}% \setlength{\columnsep}{\leftmarginii}% \setlength{\columnseprule}{.4pt}% n'influence pas séparation colonnes \parskip\z@skip \raggedcolumns \addvspace{\smallskipamount}% \begin{multicols}{2} \leftskip \margegauchetoc % 12 octobre 2014 \ifinmanualmaintoc \rightskip \MARGEPAGENO \else \rightskip \MARGEPAGENO plus 2em minus 1em \fi \parfillskip -\MARGEPAGENO\relax } {} {\noindent \etocifnumbered{\llap{\makebox[\margegauchetoc][l]{\ttzfamily\bfseries\etoclink {\ifinmanualmaintoc\expandafter\textcolor\sectioncouleur {\normalfont\bfseries\ETOCsectionnumber}\fi .\expandafter\gobbletodot\etocthenumber}}}}{\kern-\margegauchetoc}% \strut\etocname\nobreak \unless\ifinmanualmaintoc\leaders\etoctoclineleaders\fi \hfill\nobreak \strut\makebox[\MARGEPAGENO][r]{\small\etocpage}\endgraf } {\end{multicols}\endgroup %\addvspace{\smallskipamount} }% \etocsetstyle{subsubsection} {\begingroup\normalfont\small \leftskip \dimexpr\leftmargini+1em\relax } {} {\noindent \llap{\makebox[\dimexpr\leftmargini+1em\relax][l]% {\ttzfamily\bfseries\etoclink {\HOOKLOCALTOC.\expandafter\gobbletodot\etocthenumber}}}% \strut\etocname\nobreak \leaders\etoctoclineleaders \hfill\nobreak \strut\makebox[\MARGEPAGENO][r]{\small\etocpage}\endgraf } {\endgroup }% \let\HOOKLOCALTOC\empty% quick hack to get style I want in User defined functions \etocsetlevel{table}{6} \makeatother \addtocontents{toc}{\protect\hypersetup{hidelinks}} % ===================== % MISCELLANEOUS MARK-UP % ===================== \def\digitstt #1{\begingroup\color[named]{OrangeRed}#1\endgroup} \let\dtt\digitstt % \ctexttt is a remnant of 1.09n manual, don't have time to get rid of it now. \newcommand\ctexttt [1]{\begingroup\color[named]{DarkOrchid}%\bfseries #1\endgroup} % \fexpan 22 octobre 2013 \newcommand\fexpan {\hyperref[ssec:expansions]{\textit{f}-expan}} % Septembre 2015 % Address updated to github repo's one, May 2018 \def\liiibigint {\href{https://github.com/latex3/latex3/tree/master/l3trial/l3bigint}{l3bigint}} % \fixmeaning \makeatletter % \def\fixmeaning {\expandafter\fix@meaning\meaning} % \expandafter\edef\expandafter\fix@meaning % \expandafter #\expandafter1\string\romannumeral#2#3% % {#1\string\romannumeral`\string^\string^@} % Pour 1.4 \let\fixmeaning\meaning \makeatother % Margin Notes % ============ % Nothing here can be used in vertical mode directly. \makeatletter \def\MyMarginNote {\@ifnextchar[\@MyMarginNote{\@MyMarginNote[]}}% \let\inmarg\MyMarginNote % \smash needs \hbox here since LaTeX 2018/12/01 % https://github.com/latex3/latex2e/issues/108 \def\@MyMarginNote [#1]#2{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\color[named]{PineGreen}\normalfont\small \hsize 1.6cm\rightskip.5cm minus.5cm \hss\vtop{#2}\ $\to$#1\ }}}% \vskip\dp\strutbox }\strut\@esphack} \def\MyMarginNoteWithBrace #1#2{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\color[named]{PineGreen}%\normalfont\small \hss #1\ $\bigg\{$#2}}}% \vskip\dp\strutbox }\strut\@esphack} \def\IMPORTANT {\MyMarginNoteWithBrace {\raisebox{-.5\height}{\resizebox{2\width}{!}{\ding{43}}}}{\ }} \def\IMPORTANTf {\MyMarginNoteWithBrace {\raisebox{-.5\height}{\resizebox{2\width}{!}{\ding{43}}}}% {\kern\dimexpr\FrameSep+\FrameRule\relax\ }} \def\etype #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \itshape \xintListWithSep{\,}{#1}\ $\star$\quad }}}% \vskip\dp\strutbox }\strut\@esphack} \def\xtype #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \itshape \xintListWithSep{\,}{#1}\ \ding{73}\quad }}}% \vskip\dp\strutbox }\strut\@esphack} \def\ntype #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \itshape \xintListWithSep{\,}{#1}\quad }}}% \vskip\dp\strutbox }\strut\@esphack} % \def\Numf {{\vbox{\halign{\hfil##\hfil\cr \footnotesize \upshape Num\cr \noalign{\hrule height 0pt \vskip1pt\relax} \itshape f\cr}}}} \def\Ff {{\vbox{\halign{\hfil##\hfil\cr \footnotesize \upshape Frac\cr \noalign{\hrule height 0pt \vskip1pt\relax} \itshape f\cr}}}} \def\numx {{\vbox{\halign{\hfil##\hfil\cr \footnotesize \upshape num\cr \noalign{\hrule height 0pt \vskip1pt\relax} \itshape x\cr}}}} % \def\NewWith #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent New with #1}\ }}}% \vskip\dp\strutbox }\strut\@esphack} % \def\CHANGED #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{Red}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Changed at #1!}\ }}}% \vskip\dp\strutbox }\strut\@esphack} \def\DNU#1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{Red}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Do not use! #1}\ }}}% \vskip\dp\strutbox }\strut\@esphack} \def\UNSTABLE#1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{Red}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Unstable! #1}\ }}}% \vskip\dp\strutbox }\strut\@esphack} \def\unstable#1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{Red}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent unstable? #1}\ }}}% \vskip\dp\strutbox }\strut\@esphack} \def\DEPRECATED #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \normalfont\small\bfseries \hsize 2cm\rightskip.5cm minus.5cm \vtop{\noindent Deprecated! (#1)}\ }}}% \vskip\dp\strutbox }\strut\@esphack} % \def\CHANGEDf #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{Red}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Changed at #1!}\ \kern\dimexpr\FrameSep+\FrameRule\relax}}}% \vskip\dp\strutbox }\strut\@esphack} % \def\NewWithf #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent New with #1}\ \kern\dimexpr\FrameSep+\FrameRule\relax}}}% \vskip\dp\strutbox }\strut\@esphack} \makeatother % \centeredline: OUR OWN LITTLE MACRO FOR CENTERING LINES % ======================================================= % 7 mars 2013 % Note (2020): now a package \usepackage{centeredline} % \leftedline % =========== % 12 octobre 2014 % Note (2020): somewhat obsoleted for many years by my usage of % everbatim and everbatim* environments. \makeatletter \newif\ifinlefted \newcommand*\leftedline {% \ifhmode \\\relax \def\leftedline@{\hss\egroup\hskip\z@skip\ignorespaces }% \else \def\leftedline@{\hss\egroup }% \fi \afterassignment\@leftedline \let\next=} \def\@leftedline {\hbox to \linewidth \bgroup \inleftedtrue \everbatimeverypar \bgroup \aftergroup\leftedline@ } \makeatother % verbatim macros and environments % ================================ % % June 2013, then October 2014. % ----------------------------- % \makeatletter \catcode`_ 11 % some of my verbatim environments do not make the space active (\lverb e.g.). Then % \do@noligs must be modified, \char`#1 must be followed by a space token, else, % the `#1 expansion will swallow one space. \def\do@noligs #1{% \catcode`#1\active \begingroup \lccode`~`#1\relax \lowercase{% \endgroup\def~{\leavevmode\kern\z@\char`#1 }}% } % \lowast \def\lowast{\raisebox{-.25\height}{*}} \catcode`* 13 \def\makestarlowast {\let*\lowast\catcode`\*\active}% \catcode`* 12 % \MacroFont and \MicroFont % ========================= \def\restoreMicroFont {\def\MicroFont {\ttbfamily\makestarlowast % \ifinlefted\else\ifineverb\else\color[named]{verbatim}\fi\fi % \ifinlefted\else\color[named]{saddlebrown}\fi % \ifinlefted\else\color[named]{sedate}\fi \ifinlefted\else\color[named]{jfbrown}\fi }} \restoreMicroFont % Notice that \macrocode uses \macro@font which stores the \MacroFont meaning % in force at \begin{document}. But doc.sty's verbatim uses current \MacroFont % not the meaning at \begin{document}. Comprenne qui pourra... \def\restoreMacroFont {\def\MacroFont {\ttbfamily % \ifinlefted\else\ifineverb\else\color[named]{Blue}\fi\fi % \ifinlefted\else\color[named]{Blue}\fi % \ifinlefted\else\color[named]{sedate}\fi \ifinlefted\else\color[named]{Brown}\fi }} \restoreMacroFont % \verb % ===== % Initially, June 2013, then Sep 9, 2014, and Oct 9-12 2014 % % Initial motivation was simply that doc.sty and related classes \verb % macro is with a hard-coded \ttfamily. There were further issues. % % 1. With |stuff with space|, paragraph reformatting in the Emacs/AUCTeX % buffer caused havoc. Thus I wanted the input to accept linebreaks in % its contents. % % 2. Hence I did not want to have obeyed spaces obeyed, (Emacs reflowing % of paragraph in certain contexts often adds spaces at beginning of a line) % % 3. Also I wanted to allow hyphenated output, at least at some % locations. I did a first version which treated spaces, \, {, and } % specially. % % 4. At some point I wanted to add some colored background (I have % dropped that since due to pdf file size increase). % % 5. And also I got fed up from the non-compatibility with footnotes due % to catcode freeze. % % Because of 5. I opted for a \scantokens approach, hence for a macro % with delimited argument. Here is what I do now, this is compatible % with short verbs. \def\verb {% \relax \ifmmode\else\leavevmode\null\fi \bgroup \let\do\@makeother \dospecials \@ifstar{\@sverb}% \verb* is used in the index (obsolete: no indices at 1.3e), % leave it using ambient font {\MicroFont % used to change font (ttbfamily=slashed 0), color, % will make * active via \makestarlowast \catcode 32 10 \endlinechar 32 % allows to fetch across line breaks \frenchspacing % done globally in document \@@jfverb}% }% % Note (Oct 12, 2014): in the improbable situation a newlinechar is % found in the ##1, \scantokens will convert this to an end of line in % its "write" phase, which will be then ignored in its "read" phase due % to \endlinechar-1. This also avoids possible creation of \par which % would defeat \@@jfverb@@. Thus it is good. \def\@@jfverb #1{% \ifcat\noexpand#1\noexpand~\catcode`#1\active\fi % No problem with the EOL for the line where the short verb delimiter stands. \def\next ##1#1{% \@vobeyspaces\everyeof{\relax}\endlinechar\m@ne \expandafter\@@jfverb_a\scantokens\expandafter{##1}}% % hack with \@empty to prevent brace stripping if catcodes have been % frozen earlier, like in footnotes. \next \@empty } % We don't want a \discretionary at the very start. % But then an empty argument is forbidden! \def\@@jfverb_a #1{#1\@@jfverb_b } \def\@@jfverb_b #1{\ifx\relax #1% \egroup \else % \penalty\z@, or rather (Oct 11, 2014) but I then adjust the textwidth % precisely: \discretionary{\copy\SoftWrapIcon}{}{}% #1\expandafter\@@jfverb_b\fi } % \SoftWrapIcon box for line-breaking using discretionaries % ========================================================= \DeclareFontFamily{U}{MdSymbolC}{} \DeclareFontShape {U}{MdSymbolC}{m}{n}{<-> MdSymbolC-Regular}{} \newbox\SoftWrapIcon \colorlet {softwrapicon}{blue} % Emacs/AUCTeX uses very strange comment-like highlighting for \usefont{U}... \def\SetSoftWrapIcon{% \setbox\SoftWrapIcon\hb@xt@\z@ {\hb@xt@\fontdimen2\font {\hss{\color{softwrapicon}\usefont{U}{MdSymbolC}{m}{n}\char"97}\hss}% \hss}% } \AtBeginDocument {\SetSoftWrapIcon }% ttzfamily déjà fait \catcode`_ 8 \makeatother % everbatim environment % ===================== % October 13-14, 2014 % Verbatim with an \everypar hook, mainly to have background color, followed by % execution of the contents (not limited by a group-scope) \makeatletter \catcode`_ 11 % Je modifie Mardi 18 février 2020 \MacroFont % pour essayer couleur de foreground, % je supprime donc le \ifineverb de \MacroFont. % \newif\ifineverb \def\everbatimtop {\MacroFont \small} \let\everbatimbottom\relax \let\everbatimhook\relax \def\everbatim {\s@everbatim\@everbatim } \@namedef{everbatim*}{\s@everbatim\expandafter\@everbatimx\expandafter {\the\newlinechar}} \def\everbatimeverypar{\strut {\color{yellow!5}\vrule\@width\linewidth }% \kern-\linewidth \kern\everbatimindent } \def\everbatimindent {\z@} % voir plus loin atbegindocument \def\endeverbatim {\if@newlist \leavevmode\fi\endtrivlist } \@namedef{endeverbatim*}{\endeverbatim\aftergroup\everbatimundoparskip} %\def\everbatimundoparskip{\ifdim\parskip>\z@\vskip-\parskip\fi} \def\everbatimundoparskip{\vbox{}\kern-\baselineskip\kern-\parskip} \def\s@everbatim {% % \ineverbtrue \everbatimtop % put there size changes \topsep \z@skip \partopsep \z@skip \itemsep \z@skip \parsep \z@skip \parskip \z@skip \lineskip \z@skip \let\do\@makeother \dospecials \let\do\do@noligs \verbatim@nolig@list \makestarlowast \everbatimhook \trivlist \@topsepadd \z@skip \item\relax \leftskip \@totalleftmargin \rightskip \z@skip \parindent \z@ \parfillskip\@flushglue \parskip \z@skip \@@par \def\par{\leavevmode\null\@@par\pagebreak[1]}% \everypar\expandafter{\the\everypar \unpenalty \everbatimeverypar \everypar \expandafter{\the\everypar\everbatimeverypar}% }% \obeylines \@vobeyspaces } \begingroup \lccode`X 13 \catcode`X \active \lccode`Y `* % this is because of \makestarlowast. % I have to think whether this is useful: obviously if I were to provide % everbatim and everbatim* in a package I wouldn't do that. \catcode`Y \active \catcode`| 0 \catcode`[ 1 \catcode`] 2 \catcode`* 12 \catcode`{ 12 \catcode`} 12 |catcode`\\ 12 |lowercase[|endgroup% both freezes catcodes and converts X to active ^^M |def|@everbatim #1X#2\end{everbatim}% [#2|end[everbatim]|everbatimbottom ] |def|@everbatimx #1#2X#3\end{everbatimY}]% {#3\end{everbatim*}% \everbatimbottom \newlinechar 13 \everbatimxprehook \scantokens {#3}% \newlinechar #1\relax \everbatimxposthook }% % L'espace venant du endofline final mis par \scantokens sera inhibé si #3 se % termine par un % ou un \x, etc... \def\everbatimxprehook {\colorlet{everbsavedcolor}{.}\color[named]{OrangeRed}} \def\everbatimxposthook {\color{everbsavedcolor}} \ifpdf \def\everbatimxprehook {\pdfcolorstack\@pdfcolorstack push{0 1 0.5 0 k 0 1 0.5 0 K}\relax} \def\everbatimxposthook {\pdfcolorstack\@pdfcolorstack pop\relax} \else \ifxetex \def\everbatimxprehook {\special{color push cmyk 0 1 0.5 0}} \def\everbatimxposthook {\special{color pop}} \else \ifnum\Withdvipdfmx=1 \def\everbatimxprehook {\special{pdf:bcolor OrangeRed}} \def\everbatimxposthook {\special{pdf:ecolor}} \fi\fi\fi % \everb % ====== % % Original was called \dverb and I did it in June 2013. % Then after doing everbatim, I transformed \dverb, now called \everb % for itself being as compatible as standard verbatim with list making % surrounding environments. % Supposed to be used as % \everb|@ this will be ignored % stuff % escape character: " % | not necessarily starting a line. % I chose @ as comment character, mainly for pretty-formatting of the % source, this can be changed by \everbhook. % " comme caractère d'échappement. Par exemple pour colorier des parties. \def\restoreeverbhook{\def\everbhook{% \def\"{\begingroup\catcode123 1 \catcode 125 2 \everbescape }% \catcode`\" 0 \catcode`\@ 14 }}\restoreeverbhook \def\everbescape #1;!{#1\endgroup } \def\everb {% \bgroup \let\everbatimhook\everbhook \s@everbatim \@everb } \def\@everb #1{\catcode`#1\active \lccode`\~`#1% \lowercase{\def~{\if@newlist \leavevmode\fi \endtrivlist \egroup \@doendpe \everbatimbottom }}% }% \catcode`_8 \makeatother % \printnumber % ============ \catcode`_ 11 \makeatletter \catcode`& 3 \def\allowsplits_a {\futurelet\printnumber_token\allowsplits_b }% \def\allowsplits_b{\ifx\printnumber_token\@sptoken\space\fi\allowsplits_c } \def\allowsplits_c #1{\ifx \xint_dothis\xint_gobble_i\fi \if ,#1\xint_dothis {\discretionary{\rlap,}{}{,}}\fi \xint_orthat{\discretionary {\copy\SoftWrapIcon}% {}% {}#1}\allowsplits_a }% \def\printnumber #1{\expandafter\allowsplits_a \romannumeral-`0#1&}% \hyphenpenalty \z@ \catcode`& 4 \makeatother \catcode`_ 8 % Parameters for lists % ==================== \AtBeginDocument{% \leftmargini \dimexpr4\fontcharwd\font`X\relax \leftmarginii\dimexpr3\fontcharwd\font`X\relax \leftmarginiii \leftmarginii \leftmarginiv \leftmarginii \parindent\dimexpr2\fontcharwd\font`X\relax \leftmargin\leftmargini % pourquoi pas 0? % formerly everbatim indent was set to leftmargingi, reduce it (2017/08/26) % \edef\everbatimindent{\the\dimexpr\leftmargini\relax\space }% % setting it to \parindent does not work with \everb construct % \def\everbatimindent{\parindent}% \edef\everbatimindent{\the\dimexpr2\fontcharwd\font`X\relax\space}% \cftsubsecnumwidth 2\leftmarginii \cftsubsubsecnumwidth 2\leftmargini \cftsubsecindent 0pt \cftsubsubsecindent \cftsubsecnumwidth }% % ========== % Hyperlinks % ========== % \csa, \csbxint, \csh etc... % =========================== % These definitions in force both in manual and implementation part \DeclareRobustCommand\csa[1] {{\ttzfamily\char92\endlinechar-1 \makestarlowast \catcode`_ 12 \catcode`^ 12 \scantokens\expandafter{\detokenize{#1}}}} % csan: n means no backslash \DeclareRobustCommand\csan[1] {{\ttzfamily\endlinechar-1 \makestarlowast \catcode`_ 12 \catcode`^ 12 \scantokens\expandafter{\detokenize{#1}}}} \newcommand\csh[1] {\texorpdfstring{\csa{#1}}{\textbackslash\detokenize{#1}}} \newcommand\cshn[1] {\texorpdfstring{\csan{#1}}{\detokenize{#1}}} % \csh and \cshn will be redefined in implementation section \let\cshnolabel\csh \let\cshnnolabel\cshn % These definitions will be re-done for implementation part % Don't bother about underscore and caret for time being. \DeclareRobustCommand\csb [1] {\hyperref[\detokenize{#1}]% {{\char92 \endlinechar-1 \makestarlowast \scantokens\expandafter{\detokenize{#1}}}}} \DeclareRobustCommand\csbxint [1] {\hyperref[\detokenize{xint#1}]% {{\char92\mbox{xint}\-\endlinechar-1 \makestarlowast \scantokens\expandafter{\detokenize{#1}}}}} % \func, \funcdesc, \keyword, \keyworddesc, \prec, \precdesc, \oper, \operdesc % ============================================================================ \newcommand\func[1]{\hyperlink{\detokenize{func-#1}}{#1}()} \newcommand\funcdesc[2][x]{\item[#2({#1})]\hypertarget{\detokenize{func-#2}}{}}% \newcommand\keyword[1]{\hyperlink{\detokenize{kwd-#1}}{#1}} \newcommand\keyworddesc[1]{\item[#1]\hypertarget{\detokenize{kwd-#1}}{}}% \let\prec\relax % sinon, c'est \mathchar"321E \newcommand\prec[1]{\hyperlink{\detokenize{prec-#1}}{#1}} \newcommand\precdesc[1]{\item[\texttt{#1}]\hypertarget{\detokenize{prec-#1}}{}\leavevmode}% \newcommand\var[1]{\hyperlink{\detokenize{var-#1}}{#1}} \newcommand\vardesc[1]{\item[#1]\hypertarget{\detokenize{var-#1}}{}}% \newcommand\oper[1]{\hyperlink{\detokenize{oper-#1}}{#1}} \newcommand\operdesc[1]{\item[\texttt{#1}]\hypertarget{\detokenize{oper-#1}}{}}% % \xintname, \xintnameimp etc... % ============================== \xintForpair #1#2 in {(xint bundle,bundle), (xintkernel,kernel), (xinttools,tools), (xintcore,core),(xint,xint),(xintbinhex,binhex),(xintgcd,gcd),% (xintfrac,frac),(xintseries,series),(xintcfrac,cfrac),(xintexpr,expr),% (xinttrig, trig), (xintlog, log)} \do {% \expandafter\def\csname #1name\endcsname {\texorpdfstring {\hyperref[sec:#2]% {\relax{\color{joli}\MakeNameUp{#1}}}}% {#1}% \xspace }% \expandafter\def\csname #1nameimp\endcsname {\texorpdfstring {\hyperref[sec:#2imp]% {\relax{\color{blue}\MakeNameUp{#1}}}}% {#1}% \xspace }% }% \def\DOCxintfrontpage {\texorpdfstring {\hyperref[frontpage]{\relax{\color{joli}TOC}}}% {TOC}% \xspace }% \makeatletter \protected\def\MakeNameUp#1{% \ifcsname #1nameUp\endcsname \expandafter\@firstoftwo\else \expandafter\@secondoftwo \fi % \ifinheader 2020/01/30 {\ifinheader\fbox{\textup{#1}}\else#1\fi}% {#1}% } \makeatother \newif\ifinheader % doit être protégé \protected\def\inheadertrue{\let\ifinheader\iftrue} % \RaisedLabel % ============ % Samedi 16 juin 2018 à 15:23:22 % trick to see header of target page % there is probably better way to use the already in place % anchor from \section, but no time to go into hyperref source \newcommand\RaisedLabel[2][6]{% \vspace*{-#1\baselineskip}% \begingroup \let\leavevmode\relax\phantomsection \label{#2}% \endgroup \vspace*{#1\baselineskip}% } % begin{document} % =============== % \ttzfamily done at begin document \begin{document}\thispagestyle{empty} \pdfbookmark[1]{Title page}{TOP} \def\partname{Part} \addto\captionsenglish{\def\partname{Part}} {% \normalfont\Large\parindent0pt \parfillskip 0pt\relax \leftskip 2cm plus 1fil \rightskip 2cm plus 1fil \ifnum\dosourcexint=1 The \xintnameimp packages source code\par \gdef\DOCxintfrontpage {\texorpdfstring {\hyperref[frontpage]{\relax{\color{blue}TOC}}}% {TOC}% \xspace }% \else The \xintexprname and allied packages\par \fi \RaisedLabel{frontpage} } {\centering \textsc{Jean-Fran\c cois Burnol}\par \footnotesize jfbu (at) free (dot) fr\par Package version: \xintbndlversion\ (\xintbndldate); documentation date: \xintdocdate.\par {From source file \texttt{xint.dtx}. \xintdtxtimestamp.}\par } \medskip % 31 janvier 2020 \def\DOCxintexprintro {\texorpdfstring {\hyperref[part:1]{\relax{\color{joli}\MakeNameUp{Start here}}}}% {Start here}% \xspace }% \def\DOCxintexprmacros {\texorpdfstring {\hyperref[sec:oldxintexpr]{\relax{\color{joli}\MakeNameUp{xintexpr}}}}% {xintexpr}% \xspace }% \def\DOCexamples {\texorpdfstring {\hyperref[sec:examples]{\relax{\color{joli}\MakeNameUp{Examples}}}}% {Examples}% \xspace }% % Vendredi 15 juin 2018 % Someone makes the comma active (not me! not sure if doc.sty or KOMA) and % this derails xspace.sty, in the headers, as it uses \scantokens on a list of % tokens, so it fails to recognize the commas which of course are of catcode12 \def\xintRunningHeader{{\inheadertrue\catcode`,12\relax \DOCxintfrontpage, \DOCxintexprintro, \xintexprname, \xinttrigname, \xintlogname, \csname xint bundlename\endcsname}} \markboth{\makebox[0pt]{\xintRunningHeader}}{\makebox[0pt]{\xintRunningHeader}} % Skips safely. \ifnum\dosourcexint=1 \catcode`+ 0 \catcode0 9 % n'importe quoi sauf 15 (car ^^@) \catcode`\\ 12 +expandafter+iffalse+fi \fi % \newcommand\TeXnote{\par\smallskip\textbf{\TeX hackers note: }} \etocsetlevel{toctobookmark}{6} \etocsetlevel{table}{2}% subsection \renewcommand*{\etocbelowtocskip}{0pt} \renewcommand*{\etocinnertopsep}{0pt} \renewcommand*{\etoctoclineleaders} {\hbox{\normalfont\normalsize\hbox to 1ex {\hss.\hss}}} % \etocmulticolstyle [1]{% % \phantomsection\section* {Contents} % \etoctoccontentsline*{toctobookmark}{Contents}{1}% % } \etocsettocstyle{}{} \etocsettagdepth {part1A}{subsection} \etocsettagdepth {part1B}{section} \etocsettagdepth {macros}{none} \etocsettagdepth {implementation}{none} \etocsettocdepth{subsection} \tableofcontents \renewcommand*\etocabovetocskip{\bigskipamount} \makeatletter \etocmulticolstyle [2]{\parskip\z@skip%\raggedcolumns \setlength{\columnsep}{\leftmarginii}% \setlength{\columnseprule}{0pt}% }% \makeatother \etocsettagdepth {part1A}{none} \etocsettagdepth {part1B}{none} \etocsettagdepth {macros} {section} \ifnum\NoSourceCode=1 \etocsettagdepth {implementation}{none} \else \etocsettagdepth {implementation}{section} \fi \vspace*{2\baselineskip} \tableofcontents \etocignoredepthtags \etocmulticolstyle [1]{% \phantomsection% \section* {Contents} \etoctoccontentsline*{toctobookmark}{Contents}{2}% } \inmanualmaintocfalse \clearpage % ---- % Fibonacci code % December 7, 2013. Expandably computing a big Fibonacci number % with the help of TeX+\numexpr+\xintexpr, (c) Jean-François Burnol \catcode`_ 11 % % ajouté 7 janvier 2014 au xint.dtx pour 1.07j. % % Le 17 janvier je me décide de simplifier l'algorithme car l'original ne tenait % pas compte de la relation toujours vraie A=B+C dans les matrices symétriques % utilisées en sous-main [[A,B],[B,C]]. % % la version ici est celle avec les * omis: car multiplication tacite devant les % sous-expressions depuis 1.09j, et aussi devant les parenthèses depuis 1.09k. \def\Fibonacci #1{% \expandafter\Fibonacci_a\expandafter {\the\numexpr #1\expandafter}\expandafter {\romannumeral0\xintiiexpro 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro 0\relax}} % \def\Fibonacci_a #1{% \ifcase #1 \expandafter\Fibonacci_end_i \or \expandafter\Fibonacci_end_ii \else \ifodd #1 \expandafter\expandafter\expandafter\Fibonacci_b_ii \else \expandafter\expandafter\expandafter\Fibonacci_b_i \fi \fi {#1}% }% \def\Fibonacci_b_i #1#2#3{\expandafter\Fibonacci_a\expandafter {\the\numexpr #1/2\expandafter}\expandafter {\romannumeral0\xintiiexpro sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro (2#2-#3)#3\relax}% }% end of Fibonacci_b_i \def\Fibonacci_b_ii #1#2#3#4#5{\expandafter\Fibonacci_a\expandafter {\the\numexpr (#1-1)/2\expandafter}\expandafter {\romannumeral0\xintiiexpro sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro (2#2-#3)#3\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro #2#4+#3#5\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro #2#5+#3(#4-#5)\relax}% }% end of Fibonacci_b_ii \def\Fibonacci_end_i #1#2#3#4#5{\xintthe#5} \def\Fibonacci_end_ii #1#2#3#4#5{\xinttheiiexpr #2#5+#3(#4-#5)\relax} \catcode`_ 8 \def\Fibo #1.{\Fibonacci {#1}} \def\specialprintone #1% {% \ifx #1\relax \else \makebox[877496sp]{#1}\hskip 0pt plus 2sp\relax \expandafter\specialprintone\fi }% \def\specialprintnumber #1% first ``fully'' expands its argument. {\expandafter\specialprintone \romannumeral-`0#1\relax }% \AddToShipoutPicture*{% \put(10.5cm,14.85cm) {\makebox(0,0) {\resizebox{17cm}{!}{\vbox {\hsize 8cm\Huge\baselineskip.8\baselineskip\color{black!10}% \specialprintnumber{F(1250)=}% \specialprintnumber{\Fibonacci{1250}}}\par}% }% }% } \pdfbookmark[1]{Dependency graph}{DependencyGraph} \tikzstyle{block} = [rectangle, draw, fill=yellow!10, % fill opacity=0.5, draw=black!30, line width=2pt, text width=6em, text centered, rounded corners, minimum height=4em] \tikzstyle{line} = [draw, line width=1pt, color=black!30] \vspace*{\stretch{0.3333}} \begin{figure}[ht!] \phantomsection\label{dependencygraph} \centeredline{% \begin{tikzpicture}[node distance = 2.5cm] % Place nodes \node [block] (kernel) {\xintkernelname}; \node [left of=kernel] (A) {}; \node [right of=kernel] (B) {}; \node [block, below right of=B] (core) {\xintcorename}; \node [block, below left of=A] (tools) {\xinttoolsname}; \node [block, right of=core, xshift=1cm] (bnumexpr) {\href{https://ctan.org/pkg/bnumexpr}{bnumexpr}}; \node [block, below of=core] (xint) {\xintname}; \node [block, left of=xint, xshift=-1cm] (gcd) {\xintgcdname}; \node [block, left of=gcd] (binhex) {\xintbinhexname}; \node [block, below of=xint] (frac) {\xintfracname}; \node [block, below of=frac, yshift=-.5cm] (expr) {\xintexprname}; \node [block, below right of=expr, yshift=-.5cm, xshift=2.25cm] (polexpr) {\href{https://ctan.org/pkg/polexpr}{polexpr}}; \node [block, below of=expr, yshift=-.5cm] (trig) {\xinttrigname}; \node [block, left of=trig] (log) {\xintlogname}; \node [block, left of=log, xshift=-1cm] (poormanlog) {\href{https://ctan.org/pkg/poormanlog}{poormanlog}}; \node [block, below right of=frac, xshift=1cm] (series) {\xintseriesname}; \node [block, right of=series] (cfrac) {\xintcfracname}; % Draw edges \path [line,-{Stealth[length=5mm]}] (kernel) -- (core); \path [line,-{Stealth[length=5mm]}] (kernel) -- (tools); \path [line,-{Stealth[length=5mm]}] (core) -- (bnumexpr); % \path [line,-{Stealth[length=5mm]}] (core) to [out=180,in=90] (gcd.north); \path [line,-{Stealth[length=5mm]}] (kernel) -- (binhex); \path [line,-{Stealth[length=5mm]}] (core) -- (xint); \path [line,-{Stealth[length=5mm]}] (xint) -- (frac); \path [line,-{Stealth[length=5mm]}] (xint) -- (gcd); \path [line,-{Stealth[length=5mm]}] (frac) -- (expr); \path [line,-{Stealth[length=5mm]}] (expr) -- (polexpr); \path [line,{Stealth[length=5mm]}-{Stealth[length=5mm]}] (expr) -- (trig); \path [line,{Stealth[length=5mm]}-{Stealth[length=5mm]}] (expr) -- (log); \path [line,-{Stealth[length=5mm]}] (poormanlog) -- (log); \path [line,-{Stealth[length=5mm]}] (expr) -- (polexpr); \path [line,-{Stealth[length=5mm]}] (frac) to [out=0,in=90] (series.north); \path [line,-{Stealth[length=5mm]}] (frac) to [out=0,in=90] (cfrac.north); \path [line,dashed,-{Stealth[length=5mm]}] (binhex.south) -- (expr); % at 1.3d gcd() and lcm() needs no support from xintgcd % \path [line,dashed,-{Stealth[length=5mm]}] (gcd.south) -- (expr); % at 1.4 xintgcd loads xinttools \path [line,-{Stealth[length=5mm]}] (tools) to [out=0, in=90] (gcd.north);% je dois positionner mieux mais pas le temps de lire 700 pages \path [line,dashed,-{Stealth[length=5mm]}] (tools.south west) to [out=270, in=225] (cfrac.south west);% je dois positionner mieux mais pas le temps de lire 700 pages \path [line,-{Stealth[length=5mm]}] (tools) to [out=270,in=180] (expr); \end{tikzpicture}}\bigskip \end{figure} \vspace{2\baselineskip} \begin{addmargin}{2cm} \normalfont\footnotesize Dependency graph for the \xintname bundle components: modules pointed to by arrows \textbf{automatically} import the modules originating the continuous line ended by an arrow. Dashed lines indicate a partial dependency, and to enable the corresponding functionalities of the lower module it is thus necessary to use a suitable |\usepackage| (\LaTeX) or |\input| (Plain \TeX.)\par \href{https://ctan.org/pkg/bnumexpr}{bnumexpr} is a separate (\LaTeX{} only) package by the author which uses (by default) \xintcorename as its mathematical engine. \href{https://ctan.org/pkg/polexpr}{polexpr} is a separate (\LaTeX{} only) package by the author which requires \xintexprname. \xinttrigname and \xintlogname are loaded automatically by \xintexprname; they will refuse to be loaded directly (but see \csbxint{reloadxinttrig}). \href{https://ctan.org/pkg/poormanlog}{poormanlog} is a \TeX{} and \LaTeX{} package by the author which is loaded automatically by \xintlogname. \par \end{addmargin} \vfill \clearpage \etocdepthtag.toc {part1A} \csname Start herenameUp\endcsname \part{The \xintexprname package} \RaisedLabel[12]{part:1} \etocsetnexttocdepth{section} \localtableofcontents \section {Start here} \begin{itemize} \item To use with |etex|, |pdftex|, ..., i.e. with \TeX{} engines activating the e\TeX{} extensions: \begin{everbatim} \input xintexpr.sty \xinteval{sqrt(13, 60)}% get it with 60 digits (correctly rounded) \end{everbatim} \item To use with the \LaTeX{} macro layer (|latex|, |pdflatex|, ...): \begin{everbatim} \usepackage{xintexpr} % and here you have to wait for \begin{document}... % or rather you can start playing immediately: \typeout{\xinteval{sqrt(13, 60)}} \end{everbatim} \end{itemize} \xintexprname is a package to do expandable computations, either exactly (i.e.\@ with fractions) or in the sense of floating point numbers at an arbitrary (reasonable% % \footnote{Trigonometrical functions are currently supported only up to about \dtt{58} decimal digits, and generally speaking expansion starts taking really too much time at about \dtt{500} digits. It looks as if \dtt{100} digits is a reasonable upper limit for floating point (this is already a lot to fit on one single line of text) and future development of the package will not attempt to support floating point calculations efficiently beyond that limit.}% ) precision. It supports user definition of variables and functions. Its interface allows multiple comma separated expressions and nested structures: \begin{everbatim*} \xinteval{1, 2, [3, [4, 5]], 6} \end{everbatim*}is impressive. No? \medskip I am thinking about providing a console interface (using |rlwrap etex| as sadly the e-\TeX{} binaries are not linked with the |readline| library) which would mimick sessions with Maple or Python. \medskip For a quick impression of the package abilities, check (not yet, else you will never come back here) the tables of its built-in \hyperref[tab:precedences]{operators} and \hyperref[tab:functions]{functions}. \medskip The formatted source code is available in file |sourcexint.pdf| (|texdoc sourcexint|). \medskip Warning: I don't have the time to maintain perfectly such large documentation. In preparing the |1.4| release I may have missed updating some bits which got randomly shuffled to new places (at least I did delete large sections, which was a hard decision to take, almost breaking the palimpsest quality of the document). Reports welcome.% % \footnote{Thanks to Jürgen Gilg for keeping the author motivated and helping proof-read the documentation.} \subsection{Features added since the \texttt{1.4} release} For bugfixes and possibly more details check |CHANGES.html|: \centeredline{|texdoc --list xint|} \begin{itemize} \item The function \func{zip}. \item The function \func{flat}. \item Chaining of \hyperlink{\detokenize{prec-10}}{comparison operators} à la Python (no short-circuit, though) and |l3fp|. \item \csbxint{PFloatE} to specify like \csbxint{FracToSciE} does for \csbxint{eval} since |1.4| the separator to use between mantissa and exponent in the output of \csbxint{floateval} output. \item \csbxint{thespaceseparated} (serves to provide suitable input to PS-Tricks |\listplot|). \item The optional argument |[D]| to \csbxint{iexpr} (or \csbxint{ieval}) can be negative, with the same meaning as the non-negative case, i.e. rounding to an integer multiple of |1e-D| (as formerly, for |D| positive the output uses fixed point notation with decimal digits and with |D=0| the output is an integer with no decimal separator; with |D<0| scientific notation is used% % \footnote{This was introduced at |1.4a| but due to a bug the |e| was by error of catcode 12, and \csbxint{FracToSciE} had no effect on it. Fixed at \texttt{1.4b}}% % ). \item The same applies to the functions \func{trunc} and \func{round}. And matching updates to \csbxint{Trunc}, \csbxint{Round}, \csbxint{iTrunc}, and \csbxint{iRound}. \item Support by \func{add} and \func{mul} for \keyword{omit}, \keyword{abort} and \func{break}.% % \footnote{Feature supposedly added at |1.4| but broken there.} \end{itemize} \subsection{The \texttt{1.4} release of \texttt{2020/01/31}} |1.4| brought some new features (involving significant evolution of the \xintexprname.sty source code) and a few (but important) breaking changes. See |CHANGES.html| which contains information which may not yet have been included into this PDF documentation. The main new feature was (initial) support for nested structures. For a quick idea of already available related abilities check for example \func{ndseq} or \csbxint{defufunc}. See also \csbxint{thealign}. However, please grant the author a few decades to finish absorbing Python/NumPy. \begin{framed} The main breaking changes were: \begin{itemize} \item \xintexprname |1.4| requires the |\expanded| primitive, which is provided by all major \TeX{} engines since \TeX Live 2019. The macro packages \xintname, \xintfracname, \xinttoolsname et al. do not (yet) require |\expanded|. It is probable also |\pdfstrcmp| (|\strcmp|) will be required at some point but it has been provided by major \TeX{} engines for a long time already. \item \csbxint{eval} (and \csbxint{expr}) output does not use anymore the \xintfracname ``raw'' format |A/B[N]|, rather it uses scientific notation |AeN/B|, dropping the exponent and/or denominator if they are respectively \dtt{0} and/or \dtt{1}. This means that output can now be copied pasted directly to competing software on the market, such as Python or Maple. The output format of \csbxint{floatexpr} (which uses macro \csbxint{PFloat}) was left un-modified although the prettifying done by it is not necessarily the best choice when displaying a nested structure via \csbxint{thealign} (perhaps next major release will reconsider that choice); and the way the zero value is output by \csbxint{floateval}, currently \dtt{\xintfloateval{0}} is yet to be chosen definitely. The used (\emph{expandable}) macro for output can be specified by user. \item Syntax such as |x*[a, b, c]| or |[a, b, c]+x| for itemwise operation on «lists» has been (provisorily) dropped. Indeed, the brackets |[...]| are now genuine constructors of nestable structures, and implementing the feature (analogous to NumPy's concepts) will require overloading all scalar infix operators. Alternative already exist in the syntax for example |seq(x*y, y = a,b,c)|. Actually in future |x*[a, b, c]| will be as |[x*a, x*b, x*c]| i.e.\@ will keep the brackets, which prior to |1.4| on their own were no different from parentheses. \end{itemize} \end{framed} \subsection{License and installation instructions} \label{ssec:install} \xintname is made available under the \href{http://www.latex-project.org/lppl/lppl-1-3c.txt}{LaTeX Project Public License 1.3c} and is included in the major \TeX\ distributions, thus there is probably no need for a custom install: just use the package manager to update if necessary \xintname to the latest version available. Else, \href{https://ctan.org/pkg/xint}{CTAN} access provides |xint.tds.zip| which has all source code and documentation in a TDS-compliant archive, only waiting to be |unzip -d | into some suitable hierarchical structure. Else, |etex xint.dtx| extracts all source code. A |Makefile| is also provided with targets such as |xint.pdf| or |sourcexint.pdf|. Even if your system does not allow executing |make|, the rules it contains can be imitated manually (if possible using |Latexmk|). Back to \TeX\ distributions with a |"texdoc"| or similar utility, \centeredline{|texdoc --list xint|} gives the choice to display one of: \begin{itemize}[nosep] \item |xint.pdf| (this file), \item |sourcexint.pdf| (source code), \item |README.md|, \item |CHANGES.html|. \end{itemize} \subsection{Printing big numbers on the page}\label{ssec:printnumber} When producing very long numbers there is the question of printing them on the page, without going beyond the page limits. In this document, I have most of the time made use of these macros (not provided by the package:) % \everb|@ \def\allowsplits #1{\ifx #1\relax \else #1\hskip 0pt plus 1pt\relax \expandafter\allowsplits\fi}% \def\printnumber #1{\expandafter\allowsplits \romannumeral-`0#1\relax }% % \printnumber thus first ``fully'' expands its argument. | It may be used like this: % \begin{everbatim*} \printnumber{\xintiieval{100!^3}}\newline \end{everbatim*}% The rendering here uses extra decoration. \clearpage \expandafter\let\csname Start herenameUp\endcsname\undefined \csname xintexprnameUp\endcsname \section{\xintexprname syntax reference and user guide} \RaisedLabel{sec:expr} \localtableofcontents \subsection{Oples and nut-ples: terminology for the \text{1.4} \xintname generation} \emph{Skip this on first reading, else you will never start using the package.} \fbox{SKIP THIS!} (understood?) In this section I will describe a mathematical terminology appropriate to understand the core functioning of the package in so far as it regards its numerical mode of operation. The description requires some adaptations to also cover the functioning during function declarations and this is not covered here. We have \emph{atoms}, which represent numeric data. In \TeX{} syntax such \emph{atoms} are always braced, more precisely, currently they look like \dtt{\{raw xintcore or raw xintfrac format within \TeX{} braces\}}. Such \TeX{} braces are not to be confused with set-theoretical braces: \emph{atoms} are \emph{elements} and not \emph{sets}. Our category $\mathcal{C}$ of «oples» is the smallest collection of \emph{totally ordered finite sets} verifying these properties: \begin{enumerate} \item The empty set \dtt{$\emptyset$} belongs to $\mathcal{C}$. \item Each singleton set whose element is an atom qualifies as an \emph{ople}. \item $\mathcal{C}$ is stable by concatenation. \item If \dtt{O} is an \emph{ople}, then the singleton \dtt{\{O\}} having \dtt{O} as unique element is also an \emph{ople}. \end{enumerate} Notes: \begin{itemize} \item We denote the empty set \dtt{$\emptyset$} by \emph{nil}. There is actually a built-in variable with this name. At |1.4|, |\xintexpr\relax| is legal and also generates the \emph{nil}. \item Concatenation is represented in the syntax by the comma. Thus repeated commas are like only one and |nil| is a neutral element. \item A singleton \emph{ople} \dtt{\{atom\}} whose single element is an atom is called a \emph{number}. \item The operation of constructing \dtt{\{O\}} from the \emph{ople} \dtt{O} is called \emph{bracing} (set theory, \TeX), or \emph{bracketing} (\xintexprname input syntax, Python |lists|), or \emph{packing} (as a reverse to Python's unpacking of sequence type objects). \item A braced \emph{ople} is called a \emph{nut-ple}. Among them $\{nil\}$ is a bit special. It is called the \emph{not-ple}. It is not |nil|! \end{itemize} It is perhaps important to reflect on the following: \noindent The notation |3,5,7| can be seen in two distinct but related ways: \begin{itemize} \item each one of |3|, |5|, |7| is an \emph{ople} (singleton) and |3,5,7| is their \emph{union} or rather \emph{concatenation} (order matters), \item or each one of |3|, |5|, |7| refers to an \emph{atom} and |3,5,7| is an enumeration of the atoms of the \emph{ople} it represents. \end{itemize} The second view is tempting, but recall that really the comma stands for \emph{concatenation of totally ordered sets}, thus the first view is more correct. This first view maps to \TeX{} notations where the value |3| is stored as \dtt{\{\{3\}\}}. But under \csbxint{verbosetrue} regime, the external brace pair, which is both a \TeX{} brace pair and a set-theoretical notation gets removed. There only remains one, and what is shown is actually a view of an \emph{atom}, where the braces are only \TeX{} braces. But more complicated nested objects will have \TeX{} braces representing also set-theoretical braces. If you are still here you can go on reading. Each \emph{ople} has a length which is its cardinality. The |oples| of length 1 are called \emph{one-ples}. There are two types of \emph{one-ples}: \begin{itemize} \item \emph{numbers}, \item packed \emph{oples}: the \emph{nut-ples}. \end{itemize} As said before the \emph{not-ple} |{{}}| is special. It can be input as |[]|. Recall that a \emph{number} as an \emph{ople} is a singleton whose sole element is an \emph{atom}. It is convenient to put the empty set |nil| on the same footing as \emph{atoms}. Then the \emph{not-ple} is analogous to an \emph{empty number}. We say that the empty set |nil| and \emph{atoms} are \emph{leaves}. Indeed, we can associate with any \emph{ople} a tree. The root is the ople. In the case of the |nil|, there is nothing else than the root, which we then consider also a \emph{leaf}. Else the children at top level are the successive items of the ople. Among the items some are \emph{atoms} giving \emph{leaves} of the tree, others are \emph{nut-ples} which in turn have children. In the special case of the \emph{not-ple} we consider it has a child, which is the empty set and this why we consider the empty set |nil| a \emph{leaf}. We then proceed recursively. We thus obtain from the root \emph{ople} a tree whose vertices are either \emph{oples} or \emph{leaves}. Only the empty set |nil| is both a \emph{leaf} and an \emph{ople}. Considering the empty set |nil| as an \emph{atom} fits with the \xintexprname internal implementation based on \TeX: |nil| is an empty pair of braces |{}|, whereas an \emph{atom} is a braced representation of a numeric value using digits and other characters. We construct \emph{oples} by putting one after the other such constituents and bracing them, and then repeating the process recursively. Considering the empty set as an \emph{atom} has also an impact on the definition of the \emph{depth} (a.k.a as \emph{maximal dimension}) of an \emph{ople}. For example the \emph{ople} $\{\{\}A_1A_2\}$ with three elements, among them the empty set and two atoms is said to have depth $1$, or to have maximal dimension $1$. And $\{\{\emptyset\}A_1A_2\}$ is of depth $2$ because it has a leaf (the empty set) which is a child of a child of the \emph{ople}. NumPy \emph{ndarrays} have a more restricted structure for example $\{\{A_{00}A_{01}\}\{A_{10}A_{11}\}\}$ is a $2$-dimensional array, where all leaves are at the same depth. When slicing empties the array from its atoms, NumPy keeps the shape information but prints the array as $[]$. This will not be the case with \xintexprname, which has no other way to indicate the shape than display it. \begin{everbatim*} \xinteval{[[],[]]} \end{everbatim*} \begin{everbatim*} \xinteval{[[0,1],[10,11]][:,2:]} \end{everbatim*} «Set-theoretical» slicing of an \emph{ople} means replacing it by a subset. This applies also if it is a \emph{number}. Then it can be sliced only to itself or to the empty set (indeed it has only one element, which is an atom). Similarly the \emph{not-ple} can only be sliced to give itself or the empty set. And more generally a \emph{nut-ple} is a singleton so also can only be set-sliced to either the empty set or itself. \xintexprname extends «Python-like» slicing to act on \emph{oples}: \begin{itemize}[nosep] \item if they are not \emph{nut-ples} set-theoretical slicing applies, \item if they are \emph{nut-ples} (only case having a one-to-one correspondance in Python) then the slicing happens \emph{within brackets}: i.e. the \emph{nut-ple} is unpacked then the set-theoretical slicing is applied, then the result is \emph{repacked} to produce a new \emph{nut-ple}. \end{itemize} With these conventions the \emph{not-ple} for example is invariant under slicing: unpacking it gives the empty set, which has only the empty set as subset and repacking gives back the \emph{not-ple}. Slicing a general \emph{nut-ple} returns a \emph{nut-ple} but now of course in general distinct from the first one. The syntax for Python slicing is to postfix a variable or a parenthesized ople with |[a:b]|. See \autoref{ssec:lists} for more. There are never any out-of-range errors when slicing or indexing. All operations are licit and resolved by the |nil|, a.k.a. empty set. «Set-theoretical» item indexing of an \emph{ople} means reducing it to a subset which is a singleton. It is thus a special case of set-theoretical slicing (which is the general process of selecting a subset as replacement of a set). \xintexprname extends «Python-like» indexing to act on \emph{oples}: \begin{itemize}[nosep] \item if they are not \emph{nut-ples} set-theoretical item indexing applies, \item if they are \emph{nut-ples} (only case having a one-to-one correspondance in Python) then the meaning becomes \emph{extracting}: i.e. the \emph{nut-ple} is unpacked then the set-theoretical indexing is applied, but the result is \emph{not repacked}. \end{itemize} For example when applied to the \emph{not-ple} we always obtain the |nil|. Whereas as we saw slicing the \emph{not-ple} always gives back the \emph{not-ple}. Indexing is denoted in the syntax by postfixing by |[N]|. Thus for \emph{nut-ples} (which are analogous to Python objects), there is genuine difference between the |[N]| extractor and the |[N:N+1]| slicer. But for \emph{oples} which are either |nil|, a \emph{number}, or of length at least 2, there is no difference. Nested slicing is a concept from NumPy, which is extended by \xintexprname to trees of varying depths. We have a chain of slicers and extractors. I will describe only the case of slicers and letting them act on a |nut-ple|. The first slicer gives back a new |nut-ple|. The second slicer will be applied to each of one of its remaining items. However some of them may be \emph{atoms} or the empty set. In the NumPy context all leaves are at the same depth thus this can happen only when we have reached beyond the last dimension (axis). This is not permitted by NumPy and generates an error. \xintexprname does not generate an error. But any attempt to slice an \emph{atom} or the empty set (as element of its container) removes it. Recall we call them \emph{leaves}. We can not slice leaves. We can only slice non-leaf items: such items are necessarily |nut-ples|. The procedure then applies recursively. If we handle an extractor rather than a slicer, the procedure is similar: we can not extract out of an \emph{atom} or the empty set. They are thus removed. Else we have a |nut-ple|. It is thus unpacked and replaced by the selected item. This item may be an atom or the empty set and any further slicer or extractor will remove them, or it is a |nut-ple| and the procedure applies with the next slicer/extractor. \xintexprname allows to apply such a |[a:b,c:d,N,e:f,...]| chain of slicing/extracting also to an \emph{ople}, which is not a \emph{nut-ple}. We simply apply the first step as has been described previously and successive steps will only get applied to either \emph{nut-ples} or \emph{leaves}, the latter getting silently removed by any attempted operation. One last thing. In the syntax of \xintexprname, variables as well as functions have a name and a value. The value is an |ople|. We can always use a variable whose value is an |ople| in a function call, it will occupy the place of as many arguments as its length indicates. But in a function declaration, the variables must stand for |one-ples|, i.e. either |numbers| or |nut-ples|. The |*| unpacks a |nut-ple|. The last positional argument in a function declaration can have a special form |*|\meta{name}. This means that \meta{name} is a |nut-ple| which receives as items all arguments in the function call beyond the first ones corresponding to the function declaration. \medskip In case things were too clear, let's try to add a bit of confusion with an extra word on \emph{leaves}. When we discuss informally (particularly to compare with NumPy) an input such as \begin{everbatim} [[1, 2], [3, 4]] \end{everbatim} we may well refer to |1|, |2|, |3|, and |4| as being «the leaves of the 2d array». But obviously we have here numbers and previously we explained that a number is not a \emph{leaf}, its \emph{atom} is. Well, the point here is that we must make a difference between the input form as above and the actual constructed \emph{ople} the parser will obtain out of it. In the input we do have numbers. The comma is a \emph{concatenator}, it is not a separator for enumeration! The \emph{ople} which corresponds to it has a \TeX{} representation like this: \begin{everbatim} {{{1}{2}}{{3}{4}}} \end{everbatim} where we don't have the \emph{numbers} anymore (which would look like |{{1}}|, |{{2}}|, ...) but numeric \emph{atoms} |{1}|, |{2}|, |{3}|, |{4}| where the braces are \TeX{} braces and \textbf{not} set-theoretical braces (the other braces are both). Hence we should see the above as the |ople| $\{\{A_{00}A_{01}\}\{A_{10}A_{11}\}\}$ with atoms $A_{00}=\{1\}$, ..., being the \emph{leaves} of the tree associated to (or which is) the \emph{ople}. Numbers may be called the \emph{leaves} of the \textbf{input}, but once parsed, the input becomes an \emph{ople} which is (morally) a tree whose leaves are \emph{atoms} (and the empty set). \medskip I hope this is clear to everyone. If not, maybe time to say this section was absolutely not needed to understand the rest of the manual, but I needed to write it for my own satisfaction. Believe me, you need this section if you want to write the underlying software! \subsection{The three parsers} \xintexprname provides three numerical expression parsers and two subsidiary ones. They are designed to be compatible with expansion only context. All computations ultimately rely on (and reduce to) usage of the |\numexpr| primitive from \eTeX{}% % \footnote{It can handle only integers, and they must be at most $2^{31}-1={}$\dtt{\the\numexpr"7FFFFFFF\relax}. Thus some work has to be done to handle arbitrarily big integers or arbitrary float precision.}. % These \eTeX{} extensions date back to 1999 and are by default incorporated into the |pdftex| etc... executables from major modern \TeX{} installations for more than fifteen years now. \begin{itemize} \item \csbxint{eval}\marg{expression} handles integers, decimal numbers, numbers in scientific notation and fractions. The algebraic computations are done \emph{exactly}, and in particular \oper{/} simply constructs fractions. Use \oper{//} for floored division. \begin{everbatim*} \xinteval{add(x/(x+1), x = 1000..1014)}\par \end{everbatim*} In this example, the fraction obtained by addition is already irreducible, but this is not always the case: \begin{snugframed} By default, basic operations on fractions do not automatically reduce to smallest terms the output: |A/B| multiplied by |C/D| returns |AC/BD|, and |A/B| added to |C/D| uses |lcm(B, D)| as denominator. \end{snugframed} Arbitrarily long numbers are allowed in the input. The space character (contrarily to the situation inside |\numexpr|) and also the underscore character (as allowed in Python too) can serve to separate groups of digits for better readability. But the package currently provides no macros to let the output be formatted with such separators. Formatting of numeric output is apart from some minimal facilities such as \csbxint{Frac}, \csbxint{DecToString}, \csbxint{PRaw}, \csbxint{FracToSci} or \csbxint{PFloat} left to user macros or third-party packages% % \footnote{For example I hesitated whether to let \csbxint{FracToSciE} be actually a macro with one mandatory argument as this would give a hook to customize formatting the scientific exponent. But then, why not also wrap the mantissa or the denominator in hook macros? and should the |/| or the decimal separator also be customizable? It was reasonable to provide a way to use |E| in place of |e| for the scientific part, as |E| is accepted input in \csbxint{eval} or \csbxint{floateval}. % It is already possible for the no-argument macro \csbxint{FracToSciE} to % probe the sign of the exponent and for example insert a |+| if desired, % although there is no way (the exponent having no known delimiter) for it to % act globally on the exponent. It looked however better to leave additional formatting to external utilities.}. \begin{everbatim*} \xinteval{123_456_789_012^5} \end{everbatim*} \item \csbxint{iieval}\marg{expression} does exact computations \emph{on (big) integers only.} It is (of course) slightly faster than \csbxint{eval} for equivalent operations. The forward slash \oper{/} does the \emph{rounded} integer division to match behaviour of |\numexpr|. The \oper{//} operator does floored division as in \csbxint{eval}. The \oper{/:} is the associated modulo operator (we could easily let the catcode 12 |%| character be an alias, but using such an unusual percent character would be a bit cumbersome in a \TeX{} workflow, if only for matters of syntax highlighting in \TeX-aware text editors). \begin{everbatim*} \xintiieval{add((i/:7)?{omit}{i^5}, i=1000..1020)}% only add fifth powers of multiples of 7 \end{everbatim*} \item \csbxint{floateval}\marg{expression} does floating point computations with a given precision \dtt{P}, as specified via a prior assignment |\xintDigits:=P\relax |. The \oper{/} will compute the correct rounding of the exact fraction. Again \oper{//} is floored division and \oper{/:} its associated modulo (see also \func{divmod}). \begin{everbatim*} \begingroup \xintDigits:=64\relax \xintfloateval{sqrt(3)} \endgroup \end{everbatim*} The default is with \dtt{P=16} digits. The four basic operations and the square root realize \emph{correct rounding.}\footnote{when the inputs are already floating point numbers with at most |P|-digits mantissas.} It can be used with an optional argument |[Q]| which means to do a final float rounding to mantissas of |Q| digits (this makes sense only if |Q0|: the nearest fixed point number with |D| digits after the decimal mark, \item if |D=0|: the nearest integer, \item if |D<0|: the\NewWith{1.4a} nearest multiple of |10^(-D)| (this case is new with |1.4a| and uses scientific notation). \end{itemize} ATTENTION: the optional argument |[D]| is to be located \emph{within} the braces at the start of the expression. \item \csbxint{theboolexpr}\meta{expression}|\relax| does all computations like \csbxint{eval} then converts all (non-empty) leaves% % \footnote{Currently, empty leaves are output using \csbxint{exprEmptyItem}, i.e.\@ default to \dtt{\xintexprEmptyItem}. This may change.} % to |True| or |False| (cf.\@ \csbxint{boolexprPrintOne}). There is no |\xintbooleval|. \end{itemize} These macros are wrappers for a more core syntax: \begin{itemize}[nosep] \item \csbxint{expr}\meta{expression}|\relax|, \item \csbxint{iiexpr}\meta{expression}|\relax|, \item \csbxint{floatexpr}\meta{expression}|\relax|, \item \csbxint{iexpr}\meta{expression}|\relax|, \item \csbxint{boolexpr}\meta{expression}|\relax|. \end{itemize} This core syntax can be used directly in typesetting flow.\NewWith{1.4} In an |\edef| they expand to some braced nested data (all computations having been done) prefixed with some |\protected| «typesetter» macros. When using \csbxint{eval} (in contrast to \csbxint{expr}), the protection of the «typesetter» is removed and its action gives (expandably, in two steps) explicit digits and other characters such as those of scientific notation or brackets. It is possible to use the core syntax\NewWith{1.4} \csbxint{expr}\meta{expression}|\relax| also in so-called moving arguments, because when written out to a file the final expansion result uses only standard catcodes and thus will get retokenized and the typesetter macro (which being |\protected| is there intact in external file) will expand as expected. One needs \csbxint{eval} et al. only if one really wants the final digits (and other characters), for example in a context where \TeX{} expects a number or a dimension. As alternative to \csbxint{eval}\marg{expression}, an equivalent is \csbxint{the}\csbxint{expr}\meta{expression}|\relax|. Similarly \csbxint{the} can prefix all other core parsers. And one can also use \csbxint{theexpr} as shortcut for \csbxint{the}\csbxint{expr}. Throughout this documentation I will most of the time refer to \csbxint{eval} and \csbxint{expr}. But beware that doing exact computations with fractions leads very quickly to very big results (and furthermore one needs to use explicitly the |reduce()| function to convert the fractions into smallest terms). Thus most probably what you want is \csbxint{floateval} and \csbxint{floatexpr}. \subsection{Expansion} As mentioned already, the parsers are compatible with expansion-only context. Also, they expand the expression piece by piece: the normal mode of operation of the parsers is to unveil the parsed material token by token. Unveiling is a process combining brace removal (one level generally) and \fexpan sion. For example a closing parenthesis does not have generally to be immediately visible, it may arise later from expansion. Even the ending |\relax| may arise from expansion. Even though the \csbxint{eval} user interface means that the package has at some point the entire expression in its hands, it immediately re-inserts it into token stream with an additional postfixed |\relax| and from this point on has lost any ways to manipulate formally again the whole thing; it can only re-discover it piece per piece. This general behaviour has significative exceptions mostly related to «pseudo»-functions. A «pseudo»-function will grab some of its arguments via delimited macros. For example |subs(expr1,x=expr2)| needs to see the comma, equal sign and closing parenthesis. But it has mechanisms to allow |expr1| and |expr2| to possess their own commas and parentheses. Inner semi-colons on the other hand currently always can originate from expansion. Defining functions or variables requires a visible semi-colon acting as delimiter of the expression, but inner semi-colons do not need to be hidden within braces or macros\NewWith{1.4}. The expansion stops only when the ending |\relax| has been found (it is then removed from the token stream). For catcode related matters see \csbxint{exprSafeCatcodes}. A word of warning on the bracketed optional argument of respectively \csbxint{floatexpr} and \csbxint{iexpr}. When defining macros which will hand over some argument to one of these two parsers, the argument may potentially start with a left square bracket |[| (e.g. argument could be |[1, 2, 3]|) and this will break the parser. The fix is to use in the macro definition |\xintfloatexpr\empty|. This extra |\empty| token will prevent the parser thinking there is an optional argument and it will then disappear during expansion. \begin{footnotesize} If comparing to other languages able to handle floating point numbers or big integers, such as Python, one should take into account that what the \xintname packages manipulate are streams of ascii bytes, one per digit. At no time (due to expandability) is it possible to store intermediate results in an arithmetic CPU register; each elementary operation via |\the\numexpr| will output digit tokens (hence as many bytes), not things such as handles to memory locations where some numbers are stored as memory words. The process can never put aside things but can only possibly permute them with upcoming tokens, to use them later, or, via combinations of |\expanded| and |\unexpanded| or some other more antiquated means grab some tokens and shift the expansion to some distant locations to later come back. The process is a never-ending one-dimensional one...\par \end{footnotesize} \subsection{\csh{xintthealign} and its customization} \label{xintthealign} With \csbxint{thealign} one can get nested data use a \TeX{} alignment in the output. Attention, this must be followed by \csbxint{expr} et al., never by \csbxint{theexpr} or \csbxint{eval}. Here is an example : \begin{everbatim*} \xintthealign\xintexpr ndseq(1/(i+j), i = 1..10; j=1..10)\relax \end{everbatim*} It is possible to customize the behaviour of |\xintthealign|.\CHANGED{1.4a} The helper macros, apart from |\xintexpralignbegin| and |\xintexpralignend| will be subjected to a complete (|\expanded|) expansion (once).% % \footnote{\csa{xintexpralignend} is expanded once, after the body has been submitted to exhaustive expansion, and prior to the expansion of \csa{xintexpralignbegin}.} % The package uses here |\protected| with no strong reason, as the replacement tokens are not expanding anyhow, but the idea is that this allows to define a macro in an |\edef| and later change the meaning of the auxiliary macros depending on what one wants to do with the expansion result. See also further down the \LaTeX{} example with a matrix environment, where |\noexpand| rather than |\protected| is used. \begin{everbatim} \protected\def\xintexpralignbegin {\halign\bgroup\tabskip2ex\hfil##&&##\hfil\cr}% \protected\def\xintexpralignend {\crcr\egroup}% \protected\def\xintexpralignlinesep {,\cr}% separates "lines" \protected\def\xintexpralignleftsep {&}% at left of first item in a "line" (after brackets) \protected\def\xintexpraligninnersep {,&}% at the left of non-first items \protected\def\xintexpralignrightsep {&}% at right of last item in a "line" (before brackets) \protected\def\xintexpralignleftbracket {[}% \protected\def\xintexpralignrightbracket{]}% \end{everbatim} Although we will try to keep stable the way «regular arrays» are rendered,\UNSTABLE{} the |\xintthealign| macro (and its associated customizability) is considered work-in-progress and may experience breaking changes. Use for example this for outputting to a file or a terminal: \begin{everbatim} % Better here without \protected. % We assume here \newlinechar has the LaTeX setting. \def\xintexpralignbegin {}% \def\xintexpralignend {}% \def\xintexpralignlinesep {,^^J}% separates "lines" \def\xintexpralignleftsep { }% at left of first item in a "line" (after brackets) \def\xintexpraligninnersep {, }% at the left of non-first items \def\xintexpralignrightsep { }% at right of last item in a "line" (before brackets) \def\xintexpralignleftbracket {[}% \def\xintexpralignrightbracket{]}% \end{everbatim} \medskip And here is an example using a |pmatrix| environment. But it will not break across pages, contrarily to the display produced by the default \csbxint{thealign} configuration which uses \TeX{}'s |\halign|. %\kern10\baselineskip %\hbox{Big empty space here} %\kern-11\baselineskip \begin{everbatim*} \[ \def\xintexpralignbegin {\begin{pmatrix}}% \def\xintexpralignend {\end{pmatrix}}% \def\xintexpralignlinesep {\noexpand\\}% needed to counteract an internal \expanded \def\xintexpraligninnersep {&}% \let\xintexpralignleftbracket\empty \let\xintexpralignleftsep\empty \let\xintexpralignrightbracket\empty \let\xintexpralignrightsep\empty % by default amsmath matrices can have 10 columns at most % (cf amsmath documentation for what to do to allow more) l.c.m.=\xintthealign\xintiiexpr ndmap(lcm, 1..12; 1..10)\relax \] \end{everbatim*} \subsection{Customization of typesetting of individual items} \label{xintexprEmptyItem} \label{xintexprPrintOne} \label{xintiiexprPrintOne} \label{xintfloatexprPrintOne} \label{xintboolexprPrintOne} The way individual items are formatted (whether or not using \csa{xintthealign}) is also customizable:\kern-2pt % the \kern is to fix some extra white line from first line being a bit overfull \begin{everbatim} \def\xintexprEmptyItem{[]} \let\xintexprPrintOne\xintFracToSci \def\xintFracToSciE{e} \def\xintiiexprPrintOne #1{#1} \def\xintfloatexprPrintOne#1#2{\xintPFloat[#1]{#2}} \def\xintPFloatE{e} \def\xintboolexprPrintOne#1{\xintiiifNotZero{#1}{True}{False}} \end{everbatim} Attention! The above macros convert from \xintexprname internal numeric data format to «printed» output; they are thus susceptible to require adjustments if the internal data format changes, which may happen at each release. Of course the default for |\xintexprPrintOne| etc... will be adjusted accordingly, but user custom definitions may break. Currently, this means that the macros used in place of \csbxint{FracToSci} and \csbxint{PFloat} must understand both the raw \xintfracname format |A/B[N]| and the decimal format |A.ddddd..dd|.% % \footnote{Furthermore \csbxint{ieval}|{[D]...}| with a \emph{negative} |D| (feature added at |1.4a|) relies on the \csbxint{exprPrintOne} ability to react to a catcode 12 |e| (it is always used with detokenized input). \csbxint{FracToSci} has this ability and uses catcode 11 |e| in output (or rather whatever \csbxint{FracToSciE} expands to).} % The typesetter for \csa{xintiiexpr} simply prints ``as is'', but this may change in future. The used macros must be compatible with expansion-only context, but do not have to be \fexpan dable. Note: when not using \csbxint{thealign}, output of nested structures uses left and right brackets, and commas and spaces in a non-customizable way, except via \csa{xintexprEmptyItem}. Use the \csa{xintthealign} interface for full customizability. \subsection{Built-in operators and their precedences} \makeatletter \def\@floatboxreset{\@setminipage}% faudra contrôler celui-là \makeatother \begin{table}[htbp] \edef\Ampersand{\string&}% \edef\restorehtdpstrutbox {\ht\strutbox\the\ht\strutbox\dp\strutbox\the\dp\strutbox} \ht\strutbox12pt\dp\strutbox5pt \capstart \centering\begin{tabular}{|c|p{.5\textwidth}|} \hline \multicolumn{2}{|p{.6\textwidth}|}{\prec{$\infty$}: at this top level the syntax elements whose execution is done prior to operators preceding them: \begin{itemize}[nosep] \item \hyperref[ssec:builtinfunctions]{built-in} or \hyperref[ssec:userfunctions]{user-defined} functions, \item \hyperref[ssec:uservariables]{variables}, \item the \oper{\empty\lowast} unpacking operator, \item and intrinsic constituents of numbers: decimal mark \oper{\strut.}, \oper{e} and \oper{E} of scientific notation, hexadecimal prefix \oper{"}. \end{itemize}\par\kern-\baselineskip\relax}% \\\hline\hline Precedence&``Operators'' at this level\strut\\ \hline \prec{20}& postfix \oper{!} and branching \oper{?}, \oper{??} operators\strut\\\hline % \prec{-}& minus sign as unary operator inherits the precedence of the infix operator it follows, if that precedence is higher than the one of binary \oper{+} and \oper{-}, else it inherits the latter\strut\\\hline % \prec{18}& \oper{\string^} and \oper{\lowast\lowast} are a priori synonymous (but see \xintlogname)\strut\\\hline % \prec{16}& \hyperref[ssec:tacit multiplication]{Tacit multiplication} has an elevated precedence\strut\\\hline % \prec{14}& \oper{\lowast}, \oper{/}, \oper{//} (floored division), and \oper{/:} (associated modulo, alias \oper{'mod'})\strut\\\hline % \prec{12}& \oper{+}, \oper{-}\strut\\\hline % \prec{10}& \oper{<}, \oper{>}, \oper{==}, \oper{<=}, \oper{>=}, \oper{!=} (they can be chained)\strut\\\hline % \prec{8}& Boolean conjunction \oper{\Ampersand\Ampersand} and its alias \oper{'and'}\strut\\\hline % \prec{6}& Boolean disjunction \oper{\string|\string|} and its alias \oper{'or'}. Also \oper{'xor'} and \oper{\strut..}, \oper{..[}, \oper{{]..}}, and \oper{:} have this precedence\strut\\\hline % \prec{4}& the brackets for slicers and extractors \oper{\empty[}, \oper{\empty]}\strut\\\hline % \prec{3}& the comma \oper{,}\strut\\\hline % \prec{2}& the bracketers \oper{[}, \oper{]} construct nestable «arrays»\strut\\\hline % \prec{1}& the parentheses \oper{(}, \oper{)}, and the semi-colon \oper{;} in \func{iter}, \func{rseq}, and further structures\strut\\\hline % \hline % \multicolumn{2}{|p{.6\textwidth}|}{% \begin{itemize}[nosep] \item Actually operators have a left and a right precedence, which for most coincide. But for some there is a crucial distinction. The above table is indicative, and the actual numerical levels used internally may change. \item In case of equal precedence, the rule is left-associativity: the first encountered operation is executed first. \hyperref[ssec:tacit multiplication]{Tacit multiplication} has an elevated precedence level hence seemingly breaks left-associativity: |(1+2)/(3+4)5| is computed as |(1+2)/((3+4)*5)| and |x/2y| is interpreted as |x/(2*y)| when using variables. \end{itemize} }\\\hline \end{tabular} \caption{Precedence levels} \label{tab:precedences} \etoctoccontentsline {table}{\protect\emph{Table of precedence levels of operators}} \restorehtdpstrutbox \end{table} The entries of \autoref{tab:precedences} are hyperlinked to the more detailed discussion at each level. \begin{description} %[parsep=0pt, listparindent=\leftmarginiii] % [parsep=0pt,align=left,itemindent=0pt, % leftmargin=\leftmarginii, labelwidth=\leftmarginii, labelsep=0pt, % labelindent=0pt, listparindent=\leftmarginiii] \edef\Ampersand{\string&}% \precdesc{$\infty$} At this highest level of precedence, one finds: \begin{description} \item[{\hyperref[ssec:builtinfunctions]{functions} and \hyperref[ssec:uservariables]{variables}}] Functions (even the logic functions \func{!} and \func{?} whose names consist of a single non-letter character) must be used with parentheses. These parentheses may arise from expansion after the function name is parsed (there are exceptions which are documented at the relevant locations.) \operdesc{\empty\lowast} Python-like «unpacking» prefix operator. Sometimes one needs to use it as function |*()| (but I can't find an example right now) but most of the time parentheses are unneeded. \operdesc{\strut.} is decimal mark; the number scanner treats it as an inherent, optional and unique component of a being formed number. |\xintexpr 0.^2+2^.0\relax| is interpreted as |0^2+2^0| and thus produces \dtt{\xintexpr 0.^2+2^.0\relax}. Since release |1.2| an isolated decimal mark is illegal input in the \xintexprname parsers (it remains legal as argument to the macros of \xintfracname). \operdesc{e} scientific notation. \operdesc{E} scientific notation. For output, see \csbxint{FracToSciE}. \operdesc{"} prefix for hexadecimal input. Only uppercase letters, and one optional |.| separating integer and fractional hexadecimal parts. This functionality \centeredline{\fbox{requires to load explicitly package \xintbinhexname.}}% \begin{everbatim*} \xintexpr "FEDCBA9876543210\relax\newline \xintexpr ".FEDCBA9876543210\relax\newline \xintexpr 16^5-("F75DE.0A8B9+"8A21.F5746+16^-5)\relax \end{everbatim*} It is possible that in future the |"| prefix could be dropped in favour of |0x| prefix. This would free |"| to be used for input of «string»-like entities. \end{description} \precdesc{20} The postfix operators |!| and the branching conditionals |?|, |??|. \begin{description} \operdesc{!} computes the factorial of an integer. Attention that the boolean equality test |==| confuses the parser if following directly |!| (e.g. |3! == 10|) as spaces are ignored and \oper{!=} will be intepreted as boolean inequality test, the second |=| causing then a low-level error. Use parentheses in such cases: |(3!)==10|. \operdesc{?} is used as |(stuff)?{yes}{no}|. It evaluates |stuff| and chooses the |yes| branch if the result is non-zero, else it executes |no|. After evaluation of |stuff| it acts as a macro with two mandatory arguments within braces, chooses the correct branch \emph{without evaluating the wrong one}. Once the braces are removed, the parser scans and expands the uncovered material. % so for % example % % % \leftedline{|\xinttheiexpr (3>2)?{5+6}{7-1}2^3\relax|} % % % is legal and computes % |5+62^3=|\dtt{\xinttheiexpr(3>2)?{5+(6}{7-(1}2^3)\relax}. It would be % better practice to include here the |2^3| inside the branches. The % contents of the branches may be arbitrary as long as once glued to what is % next the syntax is respected: {|\xintexpr (3>2)?{5+(6}{7-(1}2^3)\relax| % also works.} \operdesc{??} is used as |(stuff)??{<0}{=0}{>0}|, where |stuff| is anything, its sign is evaluated and depending on the sign the correct branch is un-braced, the two others are discarded with no evaluation of their contents. % The un-braced branch will then be parsed as % usual. % % % \leftedline{|\def\x{0.33}\def\y{1/3}|} % % % \leftedline{|\xinttheexpr (\x-\y)??{sqrt}{0}{1/}(\y-\x)\relax|% % \dtt{=\def\x{0.33}\def\y{1/3}% % \xinttheexpr (\x-\y)??{sqrt}{0}{1/}(\y-\x)\relax }} % % \end{description} \precdesc{-} As unary operator, the minus sign inherits the precedence of the infix operator it follows (plus signs as unary operators are simply ignored). \begin{everbatim*} \xintexpr -3-4*-5^-7, (-3)-(4*(-(5^(-7))))\relax\newline \xintexpr -3^-4*-5-7, (-((3^(-4))*(-5)))-7\relax\newline |2^-10| gives \xintexpr 2^-10\relax\space \end{everbatim*}and is thus perfectly legal, no need for parentheses. Note (|1.4b|): the above is what this documentation has always said, but it has also always been only partially true. I.e.\@ it applies only when |-| follows an infix binary operator having at least the precedence level of |+| and |-|. When the unary |-| follows an infix operator (or operator word) of less precedence, its precedence will be set to the one for the infix operators |+| and |-|. «Seul |sourcexint.pdf| fait foi». \precdesc{18} \begin{description} \operdesc{\string^} \operdesc{\lowast\lowast} Both compute powers in left associative way. \begin{everbatim*} \xintiiexpr 2^2^3\relax \end{everbatim*} Half-integer exponents are allowed in \csbxint{floateval} and use \func{sqrt}. It is possible to allow arbitrary fractional exponents (\autoref{ssec:poormanloghack}) but this currently achieves only a reduced precision. See \csbxint{FloatPower} and \xintlogname for additional information. \end{description} \precdesc{16} see \hyperref[ssec:tacit multiplication]{Tacit multiplication}. \precdesc{14} \begin{description} \operdesc{\lowast} multiplication \operdesc{/} division: exact in \csbxint{eval}, correctly rounded in \csbxint{floateval} (numerator and denominator are rounded before the division is done), and rounded to an integer (like |\numexpr| does: half-integers are rounded towards infinity of same sign) in \csbxint{iieval}. The division is left-associative: \begin{everbatim*} \xintexpr reduce(100/50/2)\relax \end{everbatim*} \operdesc{//} floored division \operdesc{/:} the associated modulo Left-associativity applies generally to operators of same precedence. \begin{everbatim*} \xintexpr 100000/:13, 100000 'mod' 13\relax\newline \xintexpr 100000/:13/13\relax \end{everbatim*} \operdesc{'mod'} is same as \oper{/:}. Note: The enclosing (right) ticks are mandatory part of all such infix operator «words». \end{description} \precdesc{12} \begin{description} \operdesc{+} addition \operdesc{-} subtraction. According to the general left-associativity rule in case of equal precedence, it is left associative: \begin{everbatim*} \xintiiexpr 100-50-2\relax \end{everbatim*} \end{description} \precdesc{10} Comparison operators are (as in Python) all at the same level of precedence, use parentheses for disambiguation. \begin{description} \operdesc{<} |a} |a>b| evaluates to \dtt{1} if the strict inequality holds to \dtt{0} if not. \operdesc{==} |a==b| evaluates to \dtt{1} if equality holds to \dtt{0} if not. \operdesc{<=} |a<=b| evaluates to \dtt{1} if left hand side is at most equal to right hand side, to \dtt{0} if not. \operdesc{>=} |a>=b| evaluates to \dtt{1} if left hand side is at least equal to right hand side, to \dtt{0} if not. \operdesc{!=} |a!=b| evaluates to \dtt{1} if they differ, to \dtt{0} if not. \end{description} Comparisons\NewWith{1.4b} can be chained arbitrarily, e.g., |x < y <= z != t| is equivalent to |x < y 'and' y <= z 'and' z != t| (and also to |all(x1}{true}{\error}, \xintifboolexpr{1<=2>=3<4>1}{\error}{false} \end{everbatim*} \precdesc{8} \begin{description} \operdesc{\Ampersand\Ampersand} logical conjunction. Evaluates to \dtt{1} if both sides are non-zero, to \dtt{0} if not. \operdesc{'and'} idem. The (right) ticks are mandatory. See also the \func{all} multi-arguments function. \end{description} \precdesc{6} \begin{description} \operdesc{\string|\string|} logical (inclusive) disjunction. Evaluates to \dtt{1} if one or both sides are non-zero, to \dtt{0} if not. \operdesc{'or'} idem. See also the \func{any} multi-arguments function. \operdesc{'xor'} logical (exclusive) disjunction. See also the \func{xor} multi-arguments function. \operdesc{\strut..} \operdesc{..[} \operdesc{{]..}} Syntax for arithmetic progressions. See \autoref{ssec:arithseq}. \operdesc{:} This is a separator involved in |[a:b]| Python-like slicing syntax. \end{description} \precdesc{4} \begin{description} \operdesc{\empty[} \operdesc{\empty]} Involved in Python-like slicing |[a:b]| and extracting |[N]| syntax. And its extension à la NumPy |[a:b,N,c:d,...,:]|. Ellipsis |...| is not yet implemented. The «step» parameter as in |[a:b:step]| is not yet implemented. \end{description} \precdesc{3} \begin{description} \operdesc{,} The comma separates expressions (or function arguments).% % \footnote{The comma is really like a binary operator, which may be called ``join''. It has lowest precedence of all (apart the parentheses) because when it is encountered all postponed operations are executed in order to finalize its \emph{first} operand; only a new comma or a closing parenthesis or the end of the expression will finalize its \emph{second} operand.} % \begin{everbatim*} \xintiiexpr 2^3,3^4,5^6\relax \end{everbatim*} \end{description} \precdesc{2} \begin{description} \operdesc{[} \operdesc{]} The bracketers construct nestable «array-like» structures. Arbitrary (heterogeneous) nesting is allowed. For output related matters see \csbxint{thealign} (its usage is optional, without it rendering is «one-dimensional»). Output shape of non-homogeneous arrays is to be considered unstable at this time. \end{description} \precdesc{1} \begin{description} \operdesc{(} \operdesc{)} The parentheses serve as mandatory part of the syntax for functions, and to disambiguate precedences.% % \footnote{It is not apt to describle the opening parenthesis as an operator, but the closing parenthesis is analogous to a postfix unary operator. It has lowest precedence which means that when it is encountered all postponed operations are executed to finalize its operand. The start of this operand was decided by the opening parenthesis.} % They do not construct any nested structure. \operdesc{;} The semi-colon as involved as part of the syntax of \func{iter}, \func{rseq}, \func{ndseq}, \func{ndmap} has the same precedence as a closing parenthesis. \end{description} \item[|\relax|] This is the expression terminator for \csbxint{expr} et al. It may arise from expansion during the parsing itself. As alternative use \csbxint{eval} et al. which proceed as macros expecting one mandatory argument. \end{description} The |;| also serves as syntax terminator for \csbxint{defvar} and \csbxint{deffunc}. It can in this rôle not arise from expansion as the expression body up to it is fetched by a delimited macro. But this is done in a way which does not require any specific hiding for inner semi-colons as involved in the syntax of \func{iter}, etc... \subsection{Built-in functions}\label{ssec:builtinfunctions} See \autoref{tab:functions} whose elements are hyperlinked to the corresponding definitions. Functions are at the same top level of priority. All functions even \func{?} and \func{!} require parentheses around their arguments. % Table of functions \begin{table}[htbp] \capstart \centering \xintAssignArray\xintCSVtoList{!, ?, \textasciigrave\lowast\textasciigrave, \textasciigrave+\textasciigrave, abs, add, all, any, acos, acosd, Arg, Argd, asin, asind, atan, atand, atan2, atan2d, binomial, bool, ceil, cos, cosd, cot, cotd, cotg, csc, cscd, divmod, even, exp, factorial, first, flat, float, float\string_, floor, frac, gcd, if, ifint, ifone, ifsgn, ilog10, isint, isone, iter, iterr, inv, last, lcm, len, log, log10, max, min, mod, mul, ndmap, ndseq, ndfillraw, not, num, nuple, odd, pArg, pArgd, pfactorial, pow, pow10, preduce, qfloat, qfrac, qint, qrand, qraw, quo, random, randrange, rbit, reduce, rem, reversed, round, rrseq, rseq, sec, secd, seq, sgn, sin, sinc, sind, sqr, sqrt, sqrtr, subs, subsm, subsn, tan, tand, tg, togl, trunc, unpack, xor, zip} \to\Functions \cnta\Functions{0} \cntb\xinttheexpr ceil(\cnta/7)\relax\space \newcommand\builtinfunction[1]{\expandafter\expandafter\expandafter\func \expandafter\expandafter\expandafter{\Functions{#1}}}% \centeredline{\begin{tabular}{|*{7}{p{2cm}|}} \hline \xintFor* #1 in {\xintSeq{1}{\cntb}}\do {\builtinfunction{#1}& \builtinfunction{#1+\cntb}&% \builtinfunction{#1+2*\cntb}&% \builtinfunction{#1+3*\cntb}&% \builtinfunction{#1+4*\cntb}&% \builtinfunction{#1+5*\cntb}&% \ifnumgreater{#1+6*\cntb}{\cnta} {} {\builtinfunction{#1+6*\cntb}}% \\\hline}% \end{tabular}} \caption{Functions (click on names)}\label{tab:functions} \etoctoccontentsline {table}{\protect\emph{Table of functions in expressions}} \etocsetnexttocdepth{subsubsection} \localtableofcontents \end{table} Miscellaneous notes: \begin{itemize}[nosep] \item since release |1.3d| \func{gcd} and \func{lcm} are extended to apply to fractions too, and do NOT require the loading of \xintgcdname, \item The randomness related functions \func{random}, \func{qrand} and \func{randrange} require that the \TeX\ engine provides the \csa{uniformdeviate} or \csa{pdfuniformdeviate} primitive. This is currently the case for |pdftex|, |(u)ptex|, |luatex|, and also for |xetex| since \TeX Live 2019.\IMPORTANT \item \func{togl} is provided for the case |etoolbox| package is loaded, \item \func{bool}, \func{togl} use delimited macros to fetch their argument and the closing parenthesis must be explicit, it can not arise from on the spot expansion. The same holds for \func{qint}, \func{qfrac}, \func{qfloat}, \func{qraw}, \func{random} and \func{qrand}. \item Also \hyperlink{ssec:dummies}{functions with dummy variables} use delimited macros for some tasks. See the relevant explanations there. \item Functions may be called with \emph{oples} as arguments as long as the total length is the number of arguments the function expects. \end{itemize} \subsubsection{Functions with no argument} \begin{description} % [parsep=0pt,align=left, % leftmargin=0pt, itemindent=0pt, % labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt, % listparindent=\leftmarginiii] \funcdesc[]{random} returns a random float |x| verifying |0 <= x < 1|. It obeys the prevailing precision as set by \csbxint{Digits}: i.e. with |P| being the precision the random float multiplied by |10^P| is an integer, uniformly distributed in the |0..10^P-1| range. This description implies that if |x| turns out to be |<0.1| then its (normalized) mantissa has |P-1| digits and a trailing zero, if |x<0.01| it has |P-2| digits and two trailing zeros, etc... This is what is observed also with Python's |random()|, of course with |10| replaced there by radix |2|.% \begin{everbatim*} \pdfsetrandomseed 12345 \xintDigits:=37\relax \xintthefloatexpr random()\relax\newline \xintthefloatexpr random()\relax\par \end{everbatim*} \funcdesc[]{qrand} returns a random float |0 <= x < 1| using \dtt{16} digits of precision (i.e. |10^{16}x| is an integer). This is provided when speed is a at premium as it is optimized for precision being precisely \dtt{16}.% \begin{everbatim*} % still with 37 digits as prevailing float precision \xintthefloatexpr qrand(), random()\relax\newline \xintDigits:=16\relax \xintthefloatexpr qrand(), random()\relax\par \end{everbatim*} One can use both |qrand()| and |random()| inside the |\xintexpr| parser too. But inside the integer only |\xintiiexpr| parser they will cause some low-level error as soon as they get involved in any kind of computation as they use an internal format not recognized by the integer-only parser. See further \func{randrange}, which generates random integers. Currently there is no |uniform()| function% % \footnote{Because I am not sure how to handle rounding issues: should the computation proceed exactly and a rounding be done only at very end?} % but it can be created by user: \begin{everbatim*} \xintdeffloatfunc uniform(a, b):= a + (b-a)*random(); \romannumeral\xintreplicate{10}% {% \xintthefloatexpr uniform(123.45678, 123.45679)\relax\newline }% \end{everbatim*} \funcdesc[]{rbit} returns a random |0| or |1|.\NewWith{1.4} \end{description} \subsubsection{Functions with one argument} \begin{description} % [parsep=0pt,align=left, % leftmargin=0pt, itemindent=0pt, % labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt, % listparindent=\leftmarginiii] \funcdesc{num} truncates to the nearest integer (truncation towards zero). It has the same sign as |x|, except of course with |-1