• <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++庫,組件
            久久久久亚洲AV无码观看| 伊人热热久久原色播放www| 亚洲国产精品无码久久一区二区| 四虎影视久久久免费| 亚洲精品乱码久久久久久蜜桃| 老男人久久青草av高清| 成人妇女免费播放久久久| 91精品国产91久久综合| 久久久久一本毛久久久| 久久精品国产日本波多野结衣| 久久久精品一区二区三区| 亚洲精品无码专区久久同性男| 欧美黑人激情性久久| 91久久精品国产成人久久| 亚洲中文字幕无码久久精品1 | 成人亚洲欧美久久久久| 国产亚州精品女人久久久久久 | 久久久久久久97| 国内精品伊人久久久久网站| 亚洲综合日韩久久成人AV| 久久久久99精品成人片牛牛影视| 久久久久亚洲AV无码观看| 国产综合成人久久大片91| 国产精品18久久久久久vr| 久久久久久久久波多野高潮| 精品久久久久久国产免费了| 国产精品岛国久久久久| 久久亚洲精品国产精品| 久久人妻无码中文字幕| 四虎久久影院| 国产精品久久新婚兰兰| 亚洲国产成人乱码精品女人久久久不卡| 久久久久久亚洲Av无码精品专口| 中文字幕无码免费久久| 久久久久高潮综合影院| 免费久久人人爽人人爽av| 狠狠色综合网站久久久久久久高清| 欧美一区二区久久精品| 亚洲精品无码专区久久同性男| 久久久www免费人成精品| 亚洲国产另类久久久精品黑人|