1 Matrix
1.1 Description
The templated class matrix<T, F, A>
is thebase container adaptor for dense matrices. For a (m xn)-dimensional matrix and 0 <= i < m, 0<= j < n every element mi,j is mapped to the (i x n + j)-th element ofthe container for row major orientation or the (i + j xm)-th element of the container for column majororientation.
1.2 Example
#include <boost/numeric/ublas/matrix.hpp> //这个很简单生成一个3行*3列的矩阵,并给予赋值 #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; }
1.3 Definition
Defined in the header matrix.hpp.
1.4 Template parameters
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> |
1.5 Model of
Matrix .
1.6 Type requirements
None, except for those imposed by the requirements of Matrix .
1.7 Public base classes
matrix_container<matrix<T, F, A> >
1.8 Members
Member | Description |
---|---|
matrix () |
Allocates an uninitialized matrix that holds zerorows of zero elements. |
matrix (size_type size1, size_type size2) |
Allocates an uninitialized matrix that holdssize1 rows of size2 elements. |
matrix (const matrix &m) |
The copy constructor. |
template<class AE> |
The extended copy constructor. |
void resize (size_type size1, size_type size2, boolpreserve = true) |
Reallocates a matrix to hold size1 rows of size2 elements. The existing elements of thematrix are 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 const reference of the j -th element in the i -th row. |
reference operator () (size_type i, size_typej) |
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 handside of the assignment should be independent. |