Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Some observations: Bigloo<->Stalin
One thing worth to mention is the fact that Bigloo will serve you very
well provided one comply to some rules. The following two code snippets
demonstrate that Stalin is indeed a good code analyzer.

The following is a code snippet from a code  which solves for simple
ordinary first order differential equations.**

But that is not the problem here; important is the fact that one has to
use a bit of a different technique in order to make the best out of
Bigloo programming, provided he is after performance.

1. Stalin snippet:

==
(define (eul-alpha n h delx u K R gamma-i A B)
(let* ((alpha-i (/ (&vr R 0)
(&vr B 0))))
(let loop-alpha ((i 2) (erg (list alpha-i)))
(if (= i (+ n 1))
(o==> (list->vector (reverse erg)))
(begin
(let ((indx (- i 1)))
(set! alpha-i (/ (- (&vr R indx)
(* (&vr A indx) alpha-i))
(+ (&vr B indx)
(* (&vr A indx)
(&vr gamma-i (- indx 1))))))
(loop-alpha (+ i 1) (cons alpha-i erg))))))))
==

2. The Bigloo snippet:

==
(define-macro (/. x y)
`(cond-expand
(bigloo (/fl ,x ,y))
(else (/ ,x ,y))))

; etc. macros here

(define (eul-alpha n h delx u K R gamma-i A B)
(let ((erg (make-vector n 0.0))
(alpha-i (/. (v& R 0)
(v& B 0))))
(vector-set! erg 0 alpha-i)
(do ((i 2 (+ i 1)))
((= i (+ n 1)))
(let ((indx (- i 1)))
(set! alpha-i
(/. (-. (v& R indx)
(*. (v& A indx) alpha-i))
(+. (v& B indx)
(*. (v& A indx)
(v& gamma-i (- indx 1))))))
(vector-set! erg indx alpha-i)))
(o==> erg)))
==

As you see: in order to get to the same performance as under Stalin one
has to use in Bigloo: a) pre-dimensionized vectors b) Bigloo operators.
The latter macros concerning the operators have been made so as to use
the code -- for test reasons -- under Stalin too.

Although, you see: in Stalin you use: a) consing-lists (list is
converted to a vector upon exit) b) normal operators.

If I had used the same Stalin code (the one with consing lists) under
Bigloo I would have had to wait much, much longer for the result. I do
not know why Stalin automatically transforms the list-consing code to
something similar to the vector code (see Bigloo code snippet).

And no: I would in no way cancel Bigloo in favor of Stalin. Bigloo
provides me much, much more; since one knows about some Bigloo tricks
and the Stalin performance advantage vanishes, at least in that special
"differential equation solver". Documentatin of ones own Bigloo code
with some basic types is at top of my list!

Förster vom Silberwald
** I made also a C++ version, because to my surprise the Bigloo output
and the Stalin output differ (same code)! However, the Bigloo output and
C++ output are the same! I implementted the solver after an example in a
book about atmospheric physics; one of the book examples provided  me
only the initial particle concentration but not the result. Hence  I am
not aware whether the Bigloo and C++ version is in error or Stalin. I am
still not sure whether my code converges eventually. But nevertheless: I
thought they -- Bigloo and Stalin, respectively -- rely on the same
internal (numerical) C layout - or don't they?

Report this thread to moderator Post Follow-up to this message
Old Post
F?rster_vom_Silberwald
10-26-04 02:00 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Scheme archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:02 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.