\hypertarget{proces_8c}{}\doxysection{proces.\+c File Reference}
\label{proces_8c}\index{proces.c@{proces.c}}
{\ttfamily \#include \char`\"{}form3.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
WORD \mbox{\hyperlink{proces_8c_a338d382ea9b88287382c9cfb22707735}{Processor}} ()
\item 
WORD \mbox{\hyperlink{proces_8c_aec46f85385d81649977a4cdfbac5796b}{Test\+Sub}} (PHEAD WORD $\ast$term, WORD level)
\item 
WORD \mbox{\hyperlink{proces_8c_a467ec836e972638891f32dda2c30e29a}{In\+Function}} (PHEAD WORD $\ast$term, WORD $\ast$termout)
\item 
WORD \mbox{\hyperlink{proces_8c_aa6a2d2ce3d22f4c481dd2a44f80f606f}{Insert\+Term}} (PHEAD WORD $\ast$term, WORD replac, WORD extractbuff, WORD $\ast$position, WORD $\ast$termout, WORD tepos)
\item 
LONG \mbox{\hyperlink{proces_8c_ad2b062ed24c5214988d5f1fd7e767b5f}{Paste\+File}} (PHEAD WORD number, WORD $\ast$accum, \mbox{\hyperlink{structPoSiTiOn}{POSITION}} $\ast$position, WORD $\ast$$\ast$accfill, \mbox{\hyperlink{structs_8h_a323639d869c15fed1226a3b508bbb1f1}{RENUMBER}} renumber, WORD $\ast$freeze, WORD nexpr)
\item 
WORD $\ast$ \mbox{\hyperlink{proces_8c_a3786f3a0dbd05ff88b2732ba4f26fd33}{Paste\+Term}} (PHEAD WORD number, WORD $\ast$accum, WORD $\ast$position, WORD times, WORD divby)
\item 
WORD \mbox{\hyperlink{proces_8c_a96c31b8050c29ab1504f53a777539775}{Fini\+Term}} (PHEAD WORD $\ast$term, WORD $\ast$accum, WORD $\ast$termout, WORD number, WORD tepos)
\item 
WORD \mbox{\hyperlink{proces_8c_af4b8717dc948864d1b368b82f20d16a8}{Generator}} (PHEAD WORD $\ast$term, WORD level)
\item 
WORD \mbox{\hyperlink{proces_8c_a127ccce808592c093efe9fa4cdc65311}{Do\+One\+Pow}} (PHEAD WORD $\ast$term, WORD power, WORD nexp, WORD $\ast$accum, WORD $\ast$aa, WORD level, WORD $\ast$freeze)
\item 
WORD \mbox{\hyperlink{proces_8c_ad5c818e233e9bdfabd56f8c991569545}{Deferred}} (PHEAD WORD $\ast$term, WORD level)
\item 
WORD \mbox{\hyperlink{proces_8c_abda941ee0f213652203152572f64baab}{Prep\+Poly}} (PHEAD WORD $\ast$term, WORD par)
\item 
WORD \mbox{\hyperlink{proces_8c_af03a5704a977a0cadefbf41b6832025b}{Poly\+Fun\+Mul}} (PHEAD WORD $\ast$term)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{proces_8c_ace6bc837ef17ced5f1772789803dcd43}\label{proces_8c_ace6bc837ef17ced5f1772789803dcd43}} 
WORD {\bfseries printscratch} \mbox{[}2\mbox{]}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Contains the central terms processor routines. This is the core of the virtual machine. All other files are to help these routines. 

\doxysubsection{Function Documentation}
\mbox{\Hypertarget{proces_8c_a338d382ea9b88287382c9cfb22707735}\label{proces_8c_a338d382ea9b88287382c9cfb22707735}} 
\index{proces.c@{proces.c}!Processor@{Processor}}
\index{Processor@{Processor}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{Processor()}{Processor()}}
{\footnotesize\ttfamily WORD Processor (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}

This is the central processor. It accepts a stream of Expressions which is accessed by calls to Get\+Term. The expressions reside either in AR.\+infile or AR.\+hidefile The definitions of an expression are seen as an id-\/statement, so the primary Expressions should be written to the system of scratch files as single terms with an expression pointer. Each expression is terminated with a zero and the whole is terminated by two zeroes.

The routine Do\+Execute should determine whether results are to be printed, should revert the scratch I/O directions etc. In principle it is Do\+Execute that calls Processor.

\begin{DoxyReturn}{Returns}
if everything OK\+: 0. Otherwise error. The preprocessor may continue with compilation though. Really fatal errors should return on the spot by calling Terminate. 
\end{DoxyReturn}


Definition at line 64 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_aec46f85385d81649977a4cdfbac5796b}\label{proces_8c_aec46f85385d81649977a4cdfbac5796b}} 
\index{proces.c@{proces.c}!TestSub@{TestSub}}
\index{TestSub@{TestSub}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{TestSub()}{TestSub()}}
{\footnotesize\ttfamily WORD Test\+Sub (\begin{DoxyParamCaption}\item[{PHEAD WORD $\ast$}]{term,  }\item[{WORD}]{level }\end{DoxyParamCaption})}

Test\+Sub hunts for subexpression pointers. If one is found its power is given in AN.\+Te\+Su\+Out. and the returnvalue is \textquotesingle{}expressionnumber\textquotesingle{}. If the expression number is negative it is an expression on disk.

In addition this routine tries to locate subexpression pointers in functions. It also notices that action must be taken with any of the special functions.


\begin{DoxyParams}{Parameters}
{\em term} & The term in which Test\+Sub hunts for potential action \\
\hline
{\em level} & The number of the \textquotesingle{}level\textquotesingle{} in the compiler buffer. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The number of the (sub)expression that was encountered.
\end{DoxyReturn}
Other values that are returned are in AN.\+Te\+Su\+Out, AR.\+Te\+Pos, AT.\+TMbuff, AN.\+Te\+In\+Fun, AN.\+Frozen, AT.\+TMaddr

The level in the compiler buffer is more or less the number of the statement in the module. Hence it refers to the element in the lhs array.

This routine is one of the most important routines in FORM. 

Definition at line 681 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_a467ec836e972638891f32dda2c30e29a}\label{proces_8c_a467ec836e972638891f32dda2c30e29a}} 
\index{proces.c@{proces.c}!InFunction@{InFunction}}
\index{InFunction@{InFunction}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{InFunction()}{InFunction()}}
{\footnotesize\ttfamily WORD In\+Function (\begin{DoxyParamCaption}\item[{PHEAD WORD $\ast$}]{term,  }\item[{WORD $\ast$}]{termout }\end{DoxyParamCaption})}

Makes the replacement of the subexpression with the number \textquotesingle{}replac\textquotesingle{} in a function argument. Additional information is passed in some of the AR, AN, AT variables.


\begin{DoxyParams}{Parameters}
{\em term} & The input term \\
\hline
{\em termout} & The output term \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0\+: everything is fine, Negative\+: fatal, Positive\+: error.
\end{DoxyReturn}
Special attention should be given to nested functions! 

Definition at line 2033 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_aa6a2d2ce3d22f4c481dd2a44f80f606f}\label{proces_8c_aa6a2d2ce3d22f4c481dd2a44f80f606f}} 
\index{proces.c@{proces.c}!InsertTerm@{InsertTerm}}
\index{InsertTerm@{InsertTerm}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{InsertTerm()}{InsertTerm()}}
{\footnotesize\ttfamily WORD Insert\+Term (\begin{DoxyParamCaption}\item[{PHEAD WORD $\ast$}]{term,  }\item[{WORD}]{replac,  }\item[{WORD}]{extractbuff,  }\item[{WORD $\ast$}]{position,  }\item[{WORD $\ast$}]{termout,  }\item[{WORD}]{tepos }\end{DoxyParamCaption})}

