Scalar functions of a matrix

next - skip - up - start

    int i, j;
    int m = A.Nrows();                     // number of rows
    int n = A.Ncols();                     // number of columns
    Real r = A.AsScalar();                 // value of 1x1 matrix
    Real ssq = A.SumSquare();              // sum of squares of elements
    Real sav = A.SumAbsoluteValue();       // sum of absolute values
    Real s = A.Sum();                      // sum of values
    Real mv = A.MaximumAbsoluteValue();    // maximum of absolute values
    Real mv = A.MinimumAbsoluteValue();    // minimum of absolute values
    Real mv = A.Maximum();                 // maximum value
    Real mv = A.Minimum();                 // minimum value
    Real mv = A.MaximumAbsoluteValue1(i);  // maximum of absolute values
    Real mv = A.MinimumAbsoluteValue1(i);  // minimum of absolute values
    Real mv = A.Maximum1(i);               // maximum value
    Real mv = A.Minimum1(i);               // minimum value
    Real mv = A.MaximumAbsoluteValue2(i,j);// maximum of absolute values
    Real mv = A.MinimumAbsoluteValue2(i,j);// minimum of absolute values
    Real mv = A.Maximum2(i,j);             // maximum value
    Real mv = A.Minimum2(i,j);             // minimum value
    Real norm = A.Norm1();                 // maximum of sum of absolute
                                              values of elements of a column
    Real norm = A.NormInfinity();          // maximum of sum of absolute
                                              values of elements of a row
    Real t = A.Trace();                    // trace
    Real d = A.Determinant();              // determinant
    LogAndSign ld = A.LogDeterminant();    // log of determinant
    bool z = A.IsZero();                   // test all elements zero
    MatrixType mt = A.Type();              // type of matrix
    Real* s = Store();                     // pointer to array of elements
    int l = Storage();                     // length of array of elements
    bool s = A.IsSingular();               // A is a CroutMatrix or
                                              BandLUMatrix
    MatrixBandWidth mbw = A.BandWidth();   // upper and lower bandwidths

The functions A.MaximumAbsoluteValue(), A.MinimumAbsoluteValue(), A.Maximum() and A.Minimum() throw an exception if A has no rows or no columns. The versions A.MaximumAbsoluteValue1(i), etc return the location of the extreme element in a RowVector, ColumnVector or DiagonalMatrix. The versions A.MaximumAbsoluteValue2(i,j), etc return the row and column numbers of the extreme element. These versions also throw an exception if A has no rows or no columns. If the extreme value occurs more than once the location of the last one is given.

A.LogDeterminant() returns a value of type LogAndSign. If ld is of type LogAndSign use

    ld.Value()    to get the value of the determinant
    ld.Sign()     to get the sign of the determinant (values 1, 0, -1)
    ld.LogValue() to get the log of the absolute value.
Note that the direct use of the function Determinant() will often cause a floating point overflow exception.

A.IsZero() returns Boolean value true if the matrix A has all elements equal to 0.0.

IsSingular is defined only for CroutMatrix and BandLUMatrix. It returns true if one of the diagonal elements of the LU decomposition is exactly zero.

MatrixType mt = A.Type() returns the type of a matrix. Use (char*)mt to get a string (UT, LT, Rect, Sym, Diag, Band, UB, LB, Crout, BndLU) showing the type (Vector types are returned as Rect).

MatrixBandWidth has member functions Upper() and Lower() for finding the upper and lower bandwidths (number of diagonals above and below the diagonal, both zero for a diagonal matrix). For non-band matrices -1 is returned for both these values.

The versions Sum(A), SumSquare(A), SumAbsoluteValue(A), MaximumAbsoluteValue(A), MinimumAbsoluteValue(A), Maximum(A), Minimum(A), Trace(A), LogDeterminant(A), Determinant(A), Norm1(A), NormInfinity(A) can be used in place of A.Sum(), A.SumSquare(), A.SumAbsoluteValue(), A.MaximumAbsoluteValue(), A.MinimumAbsoluteValue(), A.Maximum(), A.Minimum(), A.Trace(), A.LogDeterminant(), A.Norm1(), A.NormInfinity().

next - skip - up - start