Toby Thurston | 15 Aug 21:52 2015

Long numerical tokens with new number systems

The syntax for <numeric token> that MP inherits from Metafont allows for "one or more" decimal digits in the
fractional part of a number.  So it's legal to write:

numeric pi;
pi = 3.141592653589793238462643383279502884197169399375105820974944592;
show pi;

This works ok with all the number systems except "decimal" which complains about excessive precision.
Here's what I get with each number system

>> "scaled"
>> 3.14159 )

>> "double"
>> 3.1415926535897931 )

>> "binary"
>> 3.1415926535897932384626433832795028 )

>> "decimal"
! Number is too precise (numberprecision = 34).
l.80 ...643383279502884197169399375105820974944592
                                                  ;
?
>> 3.141592653589793238462643383279503 )

Doesn't this behaviour seem to be a bit inconsistent?

Clearly, with decimal it would be possible to avoid the error message by writing this sort of thing:

(Continue reading)

Olivier Péault | 13 Aug 17:09 2015
Picon

mpost or luamplib ?

Hello!
I'm looking for a way to know whether my metapost code is processed by
metapost itself or by luamplib in lualatex. Reading the luamplib code
(which I don't understand!!!) I found that the boolean mplib could do
the job. Is it right ? Can I be sure that if mplib exists and is true,
my code is processed by luamblib ?
Thank you in advance
--

-- 
Olivier
--
http://tug.org/metapost/

Toby Thurston | 4 Aug 17:41 2015

A modest proposal

Now that the higher precision number systems are maturing, and being used more, it might be a good time to
update "plain.mp" to remove the hard coded 5-figure decimals.  In all cases it's fairly easy to find an
equivalent definition which would work accurately at full numeric precision regardless of which engine
is being used.

The values I can see are 

> eps := .00049;    % this is a pretty small positive number
> infinity := 4095.99998;    % and this is the largest
> 
> .
> .
> .
> 
> %% units of measure
> 
> mm=2.83464;      pt=0.99626;        dd=1.06601;      bp:=1;
> cm=28.34645;     pc=11.95517;       cc=12.79213;     in:=72;
> 
> vardef magstep primary m = mexp(46.67432m) enddef;

The definition of epsilon shows us a better way

> epsilon := 1/256/256;   % but this is the smallest

Adopting that strategy we can write the following which work well regardless of number system

eps := 1/2048;
infinity := 64*64-epsilon;

(Continue reading)

Toby Thurston | 28 Jul 09:21 2015

Bug with simple number comparisons with new number systems

I'm getting strange results comparing numbers with the new number systems.

Consider this program:

    show 0.0001 < 0.001, numbersystem, mpversion; end.

With the default number system this gives

>> true
>> "scaled"
>> "1.999" )

on my log. But with the other number systems I get: 

>> true
>> "double"
>> "1.999" )

>> false
>> "binary"
>> "1.999" )

>> false
>> "decimal"
>> "1.999" )

which is a bit unexpected...

I'm using a version I compiled myself from source after you fixed the normaldeviate bug a couple of months ago.
Testing with V1.902, the only other version I have on hand, I only get the error with "decimal". But it does
(Continue reading)

Daniel H. Luecking | 3 Jun 00:16 2015
Picon

Change in behavior of booleans with numbersystem=decimal

Dear Metapostals:


I don't know whether --numbersystem=decimal is considered

ready to use, but I have observed some odd behavior for the

following file:


%test.mp

show known (0,0,.5,.5);

show cmykcolor (0,0,.5,.5);

end


The command

    mpost test

returns true and true, but the command

    mpost --numbersystem=decimal test

returns false and false. This is causing mfpic to fail when

the decimal numbersystem is used.


The fact that these are cmykcolor values seems to be irrelevant.

I get similar behavior with pairs and paths. The boolean

"known X" simply seems to not work. Also the booleans

