Re: Computer Algebra Algorithms lisp vs. C. BENCHMARKS?



Richard Fateman wrote:
> If we can decide on a few algorithms to code, we could look at
> the programs, each written by an advocate of a particular language,
> and see which is
>
> smaller,
> faster
> more portable
> simpler to write
> more general.

Sounds like fun. :-)

> An example that comes to mind is Karatsuba-style multiplication
> of two polynomials.

Ok. I expect that many such programs have already been written in OCaml.

> (You can look up the method via google. I found a partial solution
> in "meta-Ocamal" at
> http://www.infosun.fmi.uni-passau.de/cl/metaprog/cmpp2004prog.ml

Just to clarify, MetaOCaml is a multistage programming language. In theory,
it allows you to specify parts of your program to be compiled first
(typically for partially specialising the program over part of the data).
For example, you could partially specialise an ipow function over the
exponent 3 to get a function which cubes its input, equivalent to:

let pow3 x = x *. x *. x;;

In practice, the MetaOCaml compiler currently only targets bytecode and not
native code.

> I have a solution in lisp, too.
> I assume someone has a solution in C.

This should make for an interesting comparison.

> There are some questions about what to include. For example, in C, or
> OCAML do you have to include the source code for the arbitrary precision
> arithmetic?
> In Lisp, Maple, Mathematica, etc. such facilities are part of the
> language.

Yes, this is also true of OCaml. If you have ocaml installed then just type
ocamlbrowser to get a GUI browser of the standard library. Have a look at
the "Num" module.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com
.



Relevant Pages

  • Re: Language recommendations from ruby persons....
    ... particularly as enjoyment of a language tends not to be vicarious. ... > Ruby extensions in OCaml as opposed to C which seemed quite interesting. ... Lisp has the upper hand so far, ... >> Can someone tell me if I am talking to a troll? ...
    (comp.lang.ruby)
  • Re: Growth of the CAML family of languages
    ... search on "lisp", the first 5 pages all refers to lisp the language, ... Google Trends measures the former: ... Their third-party driver verification software is written in OCaml. ...
    (comp.lang.lisp)
  • Re: Compiler and an interpreter
    ... > cliche and recall what it means without having to read all the code. ... > The mapcar idion above is frequent in lisp. ... > 1 Because C++ is a more well known language. ... OCaml has been developed so much in other ways that I can't think ...
    (comp.programming)
  • Re: Haskell: functional languages vs Lisp
    ... >>people need and want to do with a programming language. ... >>I like ML generally, and especially Ocaml, a lot. ... >>I prefer to use Lisp. ... > a) Delivery system like for example in LispWorks ...
    (comp.lang.lisp)
  • Re: Choosing a language for an OO design
    ... > implementations of a language with the same name, ... write code but try to have a "free" Lisp as fall-back. ... that OCaml is best suited for stand-alone apps since a library ... Well that's true for all kind of libraries but you still use them.... ...
    (comp.programming)