\hypertarget{sort_8c}{}\doxysection{sort.\+c File Reference}
\label{sort_8c}\index{sort.c@{sort.c}}
{\ttfamily \#include \char`\"{}form3.\+h\char`\"{}}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{sort_8c_a3cec6a8469c5202341e4ec3cd5b5158f}\label{sort_8c_a3cec6a8469c5202341e4ec3cd5b5158f}} 
\#define {\bfseries N\+E\+W\+S\+P\+L\+I\+T\+M\+E\+R\+GE}
\item 
\mbox{\Hypertarget{sort_8c_afb15c27bdc04b9176743f65d1ff3fd39}\label{sort_8c_afb15c27bdc04b9176743f65d1ff3fd39}} 
\#define {\bfseries I\+N\+S\+L\+E\+N\+G\+TH}(x)~w\mbox{[}1\mbox{]} = F\+U\+N\+H\+E\+AD+A\+R\+G\+H\+E\+AD+x; w\mbox{[}F\+U\+N\+H\+E\+AD\mbox{]} = A\+R\+G\+H\+E\+AD+x;
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
V\+O\+ID \mbox{\hyperlink{sort_8c_ac9d4907e604906152f2561e123434519}{Write\+Stats}} (\mbox{\hyperlink{structPoSiTiOn}{P\+O\+S\+I\+T\+I\+ON}} $\ast$plspace, W\+O\+RD par)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_a41a6fb48e7021f221c53df558baee3bc}{New\+Sort}} (P\+H\+E\+A\+D0)
\item 
L\+O\+NG \mbox{\hyperlink{sort_8c_a2e9216c6a29ab7719f0d37cb2b51d361}{End\+Sort}} (P\+H\+E\+AD W\+O\+RD $\ast$buffer, int par)
\item 
L\+O\+NG \mbox{\hyperlink{sort_8c_a0c7178b3e8a23956c3f252af74948681}{Put\+In}} (\mbox{\hyperlink{structs_8h_acfdc9b730744e2cd3cdff195b7f98166}{F\+I\+L\+E\+H\+A\+N\+D\+LE}} $\ast$file, \mbox{\hyperlink{structPoSiTiOn}{P\+O\+S\+I\+T\+I\+ON}} $\ast$position, W\+O\+RD $\ast$buffer, W\+O\+RD $\ast$$\ast$take, int npat)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_a1c0b32dbf3df6772a6e730c26863a97e}{Sflush}} (\mbox{\hyperlink{structs_8h_acfdc9b730744e2cd3cdff195b7f98166}{F\+I\+L\+E\+H\+A\+N\+D\+LE}} $\ast$fi)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_a911e7252a3311fdd541e91d7a874b56b}{Put\+Out}} (P\+H\+E\+AD W\+O\+RD $\ast$term, \mbox{\hyperlink{structPoSiTiOn}{P\+O\+S\+I\+T\+I\+ON}} $\ast$position, \mbox{\hyperlink{structs_8h_acfdc9b730744e2cd3cdff195b7f98166}{F\+I\+L\+E\+H\+A\+N\+D\+LE}} $\ast$fi, W\+O\+RD ncomp)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_a2fbe76f255d33036140255457662930e}{Flush\+Out}} (\mbox{\hyperlink{structPoSiTiOn}{P\+O\+S\+I\+T\+I\+ON}} $\ast$position, \mbox{\hyperlink{structs_8h_acfdc9b730744e2cd3cdff195b7f98166}{F\+I\+L\+E\+H\+A\+N\+D\+LE}} $\ast$fi, int compr)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_ae0b20d2b5a97d8aeccd497d1adaa8302}{Add\+Coef}} (P\+H\+E\+AD W\+O\+RD $\ast$$\ast$ps1, W\+O\+RD $\ast$$\ast$ps2)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_a7171afcad3c9f5f529eaa94ba6175c2a}{Add\+Poly}} (P\+H\+E\+AD W\+O\+RD $\ast$$\ast$ps1, W\+O\+RD $\ast$$\ast$ps2)
\item 
V\+O\+ID \mbox{\hyperlink{sort_8c_ae36114ce5e26fea98876b640b3609cbf}{Add\+Args}} (P\+H\+E\+AD W\+O\+RD $\ast$s1, W\+O\+RD $\ast$s2, W\+O\+RD $\ast$m)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_abb46b460907cf1caacd072dafaea4c01}{Compare1}} (W\+O\+RD $\ast$term1, W\+O\+RD $\ast$term2, W\+O\+RD level)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_ad62064d4c0b0df17648c179547133d78}{Compare\+Symbols}} (W\+O\+RD $\ast$term1, W\+O\+RD $\ast$term2, W\+O\+RD par)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_a0d2385166b984e0decd4005f4b898a4e}{Compare\+H\+Symbols}} (W\+O\+RD $\ast$term1, W\+O\+RD $\ast$term2, W\+O\+RD par)
\item 
L\+O\+NG \mbox{\hyperlink{sort_8c_a77e8fbe2d8d79e21021a924fa30e5d65}{Com\+Press}} (W\+O\+RD $\ast$$\ast$ss, L\+O\+NG $\ast$n)
\item 
L\+O\+NG \mbox{\hyperlink{sort_8c_a1406ab273f5f7b7dfed046e1b243bb1e}{Split\+Merge}} (P\+H\+E\+AD W\+O\+RD $\ast$$\ast$Pointer, L\+O\+NG number)
\item 
V\+O\+ID \mbox{\hyperlink{sort_8c_a16d18710edf5f69660853b9dae78e8b3}{Garb\+Hand}} ()
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_a670aa98242104557b1bbbb5368cafe8e}{Merge\+Patches}} (W\+O\+RD par)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_a6848642c1c54636cc54fbcec683607f5}{Store\+Term}} (P\+H\+E\+AD W\+O\+RD $\ast$term)
\item 
V\+O\+ID \mbox{\hyperlink{sort_8c_ad756bbef980a939c623c0f93c390e585}{Stage\+Sort}} (\mbox{\hyperlink{structs_8h_acfdc9b730744e2cd3cdff195b7f98166}{F\+I\+L\+E\+H\+A\+N\+D\+LE}} $\ast$fout)
\item 
W\+O\+RD \mbox{\hyperlink{sort_8c_a30d9949d945319a088d33b5969925e08}{Sort\+Wild}} (W\+O\+RD $\ast$w, W\+O\+RD nw)
\item 
void \mbox{\hyperlink{sort_8c_ab0bf76b7c13a32df1744703bb5585270}{Clean\+Up\+Sort}} (int num)
\item 
V\+O\+ID \mbox{\hyperlink{sort_8c_a193c49bbf56940bfd6f3f476aadc3d11}{Lower\+Sort\+Level}} ()
\item 
\mbox{\Hypertarget{sort_8c_adcefbaa2c1fb9737e4b48e0cef405501}\label{sort_8c_adcefbaa2c1fb9737e4b48e0cef405501}} 
W\+O\+RD $\ast$ {\bfseries Poly\+Rat\+Fun\+Special} (P\+H\+E\+AD W\+O\+RD $\ast$t1, W\+O\+RD $\ast$t2)
\item 
\mbox{\Hypertarget{sort_8c_a7cd1324d7abcddae4c55ae2651aee0d3}\label{sort_8c_a7cd1324d7abcddae4c55ae2651aee0d3}} 
V\+O\+ID {\bfseries Simple\+Split\+Merge\+Rec} (W\+O\+RD $\ast$array, W\+O\+RD num, W\+O\+RD $\ast$auxarray)
\item 
\mbox{\Hypertarget{sort_8c_a08c64a399cf290022052f7cf895d2481}\label{sort_8c_a08c64a399cf290022052f7cf895d2481}} 
V\+O\+ID {\bfseries Simple\+Split\+Merge} (W\+O\+RD $\ast$array, W\+O\+RD num)
\item 
\mbox{\Hypertarget{sort_8c_a42357c67932cd6af49574ce9c0739d44}\label{sort_8c_a42357c67932cd6af49574ce9c0739d44}} 
W\+O\+RD {\bfseries Binary\+Search} (W\+O\+RD $\ast$array, W\+O\+RD num, W\+O\+RD x)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{sort_8c_ad8d9b43e3006411637608918d171ed05}\label{sort_8c_ad8d9b43e3006411637608918d171ed05}} 
L\+O\+NG {\bfseries numcompares}
\item 
\mbox{\Hypertarget{sort_8c_abc1173f5fb8610bfebbfa81d95727790}\label{sort_8c_abc1173f5fb8610bfebbfa81d95727790}} 
char $\ast$ {\bfseries toterms} \mbox{[}$\,$\mbox{]} = \{ \char`\"{} \char`\"{}, \char`\"{} $>$$>$\char`\"{}, \char`\"{}-\/-\/$>$\char`\"{} \}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Contains the sort routines. We distinguish levels of sorting. The ground level is the sorting of terms in an expression. When a term has functions, the arguments can contain terms that need sorting, which this then done by raising the level. This can happen recursively. New\+Sort and End\+Sort automatically raise and lower the level. Because the ground level does some special things, sometimes we have to raise immediately to the second level skipping the ground level.

Special routines for the parallel sorting are in the file \mbox{\hyperlink{threads_8c}{threads.\+c}} Also the sorting of terms in polynomials is special but most of that is controled by changing the address of the compare routine. Other routines relevant for adding rational polynomials are in the file polynito.\+c 

\doxysubsection{Function Documentation}
\mbox{\Hypertarget{sort_8c_ac9d4907e604906152f2561e123434519}\label{sort_8c_ac9d4907e604906152f2561e123434519}} 
\index{sort.c@{sort.c}!WriteStats@{WriteStats}}
\index{WriteStats@{WriteStats}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{WriteStats()}{WriteStats()}}
{\footnotesize\ttfamily V\+O\+ID Write\+Stats (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structPoSiTiOn}{P\+O\+S\+I\+T\+I\+ON}} $\ast$}]{plspace,  }\item[{W\+O\+RD}]{par }\end{DoxyParamCaption})}

