Iteration and exceeding TeX memory capacity

Denis Girou Denis.Girou at idris.fr
Thu Oct 7 18:29:50 CEST 1999


-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------

The following message is a courtesy copy of an article
that has been posted to comp.text.tex as well.

>>>>> "Maurizio.Vitale" == Maurizio Vitale <maurizio.vitale at ehv.sc.philips.com> writes:

    Maurizio.Vitale> I've tried your test program, but I still have problems with memory.
    Maurizio.Vitale> If I duplicate the \signals so that 48 signals are present (all of the 
    Maurizio.Vitale> same length, 14), my TeX gives up.
    Maurizio.Vitale> Recursion problems should be over when you finish the processing of
    Maurizio.Vitale> each \signal. Is it possible that the list being built for the output
    Maurizio.Vitale> routine is just too big?
    Maurizio.Vitale> Are there workarounds?
    Maurizio.Vitale> Thanks again for the help,
    Maurizio.Vitale> -- 
    Maurizio.Vitale> Maurizio Vitale

  In your case, you can drastically reduce the memory requirements using the
low level \lineto macro (which require to open a \pscustom macro and to first
fix the current point using the \moveto macro).

  I just adapt the (good - as all what I see Heiko doing) idea and program
sent yesterday by Heiko Oberdiek.

  For instance for 30 signals of length 14, previous version used 239972 words
of memory and this one 80633 (this is the same ratio if you have very long
signals).

\documentclass{article}

\usepackage{pstcol}

\psset{unit=1ex}

\newcount\elcount
\newcount\Xresult

\makeatletter
\def\foreach#1#2{%
  \ifx\\#2\\%
  \else
    \@ReturnAfterFi{%
      \do at foreach{#2}#1\@nil
    }%
  \fi
}
\def\do at foreach#1#2#3\@nil{%
  #1#2%
  \ifx\\#3\\%
  \else
    \@ReturnAfterFi{%
      \do at foreach{#1}#3\@nil
    }%
  \fi
}
\long\def\@ReturnAfterFi#1\fi{\fi#1}
\makeatother

\def\lambda#1{\csname do#1\endcsname}

\expandafter\def\csname do.\endcsname{\OneSignal{0}}
\expandafter\def\csname do-\endcsname{\OneSignal{1}}

\def\OneSignal#1{%
  \lineto(\the\elcount,#1)
  \advance\elcount by 1
  \lineto(\the\elcount,#1)
}

\def\signal#1#2{%
  #1 &
  \Xresult=0
  \foreach{#2}{\advance\Xresult by 1 }%
  \begin{pspicture}(\the\Xresult,1)
    \elcount=0
    \pscustom{%
      \moveto(0,0)
      \foreach{#2}{\lambda}}
  \end{pspicture}\\%
}

\begin{document}
\begin{tabular}{ll}
  \signal{XSUS\_G}{-........-----}
  \signal{XPR\_U}{.-----........}
\end{tabular}
\end{document}


Denis Girou
-- 
--------------------------------------------------------------------------
Institut du Développement et des Ressources en Informatique Scientifique |
Centre National de la Recherche Scientifique                             |
Bâtiment 506 - B.P. 167 - 91403 Orsay Cedex - France                     |
--------------------------------------------------------------------------

-----------------------------------------------------------------------------
The list interface (subscription, information, access to the archives) is on:
http://www.tug.org/cgi-bin/lwgate/pstricks
Otherway to unsubscribe, send mail to pstricks-request at mail.tug.org
with a blank subject and in body the line unsubscribe <email-address>
-----------------------------------------------------------------------------



More information about the PSTricks mailing list