casacore
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
casacore::LSQMatrix Class Reference

More...

#include <LSQMatrix.h>

Public Member Functions

Doublerow_pub (uInt i) const
 A set of public interface functions. More...
 
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. More...
 
void decRow_pub (Double *&row, uInt i) const
 
Doublediag_pub (uInt i) const
 Get diagonal element pointer [i][i] More...
 
uInt nelements_pub () const
 Get length of triangular array. More...
 
uInt nrows_pub () const
 Get number of rows. More...
 
void doDiagonal_pub (uInt n)
 Make diagonal element 1 if zero (Note that this is always called when invert() is called). More...
 
void mulDiagonal_pub (uInt n, Double fac)
 Multiply n-length of diagonal with 1+fac More...
 
void addDiagonal_pub (uInt n, Double fac)
 Add fac to n-length of diagonal. More...
 
Double maxDiagonal_pub (uInt n)
 Determine max of abs values of n-length of diagonal. More...
 
- Public Member Functions inherited from casacore::RecordTransformable
virtual ~RecordTransformable ()
 The destructor must be virtual so that the destructor of derived classes is actually used. More...
 
virtual Bool fromString (String &error, const String &inString)
 Initialise the class from a String representation. More...
 

Private Member Functions

 LSQMatrix ()
 Default constructor (empty, only usable after a set(n)) More...
 
 LSQMatrix (uInt n)
 Construct an object with the number of rows and columns indicated. More...
 
 LSQMatrix (uInt n, Bool)
 
 LSQMatrix (const LSQMatrix &other)
 Copy constructor (deep copy) More...
 
LSQMatrixoperator= (const LSQMatrix &other)
 Assignment (deep copy) More...
 
 ~LSQMatrix ()
 
Doubleoperator[] (uInt index)
 Index an element in the triangularised matrix. More...
 
Double operator[] (uInt index) const
 
void reset ()
 Reset all data to zero. More...
 
void set (uInt n)
 Set new sizes (default is for Real, a Bool argument will make it complex) More...
 
void set (uInt n, Bool)
 
Doublerow (uInt i) const
 Get row pointer in normal equation (points to element [i][0]) More...
 
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. More...
 
void decRow (Double *&row, uInt i) const
 
Doublediag (uInt i) const
 Get diagonal element pointer [i][i] More...
 
uInt nelements () const
 Get length of triangular array. More...
 
uInt nrows () const
 Get number of rows. More...
 
void copy (const LSQMatrix &other)
 Copy data. More...
 
void init ()
 Initialise matrix. More...
 
void clear ()
 Clear matrix. More...
 
void deinit ()
 De-initialise matrix. More...
 
void doDiagonal (uInt n)
 Make diagonal element 1 if zero (Note that this is always called when invert() is called). More...
 
void mulDiagonal (uInt n, Double fac)
 Multiply n-length of diagonal with 1+fac More...
 
void addDiagonal (uInt n, Double fac)
 Add fac to n-length of diagonal. More...
 
Double maxDiagonal (uInt n)
 Determine max of abs values of n-length of diagonal. More...
 
Bool fromRecord (String &error, const RecordInterface &in)
 Create a Matrix from a record. More...
 
Bool toRecord (String &error, RecordInterface &out) const
 Create a record from an LSQMatrix. More...
 
const Stringident () const
 Get identification of record. More...
 
void fromAipsIO (AipsIO &in)
 Save or restore using AipsIO. More...
 
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. More...
 
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) More...
 
uInt len_p
 Derived sizes (all 0 if n_p equals 0) More...
 
uInt nm1_p
 n-1 More...
 
Int n2m1_p
 2n-1 More...
 
Int n2p1_p
 2n+1 More...
 
Doubletrian_p
 Matrix (triangular n_p * n_p) More...
 

Static Private Attributes

static const String tmatsiz
 Record field names. More...
 
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

◆ LSQMatrix() [1/4]

casacore::LSQMatrix::LSQMatrix ( )
private

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

◆ LSQMatrix() [2/4]

casacore::LSQMatrix::LSQMatrix ( uInt  n)
explicitprivate

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() [3/4]

casacore::LSQMatrix::LSQMatrix ( uInt  n,
Bool   
)
private

◆ LSQMatrix() [4/4]

casacore::LSQMatrix::LSQMatrix ( const LSQMatrix other)
private

Copy constructor (deep copy)

◆ ~LSQMatrix()

casacore::LSQMatrix::~LSQMatrix ( )
private

Member Function Documentation

◆ addDiagonal()

void casacore::LSQMatrix::addDiagonal ( uInt  n,
Double  fac 
)
private

Add fac to n-length of diagonal.

Referenced by addDiagonal_pub().

◆ addDiagonal_pub()

void casacore::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.

◆ clear()

void casacore::LSQMatrix::clear ( )
private

Clear matrix.

Referenced by reset().

◆ copy()

void casacore::LSQMatrix::copy ( const LSQMatrix other)
private

Copy data.

◆ decRow()

void casacore::LSQMatrix::decRow ( Double *&  row,
uInt  i 
) const
inlineprivate

Definition at line 158 of file LSQMatrix.h.

References n_p, and row().

Referenced by decRow_pub().

◆ decRow_pub()

void casacore::LSQMatrix::decRow_pub ( Double *&  row,
uInt  i 
) const
inline

Definition at line 99 of file LSQMatrix.h.

References decRow(), and row().

◆ deinit()

void casacore::LSQMatrix::deinit ( )
private

De-initialise matrix.

◆ diag()

Double* casacore::LSQMatrix::diag ( uInt  i) const
inlineprivate

Get diagonal element pointer [i][i]

Definition at line 161 of file LSQMatrix.h.

References n2p1_p, and trian_p.

Referenced by diag_pub().

◆ diag_pub()

Double* casacore::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.

◆ doDiagonal()

void casacore::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().

◆ doDiagonal_pub()

void casacore::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.

◆ fromAipsIO()

void casacore::LSQMatrix::fromAipsIO ( AipsIO in)
private

Save or restore using AipsIO.

◆ fromRecord()

Bool casacore::LSQMatrix::fromRecord ( String error,
const RecordInterface in 
)
privatevirtual

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 casacore::RecordTransformable.

◆ getCArray() [1/4]

static void casacore::LSQMatrix::getCArray ( AipsIO in,
uInt  len,
Double *&  out 
)
staticprivate

◆ getCArray() [2/4]

static void casacore::LSQMatrix::getCArray ( AipsIO in,
uInt  len,
uInt *&  out 
)
staticprivate

◆ getCArray() [3/4]

static Bool casacore::LSQMatrix::getCArray ( String error,
const RecordInterface in,
const String fname,
uInt  len,
Double *&  out 
)
staticprivate

◆ getCArray() [4/4]

static Bool casacore::LSQMatrix::getCArray ( String error,
const RecordInterface in,
const String fname,
uInt  len,
uInt *&  out 
)
staticprivate

◆ ident()

const String& casacore::LSQMatrix::ident ( ) const
privatevirtual

Get identification of record.

Reimplemented from casacore::RecordTransformable.

◆ incRow()

void casacore::LSQMatrix::incRow ( Double *&  row,
uInt  i 
) const
inlineprivate

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, and row().

Referenced by incRow_pub().

◆ incRow_pub()

void casacore::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(), n_p, and row().

◆ init()

void casacore::LSQMatrix::init ( )
private

Initialise matrix.

◆ maxDiagonal()

Double casacore::LSQMatrix::maxDiagonal ( uInt  n)
private

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

Referenced by maxDiagonal_pub().

◆ maxDiagonal_pub()

Double casacore::LSQMatrix::maxDiagonal_pub ( uInt  n)
inline

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

Definition at line 115 of file LSQMatrix.h.

References maxDiagonal(), and n_p.

◆ mulDiagonal()

void casacore::LSQMatrix::mulDiagonal ( uInt  n,
Double  fac 
)
private

Multiply n-length of diagonal with 1+fac

Referenced by mulDiagonal_pub().

◆ mulDiagonal_pub()

void casacore::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.

◆ nelements()

