CGAL 6.1.2 - dD Geometry Kernel

Loading...
Searching...
No Matches
List of all members
Matrix Concept Reference
Reference Manual » Linear Algebra Concepts

## Definition

An instance of data type `Matrix` is a matrix of variables of number type `NT`. The types `Matrix` and `Vector` together realize many functions of basic linear algebra.

## Types
typedef unspecified_type | NT
| the ring type of the components.
typedef unspecified_type | iterator
| bidirectional iterator for accessing all components row-wise.
typedef unspecified_type | const_iterator
| bidirectional iterator for accessing all components row-wise.
typedef unspecified_type | row_iterator
| random access iterator for accessing row entries.
typedef unspecified_type | const_row_iterator
| random access iterator for accessing row entries.
typedef unspecified_type | column_iterator
| random access iterator for accessing column entries.
typedef unspecified_type | const_column_iterator
| random access iterator for accessing column entries.
typedef unspecified_type | Identity
| a tag class for identity initialization
typedef unspecified_type | Vector
| the vector type used.

## Creation
| Matrix ()
| creates an instance `M` of type `Matrix`.
| Matrix (int n)
| creates an instance `M` of type `Matrix` of dimension \( n \times n\) initialized to the zero matrix.
| Matrix (int m, int n)
| creates an instance `M` of type `Matrix` of dimension \( m \times n\) initialized to the zero matrix.
| Matrix (std::pair< int, int > p)
| creates an instance `M` of type `Matrix` of dimension `p.first` \( \times\)`p.second` initialized to the zero matrix.
| Matrix (int n, Identity, NT x=NT(1))
| creates an instance `M` of type `Matrix` of dimension \( n \times n\) initialized to the identity matrix (times `x`).
| Matrix (int m, int n, NT x)
| creates an instance `M` of type `Matrix` of dimension \( m \times n\) initialized to the matrix with `x` entries.
template<class Forward_iterator >
| Matrix (Forward_iterator first, Forward_iterator last)
| creates an instance `M` of type `Matrix`.
| Matrix (std::vector< Vector > A)
| creates an instance `M` of type `Matrix`.

## Operations
int | row_dimension ()
| returns \( n\), the number of rows of `M`.
int | column_dimension ()
| returns \( m\), the number of columns of `M`.
std::pair< int, int > | dimension ()
| returns \( (m,n)\), the dimension pair of `M`.
Vector | row (int i)
| returns the \( i\)-th row of `M` (an \( m\) - vector).
Vector | column (int i)
| returns the \( i\)-th column of `M` (an \( n\) - vector).
NT & | operator() (int i, int j)
| returns \( M_{i,j}\).
void | swap_rows (int i, int j)
| swaps rows \( i\) and \( j\).
void | swap_columns (int i, int j)
| swaps columns \( i\) and \( j\).
row_iterator | row_begin (int i)
| an iterator pointing to the first entry of the \( i\)th row.
row_iterator | row_end (int i)
| an iterator pointing beyond the last entry of the \( i\)th row.
const_row_iterator | row_begin (int i) const
| an iterator pointing to the first entry of the \( i\)th row.
const_row_iterator | row_end (int i) const
| an iterator pointing beyond the last entry of the \( i\)th row.
column_iterator | column_begin (int i)
| an iterator pointing to the first entry of the \( i\)th column.
column_iterator | column_end (int i)
| an iterator pointing beyond the last entry of the \( i\)th column.
const_column_iterator | column_begin (int i) const
| an iterator pointing to the first entry of the \( i\)th column.
const_column_iterator | column_end (int i) const
| an iterator pointing beyond the last entry of the \( i\)th column.
iterator | begin ()
| an iterator pointing to the first entry of \( M\).
terator | end ()
| an iterator pointing beyond the last entry of \( M\).
const_iterator | begin () const
| an iterator pointing to the first entry of \( M\).
const_terator | end () const
| an iterator pointing beyond the last entry of \( M\).
bool | operator== (const Matrix &M1)
| Test for equality.
bool | operator!= (const Matrix &M1)
| Test for inequality.

## Arithmetic Operators
Matrix | operator+ (const Matrix &M1)
| Addition.
Matrix | operator- (const Matrix &M1)
| Subtraction.
Matrix | operator- ()
| Negation.
Matrix | operator* (const Matrix &M1)
| Multiplication.
Vector | operator* (const Vector &vec)
| Multiplication with vector.
Matrix | operator* (const NT &x, const Matrix &M)
| Multiplication of every entry with `x`.
Matrix | operator* (const Matrix &M, const NT &x)
| Multiplication of every entry with `x`.

## Constructor & Destructor Documentation

## ◆ Matrix() [1/2]

template<class Forward_iterator >

