• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            兔子的技術博客

            兔子

               :: 首頁 :: 聯系 :: 聚合  :: 管理
              202 Posts :: 0 Stories :: 43 Comments :: 0 Trackbacks

            留言簿(10)

            最新評論

            閱讀排行榜

            評論排行榜

            轉自:http://grantren.javaeye.com/blog/221457

            boost::multi_array
            一言以概之,boost::multi_array就是N維數組。boost::multi_array可以看作STL容器類的擴展,可以和STL相關算法一起工作。
            在STL中,N維數組可以通過std::vector<std::vector<...> >類似的方法來模擬,相比而言,boost::multi_array更高效,更直觀。

            例程1:

             1 #include <cassert>   
             2 #include "boost/multi_array.hpp"   
             3 #include "boost/cstdlib.hpp"   
             4   
             5 int main () {   
             6   // Create a 3D array that is 3 x 4 x 2   
             7   typedef boost::multi_array<double3> array;   
             8   array A(boost::extents[3][4][2]);   
             9   // Assign a value to an element in the array   
            10   A[0][0][0= 3.14;   
            11   assert(A[0][0][0== 3.14);   
            12   return boost::exit_success;   
            13 }  
            14 

            例程2:

             1 #include <cassert>   
             2 #include "boost/multi_array.hpp"   
             3 #include "boost/array.hpp"   
             4 #include "boost/cstdlib.hpp"   
             5   
             6 int main () {   
             7   // Create a 3D array that is 3 x 4 x 2   
             8   boost::array<int3> shape = {{ 342 }};   
             9   boost::multi_array<double3> A(shape);   
            10   // Assign a value to an element in the array   
            11   A[0][0][0= 3.14;   
            12   assert(A[0][0][0== 3.14);   
            13   return boost::exit_success;   
            14 }  
            15 


            例程3:

             1 #include <iostream>   
             2 #include "boost/multi_array.hpp"   
             3 #include "boost/array.hpp"   
             4 #include "boost/cstdlib.hpp"   
             5   
             6 template <typename Array>   
             7 void print(std::ostream& os, const Array& A) {   
             8   typename Array::const_iterator i;   
             9   os << "[";   
            10   for (i = A.begin(); i != A.end(); ++i) {   
            11     print(os, *i);   
            12     if (boost::next(i) != A.end())   
            13       os << ',';   
            14   }   
            15   os << "]";   
            16 }   
            17   
            18 void print(std::ostream& os, const double& x) {   
            19   os << x;   
            20 }   
            21   
            22 int main() {   
            23   typedef boost::multi_array<double2> array;   
            24   double values[] = {   
            25     012,   
            26     345    
            27   };   
            28   const int values_size = 6;   
            29   array A(boost::extents[2][3]);   
            30   A.assign(values,values + values_size);   
            31   print(std::cout, A);   
            32   return boost::exit_success;   
            33 }  
            34 
            posted on 2009-09-28 10:18 會飛的兔子 閱讀(1971) 評論(0)  編輯 收藏 引用 所屬分類: C++庫,組件
            内射无码专区久久亚洲| 国产精品无码久久久久| 777午夜精品久久av蜜臀| 婷婷久久香蕉五月综合加勒比| 久久久一本精品99久久精品88| 精品蜜臀久久久久99网站| 久久久久亚洲精品男人的天堂 | 久久久久久久91精品免费观看 | 久久人人爽人人爽人人片AV麻豆 | 久久国产精品久久| 亚洲伊人久久综合中文成人网| 久久男人AV资源网站| 亚洲国产精品无码久久一线| 久久久艹| AA级片免费看视频久久| 亚洲乱码精品久久久久..| 久久婷婷五月综合色99啪ak| 久久91精品久久91综合| 男女久久久国产一区二区三区| 亚洲а∨天堂久久精品| 久久精品麻豆日日躁夜夜躁| 噜噜噜色噜噜噜久久| 日本欧美国产精品第一页久久| 天天综合久久久网| 欧美激情精品久久久久| 97热久久免费频精品99| 久久天天躁狠狠躁夜夜96流白浆 | 2021国内久久精品| 久久久久亚洲AV成人网人人网站| 久久福利青草精品资源站| 久久国产乱子伦精品免费强| 国产精品久久久久久| 久久99国产综合精品| 欧美午夜精品久久久久免费视| 久久天天躁狠狠躁夜夜2020一| 亚洲精品WWW久久久久久| 亚洲欧洲久久久精品| 久久久久久国产a免费观看黄色大片 | 亚洲精品国产自在久久| 色诱久久av| 亚洲综合精品香蕉久久网|