Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Examples  

matrix Class Template Reference

Implementation of a matrix with entries of type T. More...

#include <matrices.h>

Inheritance diagram for matrix::

simplex_table List of all members.

Public Methods

 matrix (index m_init=0, index n_init=0, index m_delta_init=2, index n_delta_init=2)
 matrix (index m_init, index n_init, T *A, index m_delta_init=2, index n_delta_init=2)
 matrix (const matrix< T > &x)
matrix< T > & operator= (const matrix< T > &x)
 ~matrix (void)
index get_m (void) const
index get_n (void) const
T & operator() (index i, index j)
at (index i, index j) const
access (index i, index j) const
void resize (index new_m=0, index new_n=0)
vector< T > row (index j) const
matrix< T > rows (vector< index > indices) const
void ins_row (index i)
void ins_row (index i, vector< T > x)
void join_row (vector< T > x)
void del_row (index i)
void del_rows (vector< index > indices)
vector< T > take_row (index i)
matrix< T > take_rows (vector< index > indices)
void add_row (index i1, index i2, T alpha)
void add_rows (index i1, T alpha1, index i2, T alpha2)
void mult_row (index i, T alpha)
void div_row (index i, T alpha)
void swap_rows (index i1, index i2)
vector< T > col (index j) const
matrix< T > cols (vector< index > indices) const
void ins_col (index j)
void ins_col (index j, vector< T > x)
void join_col (vector< T > x)
void del_col (index j)
void del_cols (vector< index > indices)
vector< T > take_col (index j)
matrix< T > take_cols (vector< index > indices)
void add_col (index j1, index j2, T alpha)
void add_cols (index j1, T alpha1, index j2, T alpha2)
void mult_col (index j, T alpha)
void div_col (index j, T alpha)
void swap_cols (index j1, index j2)
matrix< T > sumbatrix (vector< index > r, vector< index > c)
matrix operator+ ()
matrix operator- ()

Friends

ostream & operator<< (ostream &s, const matrix &x)
istream & operator>> (istream &s, matrix &x)
matrix< T > operator+ (const matrix< T > &, const matrix< T > &)
matrix< T > operator * (const matrix< T > &, const matrix< T > &)
matrix< T > operator * (T alpha, const matrix< T > &a)
matrix< T > operator * (const matrix< T > &a, const vector< T > &v)
matrix< T > operator * (const vector< T > &v, const matrix< T > &a)
matrix< T > transpose (const matrix< T > &a)
int operator== (const matrix< T > &a, const matrix< T > &b)
int operator!= (const matrix< T > &a, const matrix< T > &b)
matrix< T > diag (const vector< T > &d)
matrix< T > diag (T a, index m, index n)
matrix< T > diag (T a, index m)
matrix< T > eye (T a, index m, index n)
matrix< T > eye (T a, index m)
matrix< T > fill (T a, index m, index n)
matrix< T > fill (T a, index m)
matrix< T > zero (T a, index m, index n)
matrix< T > zero (T a, index m)
void pretty (ostr &s, const matrix< T > &A)
void print2 (ostr &s, const matrix< T > &A, const matrix< T > &B)
void print3 (ostr &s, const matrix< T > &A, const matrix< T > &B, const matrix< T > &C)
istream & operator>> (istream &s, matrix &x)
void print2 (ostr &s, const matrix< T > &A, const matrix< T > &B)
void print3 (ostr &s, const matrix< T > &A, const matrix< T > &B, const matrix< T > &C)

Detailed Description

template<class T>
class matrix< T >

Implementation of a matrix with entries of type T.

Definition at line 254 of file matrices.h.


Constructor & Destructor Documentation

template<class T>
matrix< T >::matrix index m_init = 0,
index n_init = 0,
index m_delta_init = 2,
index n_delta_init = 2
 

Constructor.

Creates a matrix with m_init rows and n_init columns, initial entries are undefined. All indices begin with 0 m_delta_init, n_delta_init are increasing steps

Definition at line 923 of file matrices.h.

template<class T>
matrix< T >::matrix index m_init,
index n_init,
T * A,
index m_delta_init = 2,
index n_delta_init = 2
 

Creates a matrix with m_init rows and n_init columns and initial entries from A (in the row order).

Definition at line 935 of file matrices.h.

template<class T>
matrix< T >::matrix const matrix< T > & x
 

Creates a copy of a matrix.

Definition at line 954 of file matrices.h.

template<class T>
matrix< T >::~matrix void
 

Destructor.

Definition at line 999 of file matrices.h.


Member Function Documentation

template<class T>
T matrix< T >::access index i,
index j
const
 

Two-dimensional subscript operator to get individual matrix elements.

Without bounds checking

Definition at line 1777 of file matrices.h.

Referenced by matrix(), operator *(), operator+(), and operator=().

template<class T>
void matrix< T >::add_col index j1,
index j2,
T alpha
 

Adds to the j1-column the j2-column multiplied with alpha.

Definition at line 1540 of file matrices.h.

Referenced by simplex_table::pivoting_col().

template<class T>
void matrix< T >::add_cols index j1,
T alpha1,
index j2,
T alpha2
 

Calculates a new column as a linear combination of j1-th and j2-th columns with coefficients alpha1 and alpha2, then joins a new column to the right side of a matrix.

Definition at line 1552 of file matrices.h.

template<class T>
void matrix< T >::add_row index i1,
index i2,
T alpha
 

Adds to the i1-row the i2-row multiplied with alpha.

Definition at line 1320 of file matrices.h.

template<class T>
void matrix< T >::add_rows index i1,
T alpha1,
index i2,
T alpha2
 

Calculates a new row as a linear combination of i1-th and i2-th rows with coefficients alpha1 and alpha2, then joins a new row to the bottom of a matrix.

Definition at line 1330 of file matrices.h.

template<class T>
T matrix< T >::at index i,
index j
const [inline]
 

Two-dimensional subscript operator to get individual matrix elements.

Definition at line 1013 of file matrices.h.

Referenced by cols(), simplex_table::find_generating_row(), simplex_table::find_generating_row_mip(), simplex_table::find_pivot_col(), simplex_table::find_pivot_row(), simplex_table::gomory1(), simplex_table::gomory2(), simplex_table::pivoting_col(), pretty(), print2(), print3(), and rows().

template<class T>
vector< T > matrix< T >::col index j const
 

Returns the j-th column.

Definition at line 1383 of file matrices.h.

Referenced by take_col().

template<class T>
matrix< T > matrix< T >::cols vector< index > indices const
 

Returns a matrix composed from columns with numbers indices.

Definition at line 1399 of file matrices.h.

Referenced by take_cols().

template<class T>
void matrix< T >::del_col index j
 

Deletes j-th column.

Definition at line 1482 of file matrices.h.

template<class T>
void matrix< T >::del_cols vector< index > indices
 

Deletes columns.

Definition at line 1502 of file matrices.h.

Referenced by take_cols().

template<class T>
void matrix< T >::del_row index i
 

Deletes i-th row.

Definition at line 1224 of file matrices.h.

Referenced by simplex_table::gomory1(), and simplex_table::gomory2().

template<class T>
void matrix< T >::del_rows vector< index > indices
 

Deletes rows with numbers indices.

Definition at line 1244 of file matrices.h.

template<class T>
void matrix< T >::div_col index j,
T alpha
 

Divides the j-th column with scalar alpha.

Definition at line 1585 of file matrices.h.

Referenced by simplex_table::pivoting_col().

template<class T>
void matrix< T >::div_row index i,
T alpha
 

Divides the i-th row with scalar alpha.

Definition at line 1360 of file matrices.h.

template<class T>
index matrix< T >::get_m void const [inline]
 

Returns the number of rows.

Definition at line 286 of file matrices.h.

Referenced by det(), det_int(), simplex_table::get_rows(), inv(), matrix(), operator *(), operator+(), operator=(), operator==(), operator>>(), pretty(), print2(), print3(), and transpose().

template<class T>
index matrix< T >::get_n void const [inline]
 

Returns the number of columns.

Definition at line 288 of file matrices.h.

Referenced by det(), det_int(), simplex_table::get_cols(), inv(), matrix(), operator *(), operator+(), operator=(), operator==(), operator>>(), pretty(), print2(), print3(), and transpose().

template<class T>
void matrix< T >::ins_col index j,
vector< T > x
 

