Back to Arangodb

Matrix

3rdParty/boost/1.78.0/libs/numeric/ublas/doc/matrix.html

3.12.9.115.5 KB
Original Source

Matrix

Matrix

Description

The 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 m__i, 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.

Example

#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;
}

Definition

Defined in the header matrix.hpp.

Template parameters

ParameterDescriptionDefault
TThe type of object stored in the matrix.
FFunctor describing the storage organization. [1]row_major
AThe type of the Storage array. [2]unbounded_array<T>

Model of

Matrix .

Type requirements

None, except for those imposed by the requirements of Matrix .

Public base classes

matrix_container<matrix<T, F, A> >

Members

MemberDescription
matrix ()Allocates an uninitialized matrix that holds zero rows of zero elements.
matrix (size_type size1, size_type size2)Allocates an uninitialized matrix that holds size1 rows of size2 elements.
matrix (const matrix &m)The copy constructor.
`template<class AE>
matrix (const matrix_expression<AE> &ae)`The extended copy constructor.
`void resize (size_type size1, size_type size2, bool
preserve = true)`Reallocates a matrix to hold size1 rows of size2 elements. The existing elements of the matrix are preseved when specified.
size_type size1 () constReturns the number of rows.
size_type size2 () constReturns the number of columns.
const array_type& data () const
array_type& data ()
`const_reference operator () (size_type i, size_type j)
const`Returns a const reference of the j -th element in the i-th row.
`reference operator () (size_type i, size_type
j)`Returns a reference of the j-th element in the i-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>
matrix &operator = (const matrix_expression<AE>
&ae)`The extended assignment operator.
`template<class AE>
matrix &assign (const matrix_expression<AE>
&ae)`Assigns a matrix expression to the matrix. Left and right hand side of the assignment should be independent.
`template<class AE>
matrix &operator += (const matrix_expression<AE>
&ae)`A computed assignment operator. Adds the matrix expression to the matrix.
`template<class AE>
matrix &plus_assign (const matrix_expression<AE>
&ae)`Adds a matrix expression to the matrix. Left and right hand side of the assignment should be independent.
`template<class AE>
matrix &operator -= (const matrix_expression<AE>
&ae)`A computed assignment operator. Subtracts the matrix expression from the matrix.
`template<class AE>
matrix &minus_assign (const matrix_expression<AE>
&ae)`Subtracts a matrix expression from the matrix. Left and right hand side of the assignment should be independent.
`template<class AT>
matrix &operator *= (const AT &at)`A computed assignment operator. Multiplies the matrix with a scalar.
`template<class AT>
matrix &operator /= (const AT &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 t at the j-th element of the i-th row.
void erase_element (size_type i, size_type j)Erases the value at the j-th element of the i-th row.
void clear ()Clears the matrix.
const_iterator1 begin1 () constReturns a const_iterator1 pointing to the beginning of the matrix.
const_iterator1 end1 () constReturns a const_iterator1 pointing to the end of the matrix.
iterator1 begin1 ()Returns a iterator1 pointing to the beginning of the matrix.
iterator1 end1 ()Returns a iterator1 pointing to the end of the matrix.
const_iterator2 begin2 () constReturns a const_iterator2 pointing to the beginning of the matrix.
const_iterator2 end2 () constReturns a const_iterator2 pointing to the end of the matrix.
iterator2 begin2 ()Returns a iterator2 pointing to the beginning of the matrix.
iterator2 end2 ()Returns a iterator2 pointing to the end of the matrix.
const_reverse_iterator1 rbegin1 () constReturns a const_reverse_iterator1 pointing to the beginning of the reversed matrix.
const_reverse_iterator1 rend1 () constReturns a const_reverse_iterator1 pointing to the end of the reversed matrix.
reverse_iterator1 rbegin1 ()Returns a reverse_iterator1 pointing to the beginning of the reversed matrix.
reverse_iterator1 rend1 ()Returns a reverse_iterator1 pointing to the end of the reversed matrix.
const_reverse_iterator2 rbegin2 () constReturns a const_reverse_iterator2 pointing to the beginning of the reversed matrix.
const_reverse_iterator2 rend2 () constReturns a const_reverse_iterator2 pointing to the end of the reversed matrix.
reverse_iterator2 rbegin2 ()Returns a reverse_iterator2 pointing to the beginning of the reversed matrix.
reverse_iterator2 rend2 ()Returns a reverse_iterator2 pointing to the end of the reversed matrix.

Notes

[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> .

Identity Matrix

Description

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 id i, j = 0, if i <> j, and id i, i_= 1_.

Example

#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;
}

Definition

Defined in the header matrix.hpp.

Template parameters

ParameterDescriptionDefault
TThe type of object stored in the matrix.int
ALLOCAn STL Allocator for size_type and difference_type.std::allocator

Model of

Matrix .

Type requirements

None, except for those imposed by the requirements of Matrix .

Public base classes

`matrix_container<identity_matrix<T>

`

Members

MemberDescription
identity_matrix ()Constructs an identity_matrix that holds zero rows of zero elements.
identity_matrix (size_type size)Constructs an identity_matrix that holds size rows of size elements.
`identity_matrix (const identity_matrix
&m)`The copy constructor.
`void resize (size_type size, bool preserve =
true)`Resizes a identity_matrix to hold size rows of size elements. Therefore the existing elements of the itendity_matrix are always preseved.
size_type size1 () constReturns the number of rows.
size_type size2 () constReturns the number of columns.
`const_reference operator () (size_type i, size_type j)
const`Returns the value of the j-th element in the i-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 () constReturns a const_iterator1 pointing to the beginning of the identity_matrix.
const_iterator1 end1 () constReturns a const_iterator1 pointing to the end of the identity_matrix.
const_iterator2 begin2 () constReturns a const_iterator2 pointing to the beginning of the identity_matrix.
const_iterator2 end2 () constReturns a const_iterator2 pointing to the end of the identity_matrix.
const_reverse_iterator1 rbegin1 () constReturns a const_reverse_iterator1 pointing to the beginning of the reversed identity_matrix.
const_reverse_iterator1 rend1 () constReturns a const_reverse_iterator1 pointing to the end of the reversed identity_matrix.
const_reverse_iterator2 rbegin2 () constReturns a const_reverse_iterator2 pointing to the beginning of the reversed identity_matrix.
const_reverse_iterator2 rend2 () constReturns a const_reverse_iterator2 pointing to the end of the reversed identity_matrix.

Zero Matrix

Description

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 z__i, j = 0.

Example

#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;
}