uInt casacore::LSQMatrix::nelements ( ) const
inlineprivate

Get length of triangular array.

Definition at line 163 of file LSQMatrix.h.

References len_p.

◆ nelements_pub()

uInt casacore::LSQMatrix::nelements_pub ( ) const
inline

Get length of triangular array.

Definition at line 104 of file LSQMatrix.h.

References len_p.

◆ nrows()

uInt casacore::LSQMatrix::nrows ( ) const
inlineprivate

Get number of rows.

Definition at line 165 of file LSQMatrix.h.

References n_p.

◆ nrows_pub()

uInt casacore::LSQMatrix::nrows_pub ( ) const
inline

Get number of rows.

Definition at line 106 of file LSQMatrix.h.

References n_p.

◆ operator=()

LSQMatrix& casacore::LSQMatrix::operator= ( const LSQMatrix other)
private

Assignment (deep copy)

◆ operator[]() [1/2]

Double& casacore::LSQMatrix::operator[] ( uInt  index)
inlineprivate

Index an element in the triangularised matrix.

Definition at line 140 of file LSQMatrix.h.

References trian_p.

◆ operator[]() [2/2]

Double casacore::LSQMatrix::operator[] ( uInt  index) const
inlineprivate

Definition at line 141 of file LSQMatrix.h.

References trian_p.

◆ putCArray() [1/4]

static void casacore::LSQMatrix::putCArray ( AipsIO out,
uInt  len,
const Double *const  in 
)
staticprivate

◆ putCArray() [2/4]

static void casacore::LSQMatrix::putCArray ( AipsIO out,
uInt  len,
const uInt *const  in 
)
staticprivate

◆ putCArray() [3/4]

static Bool casacore::LSQMatrix::putCArray ( String error,
RecordInterface out,
const String fname,
uInt  len,
const Double *const  in 
)
staticprivate

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

◆ putCArray() [4/4]

static Bool casacore::LSQMatrix::putCArray ( String error,
RecordInterface out,
const String fname,
uInt  len,
const uInt *const  in 
)
staticprivate

◆ reset()

void casacore::LSQMatrix::reset ( )
inlineprivate

Reset all data to zero.

Definition at line 146 of file LSQMatrix.h.

References clear().

◆ row()

Double* casacore::LSQMatrix::row ( uInt  i) const
inlineprivate

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 decRow(), decRow_pub(), incRow(), incRow_pub(), and row_pub().

◆ row_pub()

Double* casacore::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().

◆ set() [1/2]

void casacore::LSQMatrix::set ( uInt  n)
private

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

◆ set() [2/2]

void casacore::LSQMatrix::set ( uInt  n,
Bool   
)
private

◆ toAipsIO()

void casacore::LSQMatrix::toAipsIO ( AipsIO out) const
private

◆ toRecord()

Bool casacore::LSQMatrix::toRecord ( String error,
RecordInterface out 
) const
privatevirtual

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 casacore::RecordTransformable.

Friends And Related Function Documentation

◆ LSQFit

friend class LSQFit
friend

Definition at line 87 of file LSQMatrix.h.

Member Data Documentation

◆ len_p

uInt casacore::LSQMatrix::len_p
private

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

◆ n2m1_p

Int casacore::LSQMatrix::n2m1_p
private

2n-1

Definition at line 232 of file LSQMatrix.h.

Referenced by row().

◆ n2p1_p

Int casacore::LSQMatrix::n2p1_p
private

2n+1

Definition at line 234 of file LSQMatrix.h.

Referenced by diag().

◆ n_p

uInt casacore::LSQMatrix::n_p
private

◆ nm1_p

uInt casacore::LSQMatrix::nm1_p
private

n-1

Definition at line 230 of file LSQMatrix.h.

Referenced by incRow().

◆ tmatdat

const String casacore::LSQMatrix::tmatdat
staticprivate

Definition at line 240 of file LSQMatrix.h.

◆ tmatsiz

const String casacore::LSQMatrix::tmatsiz
staticprivate

Record field names.

Definition at line 239 of file LSQMatrix.h.

◆ trian_p

Double* casacore::LSQMatrix::trian_p
private

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: