 Matrix
MatrixThe templated class matrix<T, F, A> is the
base container adaptor for dense matrices. For a (m x
n)-dimensional matrix and 0 <= i < m, 0
<= j < n every element mi,
j is mapped to the (i x n + j)-th element of
the container for row major orientation or the (i + j x
m)-th element of the container for column major
orientation.
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
    using namespace boost::numeric::ublas;
    matrix<double> m (3, 3);
    for (unsigned i = 0; i < m.size1 (); ++ i)
        for (unsigned j = 0; j < m.size2 (); ++ j)
            m (i, j) = 3 * i + j;
    std::cout << m << std::endl;
}
Defined in the header matrix.hpp.
| Parameter | Description | Default | 
|---|---|---|
| T | The type of object stored in the matrix. | |
| F | Functor describing the storage organization. [1] | row_major | 
| A | The type of the Storage array. [2] | unbounded_array<T> | 
Matrix .
None, except for those imposed by the requirements of Matrix .
matrix_container<matrix<T, F, A> >
| Member | Description | 
|---|---|
| matrix () | Allocates an uninitialized matrixthat holds zero
rows of zero elements. | 
| matrix (size_type size1, size_type size2) | Allocates an uninitialized matrixthat holdssize1rows ofsize2elements. | 
| matrix (const matrix &m) | The copy constructor. | 
| template<class AE> | The extended copy constructor. | 
| void resize (size_type size1, size_type size2, bool
preserve = true) | Reallocates a matrixto holdsize1rows ofsize2elements. The existing elements of thematrixare preseved when specified. | 
| size_type size1 () const | Returns the number of rows. | 
| size_type size2 () const | Returns the number of columns. | 
| const array_type& data () const | |
| array_type& data () | |
| const_reference operator () (size_type i, size_type j)
const | Returns a constreference of thej-th element in thei-th row. | 
| reference operator () (size_type i, size_type
j) | Returns a reference of the j-th element in thei-th row. | 
| matrix &operator = (const matrix &m) | The assignment operator. | 
| matrix &assign_temporary (matrix &m) | Assigns a temporary. May change the matrix m. | 
| template<class AE> | The extended assignment operator. | 
| template<class AE> | Assigns a matrix expression to the matrix. Left and right hand side of the assignment should be independent. | 
| template<class AE> | A computed assignment operator. Adds the matrix expression to the matrix. | 
| template<class AE> | Adds a matrix expression to the matrix. Left and right hand side of the assignment should be independent. | 
| template<class AE> | A computed assignment operator. Subtracts the matrix expression from the matrix. | 
| template<class AE> | Subtracts a matrix expression from the matrix. Left and right hand side of the assignment should be independent. | 
| template<class AT> | A computed assignment operator. Multiplies the matrix with a scalar. | 
| template<class AT> | A computed assignment operator. Divides the matrix through a scalar. | 
| void swap (matrix &m) | Swaps the contents of the matrices. | 
| void insert_element (size_type i, size_type j, const_reference
t) | Inserts the value tat thej-th
element of thei-th row. | 
| void erase_element (size_type i, size_type j) | Erases the value at the j-th element of thei-th row. | 
| void clear () | Clears the matrix. | 
| const_iterator1 begin1 () const | Returns a const_iterator1pointing to the
beginning of thematrix. | 
| const_iterator1 end1 () const | Returns a const_iterator1pointing to the end of
thematrix. | 
| iterator1 begin1 () | Returns a iterator1pointing to the beginning of
thematrix. | 
| iterator1 end1 () | Returns a iterator1pointing to the end of thematrix. | 
| const_iterator2 begin2 () const | Returns a const_iterator2pointing to the
beginning of thematrix. | 
| const_iterator2 end2 () const | Returns a const_iterator2pointing to the end of
thematrix. | 
| iterator2 begin2 () | Returns a iterator2pointing to the beginning of
thematrix. | 
| iterator2 end2 () | Returns a iterator2pointing to the end of thematrix. | 
| const_reverse_iterator1 rbegin1 () const | Returns a const_reverse_iterator1pointing to the
beginning of the reversedmatrix. | 
| const_reverse_iterator1 rend1 () const | Returns a const_reverse_iterator1pointing to the
end of the reversedmatrix. | 
| reverse_iterator1 rbegin1 () | Returns a reverse_iterator1pointing to the
beginning of the reversedmatrix. | 
| reverse_iterator1 rend1 () | Returns a reverse_iterator1pointing to the end of
the reversedmatrix. | 
| const_reverse_iterator2 rbegin2 () const | Returns a const_reverse_iterator2pointing to the
beginning of the reversedmatrix. | 
| const_reverse_iterator2 rend2 () const | Returns a const_reverse_iterator2pointing to the
end of the reversedmatrix. | 
| reverse_iterator2 rbegin2 () | Returns a reverse_iterator2pointing to the
beginning of the reversedmatrix. | 
| reverse_iterator2 rend2 () | Returns a reverse_iterator2pointing to the end of
the reversedmatrix. | 
[1] Supported parameters
for the storage organization are row_major and
column_major.
[2] Common parameters
for the storage array are unbounded_array<T> ,
bounded_array<T> and
std::vector<T> .
The templated class identity_matrix<T, ALLOC>
represents identity matrices. For a (m x n)-dimensional
identity matrix and 0 <= i < m, 0 <= j <
n holds idi, j = 0, if
i <> j, and idi, i=
1.
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
    using namespace boost::numeric::ublas;
    identity_matrix<double> m (3);
    std::cout << m << std::endl;
}
Defined in the header matrix.hpp.
| Parameter | Description | Default | 
|---|---|---|
| T | The type of object stored in the matrix. | int | 
| ALLOC | An STL Allocator for size_type and difference_type. | std::allocator | 
Matrix .
None, except for those imposed by the requirements of Matrix .
matrix_container<identity_matrix<T>
>
| Member | Description | 
|---|---|
| identity_matrix () | Constructs an identity_matrixthat holds zero rows
of zero elements. | 
| identity_matrix (size_type size) | Constructs an identity_matrixthat holdssizerows ofsizeelements. | 
| identity_matrix (const identity_matrix
&m) | The copy constructor. | 
| void resize (size_type size, bool preserve =
true) | Resizes a identity_matrixto holdsizerows ofsizeelements. Therefore the
existing elements of theitendity_matrixare always
preseved. | 
| size_type size1 () const | Returns the number of rows. | 
| size_type size2 () const | Returns the number of columns. | 
| const_reference operator () (size_type i, size_type j)
const | Returns the value of the j-th element in thei-th row. | 
| identity_matrix &operator = (const identity_matrix
&m) | The assignment operator. | 
| identity_matrix &assign_temporary (identity_matrix
&m) | Assigns a temporary. May change the identity matrix m. | 
| void swap (identity_matrix &m) | Swaps the contents of the identity matrices. | 
| const_iterator1 begin1 () const | Returns a const_iterator1pointing to the
beginning of theidentity_matrix. | 
| const_iterator1 end1 () const | Returns a const_iterator1pointing to the end of
theidentity_matrix. | 
| const_iterator2 begin2 () const | Returns a const_iterator2pointing to the
beginning of theidentity_matrix. | 
| const_iterator2 end2 () const | Returns a const_iterator2pointing to the end of
theidentity_matrix. | 
| const_reverse_iterator1 rbegin1 () const | Returns a const_reverse_iterator1pointing to the
beginning of the reversedidentity_matrix. | 
| const_reverse_iterator1 rend1 () const | Returns a const_reverse_iterator1pointing to the
end of the reversedidentity_matrix. | 
| const_reverse_iterator2 rbegin2 () const | Returns a const_reverse_iterator2pointing to the
beginning of the reversedidentity_matrix. | 
| const_reverse_iterator2 rend2 () const | Returns a const_reverse_iterator2pointing to the
end of the reversedidentity_matrix. | 
The templated class zero_matrix<T, ALLOC> represents
zero matrices. For a (m x n)-dimensional zero matrix and
0 <= i < m, 0 <= j < n holds
zi, j = 0.
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
    using namespace boost::numeric::ublas;
    zero_matrix<double> m (3, 3);
    std::cout << m << std::endl;
}
Defined in the header matrix.hpp.
| Parameter | Description | Default | 
|---|---|---|
| T | The type of object stored in the matrix. | int | 
| ALLOC | An STL Allocator for size_type and difference_type. | std::allocator | 
Matrix .
None, except for those imposed by the requirements of Matrix .
matrix_container<zero_matrix<T> >
| Member | Description | 
|---|---|
| zero_matrix () | Constructs a zero_matrixthat holds zero rows of
zero elements. | 
| zero_matrix (size_type size1, size_type
size2) | Constructs a zero_matrixthat holdssize1rows ofsize2elements. | 
| zero_matrix (const zero_matrix &m) | The copy constructor. | 
| void resize (size_type size1, size_type size2, bool
preserve = true) | Resizes a zero_matrixto holdsize1rows ofsize2elements. Therefore the existing
elements of thezero_matrixare always preseved. | 
| size_type size1 () const | Returns the number of rows. | 
| size_type size2 () const | Returns the number of columns. | 
| const_reference operator () (size_type i, size_type j)
const | Returns the value of the j-th element in thei-th row. | 
| zero_matrix &operator = (const zero_matrix
&m) | The assignment operator. | 
| zero_matrix &assign_temporary (zero_matrix
&m) | Assigns a temporary. May change the zero matrix m. | 
| void swap (zero_matrix &m) | Swaps the contents of the zero matrices. | 
| const_iterator1 begin1 () const | Returns a const_iterator1pointing to the
beginning of thezero_matrix. | 
| const_iterator1 end1 () const | Returns a const_iterator1pointing to the end of
thezero_matrix. | 
| const_iterator2 begin2 () const | Returns a const_iterator2pointing to the
beginning of thezero_matrix. | 
| const_iterator2 end2 () const | Returns a const_iterator2pointing to the end of
thezero_matrix. | 
| const_reverse_iterator1 rbegin1 () const | Returns a const_reverse_iterator1pointing to the
beginning of the reversedzero_matrix. | 
| const_reverse_iterator1 rend1 () const | Returns a const_reverse_iterator1pointing to the
end of the reversedzero_matrix. | 
| const_reverse_iterator2 rbegin2 () const | Returns a const_reverse_iterator2pointing to the
beginning of the reversedzero_matrix. | 
| const_reverse_iterator2 rend2 () const | Returns a const_reverse_iterator2pointing to the
end of the reversedzero_matrix. | 
The templated class scalar_matrix<T, ALLOC>
represents scalar matrices. For a (m x n)-dimensional
scalar matrix and 0 <= i < m, 0 <= j <
n holds zi, j = s.
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
    using namespace boost::numeric::ublas;
    scalar_matrix<double> m (3, 3);
    std::cout << m << std::endl;
}
Defined in the header matrix.hpp.
| Parameter | Description | Default | 
|---|---|---|
| T | The type of object stored in the matrix. | int | 
| ALLOC | An STL Allocator for size_type and difference_type. | std::allocator | 
Matrix .
None, except for those imposed by the requirements of Matrix .
matrix_container<scalar_matrix<T>
>
| Member | Description | 
|---|---|
| scalar_matrix () | Constructs a scalar_matrixthat holds scalar rows
of zero elements. | 
| scalar_matrix (size_type size1, size_type size2, const
value_type &value) | Constructs a scalar_matrixthat holdssize1rows ofsize2elements each of the
specified value. | 
| scalar_matrix (const scalar_matrix &m) | The copy constructor. | 
| void resize (size_type size1, size_type size2, bool
preserve = true) | Resizes a scalar_matrixto holdsize1rows ofsize2elements. Therefore the existing
elements of thescalar_matrixare always
preseved. | 
| size_type size1 () const | Returns the number of rows. | 
| size_type size2 () const | Returns the number of columns. | 
| const_reference operator () (size_type i, size_type j)
const | Returns the value of the j-th element in thei-th row. | 
| scalar_matrix &operator = (const scalar_matrix
&m) | The assignment operator. | 
| scalar_matrix &assign_temporary (scalar_matrix
&m) | Assigns a temporary. May change the scalar matrix m. | 
| void swap (scalar_matrix &m) | Swaps the contents of the scalar matrices. | 
| const_iterator1 begin1 () const | Returns a const_iterator1pointing to the
beginning of thescalar_matrix. | 
| const_iterator1 end1 () const | Returns a const_iterator1pointing to the end of
thescalar_matrix. | 
| const_iterator2 begin2 () const | Returns a const_iterator2pointing to the
beginning of thescalar_matrix. | 
| const_iterator2 end2 () const | Returns a const_iterator2pointing to the end of
thescalar_matrix. | 
| const_reverse_iterator1 rbegin1 () const | Returns a const_reverse_iterator1pointing to the
beginning of the reversedscalar_matrix. | 
| const_reverse_iterator1 rend1 () const | Returns a const_reverse_iterator1pointing to the
end of the reversedscalar_matrix. | 
| const_reverse_iterator2 rbegin2 () const | Returns a const_reverse_iterator2pointing to the
beginning of the reversedscalar_matrix. | 
| const_reverse_iterator2 rend2 () const | Returns a const_reverse_iterator2pointing to the
end of the reversedscalar_matrix. | 
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
   Use, modification and distribution are subject to the
   Boost Software License, Version 1.0.
   (See accompanying file LICENSE_1_0.txt
   or copy at 
      http://www.boost.org/LICENSE_1_0.txt
   ).