comparison armadillo-2.4.4/include/armadillo_bits/unwrap_cube.hpp @ 0:8b6102e2a9b0

Armadillo Library
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 09:27:06 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8b6102e2a9b0
1 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2010 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12
13
14 //! \addtogroup unwrap_cube
15 //! @{
16
17
18
19 template<typename T1>
20 class unwrap_cube
21 {
22 public:
23
24 typedef typename T1::elem_type eT;
25
26 inline
27 unwrap_cube(const T1& A)
28 : M(A)
29 {
30 arma_extra_debug_sigprint();
31 }
32
33 const Cube<eT> M;
34 };
35
36
37
38 template<typename eT>
39 class unwrap_cube< Cube<eT> >
40 {
41 public:
42
43 inline
44 unwrap_cube(const Cube<eT>& A)
45 : M(A)
46 {
47 arma_extra_debug_sigprint();
48 }
49
50 const Cube<eT>& M;
51 };
52
53
54
55 //
56 //
57 //
58
59
60
61 template<typename T1>
62 class unwrap_cube_check
63 {
64 typedef typename T1::elem_type eT;
65
66 inline
67 unwrap_cube_check(const T1& A, const Cube<eT>& B)
68 : M(A)
69 {
70 arma_extra_debug_sigprint();
71
72 arma_type_check(( is_arma_cube_type<T1>::value == false ));
73 }
74
75 const Cube<eT> M;
76 };
77
78
79
80 template<typename eT>
81 class unwrap_cube_check< Cube<eT> >
82 {
83 public:
84
85 inline
86 unwrap_cube_check(const Cube<eT>& A, const Cube<eT>& B)
87 : M_local( (&A == &B) ? new Cube<eT>(A) : 0 )
88 , M ( (&A == &B) ? (*M_local) : A )
89 {
90 arma_extra_debug_sigprint();
91 }
92
93
94 inline
95 ~unwrap_cube_check()
96 {
97 arma_extra_debug_sigprint();
98
99 if(M_local)
100 {
101 delete M_local;
102 }
103 }
104
105
106 // the order below is important
107 const Cube<eT>* M_local;
108 const Cube<eT>& M;
109
110 };
111
112
113
114 //! @}