CamlFloat Tutorial
In mathematical notation we often use block partitioning to specify submatrices. The same thing can be done in camlFloat. As an example let us generate a large Hilbert matrix and break it up.
# let h12 = fun2mat hilbertFormula 12 12 ;; Rows = 12; Columns = 12 1 0.5 0.33 0.25 0.2 0.17 0.14 0.12 0.11 0.1 ... 0.5 0.33 0.25 0.2 0.17 0.14 0.12 0.11 0.1 0.091 ... 0.33 0.25 0.2 0.17 0.14 0.12 0.11 0.1 0.091 0.083 ... 0.25 0.2 0.17 0.14 0.12 0.11 0.1 0.091 0.083 0.077 ... 0.2 0.17 0.14 0.12 0.11 0.1 0.091 0.083 0.077 0.071 ... 0.17 0.14 0.12 0.11 0.1 0.091 0.083 0.077 0.071 0.067 ... 0.14 0.12 0.11 0.1 0.091 0.083 0.077 0.071 0.067 0.062 ... 0.12 0.11 0.1 0.091 0.083 0.077 0.071 0.067 0.062 0.059 ... 0.11 0.1 0.091 0.083 0.077 0.071 0.067 0.062 0.059 0.056 ... 0.1 0.091 0.083 0.077 0.071 0.067 0.062 0.059 0.056 0.053 ... | ... val h12 : Nla.DBlop.matrix = # let (a11, a12, a21, a22) = partition2x2 2 10 6 6 h12 ;;
In the above we first generated a 12 by 12 Hilbert matrix and then assigned names to four submatrices that define the block partitioning. The notation is meant to suggest the mathematical practice of writing the dimensions of submatrices on the border of the larger matrix. It should be read as:
Be careful! These are not new matrices: they have not been copied and if you
alter them the original matrix h12 will change too!
Now we can work with these submatrices. For now we will just print one to check that everything worked.
# printMatrix a11 ;;
1 0.5
0.5 0.33
0.33 0.25
0.25 0.2
0.2 0.17
0.17 0.14
- : unit = ()
Indeed, this is the matrix we wanted.
::: back :::