[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 3. Arrays

3.1 Constructors and Assignment |  |

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 3.1 Constructors and Assignment

Constructor: Array<T> (void)
  Create an array with no elements.

Constructor: Array<T> (int n [, const T &val])
  Create an array with n elements. If the optional argument val is supplied, the elements are initialized to val; otherwise, they are left uninitialized. If n is less than zero, the current error handler is invoked (see section 13. Error Handling).

Constructor: Array<T> (const Array<T> &a)
  Create a copy of the Array<T> object a. Memory for the Array<T> class is managed using a reference counting scheme, so the cost of this operation is independent of the size of the array.

Assignment: Array<T> Array<T>& {operator =} (const Array<T> &a)
  Assignment operator. Memory for the Array<T> class is managed using a reference counting scheme, so the cost of this operation is independent of the size of the array.

Method: Array<T> int capacity (void) const
  @deftypemethodx Array<T> int length (void) const Return the length of the array.

Method: Array<T> T& elem (int n)
  @deftypemethodx Array<T> T& checkelem (int n) If n is within the bounds of the array, return a reference to the element indexed by n; otherwise, the current error handler is invoked (see section 13. Error Handling).

Indexing: Array<T> T& {operator ()} (int n)

Method: Array<T> T elem (int n) const
  @deftypemethodx Array<T> T checkelem (int n) const If n is within the bounds of the array, return the value indexed by n; otherwise, call the current error handler. See section 13. Error Handling.

Indexing: Array<T> T {operator ()} (int n) const

Method: Array<T> T& xelem (int n)
  @deftypemethodx Array<T> T xelem (int n) const Return a reference to, or the value of, the element indexed by n. These methods never perform bounds checking.

Method: Array<T> void resize {(int n [, const T &val])}
  Change the size of the array to be n elements. All elements are unchanged, except that if n is greater than the current size and the optional argument val is provided, the additional elements are initialized to val; otherwise, any additional elements are left uninitialized. In the current implementation, if n is less than the current size, the length is updated but no memory is released.

Method: Array<T> const T* data (void) const

Constructor: Array2<T> Array2<T> Array2 (void)
Constructor: Array2<T> (int n, int m)
Constructor: Array2<T> (int n, int m, const T &val)
Constructor: Array2<T> (const Array2<T> &a)
Constructor: Array2<T> (const DiagArray<T> &a)

Assignment: Array2<T> Array2<T>& {operator =} (const Array2<T> &a)

Method: Array2<T> int dim1 (void) const
  @deftypemethodx Array2<T> int rows (void) const

Method: Array2<T> int dim2 (void) const
  @deftypemethodx Array2<T> int cols (void) const @deftypemethodx Array2<T> int columns (void) const

Method: Array2<T> T& elem (int i, int j)
  @deftypemethodx Array2<T> T& checkelem (int i, int j)

Indexing: Array2<T> T& {operator ()} (int i, int j)

Method: Array2<T> void resize (int n, int m)
  @deftypemethodx Array2<T> void resize (int n, int m, const T &val)

Constructor: Array3<T> (void)
Constructor: Array3<T> (int n, int m, int k)
Constructor: Array3<T> (int n, int m, int k, const T &val)
Constructor: Array3<T> (const Array3<T> &a)

Assignment: Array3<T> Array3<T>& {operator =} (const Array3<T> &a)

Method: Array3<T> int dim1 (void) const
  @deftypemethodx Array3<T> int dim2 (void) const @deftypemethodx Array3<T> int dim3 (void) const

Method: Array3<T> T& elem (int i, int j, int k)
  @deftypemethodx Array3<T> T& checkelem (int i, int j, int k)

Indexing: Array3<T> T& {operator ()} (int i, int j, int k)

Method: Array3<T> void resize (int n, int m, int k)
  @deftypemethodx Array3<T> void resize (int n, int m, int k, const T &val)

Constructor: DiagArray<T> (void)
Constructor: DiagArray<T> (int n)
Constructor: DiagArray<T> (int n, const T &val)
Constructor: DiagArray<T> (int r, int c)
Constructor: DiagArray<T> (int r, int c, const T &val)
Constructor: DiagArray<T> (const Array<T> &a)
Constructor: DiagArray<T> (const DiagArray<T> &a)

Assginment: DiagArray<T>& operator = (const DiagArray<T> &a)

Method: DiagArray<T> int dim1 (void) const
  @deftypemethodx DiagArray<T> int rows (void) const

Method: DiagArray<T> int dim2 (void) const
  @deftypemethodx DiagArray<T> int cols (void) const @deftypemethodx DiagArray<T> int columns (void) const

Method: DiagArray<T> T& elem (int r, int c)
  @deftypemethodx DiagArray<T> T& checkelem (int r, int c)

Indexing: DiagArray<T> T& {operator ()} (int r, int c)

Method: DiagArray<T> void resize (int n, int m)
  @deftypemethodx DiagArray<T> void resize (int n, int m, const T &val)

The real and complex `ColumnVector` and `RowVector` classes all have the following functions. These will eventually be part of an `MArray<T>` class, derived from the `Array<T>` class. Then the `ColumnVector` and `RowVector` classes will be derived from the `MArray<T>` class.

Element by element vector by scalar ops.

: RowVector operator + (const RowVector &a, const double &s)
: RowVector operator - (const RowVector &a, const double &s)
: RowVector operator * (const RowVector &a, const double &s)
: RowVector operator / (const RowVector &a, const double &s)

Element by element scalar by vector ops.

: RowVector operator + (const double &s, const RowVector &a)
: RowVector operator - (const double &s, const RowVector &a)
: RowVector operator * (const double &s, const RowVector &a)
: RowVector operator / (const double &s, const RowVector &a)

Element by element vector by vector ops.

: RowVector operator + (const RowVector &a, const RowVector &b)
: RowVector operator - (const RowVector &a, const RowVector &b)

: RowVector product (const RowVector &a, const RowVector &b)
: RowVector quotient (const RowVector &a, const RowVector &b)

Unary MArray ops.

: RowVector operator - (const RowVector &a)

The `Matrix` classes share the following functions. These will eventually be part of an `MArray2<T>` class, derived from the `Array2<T>` class. Then the `Matrix` class will be derived from the `MArray<T>` class.

Element by element matrix by scalar ops.

: Matrix operator + (const Matrix &a, const double &s)
: Matrix operator - (const Matrix &a, const double &s)
: Matrix operator * (const Matrix &a, const double &s)
: Matrix operator / (const Matrix &a, const double &s)

Element by element scalar by matrix ops.

: Matrix operator + (const double &s, const Matrix &a)
: Matrix operator - (const double &s, const Matrix &a)
: Matrix operator * (const double &s, const Matrix &a)
: Matrix operator / (const double &s, const Matrix &a)

Element by element matrix by matrix ops.

: Matrix operator + (const Matrix &a, const Matrix &b)
: Matrix operator - (const Matrix &a, const Matrix &b)

: Matrix product (const Matrix &a, const Matrix &b)
: Matrix quotient (const Matrix &a, const Matrix &b)

Unary matrix ops.

: Matrix operator - (const Matrix &a)

The `DiagMatrix` classes share the following functions. These will eventually be part of an `MDiagArray<T>` class, derived from the `DiagArray<T>` class. Then the `DiagMatrix` class will be derived from the `MDiagArray<T>` class.

Element by element MDiagArray by scalar ops.

: DiagMatrix operator * (const DiagMatrix &a, const double &s)
: DiagMatrix operator / (const DiagMatrix &a, const double &s)

Element by element scalar by MDiagArray ops.

: DiagMatrix operator * (const double &s, const DiagMatrix &a)

Element by element MDiagArray by MDiagArray ops.

: DiagMatrix operator + (const DiagMatrix &a, const DiagMatrix &b)
: DiagMatrix operator - (const DiagMatrix &a, const DiagMatrix &b)

: DiagMatrix product (const DiagMatrix &a, const DiagMatrix &b)

Unary MDiagArray ops.

: DiagMatrix operator - (const DiagMatrix &a)

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by John W. Eaton on January, 20 2004 using texi2html