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 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.
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
Parameter | Description | Default |
---|---|---|
|
The type of object stored in the matrix. |
|
|
Functor describing the storage organization. [1] |
|
|
|
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
Member | Description |
---|---|
|
Allocates an uninitialized |
|
Allocates an uninitialized
|
|
The copy constructor. |
|
The extended copy constructor. |
|
Reallocates a |
|
Returns the number of rows. |
|
Returns the number of columns. |
|
|
|
|
|
Returns
a |
|
Returns a reference
of the |
|
The assignment operator. |
|
Assigns a temporary. May change
the matrix |
|
The extended assignment operator. |
|
Assigns a matrix expression to the matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the matrix expression to the matrix. |
|
Adds a matrix expression to the matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the matrix expression from the matrix. |
|
Subtracts a matrix expression from the matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the matrix with a scalar. |
|
A computed assignment operator. Divides the matrix through a scalar. |
|
Swaps the contents of the matrices. |
|
Inserts the value |
|
Erases the value at
the |
|
Clears the matrix. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
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 idi,j = 0, if i <> j, and idi,i .
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
Parameter | Description | Default |
---|---|---|
|
The type of object stored in the matrix. |
|
|
An 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
Member | Description |
---|---|
|
Constructs an |
|
Constructs an |
|
The copy constructor. |
|
Resizes a
|
|
Returns the number of rows. |
|
Returns the number of columns. |
|
Returns
the value of the |
|
The assignment operator. |
|
Assigns a
temporary. May change the identity matrix |
|
Swaps the contents of the identity matrices. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a
|
|
Returns a
|
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 zi,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
Parameter | Description | Default |
---|---|---|
|
The type of object stored in the matrix. |
|
|
An 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
Member | Description |
---|---|
|
Constructs a |
|
Constructs a
|
|
The copy constructor. |
|
Resizes a |
|
Returns the number of rows. |
|
Returns the number of columns. |
|
Returns
the value of the |
|
The assignment operator. |
|
Assigns a temporary.
May change the zero matrix |
|
Swaps the contents of the zero matrices. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a
|
|
Returns a
|
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 zi,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
Parameter | Description | Default |
---|---|---|
|
The type of object stored in the matrix. |
|
|
An 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
Member | Description |
---|---|
|
Constructs a |
|
Constructs a |
|
The copy constructor. |
|
Resizes a |
|
Returns the number of rows. |
|
Returns the number of columns. |
|
Returns
the value of the |
|
The assignment operator. |
|
Assigns a
temporary. May change the scalar matrix |
|
Swaps the contents of the scalar matrices. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a
|
|
Returns a
|
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
Copyright (©) 2021 Shikhar Vashistha
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 ).