"cmykcolor X", "pair X" and "path X" (those are the only

ones I've tried so far).


I'm using MetaPost, version 1.999 (TeX Live 2015/W32TeX)

under windows 7.



Thanks,



Daniel H. Luecking [luecking <at> uark.edu]
Graduate Coordinator
Department of Mathematical Sciences
1 University of Arkansas
Fayetteville, AR, USA 72701-1201
--
http://tug.org/metapost/
Toby Thurston | 19 May 12:44 2015

Testing with mpost compiled from trunk

I'd like to try out the latest version of mpost which contains a couple of fixes to bugs I've reported.

Can someone point me at a simple set of instructions for trying the new mpost executable without clobbering
my existing TeXLive distribution?

I have successfully cloned "trunk" into a local directory using anonymous svn and the build.sh ran without
error and produced a new mpost exectable in ./build/texk/web2c, and if I run "./build/texk/web2c/mpost
-v" I get

>  MetaPost 1.999 (TeX Live 2015) (kpathsea version 6.2.1)
>  etc...
>  etc...

as expected.

But if I try to run "./build/texk/web2c/mpost test.mp"  I get

> warning: kpathsea: configuration file texmf.cnf not found in these directories: [... long list of
directories under . ]
> Sorry, I can't find the 'mpost' preload file; will try 'plain'.
> 
> I can't find the 'plain' preload file!

and it stops.  So I guess I need to build a preload file or point it at one.  

Are the instructions documented somewhere?

Thanks Toby
--
http://tug.org/metapost/

Troy Henderson | 16 May 15:37 2015
Picon

Stroke Font

Is there a preferred method for converting a

btex Here is my sentence etex

from a picture to an array of closed paths that can be filled and stroked different colors?  Thus, I would like to convert the btex ... etex sentence picture into an array of outlines for each letter (in the current font) used in the sentence so that I can fill the outlines one color and draw them with another color.

Thanks in advance,

Troy Henderson
--
http://tug.org/metapost/
Karel | 9 May 15:46 2015
Picon

problem with Type1 font

I have problem with typesetting six symbols from Type1 font with metapost
which refuse to read the corresponding line in given curr.map
containing just one line
bor  <bor.pfb
(the same problem arises with mp1.999 also with virtual fonts, but in 
that case helps to give the corresponding line as fontmapline directly, 
which does not help here:

%q.mp
path s;

fontmapfile "curr.map";
% fontmapline "bor  <bor.pfb";

verbatimtex
\font\astro     bor scaled 1095
\astro
etex

beginfig(4);
w:=30u; h:=24u;
s:=fullcircle xscaled w yscaled h;
a:=.5;
z0=origin;
z1=point a of s;
z2=point 2 of s;
z1=point 4-a of s;
for k=4 upto 6: z[k]=z[k-3] rotated180; endfor
i:=-1;
label(btex C  etex,z[incr i]);
label(btex \i etex,z[incr i]);
label(btex A  etex,z[incr i]);
label(btex D  etex,z[incr i]);
label(btex I  etex,z[incr i]);
label(btex U  etex,z[incr i]);
label(btex E  etex,z[incr i]);
endfig;

end

The resulting mpx file seems to be OK, but mpost or stops completely, or 
gives the following log:

This is MetaPost, version 1.999 (TeX Live 2014/W32TeX) (kpathsea version 
6.2.0)  9 MAY 2015 15:32
**\nonstopmode; input q
(c:/texlive/2013/texmf-dist/metapost/base/mpost.mp
(c:/texlive/2013/texmf-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.004) )
(./q.mp{curr.map
! Emergency stop.
l.4 fontmapfile "curr.map";

buffer overflow: (1025,1024) at file ./psout.w, line 1216

Thanks for help,
Karel horak

--
http://tug.org/metapost/

Taco Hoekwater | 12 Mar 16:52 2015

Fwd: problem with mpost number of strings exceeded



Begin forwarded message:

Date: 12 Mar 2015 16:49:43 CET
From: Denis Roegel <denis.roegel <at> loria.fr>
To: Taco Hoekwater <taco <at> elvenkind.com>
Subject: problem with mpost number of strings exceeded

Hi Taco,

I am running into a problem with a metapost file which generates about 20 files,
each being about 500kb. These files use a lot of labels (with latexmp) and eventually
I get metapost capacity exceeded [number of strings = 31228]
(on an old distribution). I have tried to increase max_strings to 200000, pool_size to
more than a million, main_memory has been set to 3000000, (I changed texmf.cnf
and regenerated the format with fmtutil), but I still get that error.
What should I increase? In the worst case, I could split my file to generate a smaller
number of figures.

Thanks,

Denis

--
http://tug.org/metapost/
Franck Pastor | 9 Mar 17:01 2015

Bug with the binary operator `point ... on ...` from Metafun

I’ve just encountered a very puzzling bug with the binary operator `point <len> of <path>` defined in the
Metafun format.

In the Metafun manual (http://www.pragma-ade.com/general/manuals/metafun-p.pdf), p. 61, this
binary operator is defined as such:

primarydef len of pat =
  (arctime len of pat) of pat
enddef;

So if I write `point 0 on pat`, it should return the starting point of the path <pat>, right? But n. To the
contrary, it returns the end point of <pat>! Stranger yet, if I try `point (arctime 0 of pat) of pat`, it
returns the starting point, as expected. 

This weird behavior is illustrated by the following program, to be run with the Metafun format of course:

beginfig(1);
path line[]; line1 = origin -- 3cm*right; line2 = line1 yshifted -1cm;
draw line1; draw line2;
pickup pencircle scaled 3bp;
draw point 0 of line1; % draw a dot at the start point, as expected
draw point 0 on line1; % draws a dot at the end point!!!!!
draw point (arctime 0 of line2) of line2; % draws a dot at the starting point…
endfig;
end.

An idea about what is wrong? 

I use MetaPost 1.902 and Metafun version 1.004, from TeX Live 2014.

Thanks in advance,

Franck Pastor

--
http://tug.org/metapost/
luigi scarso | 21 Jan 09:14 2015
Picon

Turning Number and QuickSort

It seems that the University College Cork has some problem to deliver emails to the metapost list,
so I forward some notes that 
Marc van Dongen has sent to me last days:

"""
I have noticed lots of problems with standard metapost, including
lots of problems related to rounding and an error in turningnumber.

I re-implemented turningnumber (in mpost) and it seems to work for
my purpose. The implementation is quite simple and it avoids rounding
errors. (It's still possible to reduce more rounding but I don't
think it's needed.) Please let me know if you want the implementation.
(I still have to do some proper testing on it.)
"""
The files are in attachment.


--
luigi
% This is a simple implementation to determine whether a  path
% is drawn anti clockwise. To do this, it computes the signed
% area of the path consisting of the support points of the path.
% ASSUMPTION: _pat_ does have a non-zero area.
vardef IsAntiClockwise( expr pat ) =
    ((cycle pat) and (Area( pat ) > AREA_ACCURACY))
    %(turningnumber( pat ) > 0)
enddef;

vardef Area( expr pat ) =
    save a, len, sum; numeric a[], len[], sum;
    len := length pat;
    % First we compute (twice) the signed areas of the triangles
    % _(0,0) -- (point i of pat) -- (point (i + 1) of pat) -- cycle_
    for i = len - 1 downto 0:
        a[ i ] := Det( point i of pat, point (i + 1) of pat );
    endfor
    % Since adding the sizes may result in large rounding errors,
    % we sort them in descending order
    SortAbsGeq( a )( len );
    % The remaining statements compute the sum of the signed areas
    % in a ``robust'' fashion, trying to minimise rounding. A little
    % bit more robust would be to first compute the frequencies of
    % the entries in _a_, then multiplying each unique number in
    % _a_ by its frequency, then sorting the products, and finally
    % adding the products.
    % e.g. [1,2,1,1];
    % sort it -> [2,1,1,1];
    % compute frequencies -> [2:1,1:3];
    % compute products -> [2,3];
    % sort -> [2,3];
    % add -> 5.
    sum := 0;
    for i = len - 1 downto 0:
        sum := sum + a[ i ];
    endfor
    % We could have just returned _sum_ but
    % this way we get the actual signed area.
    0.5sum
enddef;

endinput
vardef QuickSort( suffix a, cmp )( expr size ) =
    QuickSort_( a, cmp )( 0, size - 1 );
enddef;

vardef QuickSort_( suffix a, cmp )( expr lo, hi ) =
    if lo < hi:
        save sep; numeric sep;
        %Swop( a )( lo, floor( (lo + hi) / 2 ) );
        Swop( a )( lo, lo + floor( uniformdeviate( hi - lo - 1 ) ) );
        sep := Partition( a, cmp, lo, hi );
        Swop( a )( lo, sep );
        QuickSort_( a, cmp )( lo, sep - 1 );
        QuickSort_( a, cmp )( sep + 1, hi );
    fi
enddef;

vardef Partition( suffix a, cmp )( expr lo, hi ) =
    save dest, pivot; numeric dest, pivot;

    dest := lo;
    pivot := a[ lo ];
    for i = lo + 1 upto hi:
        if cmp( a[ i ], pivot ):
            dest := dest + 1;
            Swop( a )( dest, i );
        fi
    endfor
    dest
enddef;

vardef Swop( suffix a )( expr fst, snd ) =
    save tmp; numeric tmp;
    tmp := a[ fst ];
    a[ fst ] := a[ snd ];
    a[ snd ] := tmp;
enddef;

vardef SortAbsGeq( suffix a )( expr size ) =
    save CMP__;
    vardef CMP__( expr fst, snd ) =
        (abs( fst ) >= abs( snd ))
    enddef;
    QuickSort( a, CMP__ )( size );
enddef;

endinput
--
http://tug.org/metapost/

Gmane