[Shootout-list] Mandelbrot Set for CMUCL and SBCL 2nd try

Greg Buchholz sleepingsquirrel@member.fsf.org
Mon, 28 Mar 2005 16:14:15 -0800 (PST)


Yannick Gingras wrote:
>Yes, I'm really close to the C output but I still get a few bits here
>and there that are not the same.  If I look at the pictures they
>really look the same.  About 99.99% of the bits are the same.  It
>probably is some floating point errors creeping in...
>

    Try chaning line 35 from...

(when (not (dotimes (n 50)

...to...

(when (not (dotimes (n 51)

>
>Should my output be exactly the same ? 

   Yes.

>There is also a few
>implementations skipping the last byte if the size is not a multiple
>of 8, should I do so too ?

   Hmm.  All programs should do the same thing, please report which
implementations are skipping the final byte.


Thanks,

Greg Buchholz

P.S.  Here's a down and dirty perl script which produces a graphical diff
of *.pbm files...

#!/usr/bin/perl -w
#
#diff_pbm: graphical diff of two *.pbm files
#
#usage: diff_pbm file1.pbm file2.pbm >diff.pbm

open ONE, $ARGV[0] or die "barf 1";
open TWO, $ARGV[1] or die "barf 2";

my $i=0;
$/=undef;

my $f1=<ONE>;
my $f2 = <TWO>;

my ($header1,$body1) = ($f1 =~ /(P4\s+\d+\s+\d+\s)(.*)/s);
my ($header2,$body2) = ($f2 =~ /(P4\s+\d+\s+\d+\s)(.*)/s);

if($header1 ne $header2)
{
    die "headers don't match:\n**$header1**\n versus \n**$header2**\n";
}

if(length($body1) != length($body2))
{
    die "different body lengths!\n";
}

my @b1 = split(//, $body1);
my @b2 = split(//, $body2);
my @diff;

for my $i (0..(length($body1)-1))
{
    my $o1=ord($b1[$i]); my $o2=ord($b2[$i]);
    my $exor = $o1 ^ $o2;

    if($b1[$i] ne $b2[$i])
    {
        for (0..7)
        {
            print STDERR "different at pixel #",$i*8+(7-$_),"\n" if
($exor % 2);
            $exor = int($exor/2);
        }
    }
    push @diff, chr($o1 ^ $o2);
}

$dbody = join("", @diff);
print $header1.$dbody;




		
__________________________________ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs