Scilab code for soft iron calibration

Here's the code I use for soft iron calibration, and an example of  mag
measurements.
With this set of measurements, variance from a spherical shape is 0.0044
after offset correction, and 0.000074 after matrix correction.
This calibration should improve notably the precision of mag
measurements, in the case they're affected by soft iron... (otherwise it
is rather useless)
Given the value of the matrix computed from this data set, the soft iron
effect can shift attitude estimation up to 11 degrees... but it could be
much stronger depending on how strong soft iron effect is.