casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends
casa::LSQMatrix Class Reference

Support class for the LSQ package. More...

#include <LSQMatrix.h>

Inheritance diagram for casa::LSQMatrix:
casa::RecordTransformable

List of all members.

Public Member Functions

Doublerow_pub (uInt i) const
 A set of public interface functions.
void incRow_pub (Double *&row, uInt i) const
 Get next row or previous row pointer in normal equation if the pointer row is at row i.
void decRow_pub (Double *&row, uInt i) const
Doublediag_pub (uInt i) const
 Get diagonal element pointer [i][i]
uInt nelements_pub () const
 Get length of triangular array.
uInt nrows_pub () const
 Get number of rows.
void doDiagonal_pub (uInt n)
 Make diagonal element 1 if zero (Note that this is always called when invert() is called).
void mulDiagonal_pub (uInt n, Double fac)
 Multiply n-length of diagonal with 1+fac
void addDiagonal_pub (uInt n, Double fac)
 Add fac to n-length of diagonal.
Double maxDiagonal_pub (uInt n)
 Determine max of abs values of n-length of diagonal.

Private Member Functions

 LSQMatrix ()
 
   

 LSQMatrix (uInt n)
 Construct an object with the number of rows and columns indicated.
 LSQMatrix (uInt n, Bool)
 LSQMatrix (const LSQMatrix &other)
 Copy constructor (deep copy)
LSQMatrixoperator= (const LSQMatrix &other)
 Assignment (deep copy)
 ~LSQMatrix ()
Doubleoperator[] (uInt index)
 Index an element in the triangularised matrix.
Double operator[] (uInt index) const
void reset ()
 Reset all data to zero.
void set (uInt n)
 Set new sizes (default is for Real, a Bool argument will make it complex)
void set (uInt n, Bool)
Doublerow (uInt i) const
 Get row pointer in normal equation (points to element [i][0])
void incRow (Double *&row, uInt i) const
 Get next row or previous row pointer in normal equation if the pointer row is at row i.
void decRow (Double *&row, uInt i) const
Doublediag (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).
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.
Bool toRecord (String &error, RecordInterface &out) const
 Create a record from an LSQMatrix.
const Stringident () const
 Get identification of record.
void fromAipsIO (AipsIO &in)
 Save or restore using AipsIO.
void toAipsIO (AipsIO &out) const

Static Private Member Functions

static Bool putCArray (String &error, RecordInterface &out, const String &fname, uInt len, const Double *const in)
 Convert a carray to/from a record.
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)
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)

Private Attributes

uInt n_p
 Matrix size (linear size)
uInt len_p
 Derived sizes (all 0 if n_p equals 0)
uInt nm1_p
 n-1
Int n2m1_p
 2n-1
Int n2p1_p
 2n+1
Doubletrian_p
 Matrix (triangular n_p * n_p)

Static Private Attributes

static const String tmatsiz
 Record field names.
static const String tmatdat

Friends

class LSQFit

Detailed Description

Support class for the LSQ package.

Review Status

Reviewed By:
Wim Brouw
Date Reviewed:
2004/03/20
Test programs:
tLSQFit

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 class contains a number of public methods (with _pub in name) that can be used anywhere, and which perform index range checking.

The contents can be saved in a record (toRecord), and an object can be created from a record (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

Definition at line 85 of file LSQMatrix.h.


Constructor & Destructor Documentation

   

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

casa::LSQMatrix::LSQMatrix ( uInt  n) [explicit, private]

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).

casa::LSQMatrix::LSQMatrix ( uInt  n,
Bool   
) [private]
casa::LSQMatrix::LSQMatrix ( const LSQMatrix other) [private]

Copy constructor (deep copy)


Member Function Documentation

void casa::LSQMatrix::addDiagonal ( uInt  n,
Double  fac 
) [private]

Add fac to n-length of diagonal.

Referenced by addDiagonal_pub().

void casa::LSQMatrix::addDiagonal_pub ( uInt  n,
Double  fac 
) [inline]

Add fac to n-length of diagonal.

Definition at line 113 of file LSQMatrix.h.

References addDiagonal(), and n_p.

void casa::LSQMatrix::clear ( ) [private]

Clear matrix.

Referenced by reset().

void casa::LSQMatrix::copy ( const LSQMatrix other) [private]

Copy data.

void casa::LSQMatrix::decRow ( Double *&  row,
uInt  i 
) const [inline, private]

Definition at line 158 of file LSQMatrix.h.

References n_p.

Referenced by decRow_pub().

void casa::LSQMatrix::decRow_pub ( Double *&  row,
uInt  i 
) const [inline]

Definition at line 99 of file LSQMatrix.h.

References decRow().

void casa::LSQMatrix::deinit ( ) [private]

De-initialise matrix.

Double* casa::LSQMatrix::diag ( uInt  i) const [inline, private]

Get diagonal element pointer [i][i]

Definition at line 161 of file LSQMatrix.h.

References n2p1_p, and trian_p.

Referenced by diag_pub().

Double* casa::LSQMatrix::diag_pub ( uInt  i) const [inline]

Get diagonal element pointer [i][i]

Definition at line 102 of file LSQMatrix.h.

References diag(), and n_p.

void casa::LSQMatrix::doDiagonal ( uInt  n) [private]

Make diagonal element 1 if zero (Note that this is always called when invert() is called).

Only n-length sub-matrix is done.

Referenced by doDiagonal_pub().

void casa::LSQMatrix::doDiagonal_pub ( uInt  n) [inline]

Make diagonal element 1 if zero (Note that this is always called when invert() is called).

Only n-length sub-matrix is done.

Definition at line 109 of file LSQMatrix.h.

References doDiagonal(), and n_p.

