annotate armadillo-3.900.4/include/armadillo_bits/ProxyCube.hpp @ 84:55a047986812 tip

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