Inserts new column x.

Definition at line 1456 of file matrices.h.

template<class T>
void matrix< T >::ins_col index j
 

Inserts new column.

Definition at line 1410 of file matrices.h.

Referenced by add_cols(), ins_col(), and join_col().

template<class T>
void matrix< T >::ins_row index i,
vector< T > x
 

Inserts a row x.

Definition at line 1164 of file matrices.h.

template<class T>
void matrix< T >::ins_row index i
 

Inserts i-th row.

Definition at line 1140 of file matrices.h.

Referenced by add_rows(), simplex_table::gomory1(), simplex_table::gomory2(), ins_row(), and join_row().

template<class T>
void matrix< T >::join_col vector< T > x
 

ins_col(get_n(), x) makes the same.

Definition at line 1476 of file matrices.h.

template<class T>
void matrix< T >::join_row vector< T > x
 

ins_row(get_m(), x) makes the same.

Definition at line 1184 of file matrices.h.

Referenced by take_rows().

template<class T>
void matrix< T >::mult_col index j,
T alpha
 

Multiplies the j-th column with scalar alpha.

Definition at line 1573 of file matrices.h.

template<class T>
void matrix< T >::mult_row index i,
T alpha
 

Multiplies the i-th row with scalar alpha.

Definition at line 1350 of file matrices.h.

template<class T>
T & matrix< T >::operator() index i,
index j
[inline]
 

Two-dimensional subscript operator to get/set individual matrix elements.

Definition at line 1005 of file matrices.h.

Referenced by simplex_table::gomory1(), and simplex_table::gomory2().

template<class T>
matrix matrix< T >::operator+ [inline]
 

Unary plus.

Definition at line 385 of file matrices.h.

template<class T>
matrix< T > matrix< T >::operator-
 

Unary minus.

Definition at line 1639 of file matrices.h.

template<class T>
matrix< T > & matrix< T >::operator= const matrix< T > & x
 

Assignement.

Definition at line 969 of file matrices.h.

template<class T>
void matrix< T >::resize index new_m = 0,
index new_n = 0
 

Construct new new_m-by-new_n matrix.

New entries are undefined

Definition at line 1024 of file matrices.h.

Referenced by matrix(), operator *(), operator+(), operator=(), operator>>(), and transpose().

template<class T>
vector< T > matrix< T >::row index i const
 

Returns the j-th row.

Definition at line 1113 of file matrices.h.

Referenced by take_row(), and take_rows().

template<class T>
matrix< T > matrix< T >::rows vector< index > indices const
 

Returns the matrix composed from the rows with numbers indices.

Definition at line 1129 of file matrices.h.

template<class T>
matrix< T > matrix< T >::sumbatrix vector< index > r,
vector< index > c
 

Returns a submatrix compose from rows r and columns c.

Definition at line 1615 of file matrices.h.

template<class T>
void matrix< T >::swap_cols index j1,
index j2
 

Swaps j1-th and j2-th columns.

Definition at line 1597 of file matrices.h.

template<class T>
void matrix< T >::swap_rows index i1,
index i2
 

Swaps i1-th and i2-th rows.

Definition at line 1370 of file matrices.h.

template<class T>
vector< T > matrix< T >::take_col index j
 

Returns j-th column deleting it from the matrix.

Definition at line 1488 of file matrices.h.

Referenced by del_col().

template<class T>
matrix< T > matrix< T >::take_cols vector< index > indices
 

Returns columns deleting them from the matrix.

Definition at line 1531 of file matrices.h.

template<class T>
vector< T > matrix< T >::take_row index i
 

Deletes i-th row and return it.

Definition at line 1230 of file matrices.h.

Referenced by del_row().

template<class T>
matrix< T > matrix< T >::take_rows vector< index > indices
 

Returns the matrix composed from the rows with numbers indices deleting they from the matrix.

Definition at line 1275 of file matrices.h.


Friends And Related Function Documentation

template<class T>
matrix<T> diag T a,
index m
[friend]
 

Returns a square (m, m)-matrix with entry a on the diagonal.

Definition at line 1814 of file matrices.h.

template<class T>
matrix<T> diag T a,
index m,
index n
[friend]
 

Returns an (m, n)-matrix with entry a on the diagonal.

