annotate armadillo-2.4.4/include/armadillo_bits/ProxyCube.hpp @ 0:8b6102e2a9b0

Armadillo Library
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 09:27:06 +0100
parents
children
rev   line source
max@0 1 // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
max@0 2 // Copyright (C) 2010-2012 Conrad Sanderson
max@0 3 //
max@0 4 // This file is part of the Armadillo C++ library.
max@0 5 // It is provided without any warranty of fitness
max@0 6 // for any purpose. You can redistribute this file
max@0 7 // and/or modify it under the terms of the GNU
max@0 8 // Lesser General Public License (LGPL) as published
max@0 9 // by the Free Software Foundation, either version 3
max@0 10 // of the License or (at your option) any later version.
max@0 11 // (see http://www.opensource.org/licenses for more info)
max@0 12
max@0 13
max@0 14 //! \addtogroup ProxyCube
max@0 15 //! @{
max@0 16
max@0 17
max@0 18
max@0 19 template<typename T1>
max@0 20 class ProxyCube
max@0 21 {
max@0 22 public:
max@0 23 inline ProxyCube(const T1& A)
max@0 24 {
max@0 25 arma_type_check(( is_arma_cube_type<T1>::value == false ));
max@0 26 }
max@0 27 };
max@0 28
max@0 29
max@0 30
max@0 31 // ea_type is the "element accessor" type,
max@0 32 // which can provide access to elements via operator[]
max@0 33
max@0 34 template<typename eT>
max@0 35 class ProxyCube< Cube<eT> >
max@0 36 {
max@0 37 public:
max@0 38
max@0 39 typedef eT elem_type;
max@0 40 typedef typename get_pod_type<elem_type>::result pod_type;
max@0 41 typedef Cube<eT> stored_type;
max@0 42 typedef const eT* ea_type;
max@0 43
max@0 44 static const bool prefer_at_accessor = false;
max@0 45 static const bool has_subview = false;
max@0 46
max@0 47 arma_aligned const Cube<eT>& Q;
max@0 48
max@0 49 inline explicit ProxyCube(const Cube<eT>& A)
max@0 50 : Q(A)
max@0 51 {
max@0 52 arma_extra_debug_sigprint();
max@0 53 }
max@0 54
max@0 55 arma_inline uword get_n_rows() const { return Q.n_rows; }
max@0 56 arma_inline uword get_n_cols() const { return Q.n_cols; }
max@0 57 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
max@0 58 arma_inline uword get_n_slices() const { return Q.n_slices; }
max@0 59 arma_inline uword get_n_elem() const { return Q.n_elem; }
max@0 60
max@0 61 arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
max@0 62 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
max@0 63
max@0 64 arma_inline ea_type get_ea() const { return Q.memptr(); }
max@0 65
max@0 66 template<typename eT2>
max@0 67 arma_inline bool is_alias(const Cube<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); }
max@0 68 };
max@0 69
max@0 70
max@0 71
max@0 72 template<typename eT, typename gen_type>
max@0 73 class ProxyCube< GenCube<eT, gen_type > >
max@0 74 {
max@0 75 public:
max@0 76
max@0 77 typedef eT elem_type;
max@0 78 typedef typename get_pod_type<elem_type>::result pod_type;
max@0 79 typedef GenCube<eT, gen_type> stored_type;
max@0 80 typedef const GenCube<eT, gen_type>& ea_type;
max@0 81
max@0 82 static const bool prefer_at_accessor = false;
max@0 83 static const bool has_subview = false;
max@0 84
max@0 85 arma_aligned const GenCube<eT, gen_type>& Q;
max@0 86
max@0 87 inline explicit ProxyCube(const GenCube<eT, gen_type>& A)
max@0 88 : Q(A)
max@0 89 {
max@0 90 arma_extra_debug_sigprint();
max@0 91 }
max@0 92
max@0 93 arma_inline uword get_n_rows() const { return Q.n_rows; }
max@0 94 arma_inline uword get_n_cols() const { return Q.n_cols; }
max@0 95 arma_inline uword get_n_elem_slice() const { return Q.n_rows*Q.n_cols; }
max@0 96 arma_inline uword get_n_slices() const { return Q.n_slices; }
max@0 97 arma_inline uword get_n_elem() const { return Q.n_rows*Q.n_cols*Q.n_slices; }
max@0 98
max@0 99 arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
max@0 100 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
max@0 101
max@0 102 arma_inline ea_type get_ea() const { return Q; }
max@0 103
max@0 104 template<typename eT2>
max@0 105 arma_inline bool is_alias(const Cube<eT2>&) const { return false; }
max@0 106 };
max@0 107
max@0 108
max@0 109
max@0 110 template<typename T1, typename op_type>
max@0 111 class ProxyCube< OpCube<T1, op_type> >
max@0 112 {
max@0 113 public:
max@0 114
max@0 115 typedef typename T1::elem_type elem_type;
max@0 116 typedef typename get_pod_type<elem_type>::result pod_type;
max@0 117 typedef Cube<elem_type> stored_type;
max@0 118 typedef const elem_type* ea_type;
max@0 119
max@0 120 static const bool prefer_at_accessor = false;
max@0 121 static const bool has_subview = false;
max@0 122
max@0 123 arma_aligned const Cube<elem_type> Q;
max@0 124
max@0 125 inline explicit ProxyCube(const OpCube<T1, op_type>& A)
max@0 126 : Q(A)
max@0 127 {
max@0 128 arma_extra_debug_sigprint();
max@0 129 }
max@0 130
max@0 131 arma_inline uword get_n_rows() const { return Q.n_rows; }
max@0 132 arma_inline uword get_n_cols() const { return Q.n_cols; }
max@0 133 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
max@0 134 arma_inline uword get_n_slices() const { return Q.n_slices; }
max@0 135 arma_inline uword get_n_elem() const { return Q.n_elem; }
max@0 136
max@0 137 arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
max@0 138 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
max@0 139
max@0 140 arma_inline ea_type get_ea() const { return Q.memptr(); }
max@0 141
max@0 142 template<typename eT2>
max@0 143 arma_inline bool is_alias(const Cube<eT2>&) const { return false; }
max@0 144 };
max@0 145
max@0 146
max@0 147
max@0 148 template<typename T1, typename T2, typename glue_type>
max@0 149 class ProxyCube< GlueCube<T1, T2, glue_type> >
max@0 150 {
max@0 151 public:
max@0 152
max@0 153 typedef typename T1::elem_type elem_type;
max@0 154 typedef typename get_pod_type<elem_type>::result pod_type;
max@0 155 typedef Cube<elem_type> stored_type;
max@0 156 typedef const elem_type* ea_type;
max@0 157
max@0 158 static const bool prefer_at_accessor = false;
max@0 159 static const bool has_subview = false;
max@0 160
max@0 161 arma_aligned const Cube<elem_type> Q;
max@0 162
max@0 163 inline explicit ProxyCube(const GlueCube<T1, T2, glue_type>& A)
max@0 164 : Q(A)
max@0 165 {
max@0 166 arma_extra_debug_sigprint();
max@0 167 }
max@0 168
max@0 169 arma_inline uword get_n_rows() const { return Q.n_rows; }
max@0 170 arma_inline uword get_n_cols() const { return Q.n_cols; }
max@0 171 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
max@0 172 arma_inline uword get_n_slices() const { return Q.n_slices; }
max@0 173 arma_inline uword get_n_elem() const { return Q.n_elem; }
max@0 174
max@0 175 arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
max@0 176 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
max@0 177
max@0 178 arma_inline ea_type get_ea() const { return Q.memptr(); }
max@0 179
max@0 180 template<typename eT2>
max@0 181 arma_inline bool is_alias(const Cube<eT2>&) const { return false; }
max@0 182 };
max@0 183
max@0 184
max@0 185
max@0 186 template<typename eT>
max@0 187 class ProxyCube< subview_cube<eT> >
max@0 188 {
max@0 189 public:
max@0 190
max@0 191 typedef eT elem_type;
max@0 192 typedef typename get_pod_type<elem_type>::result pod_type;
max@0 193 typedef subview_cube<eT> stored_type;
max@0 194 typedef const subview_cube<eT>& ea_type;
max@0 195
max@0 196 static const bool prefer_at_accessor = true;
max@0 197 static const bool has_subview = true;
max@0 198
max@0 199 arma_aligned const subview_cube<eT>& Q;
max@0 200
max@0 201 inline explicit ProxyCube(const subview_cube<eT>& A)
max@0 202 : Q(A)
max@0 203 {
max@0 204 arma_extra_debug_sigprint();
max@0 205 }
max@0 206
max@0 207 arma_inline uword get_n_rows() const { return Q.n_rows; }
max@0 208 arma_inline uword get_n_cols() const { return Q.n_cols; }
max@0 209 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
max@0 210 arma_inline uword get_n_slices() const { return Q.n_slices; }
max@0 211 arma_inline uword get_n_elem() const { return Q.n_elem; }
max@0 212
max@0 213 arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
max@0 214 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
max@0 215
max@0 216 arma_inline ea_type get_ea() const { return Q; }
max@0 217
max@0 218 template<typename eT2>
max@0 219 arma_inline bool is_alias(const Cube<eT2>& X) const { return (void_ptr(&(Q.m)) == void_ptr(&X)); }
max@0 220 };
max@0 221
max@0 222
max@0 223
max@0 224 template<typename T1, typename eop_type>
max@0 225 class ProxyCube< eOpCube<T1, eop_type > >
max@0 226 {
max@0 227 public:
max@0 228
max@0 229 typedef typename T1::elem_type elem_type;
max@0 230 typedef typename get_pod_type<elem_type>::result pod_type;
max@0 231 typedef eOpCube<T1, eop_type> stored_type;
max@0 232 typedef const eOpCube<T1, eop_type>& ea_type;
max@0 233
max@0 234 static const bool prefer_at_accessor = eOpCube<T1, eop_type>::prefer_at_accessor;
max@0 235 static const bool has_subview = eOpCube<T1, eop_type>::has_subview;
max@0 236
max@0 237 arma_aligned const eOpCube<T1, eop_type>& Q;
max@0 238
max@0 239 inline explicit ProxyCube(const eOpCube<T1, eop_type>& A)
max@0 240 : Q(A)
max@0 241 {
max@0 242 arma_extra_debug_sigprint();
max@0 243 }
max@0 244
max@0 245 arma_inline uword get_n_rows() const { return Q.get_n_rows(); }
max@0 246 arma_inline uword get_n_cols() const { return Q.get_n_cols(); }
max@0 247 arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice(); }
max@0 248 arma_inline uword get_n_slices() const { return Q.get_n_slices(); }
max@0 249 arma_inline uword get_n_elem() const { return Q.get_n_elem(); }
max@0 250
max@0 251 arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
max@0 252 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
max@0 253
max@0 254 arma_inline ea_type get_ea() const { return Q; }
max@0 255
max@0 256 template<typename eT2>
max@0 257 arma_inline bool is_alias(const Cube<eT2>& X) const { return Q.P.is_alias(X); }
max@0 258 };
max@0 259
max@0 260
max@0 261
max@0 262 template<typename T1, typename T2, typename eglue_type>
max@0 263 class ProxyCube< eGlueCube<T1, T2, eglue_type > >
max@0 264 {
max@0 265 public:
max@0 266
max@0 267 typedef typename T1::elem_type elem_type;
max@0 268 typedef typename get_pod_type<elem_type>::result pod_type;
max@0 269 typedef eGlueCube<T1, T2, eglue_type> stored_type;
max@0 270 typedef const eGlueCube<T1, T2, eglue_type>& ea_type;
max@0 271
max@0 272 static const bool prefer_at_accessor = eGlueCube<T1, T2, eglue_type>::prefer_at_accessor;
max@0 273 static const bool has_subview = eGlueCube<T1, T2, eglue_type>::has_subview;
max@0 274
max@0 275 arma_aligned const eGlueCube<T1, T2, eglue_type>& Q;
max@0 276
max@0 277 inline explicit ProxyCube(const eGlueCube<T1, T2, eglue_type>& A)
max@0 278 : Q(A)
max@0 279 {
max@0 280 arma_extra_debug_sigprint();
max@0 281 }
max@0 282
max@0 283 arma_inline uword get_n_rows() const { return Q.get_n_rows(); }
max@0 284 arma_inline uword get_n_cols() const { return Q.get_n_cols(); }
max@0 285 arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice(); }
max@0 286 arma_inline uword get_n_slices() const { return Q.get_n_slices(); }
max@0 287 arma_inline uword get_n_elem() const { return Q.get_n_elem(); }
max@0 288
max@0 289 arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
max@0 290 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
max@0 291
max@0 292 arma_inline ea_type get_ea() const { return Q; }
max@0 293
max@0 294 template<typename eT2>
max@0 295 arma_inline bool is_alias(const Cube<eT2>& X) const { return (Q.P1.is_alias(X) || Q.P2.is_alias(X)); }
max@0 296 };
max@0 297
max@0 298
max@0 299
max@0 300 template<typename out_eT, typename T1, typename op_type>
max@0 301 class ProxyCube< mtOpCube<out_eT, T1, op_type> >
max@0 302 {
max@0 303 public:
max@0 304
max@0 305 typedef out_eT elem_type;
max@0 306 typedef typename get_pod_type<out_eT>::result pod_type;
max@0 307 typedef Cube<out_eT> stored_type;
max@0 308 typedef const elem_type* ea_type;
max@0 309
max@0 310 static const bool prefer_at_accessor = false;
max@0 311 static const bool has_subview = false;
max@0 312
max@0 313 arma_aligned const Cube<out_eT> Q;
max@0 314
max@0 315 inline explicit ProxyCube(const mtOpCube<out_eT, T1, op_type>& A)
max@0 316 : Q(A)
max@0 317 {
max@0 318 arma_extra_debug_sigprint();
max@0 319 }
max@0 320
max@0 321 arma_inline uword get_n_rows() const { return Q.n_rows; }
max@0 322 arma_inline uword get_n_cols() const { return Q.n_cols; }
max@0 323 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
max@0 324 arma_inline uword get_n_slices() const { return Q.n_slices; }
max@0 325 arma_inline uword get_n_elem() const { return Q.n_elem; }
max@0 326
max@0 327 arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
max@0 328 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
max@0 329
max@0 330 arma_inline ea_type get_ea() const { return Q.memptr(); }
max@0 331
max@0 332 template<typename eT2>
max@0 333 arma_inline bool is_alias(const Cube<eT2>&) const { return false; }
max@0 334 };
max@0 335
max@0 336
max@0 337
max@0 338 template<typename out_eT, typename T1, typename T2, typename glue_type>
max@0 339 class ProxyCube< mtGlueCube<out_eT, T1, T2, glue_type > >
max@0 340 {
max@0 341 public:
max@0 342
max@0 343 typedef out_eT elem_type;
max@0 344 typedef typename get_pod_type<out_eT>::result pod_type;
max@0 345 typedef Cube<out_eT> stored_type;
max@0 346 typedef const elem_type* ea_type;
max@0 347
max@0 348 static const bool prefer_at_accessor = false;
max@0 349 static const bool has_subview = false;
max@0 350
max@0 351 arma_aligned const Cube<out_eT> Q;
max@0 352
max@0 353 inline explicit ProxyCube(const mtGlueCube<out_eT, T1, T2, glue_type>& A)
max@0 354 : Q(A)
max@0 355 {
max@0 356 arma_extra_debug_sigprint();
max@0 357 }
max@0 358
max@0 359 arma_inline uword get_n_rows() const { return Q.n_rows; }
max@0 360 arma_inline uword get_n_cols() const { return Q.n_cols; }
max@0 361 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
max@0 362 arma_inline uword get_n_slices() const { return Q.n_slices; }
max@0 363 arma_inline uword get_n_elem() const { return Q.n_elem; }
max@0 364
max@0 365 arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
max@0 366 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
max@0 367
max@0 368 arma_inline ea_type get_ea() const { return Q.memptr(); }
max@0 369
max@0 370 template<typename eT2>
max@0 371 arma_inline bool is_alias(const Cube<eT2>&) const { return false; }
max@0 372 };
max@0 373
max@0 374
max@0 375
max@0 376 //! @}