Matrix::Matrix | ( | Forward_iterator | first,
|  | Forward_iterator | last
| ) |  |

creates an instance `M` of type `Matrix`.

Let \( S\) be the ordered set of \( n\) column-vectors of common dimension \( m\) as given by the iterator range `[first,last)`. `M` is initialized to an \( m \times n\) matrix with the columns as specified by \( S\).

Precondition
  `Forward_iterator` has a value type `V` from which we require to provide a iterator type `V::const_iterator`, to have `V::value_type == NT`.

Note that `Vector` or `std::vector<NT>` fulfill these requirements.

## ◆ Matrix() [2/2]

Matrix::Matrix | ( | std::vector< Vector > | A | ) |

creates an instance `M` of type `Matrix`.

Let \( A\) be an array of \( n\) column-vectors of common dimension \( m\). `M` is initialized to an \( m \times n\) matrix with the columns as specified by \( A\).

## Member Function Documentation

## ◆ column()

Vector Matrix::column | ( | int | i | ) |

returns the \( i\)-th column of `M` (an \( n\) - vector).

Precondition
  \( 0 \le i \le n - 1\).

## ◆ column_begin() [1/2]

column_iterator Matrix::column_begin | ( | int | i | ) |

an iterator pointing to the first entry of the \( i\)th column.

Precondition
  \( 0\le i\le n-1\).

## ◆ column_begin() [2/2]

const_column_iterator Matrix::column_begin | ( | int | i | ) | const

an iterator pointing to the first entry of the \( i\)th column.

Precondition
  \( 0\le i\le n-1\).

## ◆ column_end() [1/2]

column_iterator Matrix::column_end | ( | int | i | ) |

an iterator pointing beyond the last entry of the \( i\)th column.

Precondition
  \( 0\le i\le n-1\).

## ◆ column_end() [2/2]

const_column_iterator Matrix::column_end | ( | int | i | ) | const

an iterator pointing beyond the last entry of the \( i\)th column.

Precondition
  \( 0\le i\le n-1\).

## ◆ operator()()

NT & Matrix::operator() | ( | int | i,
|  | int | j
| ) |  |

returns \( M_{i,j}\).

Precondition
  \( 0\le i\le m-1\) and \( 0\le j\le n-1\).

## ◆ operator*() [1/2]

Matrix Matrix::operator* | ( | const Matrix & | M1 | ) |

Multiplication.

Precondition
  `M.column_dimension() == M1.row_dimension()`

## ◆ operator*() [2/2]

Vector Matrix::operator* | ( | const Vector & | vec | ) |

Multiplication with vector.

Precondition
  `M.column_dimension() == vec.dimension()`

## ◆ operator+()

Matrix Matrix::operator+ | ( | const Matrix & | M1 | ) |

Addition.

Precondition
  `M.row_dimension() == M1.row_dimension()`
  `M.column_dimension() == M1.column_dimension()`

## ◆ operator-()

Matrix Matrix::operator- | ( | const Matrix & | M1 | ) |

Subtraction.

Precondition
  `M.row_dimension() == M1.row_dimension()`
  `M.column_dimension() == M1.column_dimension()`

## ◆ row()

Vector Matrix::row | ( | int | i | ) |

returns the \( i\)-th row of `M` (an \( m\) - vector).

Precondition
  \( 0 \le i \le m - 1\).

## ◆ row_begin() [1/2]

row_iterator Matrix::row_begin | ( | int | i | ) |

an iterator pointing to the first entry of the \( i\)th row.

Precondition
  \( 0\le i\le m-1\).

## ◆ row_begin() [2/2]

const_row_iterator Matrix::row_begin | ( | int | i | ) | const

an iterator pointing to the first entry of the \( i\)th row.

Precondition
  \( 0\le i\le m-1\).

## ◆ row_end() [1/2]

row_iterator Matrix::row_end | ( | int | i | ) |

an iterator pointing beyond the last entry of the \( i\)th row.

Precondition
  \( 0\le i\le m-1\).

## ◆ row_end() [2/2]

const_row_iterator Matrix::row_end | ( | int | i | ) | const

an iterator pointing beyond the last entry of the \( i\)th row.

Precondition
  \( 0\le i\le m-1\).

## ◆ swap_columns()

void Matrix::swap_columns | ( | int | i,
|  | int | j
| ) |  |

swaps columns \( i\) and \( j\).

Precondition
  \( 0\le i\le n-1\) and \( 0\le j\le n-1\).

## ◆ swap_rows()

void Matrix::swap_rows | ( | int | i,
|  | int | j
| ) |  |

swaps rows \( i\) and \( j\).

Precondition
  \( 0\le i\le m-1\) and \( 0\le j\le m-1\).