2013-01-11 17 views
3

這爲什麼有效?這不是任何地方的文件中...爲什麼我可以像標量矩陣一樣初始化一個規則的Boost矩陣?

#include <iostream> 
#include <boost/numeric/ublas/matrix.hpp> 
#include <boost/numeric/ublas/io.hpp> 

int main() 
{ 

boost::numeric::ublas::matrix<double> twoByTwoMat(2,2,-2); 

std::cout << "This is the matrix: " << twoByTwoMat << std::endl; 

return 0; 
} 

輸出:

This is the matrix: [2,2]((-2,-2),(-2,-2)) 

回答

5

它在<boost/numeric/ublas/matrix.hpp>頭文件中定義。

matrix (size_type size1, size_type size2, const value_type &init): 
     matrix_container<self_type>(), 
     size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2), init) { 
    } 
+0

對,謝謝。太糟糕了,我現在覺得自己像個白癡。也許boost文檔應該更新以反映這個? –