[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Simpe Gwydion question
Faried Nawaz (fn@hungry.com) wrote:
: hebisch@math.uni.wroc.pl (Waldek Hebisch) wrote in message news:<aghjiv$lt6$1@panorama.wcss.wroc.pl>...
: > -- How one prints a floating point number. I was able
: > to find examples of format, but only for integers
: Use the %= control sequence with format.
: format-out("%=", 2.3 * 9.443341) => 21.7196843d0
: For the guts: gd/src/common/print/print.dylan
With format-out my gwydion-dylan-2.3.8 prints:
Error: Undefined variable: format-out
When I change it to format it prints:
{an instance of <double-float>}
: > -- How one conwerts between numbers and strings (both integers
: > and floating point)
: Use the common-extensions library. It has float-to-string, integer-to-string,
: string-to-integer, and number-to-string.
I get:
In Define Method main{<byte-string>}:
"hello-world.dylan", line 22, characters 18 through 32:
format("%s\n", float-to-string( 0.123) );
^^^^^^^^^^^^^^^
Error: Undefined variable: float-to-string
: > -- How one declares an array of doubles. Currently I use generic
: > array and the program is VERY slow. I tried
: > limited(<vector>, of: <double-float>)
: > but then the program died at runtime.
: How did it die? Can you post the code?
: I tried this (which worked):
: define constant <double-vector> = limited(<vector>, of: <double-float>);
: define function vector-foo() => ()
: let dvec :: <double-vector> = make(<double-vector>, size: 10000, fill: 0.0);
: for (i from 0 below dvec.size)
: // i wanted to fill this with random numbers, but i couldn't find
: // random() in common-extensions.
: dvec[i] := i * 1.64;
: end for;
: for (i from 0 below dvec.size)
: format-out("%d %=\n", i, dvec[i])
: end for;
: end function vector-foo;
: With size: 10000000 and without the format-out loop, it still took 13 seconds
: on my 800MHz Athlon box.
Well, I had to change format-out to format. Then Gwydion Dylan 2.3.4 gives:
No applicable methods in call of {the <generic-function> make} when given arguments:
#[{an instance of <limited-collection>}, #"size", 100, #"fill", {an instance of <double-float>}]
Aborted (core dumped)
Under 2.3.8 it works. I had no idea that I am hitting unimplemented
stuff :-(. I got an e-mail from Thomas V. Williams after which I
decided to upgrade my Dylan. Still, the program (simple heapsort benchmark)
works as slow as previously -- many times slower then C, 15 times slower
then CMU Common Lisp (generated C code still calls what looks like generic
methods). At least I know I gave the compiler all possible help.
Thanks for help
--
Waldek Hebisch
hebisch@math.uni.wroc.pl or hebisch@hera.math.uni.wroc.pl