Puts the terms \textquotesingle{}term\textquotesingle{} and \textquotesingle{}position\textquotesingle{} together into a single legal term in termout. replac is the number of the subexpression that should be replaced. It must be a positive term. When action is needed in the argument of a function all terms in that argument are dealt with recursively. The subexpression is sorted. Only one subexpression is done at a time this way.


\begin{DoxyParams}{Parameters}
{\em term} & the input term \\
\hline
{\em replac} & number of the subexpression pointer to replace \\
\hline
{\em extractbuff} & number of the compiler buffer replac refers to \\
\hline
{\em position} & position from where to take the term in the compiler buffer \\
\hline
{\em termout} & the output term \\
\hline
{\em tepos} & offset in term where the subexpression is. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Normal conventions (OK = 0). 
\end{DoxyReturn}


Definition at line 2579 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_ad2b062ed24c5214988d5f1fd7e767b5f}\label{proces_8c_ad2b062ed24c5214988d5f1fd7e767b5f}} 
\index{proces.c@{proces.c}!PasteFile@{PasteFile}}
\index{PasteFile@{PasteFile}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{PasteFile()}{PasteFile()}}
{\footnotesize\ttfamily LONG Paste\+File (\begin{DoxyParamCaption}\item[{PHEAD WORD}]{number,  }\item[{WORD $\ast$}]{accum,  }\item[{\mbox{\hyperlink{structPoSiTiOn}{POSITION}} $\ast$}]{position,  }\item[{WORD $\ast$$\ast$}]{accfill,  }\item[{\mbox{\hyperlink{structs_8h_a323639d869c15fed1226a3b508bbb1f1}{RENUMBER}}}]{renumber,  }\item[{WORD $\ast$}]{freeze,  }\item[{WORD}]{nexpr }\end{DoxyParamCaption})}

Gets a term from stored expression expr and puts it in the accumulator at position number. It returns the length of the term that came from file.


\begin{DoxyParams}{Parameters}
{\em number} & number of partial terms to skip in accum \\
\hline
{\em accum} & the accumulator \\
\hline
{\em position} & file position from where to get the stored term \\
\hline
{\em accfill} & returns tail position in accum \\
\hline
{\em renumber} & the renumber struct for the variables in the stored expression \\
\hline
{\em freeze} & information about if we need only the contents of a bracket \\
\hline
{\em nexpr} & the number of the stored expression \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Normal conventions (OK = 0). 
\end{DoxyReturn}


Definition at line 2715 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_a3786f3a0dbd05ff88b2732ba4f26fd33}\label{proces_8c_a3786f3a0dbd05ff88b2732ba4f26fd33}} 
\index{proces.c@{proces.c}!PasteTerm@{PasteTerm}}
\index{PasteTerm@{PasteTerm}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{PasteTerm()}{PasteTerm()}}
{\footnotesize\ttfamily WORD$\ast$ Paste\+Term (\begin{DoxyParamCaption}\item[{PHEAD WORD}]{number,  }\item[{WORD $\ast$}]{accum,  }\item[{WORD $\ast$}]{position,  }\item[{WORD}]{times,  }\item[{WORD}]{divby }\end{DoxyParamCaption})}

Puts the term at position in the accumulator accum at position \textquotesingle{}number+1\textquotesingle{}. if times $>$ 0 the coefficient of this term is multiplied by times/divby.


\begin{DoxyParams}{Parameters}
{\em number} & The number of term fragments in accum that should be skipped \\
\hline
{\em accum} & The accumulator of term fragments \\
\hline
{\em position} & A position in (typically) a compiler buffer from where a (piece of a) term comes. \\
\hline
{\em times} & Multiply the result by this \\
\hline
{\em divby} & Divide the result by this.\\
\hline
\end{DoxyParams}
This routine is typically used when we have to replace a (sub)expression pointer by a power of a (sub)expression. This uses mostly a binomial expansion and the new term is the old term multiplied one by one by terms of the new expression. The factors times and divby keep track of the binomial coefficient. Once this is complete, the routine Fini\+Term will make the contents of the accumulator into a proper term that still needs to be normalized. 

Definition at line 2837 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_a96c31b8050c29ab1504f53a777539775}\label{proces_8c_a96c31b8050c29ab1504f53a777539775}} 
\index{proces.c@{proces.c}!FiniTerm@{FiniTerm}}
\index{FiniTerm@{FiniTerm}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{FiniTerm()}{FiniTerm()}}
{\footnotesize\ttfamily WORD Fini\+Term (\begin{DoxyParamCaption}\item[{PHEAD WORD $\ast$}]{term,  }\item[{WORD $\ast$}]{accum,  }\item[{WORD $\ast$}]{termout,  }\item[{WORD}]{number,  }\item[{WORD}]{tepos }\end{DoxyParamCaption})}

Concatenates the contents of the accumulator into a single legal term, which replaces the subexpression pointer


\begin{DoxyParams}{Parameters}
{\em term} & the input term with the (sub)expression subterm \\
\hline
{\em accum} & the accumulator with the term fragments \\
\hline
{\em termout} & the location where the output should be written \\
\hline
{\em number} & the number of term fragments in the accumulator \\
\hline
{\em tepos} & the position of the subterm in term to be replaced \\
\hline
\end{DoxyParams}


Definition at line 2902 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_af4b8717dc948864d1b368b82f20d16a8}\label{proces_8c_af4b8717dc948864d1b368b82f20d16a8}} 
\index{proces.c@{proces.c}!Generator@{Generator}}
\index{Generator@{Generator}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{Generator()}{Generator()}}
{\footnotesize\ttfamily WORD Generator (\begin{DoxyParamCaption}\item[{PHEAD WORD $\ast$}]{term,  }\item[{WORD}]{level }\end{DoxyParamCaption})}

The heart of the program. Here the expansion tree is set up in one giant recursion


\begin{DoxyParams}{Parameters}
{\em term} & the input term. may be overwritten \\
\hline
{\em level} & the level in the compiler buffer (number of statement) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Normal conventions (OK = 0).
\end{DoxyReturn}
The routine looks first whether there are unsubstituted (sub)expressions. If so, one of them gets inserted term by term and the new term is used in a renewed call to Generator. If there are no (sub)expressions, the term is normalized, the compiler level is raised (next statement) and the program looks what type of statement this is. If this is a special statement it is either treated on the spot or the appropriate routine is called. If it is a substitution, the pattern matcher is called (Test\+Match) which tells whether there was a match. If so we need to call Test\+Sub again to test for (sub)expressions. If we run out of levels, the term receives a final treatment for modulus calculus and/or brackets and is then sent off to the sorting routines. 

Definition at line 3101 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_a127ccce808592c093efe9fa4cdc65311}\label{proces_8c_a127ccce808592c093efe9fa4cdc65311}} 
\index{proces.c@{proces.c}!DoOnePow@{DoOnePow}}
\index{DoOnePow@{DoOnePow}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{DoOnePow()}{DoOnePow()}}
{\footnotesize\ttfamily WORD Do\+One\+Pow (\begin{DoxyParamCaption}\item[{PHEAD WORD $\ast$}]{term,  }\item[{WORD}]{power,  }\item[{WORD}]{nexp,  }\item[{WORD $\ast$}]{accum,  }\item[{WORD $\ast$}]{aa,  }\item[{WORD}]{level,  }\item[{WORD $\ast$}]{freeze }\end{DoxyParamCaption})}

Routine gets one power of an expression in the scratch system. If there are more powers needed there will be a recursion.

No attempt is made to use binomials because we have no information about commutating properties.

There is a searching for the contents of brackets if needed. This searching may be rather slow because of the single links.


