casa
$Rev:20696$
|
Support class for the LSQ package. More...
#include <LSQMatrix.h>
Public Member Functions | |
Double * | row_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 |
Double * | diag_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) | |
LSQMatrix & | operator= (const LSQMatrix &other) |
Assignment (deep copy) | |
~LSQMatrix () | |
Double & | operator[] (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) |
Double * | row (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 |
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). | |
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 String & | ident () 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 | |
Double * | trian_p |
Matrix (triangular n_p * n_p) | |
Static Private Attributes | |
static const String | tmatsiz |
Record field names. | |
static const String | tmatdat |
Friends | |
class | LSQFit |
Support class for the LSQ package.
From Least SQuares and Matrix
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'.
See the LSQFit class for its use.
The class was written to isolate the handling of the normal equations used in the LSQ
classes.
Definition at line 85 of file LSQMatrix.h.
casa::LSQMatrix::LSQMatrix | ( | ) | [private] |
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)
casa::LSQMatrix::~LSQMatrix | ( | ) | [private] |
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] |
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.
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.
void casa::LSQMatrix::init | ( | ) | [private] |
Initialise matrix.
Double casa::LSQMatrix::maxDiagonal | ( | uInt | n | ) | [private] |
Determine max of abs values of n-length of diagonal.
Referenced by maxDiagonal_pub().
Double casa::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.
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] |
uInt casa::LSQMatrix::nelements_pub | ( | ) | const [inline] |
uInt casa::LSQMatrix::nrows | ( | ) | const [inline, private] |
uInt casa::LSQMatrix::nrows_pub | ( | ) | const [inline] |
Index an element in the triangularised matrix.
Definition at line 140 of file LSQMatrix.h.
References trian_p.
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] |
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.
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.
friend class LSQFit [friend] |
Definition at line 87 of file LSQMatrix.h.
uInt casa::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().
Int casa::LSQMatrix::n2m1_p [private] |
Int casa::LSQMatrix::n2p1_p [private] |
uInt casa::LSQMatrix::n_p [private] |
Matrix size (linear size)
Definition at line 224 of file LSQMatrix.h.
Referenced by addDiagonal_pub(), decRow(), diag_pub(), doDiagonal_pub(), incRow_pub(), maxDiagonal_pub(), mulDiagonal_pub(), nrows(), nrows_pub(), and row_pub().
uInt casa::LSQMatrix::nm1_p [private] |
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.
Double* casa::LSQMatrix::trian_p [private] |
Matrix (triangular n_p * n_p)
Definition at line 237 of file LSQMatrix.h.
Referenced by diag(), operator[](), and row().