Writes the statistics.


\begin{DoxyParams}{Parameters}
{\em plspace} & The size in bytes currently occupied \\
\hline
{\em par} & par = 0 after a splitmerge. par = 1 after merge to sortfile. par = 2 after the sort\\
\hline
\end{DoxyParams}
current expression is to be found in A\+R.\+Cur\+Expr. terms are in S-\/$>$Terms\+Left. S-\/$>$Gen\+Terms. 

Definition at line 93 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a41a6fb48e7021f221c53df558baee3bc}\label{sort_8c_a41a6fb48e7021f221c53df558baee3bc}} 
\index{sort.c@{sort.c}!NewSort@{NewSort}}
\index{NewSort@{NewSort}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{NewSort()}{NewSort()}}
{\footnotesize\ttfamily W\+O\+RD New\+Sort (\begin{DoxyParamCaption}\item[{P\+H\+E\+A\+D0}]{ }\end{DoxyParamCaption})}

Starts a new sort. At the lowest level this is a \textquotesingle{}main sort\textquotesingle{} with the struct according to the parameters in S0. At higher levels this is a sort for functions, subroutines or dollars. We prepare the arrays and structs.

\begin{DoxyReturn}{Returns}
Regular convention (OK -\/$>$ 0) 
\end{DoxyReturn}