void casa::LSQMatrix::fromAipsIO ( AipsIO in) [private]

Save or restore using AipsIO.

Bool casa::LSQMatrix::fromRecord ( String error,
const RecordInterface in 
) [private, virtual]

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.

Implements casa::RecordTransformable.

static Bool casa::LSQMatrix::getCArray ( String error,
const RecordInterface in,
const String fname,
uInt  len,
Double *&  out 
) [static, private]
static Bool casa::LSQMatrix::getCArray ( String error,
const RecordInterface in,
const String fname,
uInt  len,
uInt *&  out 
) [static, private]
static void casa::LSQMatrix::getCArray ( AipsIO in,
uInt  len,
Double *&  out 
) [static, private]
static void casa::LSQMatrix::getCArray ( AipsIO in,
uInt  len,
uInt *&  out 
) [static, private]
const String& casa::LSQMatrix::ident ( ) const [private, virtual]

Get identification of record.

Reimplemented from casa::RecordTransformable.

void casa::LSQMatrix::incRow ( Double *&  row,
uInt  i 
) const [inline, private]

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

Definition at line 157 of file LSQMatrix.h.

References nm1_p.

Referenced by incRow_pub().

void casa::LSQMatrix::incRow_pub ( Double *&  row,
uInt  i 
) const [inline]

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

Definition at line 98 of file LSQMatrix.h.

References incRow(), and n_p.

void casa::LSQMatrix::init ( ) [private]

Initialise matrix.

Determine max of abs values of n-length of diagonal.

Referenced by maxDiagonal_pub().

Determine max of abs values of n-length of diagonal.

Definition at line 115 of file LSQMatrix.h.

References maxDiagonal(), and n_p.

void casa::LSQMatrix::mulDiagonal ( uInt  n,
Double  fac 
) [private]

Multiply n-length of diagonal with 1+fac

Referenced by mulDiagonal_pub().

void casa::LSQMatrix::mulDiagonal_pub ( uInt  n,
Double  fac 
) [inline]

Multiply n-length of diagonal with 1+fac

Definition at line 111 of file LSQMatrix.h.

References mulDiagonal(), and n_p.

uInt casa::LSQMatrix::nelements ( ) const [inline, private]

Get length of triangular array.

Definition at line 163 of file LSQMatrix.h.

References len_p.

Get length of triangular array.

Definition at line 104 of file LSQMatrix.h.

References len_p.

uInt casa::LSQMatrix::nrows ( ) const [inline, private]

Get number of rows.

Definition at line 165 of file LSQMatrix.h.

References n_p.

uInt casa::LSQMatrix::nrows_pub ( ) const [inline]

Get number of rows.

Definition at line 106 of file LSQMatrix.h.

References n_p.

LSQMatrix& casa::LSQMatrix::operator= ( const LSQMatrix other) [private]

Assignment (deep copy)

Double& casa::LSQMatrix::operator[] ( uInt  index) [inline, private]

Index an element in the triangularised matrix.

Definition at line 140 of file LSQMatrix.h.

References trian_p.

Double casa::LSQMatrix::operator[] ( uInt  index) const [inline, private]

Definition at line 141 of file LSQMatrix.h.

References trian_p.

static Bool casa::LSQMatrix::putCArray ( String error,
RecordInterface out,
const String fname,
uInt  len,
const Double *const  in 
) [static, private]

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).

static Bool casa::LSQMatrix::putCArray ( String error,
RecordInterface out,
const String fname,
uInt  len,
const uInt *const  in 
) [static, private]
static void casa::LSQMatrix::putCArray ( AipsIO out,
uInt  len,
const Double *const  in 
) [static, private]
static void casa::LSQMatrix::putCArray ( AipsIO out,
uInt  len,
const uInt *const  in 
) [static, private]
void casa::LSQMatrix::reset ( ) [inline, private]

Reset all data to zero.

Definition at line 146 of file LSQMatrix.h.

References clear().

Double* casa::LSQMatrix::row ( uInt  i) const [inline, private]

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

Definition at line 153 of file LSQMatrix.h.

References n2m1_p, and trian_p.

Referenced by row_pub().

Double* casa::LSQMatrix::row_pub ( uInt  i) const [inline]

A set of public interface functions.

Checks for index ranges are made, and zero or null returned if error.

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

Definition at line 94 of file LSQMatrix.h.

References n_p, and row().

void casa::LSQMatrix::set ( uInt  n) [private]

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

void casa::LSQMatrix::set ( uInt  n,
Bool   
) [private]
void casa::LSQMatrix::toAipsIO ( AipsIO out) const [private]
Bool casa::LSQMatrix::toRecord ( String error,
RecordInterface out 
) const [private, virtual]

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.

Implements casa::RecordTransformable.


Friends And Related Function Documentation

friend class LSQFit [friend]

Definition at line 87 of file LSQMatrix.h.


Member Data Documentation

Derived sizes (all 0 if n_p equals 0)

Total size

Definition at line 228 of file LSQMatrix.h.

Referenced by nelements(), and nelements_pub().

2n-1

Definition at line 232 of file LSQMatrix.h.

Referenced by row().

2n+1

Definition at line 234 of file LSQMatrix.h.

Referenced by diag().

n-1

Definition at line 230 of file LSQMatrix.h.

Referenced by incRow().

const String casa::LSQMatrix::tmatdat [static, private]

Definition at line 240 of file LSQMatrix.h.

const String casa::LSQMatrix::tmatsiz [static, private]

Record field names.

Definition at line 239 of file LSQMatrix.h.

Matrix (triangular n_p * n_p)

Definition at line 237 of file LSQMatrix.h.

Referenced by diag(), operator[](), and row().


The documentation for this class was generated from the following file: