ivl 679
|
00001 /* This file is part of the ivl C++ library <http://image.ntua.gr/ivl>. 00002 A C++ template library extending syntax towards mathematical notation. 00003 00004 Copyright (C) 2012 Yannis Avrithis <iavr@image.ntua.gr> 00005 Copyright (C) 2012 Kimon Kontosis <kimonas@image.ntua.gr> 00006 00007 ivl is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU Lesser General Public License 00009 version 3 as published by the Free Software Foundation. 00010 00011 Alternatively, you can redistribute it and/or modify it under the terms 00012 of the GNU General Public License version 2 as published by the Free 00013 Software Foundation. 00014 00015 ivl is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 See the GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 and a copy of the GNU Lesser General Public License along 00022 with ivl. If not, see <http://www.gnu.org/licenses/>. */ 00023 00024 00025 00026 00027 template <class T, 00028 template <typename, typename, typename> class F, 00029 class A1, class A2, bool SWAP_ARGS, 00030 class PARAMS, // this argument is redundant. used for convenience 00031 class DERIVED_INFO 00032 > 00033 class array_nd<T, 00034 data::array_traits<data::binary_elem_func_data_id<F, A1, A2, SWAP_ARGS>, 00035 PARAMS>, DERIVED_INFO> : 00036 00037 public array<T, data::array_traits<data::binary_elem_func_data_id<F, 00038 A1, A2, SWAP_ARGS>, PARAMS>, 00039 typename types::derive <array_nd <T, data::array_traits<data:: 00040 binary_elem_func_data_id<F, A1, A2, SWAP_ARGS>, PARAMS>, 00041 DERIVED_INFO> >::type>, 00042 00043 public 00044 array_nd_details::basic_iterator_nd_interface<T, DATA_CLASS_SET, DERIVED_INFO>, 00045 public 00046 array_nd_details::array_nd_common_expander<T, DATA_CLASS_SET, DERIVED_INFO> 00047 { 00048 private: 00049 class not_a_type {}; 00050 00051 00052 public: 00053 typedef DATA_CLASS_SET data_type; 00054 00055 typedef array_nd <T, data_type, DERIVED_INFO> this_type; 00056 00057 typedef this_type this_array_nd_type; 00058 00059 typedef typename types::derive<this_type>::type derived_type; 00060 00061 typedef array<T, data_type, derived_type> base_class; 00062 00063 typedef this_type array_type; 00064 00066 typedef array<size_t, tiny> size_type; 00067 00069 typedef array<size_t, tiny> size_type; 00070 00072 typedef typename A1::size_nd_type size_nd_type; 00073 00075 typedef typename types::t_if<typename array_nd::has_random_access, 00076 typename A1::stride_type, not_a_type>::type stride_type; 00077 00079 typedef typename types::t_and< 00080 typename A1::has_1d_parenthesis, 00081 typename A2::has_1d_parenthesis, 00082 >::type has_1d_parenthesis; 00083 00084 typedef typename types::t_and< 00085 typename A1::has_2d_parenthesis, 00086 typename A2::has_2d_parenthesis, 00087 >::type has_2d_parenthesis; 00088 00089 typedef typename types::t_and< 00090 typename A1::has_3d_parenthesis, 00091 typename A2::has_3d_parenthesis, 00092 >::type has_3d_parenthesis; 00093 00094 typedef typename types::t_and< 00095 typename A1::has_nd_parenthesis, 00096 typename A2::has_nd_parenthesis, 00097 >::type has_nd_parenthesis; 00098 00099 using base_class::derived; 00100 00102 base_class& base() { return *this; } 00103 const base_class& base() const { return *this; } 00104 00109 T& operator()(size_t s1); 00110 T& operator()(size_t s1, size_t s2); 00111 T& operator()(size_t s1, size_t s2, size_t s3); 00112 T& operator()(size_t s1, size_t s2, size_t s3, size_t s4); 00113 T& operator()(size_t s1, size_t s2, size_t s3, size_t s4, size_t s5); 00114 T& operator()(size_t s1, size_t s2, size_t s3, size_t s4, size_t s5, size_t s6); 00117 template<class S, class K> 00118 T& operator()(const array<size_t, S, K>& indx) 00119 { return derived()[sub2ind(derived(), indx)]; } 00120 00121 const T& operator()(size_t s1) const; 00122 const T& operator()(size_t s1, size_t s2) const; 00123 const T& operator()(size_t s1, size_t s2, size_t s3) const; 00124 const T& operator()(size_t s1, size_t s2, size_t s3, size_t s4) const; 00125 const T& operator()(size_t s1, size_t s2, size_t s3, size_t s4, size_t s5) const; 00126 const T& operator()(size_t s1, size_t s2, size_t s3, size_t s4, size_t s5, size_t s6) const; 00129 template<class S, class K> 00130 const T& operator()(const array<size_t, S, K>& indx) const 00131 { return derived()[sub2ind(derived(), indx)]; } 00133 00134 00135 00139 00140 array_nd() { } 00141 00143 array_nd(const array_nd& a) { in1 = a.in1; in2 = a.in2; } 00144 00151 00152 size_nd_type size_nd() const { return in1->size_nd(); } 00153 00155 size_t size_nd(size_t d) const { return in1->size_nd(d); } 00156 00158 stride_type stride(typename tool::brackets_arg 00159 enable = typename tool::brackets_arg()) const { return in1->stride(); } 00160 00162 size_type size() const { return in1->size(); } 00163 00165 size_t ndims() const { return in1->ndim(); } 00170 }; 00171 00172