Definition at line 591 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a2e9216c6a29ab7719f0d37cb2b51d361}\label{sort_8c_a2e9216c6a29ab7719f0d37cb2b51d361}} 
\index{sort.c@{sort.c}!EndSort@{EndSort}}
\index{EndSort@{EndSort}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{EndSort()}{EndSort()}}
{\footnotesize\ttfamily L\+O\+NG End\+Sort (\begin{DoxyParamCaption}\item[{P\+H\+E\+AD W\+O\+RD $\ast$}]{buffer,  }\item[{int}]{par }\end{DoxyParamCaption})}

Finishes a sort. At A\+R.\+s\+Level == 0 the output is to the regular output stream. When A\+R.\+s\+Level $>$ 0, the parameter par determines the actual output. The A\+R.\+s\+Level will be popped. All ongoing stages are finished and if the sortfile is open it is closed. The statistics are printed when A\+R.\+s\+Level == 0 par == 0 Output to the buffer. par == 1 Sort for function arguments. The output will be copied into the buffer. It is assumed that this is in the Work\+Space. par == 2 Sort for \$-\/variable. We return the address of the buffer that contains the output in buffer (treated like W\+O\+RD $\ast$$\ast$). We first catch the output in a file (unless we can intercept things after the small buffer has been sorted) Then we read from the file into a buffer. Only when par == 0 data compression can be attempted at A\+T.\+SS==A\+T.\+S0.


\begin{DoxyParams}{Parameters}
{\em buffer} & buffer for output when needed \\
\hline
{\em par} & See above \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
If negative\+: error. If positive\+: number of words in output. 
\end{DoxyReturn}


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