Definition

Defined in the header matrix.hpp.

Template parameters

ParameterDescriptionDefault
TThe type of object stored in the matrix.int
ALLOCAn STL Allocator for size_type and difference_type.std::allocator

Model of

Matrix .

Type requirements

None, except for those imposed by the requirements of Matrix .

Public base classes

matrix_container<zero_matrix<T> >

Members

MemberDescription
zero_matrix ()Constructs a zero_matrix that holds zero rows of zero elements.
`zero_matrix (size_type size1, size_type
size2)`Constructs a zero_matrix that holds size1 rows of size2 elements.
zero_matrix (const zero_matrix &m)The copy constructor.
`void resize (size_type size1, size_type size2, bool
preserve = true)`Resizes a zero_matrix to hold size1 rows of size2 elements. Therefore the existing elements of the zero_matrix are always preseved.
size_type size1 () constReturns the number of rows.
size_type size2 () constReturns the number of columns.
`const_reference operator () (size_type i, size_type j)
const`Returns the value of the j-th element in the i-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 () constReturns a const_iterator1 pointing to the beginning of the zero_matrix.
const_iterator1 end1 () constReturns a const_iterator1 pointing to the end of the zero_matrix.
const_iterator2 begin2 () constReturns a const_iterator2 pointing to the beginning of the zero_matrix.
const_iterator2 end2 () constReturns a const_iterator2 pointing to the end of the zero_matrix.
const_reverse_iterator1 rbegin1 () constReturns a const_reverse_iterator1 pointing to the beginning of the reversed zero_matrix.
const_reverse_iterator1 rend1 () constReturns a const_reverse_iterator1 pointing to the end of the reversed zero_matrix.
const_reverse_iterator2 rbegin2 () constReturns a const_reverse_iterator2 pointing to the beginning of the reversed zero_matrix.
const_reverse_iterator2 rend2 () constReturns a const_reverse_iterator2 pointing to the end of the reversed zero_matrix.

Scalar Matrix

Description

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 z__i, j = s.

Example

#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;
}

Definition

Defined in the header matrix.hpp.

Template parameters

ParameterDescriptionDefault
TThe type of object stored in the matrix.int
ALLOCAn STL Allocator for size_type and difference_type.std::allocator

Model of

Matrix .

Type requirements

None, except for those imposed by the requirements of Matrix .

Public base classes

`matrix_container<scalar_matrix<T>

`

Members

MemberDescription
scalar_matrix ()Constructs a scalar_matrix that holds scalar rows of zero elements.
`scalar_matrix (size_type size1, size_type size2, const
value_type &value)`Constructs a scalar_matrix that holds size1 rows of size2 elements 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_matrix to hold size1 rows of size2 elements. Therefore the existing elements of the scalar_matrix are always preseved.
size_type size1 () constReturns the number of rows.
size_type size2 () constReturns the number of columns.
`const_reference operator () (size_type i, size_type j)
const`Returns the value of the j-th element in the i-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 () constReturns a const_iterator1 pointing to the beginning of the scalar_matrix.
const_iterator1 end1 () constReturns a const_iterator1 pointing to the end of the scalar_matrix.
const_iterator2 begin2 () constReturns a const_iterator2 pointing to the beginning of the scalar_matrix.
const_iterator2 end2 () constReturns a const_iterator2 pointing to the end of the scalar_matrix.
const_reverse_iterator1 rbegin1 () constReturns a const_reverse_iterator1 pointing to the beginning of the reversed scalar_matrix.
const_reverse_iterator1 rend1 () constReturns a const_reverse_iterator1 pointing to the end of the reversed scalar_matrix.
const_reverse_iterator2 rbegin2 () constReturns a const_reverse_iterator2 pointing to the beginning of the reversed scalar_matrix.
const_reverse_iterator2 rend2 () constReturns a const_reverse_iterator2 pointing to the end of the reversed scalar_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).