boost::ublas之Matrix定义

1 Matrix1.1 DescriptionThe templated class matrix is thebase container adaptor for dense matrices. For a(m xn)-dimensional matrix and 0 , 0 every elementmi,j is mapped to the (i x n + j)-th el
摘要由CSDN通过智能技术生成

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>
matrix (const matrix_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size1, size_type size2, boolpreserve = true) Reallocates a matrix to hold size1rows 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>
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 handside of the assignment should be independent.
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值