r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Red] Red language group

Kaj
15-Jan-2012
[4385]
Good stuff
Robert
16-Jan-2012
[4386]
Doc, might be of interest to you: http://drdobbs.com/blogs/parallel/232301070
Dockimbel
16-Jan-2012
[4387]
Yes it is, thanks. Good stuff for 64-bit Mach-o version. The GOT 
handling seems intricated in Mach-o, I will try to avoid the methods 
that involve fixups in code.
Dockimbel
23-Jan-2012
[4388x2]
For the floating point format experts around: 


I am investigating the simplest and most accurate way to support 
floating point comparison by implementing an `almost-equal` operator 
in Red/System. Due to the intricacies of such task, I have selected 
the two algorithms that look the best to me:


1) Tolerance-based: http://realtimecollisiondetection.net/blog/?p=89

2) Ulp-based: http://www.cygnus-software.com/papers/comparingfloats/Comparingfloating point numbers.htm


Of course, in both approaches, there are some accuracy parameters 
to be set by the user to adjust the comparison formula (good defaults 
will be provided anyway).


Are there better algorithms or better implementations of methods 
1) or 2)?
I have x-posted that message to the Red ML also: http://groups.google.com/group/red-lang/browse_thread/thread/527afaf181eee8c7?hl=en
Ladislav
23-Jan-2012
[4390]
2) is now used in R3
Dockimbel
23-Jan-2012
[4391]
Do you know if it uses the implementation from above link or a custom 
one?
Pekr
24-Jan-2012
[4392]
ad 2) This seems to be dated, and new stuff by Bruce Dawson's here 
- http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
Ladislav
24-Jan-2012
[4393]
Well, the implementation may be dated, but the principle remains 
the same. Moreover, we use it for doubles, not for floats, but as 
said, the principle remains the same.
Pekr
24-Jan-2012
[4394]
Well, I just pointed to the new stuff, can't comment on validity, 
as I don't understand  the topics discussed properly, so you might 
be right of course ...
Geomol
24-Jan-2012
[4395]
Doc, the last part of your 2nd choise (the ulp-based) named "Comparing 
using integers" is the method, I would look at. It's simple and I 
would guess, performs well. Tests are needed to say, if the other 
methods are faster. Could it be CPU dependent, which is faster?
PeterWood
24-Jan-2012
[4396]
In order to implement the algorithm for doubles did you need to have 
64-bit integers available?
Geomol
24-Jan-2012
[4397x2]
I guess, you could split the 64-bit in 2 times 32-bit. If the most 
significant 32-bits are the same, you do the comparison the the least 
significant ones. This should work.
*on* the
PeterWood
24-Jan-2012
[4399x2]
Is that assuming you can convert a double to two 32-bit integers 
or that you jsut split the 64 bits into 2x32 bits?
jsut -> just
Geomol
24-Jan-2012
[4401]
No conversion, just split.


The IEEE float and double formats were designed so that the numbers 
are Òlexicographically orderedÓ, which Ð in the words of IEEE architect 
William Kahan means Òif two floating-point numbers in the same format 
are ordered ( say x < y ), then they are ordered the same way when 
their bits are reinterpreted as Sign-Magnitude integers.Ó
PeterWood
24-Jan-2012
[4402]
Thanks.
Dockimbel
24-Jan-2012
[4403]
Pekr: the link you're giving is the exact same article I've pointed 
to in 2), it just have a left menu added for quicker navigation, 
but that's the same article. If I haven't just stopped on this algorithm, 
it's because of the initial warning at the beginning: 


This article is obsolete. Its replacement - which will fix some errors 
and better explain the relevant issues - is being crafted as a multi-part 
series


And from Dawson's blog: "Years ago I wrote an article about how to 
do epsilon floating-point comparisons by using integer comparisons. 
That article has been quite popular (it is frequently cited, and 
the code samples have been used by a number of companies) and this 
worries me a bit, because the article has some flaws. I’m not going 
to link to the article because I want to replace it, not send people 
looking for it." 