\begin{DoxyParams}{Parameters}
{\em term} & is the term we are adding to. \\
\hline
{\em power} & is the power of the expression that we need. \\
\hline
{\em nexp} & is the number of the expression. \\
\hline
{\em accum} & is the accumulator of terms. It accepts the termfragments that are made into a proper term in Fini\+Term \\
\hline
{\em aa} & points to the start of the entire accumulator. In $\ast$aa we store the number of term fragments that are in the accumulator. \\
\hline
{\em level} & is the current depth in the tree of statements. It is needed to continue to the next operation/substitution with each generated term \\
\hline
{\em freeze} & is the pointer to the bracket information that should be matched. \\
\hline
\end{DoxyParams}


Definition at line 4395 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_ad5c818e233e9bdfabd56f8c991569545}\label{proces_8c_ad5c818e233e9bdfabd56f8c991569545}} 
\index{proces.c@{proces.c}!Deferred@{Deferred}}
\index{Deferred@{Deferred}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{Deferred()}{Deferred()}}
{\footnotesize\ttfamily WORD Deferred (\begin{DoxyParamCaption}\item[{PHEAD WORD $\ast$}]{term,  }\item[{WORD}]{level }\end{DoxyParamCaption})}

Picks up the deferred brackets. These are the bracket contents of which we postpone the reading when we use the \textquotesingle{}Keep Brackets\textquotesingle{} statement. These contents are multiplying the terms just before they are sent to the sorting system. Special attention goes to having it thread-\/safe We have to lock positioning the file and reading it in a thread specific buffer.


\begin{DoxyParams}{Parameters}
{\em term} & The term that must be multiplied by the contents of the current bracket \\
\hline
{\em level} & The compiler level. This is needed because after multiplying term by term we call Generator again. \\
\hline
\end{DoxyParams}


Definition at line 4616 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_abda941ee0f213652203152572f64baab}\label{proces_8c_abda941ee0f213652203152572f64baab}} 
\index{proces.c@{proces.c}!PrepPoly@{PrepPoly}}
\index{PrepPoly@{PrepPoly}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{PrepPoly()}{PrepPoly()}}
{\footnotesize\ttfamily WORD Prep\+Poly (\begin{DoxyParamCaption}\item[{PHEAD WORD $\ast$}]{term,  }\item[{WORD}]{par }\end{DoxyParamCaption})}

Routine checks whether the count of function AR.\+Poly\+Fun is zero or one. If it is one and it has one scalarlike argument the coefficient of the term is pulled inside the argument. If the count is zero a new function is made with the coefficient as its only argument. The function should be placed at its proper position.

When this function is active it places the Poly\+Fun as last object before the coefficient. This is needed because otherwise the compress algorithm has problems in Merge\+Patches.

The bracket routine should also place the Poly\+Fun at a comparable spot. The compression should then stop at the Poly\+Fun. It doesn\textquotesingle{}t really have to stop when writing the final result but this may be too complicated.

The parameter par tells whether we are at groundlevel or inside a function or dollar variable. 

Definition at line 4744 of file proces.\+c.

\mbox{\Hypertarget{proces_8c_af03a5704a977a0cadefbf41b6832025b}\label{proces_8c_af03a5704a977a0cadefbf41b6832025b}} 
\index{proces.c@{proces.c}!PolyFunMul@{PolyFunMul}}
\index{PolyFunMul@{PolyFunMul}!proces.c@{proces.c}}
\doxysubsubsection{\texorpdfstring{PolyFunMul()}{PolyFunMul()}}
{\footnotesize\ttfamily WORD Poly\+Fun\+Mul (\begin{DoxyParamCaption}\item[{PHEAD WORD $\ast$}]{term }\end{DoxyParamCaption})}

Multiplies the arguments of multiple occurrences of the polyfun. In this routine we do the original Poly\+Fun with one argument only. The Poly\+Rat\+Fun (Poly\+Fun\+Type = 2) is done in a dedicated routine in the file \mbox{\hyperlink{polywrap_8cc}{polywrap.\+cc}} The new result is written over the old result.


\begin{DoxyParams}{Parameters}
{\em term} & It contains the input term and later the output. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Normal conventions (OK = 0). 
\end{DoxyReturn}


Definition at line 5132 of file proces.\+c.

