LSQMatrix.h

Classes

LSQMatrix -- Support class for the LSQ package (full description)

class LSQMatrix : public RecordTransformable

Interface

Private Members
LSQMatrix()
explicit LSQMatrix(uInt n)
LSQMatrix(uInt n, Bool)
LSQMatrix(const LSQMatrix &other)
LSQMatrix &operator=(const LSQMatrix &other)
~LSQMatrix()
Double &operator[](uInt index)
const Double operator[](uInt index) const
void reset()
void set(uInt n)
void set(uInt n, Bool)
Double *row(uInt i) const
void incRow(Double *&row, uInt i) const
void decRow(Double *&row, uInt i) const
Double *diag(uInt i) const
uInt nelements() const
uInt nrows() const
void copy(const LSQMatrix &other)
void init()
void clear()
void deinit()
void doDiagonal(uInt n)
void mulDiagonal(uInt n, Double fac)
void addDiagonal(uInt n, Double fac)
Double maxDiagonal(uInt n)
Bool fromRecord(String &error, const RecordInterface &in)
Bool toRecord(String &error, RecordInterface &out) const
const String &ident() const
static Bool putCArray(String &error, RecordInterface &out, const String &fname, uInt len, const Double * const in)
static Bool getCArray(String &error, const RecordInterface &in, const String &fname, uInt len, Double *&out)
static Bool putCArray(String &error, RecordInterface &out, const String &fname, uInt len, const uInt * const in)
static Bool getCArray(String &error, const RecordInterface &in, const String &fname, uInt len, uInt *&out)
void fromAipsIO (AipsIO& in)
void toAipsIO (AipsIO& out) const
static void putCArray (AipsIO& out, uInt len, const Double* const in)
static void getCArray (AipsIO& in, uInt len, Double*& out)
static void putCArray (AipsIO& out, uInt len, const uInt* const in)
static void getCArray (AipsIO& in, uInt len, uInt*& out)

Description

Prerequisite

Etymology

From Least SQuares and Matrix

Synopsis

The LSQMatrix class contains the handling of the basic container used in the LSQFit class and its derivatives. This basic container is a triangular matrix.

The basic operations provided are referencing and indexing of cells, rows, columns and diagonal of the triangular matrix. The class is a private structure, with explicit friends.

The contents can be saved in a record (toRecord<src>), and an object can be created from a record (<src>fromRecord). The record identifier is 'tmat'.

Example

See the LSQFit class for its use.

Motivation

The class was written to isolate the handling of the normal equations used in the LSQ classes.

To Do

Member Description

LSQMatrix()

Default constructor (empty, only usable after a set(n))

explicit LSQMatrix(uInt n)
LSQMatrix(uInt n, Bool)

Construct an object with the number of rows and columns indicated. If a Bool argument is present, the number will be taken as double the number given (assumes complex).

LSQMatrix(const LSQMatrix &other)

Copy constructor (deep copy)

LSQMatrix &operator=(const LSQMatrix &other)

Assignment (deep copy)

~LSQMatrix()

Double &operator[](uInt index)
const Double operator[](uInt index) const

Index an element in the triangularised matrix

void reset()

Reset all data to zero

void set(uInt n)
void set(uInt n, Bool)

Set new sizes (default is for Real, a Bool argument will make it complex)

Double *row(uInt i) const

Get row pointer in normal equation (points to element [i][0])

void incRow(Double *&row, uInt i) const
void decRow(Double *&row, uInt i) const

Get next row or previous row pointer in normal equation if the pointer row is at row i.

Double *diag(uInt i) const

Get diagonal element pointer [i][i]

uInt nelements() const

Get length of triangular array

uInt nrows() const

Get number of rows

void copy(const LSQMatrix &other)

Copy data.

void init()

Initialise matrix

void clear()

Clear matrix

void deinit()

De-initialise matrix

void doDiagonal(uInt n)

Make diagonal element 1 if zero (Note that this is always called when invert() is called). Only n-length sub-matrix is done.

void mulDiagonal(uInt n, Double fac)

Multiply n-length of diagonal with 1+fac

void addDiagonal(uInt n, Double fac)

Add fac to n-length of diagonal

Double maxDiagonal(uInt n)

Determine max of abs values of n-length of diagonal

Bool fromRecord(String &error, const RecordInterface &in)

Create a Matrix from a record. An error message is generated, and False returned if an invalid record is given. A valid record will return True. Error messages are postfixed to error.

Bool toRecord(String &error, RecordInterface &out) const

Create a record from an LSQMatrix. The return will be False and an error message generated only if the object does not contain a valid Matrix. Error messages are postfixed to error.

const String &ident() const

Get identification of record

static Bool putCArray(String &error, RecordInterface &out, const String &fname, uInt len, const Double * const in)
static Bool getCArray(String &error, const RecordInterface &in, const String &fname, uInt len, Double *&out)
static Bool putCArray(String &error, RecordInterface &out, const String &fname, uInt len, const uInt * const in)
static Bool getCArray(String &error, const RecordInterface &in, const String &fname, uInt len, uInt *&out)

Convert a carray to/from a record. Field only written if non-zero length. No carray created if field does not exist on input. False returned if unexpectedly no data available for non-zero length (put), or a field has zero length vector(get).

void fromAipsIO (AipsIO& in)

Save or restore using AipsIO.

void toAipsIO (AipsIO& out) const

static void putCArray (AipsIO& out, uInt len, const Double* const in)

static void getCArray (AipsIO& in, uInt len, Double*& out)

static void putCArray (AipsIO& out, uInt len, const uInt* const in)

static void getCArray (AipsIO& in, uInt len, uInt*& out)