## toolMatrix toolMatrix — Defines basic handlings on matrix. |

## Synopsis

    void                matrix_sphericalToCartesian         (float *cartesian,
                                                             float *spherical);
    void                matrix_productMatrix                (float matRes[3][3],
                                                             float matA[3][3],
                                                             float matB[3][3]);
    void                matrix_cartesianToSpherical         (float *spherical,
                                                             float *cartesian);
    gboolean            matrix_reducePrimitiveVectors       (double reduced[6],
                                                             double full[3][3]);
    void                matrix_productVector                (float vectRes[3],
                                                             float mat[3][3],
                                                             float vect[3]);

    enum                matrix_scaleflag;
    double              matrixGet_invLinear                 (double x,
                                                             double minmax[2],
                                                             double param);
    double              matrixGet_invLogarithm              (double x,
                                                             double minmax[2],
                                                             double param);
    double              matrixGet_invZeroCenteredLog        (double x,
                                                             double minmax[2],
                                                             double param);
    double              matrixGet_linear                    (double x,
                                                             double minmax[2],
                                                             double param);
    double              matrixGet_logarithm                 (double x,
                                                             double minmax[2],
                                                             double param);
    double              (*matrixGet_scaleVal)               (double x,
                                                             double minmax[2],
                                                             double param);
    double              matrixGet_zeroCenteredLog           (double x,
                                                             double minmax[2],
                                                             double param);

    void                matrixInit                          ();

## Description

Some very basic linear algebra are redefined here. It also gives access to coordinates conversion, essentially between cartesian and spherical.

## Details

### matrix_sphericalToCartesian ()

    void                matrix_sphericalToCartesian         (float *cartesian,
                                                             float *spherical);

A method to transform spherical coordinates (radius, phi and theta) to cartesian coordinates.

`cartesian` : | an allocated array of 3 floating point values to store the result ;
`spherical` : | an allocated array of 3 floating point values to read the input.

### matrix_productMatrix ()

    void                matrix_productMatrix                (float matRes[3][3],
                                                             float matA[3][3],
                                                             float matB[3][3]);

Compute the mathematical product between `matA` and `matB` and put the result matrix in `matRes`.

`matRes` : | an array of floating point values of size 3x3 ;
`matA` : | an array of floating point values of size 3x3 ;
`matB` : | an array of floating point values of size 3x3.

### matrix_cartesianToSpherical ()

    void                matrix_cartesianToSpherical         (float *spherical,
                                                             float *cartesian);

A method to transform cartesian coordinates in spherical coordinates (radius, phi and theta).

`spherical` : | an allocated array of 3 floating point values to store the result ;
`cartesian` : | an allocated array of 3 floating point values to read the input.

### matrix_reducePrimitiveVectors ()

    gboolean            matrix_reducePrimitiveVectors       (double reduced[6],
                                                             double full[3][3]);

This routine transforms the given matrix `full` into a reduced array used by V_Sim to store box definition.

`reduced` : | a storage for 6 floating point values ;
`full` : | a full 3x3 matrix to be transformed.
Returns : | FALSE if the given matrix is planar.

### matrix_productVector ()

    void                matrix_productVector                (float vectRes[3],
                                                             float mat[3][3],
                                                             float vect[3]);

Compute the mathematical product between `matA` and `vect` and put the result vector in `vectRes`.

`vectRes` : | an array of floating point values of size 3 ;
`mat` : | an array of floating point values of size 3x3 ;
`vect` : | an array of floating point values of size 3.

### enum matrix_scaleflag

    typedef enum
      {
        linear,
        logarithm,
        zeroCentredLog,
        n_scaleflag
      } matrix_scaleflag;

Flag used to specify the transformation for `scalarFieldDraw_map()` routine.

`linear` | a linear convertion from [min,max] to [0,1] ;
`logarithm` | a logarithmic transformation from [min,max] to [0,1], the formula is -(f(x) - f(m) / f(m) where f(x) = ln((x-xmin)/(xmax-xmin)) ;
`zeroCentredLog` | a logarithmic transformation for data that are zero centred, the formula is 0.5+s*(log(MAX*SEUIL)-log(max(abs(x),MAX*SEUIL)))/(2*log(SEUIL)) where s is the sign, max=max(xmax,-xmin) and seuil a parameter (1e-5).
`n_scaleflag` | number of available scale functions.

Since 3.4

### matrixGet_invLinear ()

    double              matrixGet_invLinear                 (double x,
                                                             double minmax[2],
                                                             double param);

Reverse function for `matrixGet_linear()`.

`x` : | the initial value ;
`minmax` : | the boundaries for the `x` argument ;
`param` : | a parameter (unused).
Returns : | a value into [0;1].

Since 3.5

### matrixGet_invLogarithm ()

    double              matrixGet_invLogarithm              (double x,
                                                             double minmax[2],
                                                             double param);

Reverse function for `matrixGet_logarithm()`.

`x` : | the initial value ;
`minmax` : | the boundaries for the `x` argument ;
`param` : | the second minimum value, used as reference for the log scale.
Returns : | a value into [0;1].

Since 3.5

### matrixGet_invZeroCenteredLog ()

    double              matrixGet_invZeroCenteredLog        (double x,
                                                             double minmax[2],
                                                             double param);

Reverse function for `matrixGet_zeroCenteredLog()`.

`x` : | the initial value ;
`minmax` : | the boundaries for the `x` argument ;
`param` : | the result of MAX(`minmax`[1], -`minax`[0]).
Returns : | a value into [0;1].

Since 3.5

### matrixGet_linear ()

    double              matrixGet_linear                    (double x,
                                                             double minmax[2],
                                                             double param);

Transform `x` into [0;1] with a linear scale.

`x` : | the initial value ;
`minmax` : | the boundaries for the `x` argument ;
`param` : | a parameter (unused).
Returns : | a value into [0;1].

Since 3.5

### matrixGet_logarithm ()

    double              matrixGet_logarithm                 (double x,
                                                             double minmax[2],
                                                             double param);

Transform `x` into [0;1] with a log scale.

`x` : | the initial value ;
`minmax` : | the boundaries for the `x` argument ;
`param` : | the second minimum value, used as reference for the log scale.
Returns : | a value into [0;1].

Since 3.5

### matrixGet_scaleVal ()

    double              (*matrixGet_scaleVal)               (double x,
                                                             double minmax[2],
                                                             double param);

Transform `x` into [0;1] using the given `minmax` values.

`x` : | the initial value ;
`minmax` : | the boundaries for the `x` argument ;
`param` : | a parameter.
Returns : | a value into [0;1].

Since 3.4

### matrixGet_zeroCenteredLog ()

    double              matrixGet_zeroCenteredLog           (double x,
                                                             double minmax[2],
                                                             double param);

Transform `x` into [0;1] with a log scale with zero centred values.

`x` : | the initial value ;
`minmax` : | the boundaries for the `x` argument ;
`param` : | the result of MAX(`minmax`[1], -`minax`[0]).
Returns : | a value into [0;1].

Since 3.5

### matrixInit ()

    void                matrixInit                          ();

This method is used by V_Sim internally and should not be called.

Since 3.5