Skip to content

Commit

Permalink
Added #SkipExtraSymbols and Delete ExtraSymbols
Browse files Browse the repository at this point in the history
  • Loading branch information
vermaseren committed Dec 11, 2013
1 parent 693d016 commit 79649c2
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 32 deletions.
51 changes: 51 additions & 0 deletions doc/manual/prepro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,57 @@ \section{\#show}
input is off.

%--#] show :
%--#[ skipextrasymbols :

\section{\#skipextrasymbols}
\label{preskipextrasymbols}

\noindent Syntax:

\#skipextrasymbols positivenumber

\noindent See also ExtraSymbols(\ref{substaextrasymbols}) and the chapter
on optimization(\ref{optimization}).

\noindent This instructions adds a number of dummy extra
symbols\index{extra symbols} to the list of extra
symbols(\ref{substaextrasymbols}). This can be used when several
optimizations are done on an expression in such a way that the extra
symbols of previous optimizations are still present. Normally the number
space for them is erased in a \#clearoptimize instruction. This can be
avoided with a sequence like
\begin{verbatim}
#skipextrasymbols,{`optimmaxvar_'-`optimminvar_'+1}
\end{verbatim}
In this case the numbering of the next optimization will start after the
last extra symbol of the previous optimization.
One should realize however that the definitions of the extra symbols are
not kept once the new optimization is started or once a \#clearoptimize
instruction is issued. Example:
\begin{verbatim}
#-
S a,b,c,d,e;
L F = (a+b+c+d+3*e)^3;
B b;
.sort
ExtraSymbols,array,w;
Format O3,stats=ON;
#optimize F
#write <> " %4O"
.sort
#SkipExtraSymbols,{`optimmaxvar_'-`optimminvar_'+1}
id b = b+1;
Print +f;
B b;
.end
\end{verbatim}
Because the O3 format is still active, the final printing uses the
optimization as well. If the \#SkipExtraSymbols instruction would have been
omitted, the numbering would start again from one, while the rhs. of their
definitions would contain the old extra symbols. The result would be
incorrect.

%--#] skipextrasymbols :
%--#[ switch :

\section{\#switch}
Expand Down
2 changes: 1 addition & 1 deletion doc/manual/startup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ \chapter{Running FORM}
the make -j option).
\item[-p] Next argument/option is the path of a directory for
input, include, procedure and subroutine files.
\item[-pipe] Indicates that \FORM\ is started up as the receiving
\item[-{pipe}] Indicates that \FORM\ is started up as the receiving
end of a pipe. Action will be taken to set up the proper communication
channels.
\item[-q] Quiet option. Only output expressions are printed.
Expand Down
80 changes: 49 additions & 31 deletions doc/manual/statements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -820,20 +820,38 @@ \section{delete}

\noindent \begin{tabular}{ll}
Type & Specification statement\\
Syntax & delete storage;
\\ See also & save (\ref{substasave}), load (\ref{substaload})
\end{tabular} \vspace{4mm}

\noindent This statement\index{delete} clears the complete
storage\index{storage file} file\index{file!storage} and
reduces it to zero size. The effect is that all stored expressions are
removed from the system. Because it is impossible to remove individual
expressions from the store file (there is no mechanism to fill the
resulting holes) it is the only way to clean up the storage file. If some
expressions should be excluded from this elimination process, one should
copy them first into active global expressions, then delete the storage
file, after which the expressions can be written to storage again with a
.store\index{.store} instruction. \vspace{10mm}
Syntax & delete storage; \\
See also & save (\ref{substasave}), load (\ref{substaload}) \\
Syntax & delete extrasymbols; \\
Syntax & delete extrasymbols>number; \\
See also & extrasymbols (\ref{substaextrasymbols}) \\

\end{tabular} \vspace{4mm}

\noindent This statement has currently two varieties. The delete
storage\index{delete} clears the complete storage\index{storage file}
file\index{file!storage} and reduces it to zero size. The effect is that
all stored expressions are removed from the system. Because it is
impossible to remove individual expressions from the store file (there is
no mechanism to fill the resulting holes) it is the only way to clean up
the storage file. If some expressions should be excluded from this
elimination process, one should copy them first into active global
expressions, then delete the storage file, after which the expressions can
be written to storage again with a .store\index{.store} instruction.

\noindent The delete extrasymbols\index{delete}\index{} variety removes
extra symbols\index{extra symbols} from the list. The default is that all
extra symbols are removed, but one can also remove the symbols above a
given number as in
\begin{verbatim}
#$es = `extrasymbols_';
ToPolynomial;
....some code....
.sort
* now the new extra symbols are not needed anylonger
Delete extrasymbols>`$es';
\end{verbatim}
\vspace{10mm}

%--#] delete :
%--#[ denominators :
Expand Down Expand Up @@ -1321,19 +1339,20 @@ \section{extrasymbols}
factorization(\ref{substafactarg}) (which uses the topolynomial facilities
automatically) and output simplification (see the Format
statement \ref{substaformat}).
The ToPolynomial statement takes each term, looks for objects
that are not symbols to positive powers and replaces them by symbols. If
the object has been encountered before the same symbol will be used,
otherwise a new symbol will be defined. The object represented by the
`extra symbol' is stored internally and can be printed if needed with the
\%X option in the \#write instruction (\ref{prewrite}). The representation
of the extra symbols is by default the name Z followed by a number and an
underscore character. If another name is desired this should be specified
in an `ExtraSymbols' statement. The name given may contain only alphabetic
characters! Because some compilers do not like the underscore character,
there is an alternative notation for the extra symbols. This is just for
cosmetic reasons and one cannot feed these symbols into the compiler this
way. This is with an array notation. The statement
The ToPolynomial statement\index{topolynomial} takes each term, looks for
objects that are not symbols to positive powers and replaces them by
symbols. If the object has been encountered before the same symbol will be
used, otherwise a new symbol will be defined. The object represented by the
`extra symbol'\index{extra symbols} is stored internally and can be printed
if needed with the \%X option in the \#write instruction (\ref{prewrite}).
The representation of the extra symbols is by default the name Z followed
by a number and an underscore character. If another name is desired this
should be specified in an `ExtraSymbols' statement. The name given may
contain only alphabetic characters! Because some compilers do not like the
underscore character, there is an alternative notation for the extra
symbols. This is just for cosmetic reasons and one cannot feed these
symbols into the compiler this way. This is with an array notation. The
statement
\begin{verbatim}
ExtraSymbols,array,Ab;
\end{verbatim}
Expand Down Expand Up @@ -2749,7 +2768,7 @@ \section{makeinteger}
this argument may be negative. If this is not desired one can first
normalize\index{normalize} the argument and then make its coefficients
integer. The overall factor that is needed to make the coefficients like
described is taken from the overall factor of the complete term. Example
described is taken from the overall factor of the complete term. Example:
% THIS EXAMPLE IS PART OF THE TESTSUITE. CHANGES HERE SHOULD BE APPLIED THERE AS
% WELL!
\begin{verbatim}
Expand All @@ -2759,7 +2778,6 @@ \section{makeinteger}
MakeInteger,f;
Print +f;
.end
F =
2/105*f(135*c + 147*b + 385*a);
\end{verbatim}
Expand All @@ -2773,7 +2791,7 @@ \section{makeinteger}
It is possible to introduce a scale factor when extracting the coefficient
and multiplying it into the complete term.

\leftvitem{4cm}{MakeInteger,$\wedge<n>$:,f;}
\leftvitem{4cm}{MakeInteger,$\wedge<n>$,f;}
\rightvitem{12cm}{The number n must be an integer (may be negative) and if
the coefficient that is extracted is c the whole term is multiplied by the
factor $c^n$.}
Expand Down Expand Up @@ -3209,7 +3227,7 @@ \section{normalize}
A more flexible way to extract the coefficient of the (first) term is by
providing a scale factor as in

\leftvitem{4cm}{Normalize,$\wedge<n>$:,f;}
\leftvitem{4cm}{Normalize,$\wedge<n>$,f;}
\rightvitem{12cm}{The number n must be an integer (may be negative) and if
the coefficient of the first term was c the whole term is multiplied by the
factor $c^n$.}
Expand Down

0 comments on commit 79649c2

Please sign in to comment.