\mbox{\Hypertarget{sort_8c_a0c7178b3e8a23956c3f252af74948681}\label{sort_8c_a0c7178b3e8a23956c3f252af74948681}} 
\index{sort.c@{sort.c}!PutIn@{PutIn}}
\index{PutIn@{PutIn}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{PutIn()}{PutIn()}}
{\footnotesize\ttfamily L\+O\+NG Put\+In (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structs_8h_acfdc9b730744e2cd3cdff195b7f98166}{F\+I\+L\+E\+H\+A\+N\+D\+LE}} $\ast$}]{file,  }\item[{\mbox{\hyperlink{structPoSiTiOn}{P\+O\+S\+I\+T\+I\+ON}} $\ast$}]{position,  }\item[{W\+O\+RD $\ast$}]{buffer,  }\item[{W\+O\+RD $\ast$$\ast$}]{take,  }\item[{int}]{npat }\end{DoxyParamCaption})}

Reads a new patch from position in file handle. It is put at buffer, anything after take is moved forward. This would be part of a term that hasn\textquotesingle{}t been used yet. Because of this there should be some space before the start of the buffer


\begin{DoxyParams}{Parameters}
{\em file} & The file system from which to read \\
\hline
{\em position} & The position from which to read \\
\hline
{\em buffer} & The buffer into which to read \\
\hline
{\em take} & The unused tail should be moved before the buffer \\
\hline
{\em npat} & The number of the patch. Is needed if the information was compressed with gzip, because each patch has its own independent gzip encoding. \\
\hline
\end{DoxyParams}


Definition at line 1258 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a1c0b32dbf3df6772a6e730c26863a97e}\label{sort_8c_a1c0b32dbf3df6772a6e730c26863a97e}} 
\index{sort.c@{sort.c}!Sflush@{Sflush}}
\index{Sflush@{Sflush}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{Sflush()}{Sflush()}}
{\footnotesize\ttfamily W\+O\+RD Sflush (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structs_8h_acfdc9b730744e2cd3cdff195b7f98166}{F\+I\+L\+E\+H\+A\+N\+D\+LE}} $\ast$}]{fi }\end{DoxyParamCaption})}

Puts the contents of a buffer to output Only to be used when there is a single patch in the large buffer.


\begin{DoxyParams}{Parameters}
{\em fi} & The filesystem (or its cache) to which the patch should be written \\
\hline
\end{DoxyParams}


Definition at line 1318 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a911e7252a3311fdd541e91d7a874b56b}\label{sort_8c_a911e7252a3311fdd541e91d7a874b56b}} 
\index{sort.c@{sort.c}!PutOut@{PutOut}}
\index{PutOut@{PutOut}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{PutOut()}{PutOut()}}
{\footnotesize\ttfamily W\+O\+RD Put\+Out (\begin{DoxyParamCaption}\item[{P\+H\+E\+AD W\+O\+RD $\ast$}]{term,  }\item[{\mbox{\hyperlink{structPoSiTiOn}{P\+O\+S\+I\+T\+I\+ON}} $\ast$}]{position,  }\item[{\mbox{\hyperlink{structs_8h_acfdc9b730744e2cd3cdff195b7f98166}{F\+I\+L\+E\+H\+A\+N\+D\+LE}} $\ast$}]{fi,  }\item[{W\+O\+RD}]{ncomp }\end{DoxyParamCaption})}

Routine writes one term to file handle at position. It returns the new value of the position.

N\+O\+TE\+: For \textquotesingle{}final output\textquotesingle{} we may have to index the brackets. See the struct B\+R\+A\+C\+K\+E\+T\+I\+N\+D\+EX. We should maintain\+: 1\+: a list with brackets array with the brackets 2\+: a list of objects of type B\+R\+A\+C\+K\+E\+T\+I\+N\+D\+EX. It contains array with either pointers or offsets to the list of brackets. starting positions in the file. The index may be tied to a maximum size. In that case we may have to prune the list occasionally.


\begin{DoxyParams}{Parameters}
{\em term} & The term to be written \\
\hline
{\em position} & The position in the file. Afterwards it is updated \\
\hline
{\em fi} & The file (or its cache) to which should be written \\
\hline
{\em ncomp} & Information about what type of compression should be used \\
\hline
\end{DoxyParams}