Definition at line 1799 of file matrices.h.

template<class T>
matrix<T> diag const vector< T > & d [friend]
 

Returns a square diagonal matrix with entries d on the diagonal.

Definition at line 1783 of file matrices.h.

template<class T>
matrix<T> eye T a,
index m
[friend]
 

Returns an identity (n, n)-matrix.

Definition at line 1826 of file matrices.h.

template<class T>
matrix<T> eye T a,
index m,
index n
[friend]
 

Returns an identity (m, n)-matrix.

Definition at line 1820 of file matrices.h.

template<class T>
matrix<T> fill T a,
index m
[friend]
 

Returns a (m, m)-matrix filled with scalar a.

Definition at line 1844 of file matrices.h.

template<class T>
matrix<T> fill T a,
index m,
index n
[friend]
 

Returns an (m, n)-matrix filled with scalar a.

Definition at line 1832 of file matrices.h.

template<class T>
matrix<T> operator * const vector< T > & v,
const matrix< T > & a
[friend]
 

Multiplies vector (interpreted as a row) with matrix.

template<class T>
matrix<T> operator * const matrix< T > & a,
const vector< T > & v
[friend]
 

Multiplies matrix with vector (interpreted as a column).

template<class T>
matrix<T> operator * T alpha,
const matrix< T > & a
[friend]
 

Multiplies matrix with scalar alpha.

Definition at line 1724 of file matrices.h.

template<class T>
matrix<T> operator * const matrix< T > & a,
const matrix< T > & b
[friend]
 

Matrix multiplication.

Definition at line 1672 of file matrices.h.

template<class T>
int operator!= const matrix< T > & a,
const matrix< T > & b
[friend]
 

Test for inequality.

Definition at line 1762 of file matrices.h.

template<class T>
matrix<T> operator+ const matrix< T > & a,
const matrix< T > & b
[friend]
 

Addition.

Definition at line 1653 of file matrices.h.

template<class T>
ostream& operator<< ostream & s,
const matrix< T > & x
[friend]
 

First, writes the number of rows and the number of columns.

Then writes entries

Definition at line 1083 of file matrices.h.

template<class T>
int operator== const matrix< T > & a,
const matrix< T > & b
[friend]
 

Test for equality.

Definition at line 1750 of file matrices.h.

template<class T>
istream& operator>> istream & s,
matrix< T > & x
[friend]
 

Then reads entries

Definition at line 1098 of file matrices.h.

template<class T>
istream& operator>> istream & s,
matrix< T > & x
[friend]
 

First, reads the number of rows and the number of columns.

Then reads entries

Definition at line 1098 of file matrices.h.

template<class T>
void pretty ostr & s,
const matrix< T > & A
[friend]
 

Outputs a matrix using latex notation.

Definition at line 1887 of file matrices.h.

template<class T>
void print2 ostr & s,
const matrix< T > & A,
const matrix< T > & B
[friend]
 

Prints matrices in the form:.

A B

Definition at line 1912 of file matrices.h.

template<class T>
void print2 ostr & s,
const matrix< T > & A,
const matrix< T > & B
[friend]
 

Prints matrices in the form:.

A B

Definition at line 1912 of file matrices.h.

template<class T>
void print3 ostr & s,
const matrix< T > & A,
const matrix< T > & B,
const matrix< T > & C
[friend]
 

Prints matrices in the form:.

A B C

Definition at line 1962 of file matrices.h.

template<class T>
void print3 ostr & s,
const matrix< T > & A,
const matrix< T > & B,
const matrix< T > & C
[friend]
 

Prints matrices in the form:.

A B C

Definition at line 1962 of file matrices.h.

template<class T>
matrix<T> transpose const matrix< T > & a [friend]
 

Transposition.

Definition at line 1737 of file matrices.h.

template<class T>
matrix<T> zero T a,
index m
[friend]
 

Returns a zero (m)-matrix.

Definition at line 1856 of file matrices.h.

template<class T>
matrix<T> zero T a,
index m,
index n
[friend]
 

Returns a zero (m, n)-matrix.

Definition at line 1850 of file matrices.h.


The documentation for this class was generated from the following file:
Generated at Tue Jan 22 20:37:04 2002 for Arageli by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001