Re: execution times



Hey Mark,

Thanks for your detailed & informative response. Yes I know AP is
significantly slower than standard computer aitthmetic, but to overcome
problems with ill-conditioning I really cant see any other option. I know
measures such as 'pivotting' can help to reduce this problem but they only
go so far. My original program used doubles and it wasnt hard to find
example matrices for which the answer returned was well off. I know there
are 'quadruple' number types in some languages but i dont think java has
them.

Not of what i've written uses BLAS but is simply my own algorithms or
implementations of algorithms from books such as Golub & Van Loan.

thanks for your input anyway. ps did you write JAMaA then?

"Mark Westwood" <markc.westwood@xxxxxxxxx> wrote in message
news:1161159260.475795.52690@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Jeremy

The difference in run times could be entirely explained by your use of
arbitrary precision arithmetic in your Java code. Could be -- but it's
very difficult to be definitive and there are other reasons why a Java
code (indeed any code) might be slower than a Mathcad code. It's a
while since I used Mathcad so I speak with no authority on it, but I'd
be very surprised to learn that it does, by default, linear algebra in
arbitrary precision. I suspect that you are comparing apples and
oranges. Try recoding the Java program to use doubles or floats.

(If you are surprised to learn that arbitrary precision arithmetic is
much slower than machine precision arithmetic you need to find out if
you ever want to achieve happiness in numeric programming. Google
around a bit.)

Some other reasons:
-- Your Java program might be making a lot of RAM accesses, while
Mathcad runs in cache.
-- The Mathcad program might take good advantage of memory locality,
your code might not (this is not entirely distinct from the previous
reason).
-- Mathcad is likely to have built-in fast implementations of BLAS and
similar standard tools for linear algebra; it's very difficult for most
of us to write programs which match them for speed. Does your program
call BLAS or LAPACK or something else for its computational kernel ?
-- Some Java operations, for example creating a new object, are very
slow compared with numeric calculations. Does your program do a lot of
object creation inside inner loops ? Or lots of copying of data ?
-- There's often a big difference between Java VMs. Make sure you're
using the latest and best for your platform and compare the performance
of a server VM and a client VM, the former is often significantly
faster.

Don't believe anything anyone tells you about Java performance compared
with the performance of C, C++, Mathcad, Matlab or anything else.
Believe only your own test results. Oh, and me of course :-) Google
around for Java Numerics, Jampack, JAMA, Javagrande. You'll find some
libraries for Java linear algebra and some data comparing Java
execution speed with that of C and C++. I'd be surprised if you
couldn't get a Java linear algebra program no more than 3 or 4 times
slower than Mathcad.

Regards
Mark Westwood

Jeremy Watts wrote:
a little off topic maybe a computer group would be more suitable, but
this is to do with numerical linear algebra so..

i have coded up myself the QR algorithm in java for general
real/complex matrices, using the hessenberg decomposition front end,
deflation, and the double shifts strategy. it uses arbitrary precision
arithmetic in the form of java's 'big decimal' feature.

i have compared the run-times of my program with that of the commercial
computer algebra system 'mathcad'. it performs far quicker than my
program on the same matrix. for instance , it does a 100 x 100 matrix
in the blink of an eye whereas with mine you could go out make a cup of
tea come back and it still hasnt done it...

just wondered what the cause of the execution speed difference was down
to? is it simply because mathcad is obviously running in machine code
whereas java runs in slower java-byte code? or is there also something
else going on, maybe mathcad runs in standard floating point arithmetic
if the matrix is well conditioned? but then it must also use APR
because it can deliver answers up to 15decimal places in length.

thanks



.



Relevant Pages

  • Re: execution times
    ... arbitrary precision arithmetic in your Java code. ... while since I used Mathcad so I speak with no authority on it, ... libraries for Java linear algebra and some data comparing Java ...
    (sci.math.num-analysis)
  • Re: which collection to use
    ... Patricia Shanahan wrote: ... In any situation where the system is multi-tasking (and Java is always multitasking to a first approximation because there are at least two threads running) its meaningless to measure elapsed time. ... the number of items and the key value distribution are both vital information which you didn't provide. ... If your item swap method is very fast and the key comparison is slow (e.g. a lexicographic string comparison over multiple keys rather than comparing single integer keys) then you'll find in practice that a Replacement sort is several times faster than Quicksort. ...
    (comp.lang.java.programmer)
  • Re: RB or Python?
    ... they essentially have #pragma backgroundtasks false all the ... slower than Java. ... On the PPC the gap is narrower, but Java is still 3-4x faster (and this ... slower than g++ and compares ...
    (comp.lang.basic.realbasic)
  • Re: Optimise my ray tracer
    ... All of my tests indicate that Java is many ... >> times slower than most other modern languages, ... >> languages like SML and OCaml. ... > I strongly suspect that the issue is startup time. ...
    (comp.lang.java.programmer)
  • Re: Cross Platform Development
    ... IIRC the C++ version ran 4 times slower than the C version, though the comparison was a little unfair: the test problem was a very simple genetic algorithm which I picked simply because it was simple, but this had the side effect of putting too much emphasis on the complex and indirect method calling overheads of C++ as compared with the simpler C function call mechanism. ... I can't be specific about the relative runtime speeds of C and Java because I've never made direct comparisons. ... A good example from the old ICL 1900 era is the comparison between NCL Filetab and 1900 COBOL. ... I have a set of runnable skeleton client and server applications written in C and Java, which use a small set of server commands for test purposes. ...
    (uk.comp.os.linux)