Definition at line 1404 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a2fbe76f255d33036140255457662930e}\label{sort_8c_a2fbe76f255d33036140255457662930e}} 
\index{sort.c@{sort.c}!FlushOut@{FlushOut}}
\index{FlushOut@{FlushOut}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{FlushOut()}{FlushOut()}}
{\footnotesize\ttfamily W\+O\+RD Flush\+Out (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structPoSiTiOn}{P\+O\+S\+I\+T\+I\+ON}} $\ast$}]{position,  }\item[{\mbox{\hyperlink{structs_8h_acfdc9b730744e2cd3cdff195b7f98166}{F\+I\+L\+E\+H\+A\+N\+D\+LE}} $\ast$}]{fi,  }\item[{int}]{compr }\end{DoxyParamCaption})}

Completes output to an output file and writes the trailing zero.


\begin{DoxyParams}{Parameters}
{\em position} & The position in the file after writing \\
\hline
{\em fi} & The file (or its cache) \\
\hline
{\em compr} & Indicates whether there should be compression with gzip. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Regular conventions (OK -\/$>$ 0). 
\end{DoxyReturn}


Definition at line 1747 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_ae0b20d2b5a97d8aeccd497d1adaa8302}\label{sort_8c_ae0b20d2b5a97d8aeccd497d1adaa8302}} 
\index{sort.c@{sort.c}!AddCoef@{AddCoef}}
\index{AddCoef@{AddCoef}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{AddCoef()}{AddCoef()}}
{\footnotesize\ttfamily W\+O\+RD Add\+Coef (\begin{DoxyParamCaption}\item[{P\+H\+E\+AD W\+O\+RD $\ast$$\ast$}]{ps1,  }\item[{W\+O\+RD $\ast$$\ast$}]{ps2 }\end{DoxyParamCaption})}

Adds the coefficients of the terms $\ast$ps1 and $\ast$ps2. The problem comes when there is not enough space for a new longer coefficient. First a local solution is tried. If this is not succesfull we need to move terms around. The possibility of a garbage collection should not be ignored, as avoiding this costs very much extra space which is nearly wasted otherwise.

If the return value is zero the terms cancelled.

The resulting term is left in $\ast$ps1. 

Definition at line 1961 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a7171afcad3c9f5f529eaa94ba6175c2a}\label{sort_8c_a7171afcad3c9f5f529eaa94ba6175c2a}} 
\index{sort.c@{sort.c}!AddPoly@{AddPoly}}
\index{AddPoly@{AddPoly}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{AddPoly()}{AddPoly()}}
{\footnotesize\ttfamily W\+O\+RD Add\+Poly (\begin{DoxyParamCaption}\item[{P\+H\+E\+AD W\+O\+RD $\ast$$\ast$}]{ps1,  }\item[{W\+O\+RD $\ast$$\ast$}]{ps2 }\end{DoxyParamCaption})}

Routine should be called when S-\/$>$Poly\+Wise != 0. It points then to the position of A\+R.\+Poly\+Fun in both terms.

We add the contents of the arguments of the two polynomials. Special attention has to be given to special arguments. We have to reserve a space equal to the size of one term + the size of the argument of the other. The addition has to be done in this routine because not all objects are reentrant.

Newer addition (12-\/nov-\/2007). The Poly\+Fun can have two arguments. In that case S-\/$>$Poly\+Flag is 2 and we have to call the routine for adding rational polynomials. We have to be rather careful what happens with\+: The location of the output The order of the terms in the arguments At first we allow only univariate polynomials in the Poly\+Fun. This restriction will be lifted a.\+s.\+a.\+p.


\begin{DoxyParams}{Parameters}
{\em ps1} & A pointer to the postion of the first term \\
\hline
{\em ps2} & A pointer to the postion of the second term \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
If zero the terms cancel. Otherwise the new term is in $\ast$ps1. 
\end{DoxyReturn}


Definition at line 2088 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_ae36114ce5e26fea98876b640b3609cbf}\label{sort_8c_ae36114ce5e26fea98876b640b3609cbf}} 
\index{sort.c@{sort.c}!AddArgs@{AddArgs}}
\index{AddArgs@{AddArgs}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{AddArgs()}{AddArgs()}}
{\footnotesize\ttfamily V\+O\+ID Add\+Args (\begin{DoxyParamCaption}\item[{P\+H\+E\+AD W\+O\+RD $\ast$}]{s1,  }\item[{W\+O\+RD $\ast$}]{s2,  }\item[{W\+O\+RD $\ast$}]{m }\end{DoxyParamCaption})}

Adds the arguments of two occurrences of the Poly\+Fun. 
\begin{DoxyParams}{Parameters}
{\em s1} & Pointer to the first occurrence. \\
\hline
{\em s2} & Pointer to the second occurrence. \\
\hline
{\em m} & Pointer to where the answer should be. \\
\hline
\end{DoxyParams}


Definition at line 2250 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_abb46b460907cf1caacd072dafaea4c01}\label{sort_8c_abb46b460907cf1caacd072dafaea4c01}} 
\index{sort.c@{sort.c}!Compare1@{Compare1}}
\index{Compare1@{Compare1}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{Compare1()}{Compare1()}}
{\footnotesize\ttfamily W\+O\+RD Compare1 (\begin{DoxyParamCaption}\item[{W\+O\+RD $\ast$}]{term1,  }\item[{W\+O\+RD $\ast$}]{term2,  }\item[{W\+O\+RD}]{level }\end{DoxyParamCaption})}

Compares two terms. The answer is\+: 0 equal ( with exception of the coefficient if level == 0. ) $>$0 term1 comes first. $<$0 term2 comes first. Some special precautions may be needed to keep the Comp\+Coef routine from generating overflows, although this is very unlikely in subterms. This routine should not return an error condition.

Originally this routine was called Compare. With the treatment of special polynomials with terms that contain only symbols and the need for extreme speed for the polynomial routines we made a special compare routine and now we store the address of the current compare routine in A\+R.\+Compare\+Routine and have a macro Compare which makes all existing code work properly and we can just replace the routine on a thread by thread basis (each thread has its own AR struct).


\begin{DoxyParams}{Parameters}
{\em term1} & First input term \\
\hline
{\em term2} & Second input term \\
\hline
{\em level} & The sorting level (may influence on the result) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 equal ( with exception of the coefficient if level == 0. ) $>$0 term1 comes first. $<$0 term2 comes first. 
\end{DoxyReturn}


Definition at line 2535 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_ad62064d4c0b0df17648c179547133d78}\label{sort_8c_ad62064d4c0b0df17648c179547133d78}} 
\index{sort.c@{sort.c}!CompareSymbols@{CompareSymbols}}
\index{CompareSymbols@{CompareSymbols}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{CompareSymbols()}{CompareSymbols()}}
{\footnotesize\ttfamily W\+O\+RD Compare\+Symbols (\begin{DoxyParamCaption}\item[{W\+O\+RD $\ast$}]{term1,  }\item[{W\+O\+RD $\ast$}]{term2,  }\item[{W\+O\+RD}]{par }\end{DoxyParamCaption})}

Compares the terms, based on the value of A\+N.\+polysortflag. If term1 $<$ term2 the return value is -\/1 If term1 $>$ term2 the return value is 1 If term1 = term2 the return value is 0 The coefficients may differ. The terms contain only a single subterm of type S\+Y\+M\+B\+OL. If A\+N.\+polysortflag = 0 it is a \textquotesingle{}regular\textquotesingle{} compare. If A\+N.\+polysortflag = 1 the sum of the powers is more important par is a dummy parameter to make the parameter field identical to that of Compare1 which is the regular compare routine in \mbox{\hyperlink{sort_8c}{sort.\+c}} 

Definition at line 2975 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a0d2385166b984e0decd4005f4b898a4e}\label{sort_8c_a0d2385166b984e0decd4005f4b898a4e}} 
\index{sort.c@{sort.c}!CompareHSymbols@{CompareHSymbols}}
\index{CompareHSymbols@{CompareHSymbols}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{CompareHSymbols()}{CompareHSymbols()}}
{\footnotesize\ttfamily W\+O\+RD Compare\+H\+Symbols (\begin{DoxyParamCaption}\item[{W\+O\+RD $\ast$}]{term1,  }\item[{W\+O\+RD $\ast$}]{term2,  }\item[{W\+O\+RD}]{par }\end{DoxyParamCaption})}

Compares terms that can have only S\+Y\+M\+B\+OL and H\+A\+A\+K\+JE subterms. If term1 $<$ term2 the return value is -\/1 If term1 $>$ term2 the return value is 1 If term1 = term2 the return value is 0 par is a dummy parameter to make the parameter field identical to that of Compare1 which is the regular compare routine in \mbox{\hyperlink{sort_8c}{sort.\+c}} 

