Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #ifndef MLN_METAL_ARRAY_HH 00027 # define MLN_METAL_ARRAY_HH 00028 00029 # include <mln/metal/array1d.hh> 00030 # include <mln/metal/array2d.hh> 00031 # include <mln/metal/array3d.hh> 00032 00033 namespace mln 00034 { 00035 00036 namespace metal 00037 { 00038 00039 // a1 00040 00041 template<unsigned i, class T, unsigned n> inline 00042 T get_at(const array1d<T, n>& arr) 00043 { 00044 return arr.template get_at_<i>(); 00045 } 00046 00047 template<unsigned i, class T, unsigned n> inline 00048 T get(const array1d<T, n>& arr) 00049 { 00050 return arr.template get_<i>(); 00051 } 00052 00053 // a2 00054 00055 template<unsigned row, unsigned col, class T, 00056 unsigned r, unsigned c> inline 00057 T get_at(const array2d<T, r, c>& arr) 00058 { 00059 return arr.template get_at_<row, col>(); 00060 } 00061 00062 template<unsigned row, unsigned col, class T, 00063 unsigned r, unsigned c> inline 00064 T get(const array2d<T, r, c>& arr) 00065 { 00066 return arr.template get_<row, col>(); 00067 } 00068 00069 // a3 00070 00071 template<unsigned sli, unsigned row, unsigned col, 00072 class T, unsigned s, unsigned r, unsigned c> inline 00073 T get_at(const array3d<T, s, r, c>& arr) 00074 { 00075 return arr.template get_at_<sli, row, col>(); 00076 } 00077 00078 template<unsigned sli, unsigned row, unsigned col, 00079 class T, unsigned s, unsigned r, unsigned c> inline 00080 T get_(const array3d<T, s, r, c>& arr) 00081 { 00082 return arr.template get_<sli, row, col>(); 00083 } 00084 00085 // print 00086 00087 template<typename T, unsigned n> 00088 std::ostream& operator<<(std::ostream& ostr, const array1d<T, n>& rhs) 00089 { 00090 for (unsigned i = 0; i < n; ++i) 00091 ostr << rhs[i] << " "; 00092 ostr << std::endl; 00093 00094 return ostr; 00095 } 00096 00097 template<typename T, unsigned r, unsigned c> 00098 std::ostream& operator<<(std::ostream& ostr, const array2d<T, r, c>& rhs) 00099 { 00100 for (unsigned i = 0; i < r; ++i) 00101 { 00102 for (unsigned j = 0; j < c; ++j) 00103 ostr << rhs(i,j) << '\t'; 00104 ostr << '\n'; 00105 } 00106 ostr << std::endl; 00107 00108 return ostr; 00109 } 00110 00111 } 00112 00113 } 00114 00115 #endif // ! MLN_METAL_ARRAY_HH