So it appears that there are some errors (probably some edge cases 
not handled properly).
Pekr
24-Jan-2012
[4404x2]
It's not imo the same article, it is supposed to be a fixed one, 
where its author does not even want to point out to what you posted 
as 2) :-) But - that does not matter, what matters is, what works 
for you/Red :-)
ah, now I can see it. It's in the frame, my intention was to post 
link "here" URL, but cutted and pasted the wrong one ...
Dockimbel
24-Jan-2012
[4406]
Th new fixed version of Dawson's article is split in a new series 
of blog entries: http://randomascii.wordpress.com/category/floating-point/


But, alas, he hasn't yet reached the point where he shows the fixed 
version of `almost-equal` function.
Ladislav
24-Jan-2012
[4407x2]
I did not take anything else than the principle (did not copy/use 
his code) to implement the comparison.
To Geomol: the speed should not be bad, but that is not the main 
reason why this approach is good.
Dockimbel
24-Jan-2012
[4409x3]
Variadic and typed functions now support floats datatypes (float-partial 
branch).


https://github.com/dockimbel/Red/commit/331a50e8e5535ffec710e86c7f5f2704292fc433
BTW, math operations (+, -, *, /) have been implemented for floats 
(only float! / float! or float32! / float32!).
Remainder and modulo should also work, but untested. The meaning 
of these operators has been adapted for floats, remainder (%) will 
return a standard IEEE rounded remainder, while modulo (//) will 
return a floating point remainder.
Kaj
24-Jan-2012
[4412x2]
That's really great!
How do 64-bits typed values affect the other typed values?
Dockimbel
24-Jan-2012
[4414x3]
The stack layout has changed for typed functions arguments, but it 
is backward-compatible, so all your dialects should work with the 
new version (not tested yet).
For float!, you need to do an extra type-casting on the arguments 
pointer to convert it to typed-float! instead of typed-value!. You 
have an example of that in %red-system/runtime/utils.reds in _print 
function.
Oldes, could you please test your bindings with the lastest revision 
of float-partial branch? They should run fine now.
Henrik
25-Jan-2012
[4417]
Continuing here, briefly:


When I'm tired, I usually stick to running "monkey tests" or button 
mashing and take notes for the next day if something crashes. :-)
Oldes
25-Jan-2012
[4418]
I made just a quick test with blur effect and it works... cool:)
Dockimbel
25-Jan-2012
[4419]
Great, let me know when your ImageMagic binding will be ready, so 
I'll add it to the list of existing bindings.
Evgeniy Philippov
26-Jan-2012
[4420x4]
I maybe need Red instead of Bash! /Reading syntax spec
DocKimber: was this possibility discussed anywhere --- re: bash vs. 
rebol or red instead of bash?
Sorry! DocKimbel
I've skimmed the BNF doc at the red-lang site. It seems it is rather 
vague and unverified. I think maybe I need to build a Coco/R EBNF 
grammar and to check the grammar formally, for unabiguity and other 
grammar errors.
Gabriele
26-Jan-2012
[4424x2]
maybe Doc is actually using the PARSE dialect rather than proper 
BNF.
Re: bash... i thought about this a lot, i'm not sure you can come 
up with a decent dialect, though it would be possible to create a 
bash-like language with more rebol-like syntax and semantics.
Dockimbel
26-Jan-2012
[4426x5]
The BNF doc was written by Rudolf Meijer and it it strict EBNF. I 
did only a manual checking of the grammar and found no issues. I 
have planned to model it in ANTLR, but never found the time.
it it
 => "it is"
strict EBNF
 => "strict BNF"
The grammar rules I wrote for Red/System expressions should also 
pass through a BNF loader (except for the first five definitions): 
http://static.red-lang.org/red-system-specs.html#section-5.1
Evgeny: Red/System is a bad fit for scripting, it is too low-level, 
you'll need to wait for Red for having a good alternative to Bash.
Pekr
26-Jan-2012
[4431]
Doc - what' coming after floating point support? Are you moving to 
work on Red itself?
Dockimbel
26-Jan-2012
[4432x2]
I have to fix the LibC starting and ending code, then I'll move to 
Red runtime to finish it and start Red's compiler.
I'll also continue to work on the shared library support for Red/System 
at part-time, during weekends. I would like to have it working for 
the conference in Netherlands in march.
Oldes
26-Jan-2012
[4434]
Is there something like QUIT function already?