Definition at line 3019 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a77e8fbe2d8d79e21021a924fa30e5d65}\label{sort_8c_a77e8fbe2d8d79e21021a924fa30e5d65}} 
\index{sort.c@{sort.c}!ComPress@{ComPress}}
\index{ComPress@{ComPress}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{ComPress()}{ComPress()}}
{\footnotesize\ttfamily L\+O\+NG Com\+Press (\begin{DoxyParamCaption}\item[{W\+O\+RD $\ast$$\ast$}]{ss,  }\item[{L\+O\+NG $\ast$}]{n }\end{DoxyParamCaption})}

Gets a list of pointers to terms and compresses the terms. In n it collects the number of terms and the return value of the function is the space that is occupied.

We have to pay some special attention to the compression of terms with a Poly\+Fun. This Poly\+Fun should occur only straight before the coefficient, so we can use the same trick as for the coefficient to sabotage compression of this object (Replace in the history the function pointer by zero. This is safe, because terms that would be identical otherwise would have been added).


\begin{DoxyParams}{Parameters}
{\em ss} & Array of pointers to terms to be compressed. \\
\hline
{\em n} & Number of pointers in ss. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Total number of words needed for the compressed result. 
\end{DoxyReturn}


Definition at line 3073 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a1406ab273f5f7b7dfed046e1b243bb1e}\label{sort_8c_a1406ab273f5f7b7dfed046e1b243bb1e}} 
\index{sort.c@{sort.c}!SplitMerge@{SplitMerge}}
\index{SplitMerge@{SplitMerge}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{SplitMerge()}{SplitMerge()}}
{\footnotesize\ttfamily L\+O\+NG Split\+Merge (\begin{DoxyParamCaption}\item[{P\+H\+E\+AD W\+O\+RD $\ast$$\ast$}]{Pointer,  }\item[{L\+O\+NG}]{number }\end{DoxyParamCaption})}

Algorithm by J.\+A.\+M.\+Vermaseren (31-\/7-\/1988)

Note that A\+N.\+Split\+Scratch and A\+N.\+In\+Scratch are used also in Garb\+Hand

Merge sort in memory. The input is an array of pointers. Sorting is done recursively by dividing the array in two equal parts and calling Split\+Merge for each. When the parts are small enough we can do the compare and take the appropriate action. An addition is that we look for \textquotesingle{}runs\textquotesingle{}. Sequences that are already ordered. This happens a lot when there is very little action in a module. This made F\+O\+RM faster by a few percent.


\begin{DoxyParams}{Parameters}
{\em Pointer} & The array of pointers to the terms to be sorted. \\
\hline
{\em number} & The number of pointers in Pointer.\\
\hline
\end{DoxyParams}
The terms are supposed to be sitting in the small buffer and there is supposed to be an extension to this buffer for when there are two terms that should be added and the result takes more space than each of the original terms. The notation guarantees that the result never needs more space than the sum of the spaces of the original terms. 

Definition at line 3239 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a16d18710edf5f69660853b9dae78e8b3}\label{sort_8c_a16d18710edf5f69660853b9dae78e8b3}} 
\index{sort.c@{sort.c}!GarbHand@{GarbHand}}
\index{GarbHand@{GarbHand}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{GarbHand()}{GarbHand()}}
{\footnotesize\ttfamily V\+O\+ID Garb\+Hand (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}

Garbage collection that takes place when the small extension is full and we need to place more terms there. When this is the case there are many holes in the small buffer and the whole can be compactified. The major complication is the buffer for Split\+Merge. There are to options for temporary memory\+: 1\+: find some buffer that has enough space (maybe in the large buffer). 2\+: allocate a buffer. Give it back afterwards of course. If the small extension is properly dimensioned this routine should be called very rarely. Most of the time it will be called when the polyfun or polyratfun is active. 

Definition at line 3461 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a670aa98242104557b1bbbb5368cafe8e}\label{sort_8c_a670aa98242104557b1bbbb5368cafe8e}} 
\index{sort.c@{sort.c}!MergePatches@{MergePatches}}
\index{MergePatches@{MergePatches}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{MergePatches()}{MergePatches()}}
{\footnotesize\ttfamily W\+O\+RD Merge\+Patches (\begin{DoxyParamCaption}\item[{W\+O\+RD}]{par }\end{DoxyParamCaption})}

