Skip to topic | Skip to bottom

Arthur.NumericalProgrammingr1.3 - 07 Apr 2007 - 12:54 - ArthurVanDamtopic end

Start of topic | Skip to actions

Numerical Programming

Again, a page with just some handy tricks I found out in practice. This page mainly serves as a scrapbook for my personal use.


I used to have problems with dense adaptive mesh pictures in beamer presentations, but now I found a workable solution: Mesh graphics without moiré

Data files

Formatted IO

Long exponentials

For very big or very small numbers, i.e. where the exponent has more than two digits, FORTRAN is quite flexible in its output. It is able to drop the character `E` in the number and still understand it: '1.234E-167' is the same as '1.234-167'. I am only talking about formatted READ and WRITE here, not FORTRAN code! Read more at

My problems was: when reading FORTRAN produced data files in C (actually MATLAB), the dropped 'E' causes problems. A dirty workaround is to drop the least significant digit in the number and replace it by an 'E':

$ echo '123+12 45 .33 -.34-5 67E+5 89-167 8.00349801-289' | \
    sed -e 's/\(\.[0-9]*\)[0-9]\([-+]\)\([0-9]*\)/\1E\2\3/g'

This produces:
        123+12 45 .33 -.3E-5 67E+5 89-167 8.0034980E-289

Note how I only replace numbers with a decimal point (replacing 89-167 by 8E-167 would be wrong). This is not too difficult, but still a todo...
to top

Arthur.NumericalProgramming r1.3 - 07 Apr 2007 - 12:54 - ArthurVanDam
Revisions: | r1.3 | > | r1.2 | > | r1.1 | Total page history

You are here: Arthur > NumericalProgramming