CamlFloat Tutorial


Setting up the camlFloat toplevel

In order to get the most out of the toplevel, it's a good idea to create a .ocamlinit file. It should read as follows (change the last line to point to the location of your installation):

open Nla.DBlop;; 
#install_printer printMatrix;;
#directory "/Users/bill/Documents/Programs/CamlFloat-0.1";;

The toplevel is built to include the numerical linear algebra routines in Nla.ml, but no namespace is opened by default. The first line in the above code opens the namespace of the module DBlop, corresponding to double precision calculation with reals. For single precision, double precision complex or single precision complex you would open Nla.SBlop, Nla.ZBlop or Nla.CBlop, respectively. (see the docs for Nla.ml for information on this set-up)

The second line tells the toplevel how to print out the results of your calculations as they proceed. If you are doing large, serious computations you would not want this, so it's not on by default. However, for interaction and especially learning, it helps to see what you're doing.

Finally, we add the camlFloat directory to the search path. For other options you can use check the toplevel documentation. It's especially useful to #load objects you work with frequently.

Trying out commands

There are a number of commands that can be used to create new matrices. One of these is the function zeros. To create a 2 by 3 zero matrix we use:

# let aMatrix = zeros 2 3  ;;
   0       0       0
   0       0       0
val aMatrix : Nla.DBlop.matrix = 
where the lines following the first, as usual in OCaml, are the toplevel's response. As you can see the type of the camlFloat matrix is Nla.DBlop.matrix.


::: back :::