The general merge routine. Can be used for the large buffer and the file merging. The array S-\/$>$Patches tells where the patches start S-\/$>$p\+Stop tells where they end (has to be computed first). The end of a \textquotesingle{}line to be merged\textquotesingle{} is indicated by a zero. If the end is reached without running into a zero or a term runs over the boundary of a patch it is a file merging operation and a new piece from the file is read in.


\begin{DoxyParams}{Parameters}
{\em par} & If par == 0 the sort is for file -\/$>$ outputfile. If par == 1 the sort is for large buffer -\/$>$ sortfile. If par == 2 the sort is for large buffer -\/$>$ outputfile. \\
\hline
\end{DoxyParams}


Definition at line 3576 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a6848642c1c54636cc54fbcec683607f5}\label{sort_8c_a6848642c1c54636cc54fbcec683607f5}} 
\index{sort.c@{sort.c}!StoreTerm@{StoreTerm}}
\index{StoreTerm@{StoreTerm}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{StoreTerm()}{StoreTerm()}}
{\footnotesize\ttfamily W\+O\+RD Store\+Term (\begin{DoxyParamCaption}\item[{P\+H\+E\+AD W\+O\+RD $\ast$}]{term }\end{DoxyParamCaption})}

The central routine to accept terms, store them and keep things at least partially sorted. A call to End\+Sort will then complete storing and sorting.


\begin{DoxyParams}{Parameters}
{\em term} & The term to be stored \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Regular return conventions (OK -\/$>$ 0) 
\end{DoxyReturn}


Definition at line 4332 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_ad756bbef980a939c623c0f93c390e585}\label{sort_8c_ad756bbef980a939c623c0f93c390e585}} 
\index{sort.c@{sort.c}!StageSort@{StageSort}}
\index{StageSort@{StageSort}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{StageSort()}{StageSort()}}
{\footnotesize\ttfamily V\+O\+ID Stage\+Sort (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structs_8h_acfdc9b730744e2cd3cdff195b7f98166}{F\+I\+L\+E\+H\+A\+N\+D\+LE}} $\ast$}]{fout }\end{DoxyParamCaption})}

Prepares a stage 4 or higher sort. Stage 4 sorts occur when the sort file contains more patches than can be merged in one pass. 

Definition at line 4452 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a30d9949d945319a088d33b5969925e08}\label{sort_8c_a30d9949d945319a088d33b5969925e08}} 
\index{sort.c@{sort.c}!SortWild@{SortWild}}
\index{SortWild@{SortWild}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{SortWild()}{SortWild()}}
{\footnotesize\ttfamily W\+O\+RD Sort\+Wild (\begin{DoxyParamCaption}\item[{W\+O\+RD $\ast$}]{w,  }\item[{W\+O\+RD}]{nw }\end{DoxyParamCaption})}

Sorts the wildcard entries in the parameter w. Double entries are removed. Full space taken is nw words. Routine serves for the reading of wildcards in the compiler. The entries come in the format\+: (type,4,number,0) in which the zero is reserved for the future replacement of \textquotesingle{}number\textquotesingle{}.


\begin{DoxyParams}{Parameters}
{\em w} & buffer with wildcard entries. \\
\hline
{\em nw} & number of wildcard entries. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Normal conventions (OK -\/$>$ 0) 
\end{DoxyReturn}


Definition at line 4551 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_ab0bf76b7c13a32df1744703bb5585270}\label{sort_8c_ab0bf76b7c13a32df1744703bb5585270}} 
\index{sort.c@{sort.c}!CleanUpSort@{CleanUpSort}}
\index{CleanUpSort@{CleanUpSort}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{CleanUpSort()}{CleanUpSort()}}
{\footnotesize\ttfamily void Clean\+Up\+Sort (\begin{DoxyParamCaption}\item[{int}]{num }\end{DoxyParamCaption})}

Partially or completely frees function sort buffers. 

Definition at line 4643 of file sort.\+c.

\mbox{\Hypertarget{sort_8c_a193c49bbf56940bfd6f3f476aadc3d11}\label{sort_8c_a193c49bbf56940bfd6f3f476aadc3d11}} 
\index{sort.c@{sort.c}!LowerSortLevel@{LowerSortLevel}}
\index{LowerSortLevel@{LowerSortLevel}!sort.c@{sort.c}}
\doxysubsubsection{\texorpdfstring{LowerSortLevel()}{LowerSortLevel()}}
{\footnotesize\ttfamily V\+O\+ID Lower\+Sort\+Level (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}

Lowers the level in the sort system. 

Definition at line 4726 of file sort.\+c.

