comparison armadillo-2.4.4/include/armadillo_bits/op_misc_meat.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-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2011 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 op_misc
15 //! @{
16
17
18
19 template<typename T1>
20 inline
21 void
22 op_real::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_real>& X )
23 {
24 arma_extra_debug_sigprint();
25
26 typedef typename T1::pod_type T;
27
28 const Proxy<T1> A(X.m);
29
30 out.set_size(A.get_n_rows(), A.get_n_cols());
31
32 const uword n_elem = out.n_elem;
33 T* out_mem = out.memptr();
34
35 for(uword i=0; i<n_elem; ++i)
36 {
37 out_mem[i] = std::real(A[i]);
38 }
39 }
40
41
42
43 template<typename T1>
44 inline
45 void
46 op_real::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1::pod_type, T1, op_real>& X )
47 {
48 arma_extra_debug_sigprint();
49
50 typedef typename T1::pod_type T;
51
52 const ProxyCube<T1> A(X.m);
53
54 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
55
56 const uword n_elem = out.n_elem;
57 T* out_mem = out.memptr();
58
59 for(uword i=0; i<n_elem; ++i)
60 {
61 out_mem[i] = std::real(A[i]);
62 }
63 }
64
65
66
67 template<typename T1>
68 inline
69 void
70 op_imag::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_imag>& X )
71 {
72 arma_extra_debug_sigprint();
73
74 typedef typename T1::pod_type T;
75
76 const Proxy<T1> A(X.m);
77
78 out.set_size(A.get_n_rows(), A.get_n_cols());
79
80 const uword n_elem = out.n_elem;
81 T* out_mem = out.memptr();
82
83 for(uword i=0; i<n_elem; ++i)
84 {
85 out_mem[i] = std::imag(A[i]);
86 }
87 }
88
89
90
91 template<typename T1>
92 inline
93 void
94 op_imag::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1::pod_type, T1, op_imag>& X )
95 {
96 arma_extra_debug_sigprint();
97
98 typedef typename T1::pod_type T;
99
100 const ProxyCube<T1> A(X.m);
101
102 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
103
104 const uword n_elem = out.n_elem;
105 T* out_mem = out.memptr();
106
107 for(uword i=0; i<n_elem; ++i)
108 {
109 out_mem[i] = std::imag(A[i]);
110 }
111 }
112
113
114
115 template<typename T1>
116 inline
117 void
118 op_abs::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_abs>& X )
119 {
120 arma_extra_debug_sigprint();
121
122 typedef typename T1::pod_type T;
123
124 const Proxy<T1> A(X.m);
125
126 out.set_size(A.get_n_rows(), A.get_n_cols());
127
128 const uword n_elem = out.n_elem;
129 T* out_mem = out.memptr();
130
131 for(uword i=0; i<n_elem; ++i)
132 {
133 out_mem[i] = std::abs(A[i]);
134 }
135 }
136
137
138
139 template<typename T1>
140 inline
141 void
142 op_abs::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1::pod_type, T1, op_abs>& X )
143 {
144 arma_extra_debug_sigprint();
145
146 typedef typename T1::pod_type T;
147
148 const ProxyCube<T1> A(X.m);
149
150 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
151
152 const uword n_elem = out.n_elem;
153 T* out_mem = out.memptr();
154
155 for(uword i=0; i<n_elem; ++i)
156 {
157 out_mem[i] = std::abs(A[i]);
158 }
159 }
160
161
162
163 template<typename T1>
164 inline
165 void
166 op_sympd::apply( Mat<typename T1::elem_type>& out, const Op<T1, op_sympd>& X )
167 {
168 arma_extra_debug_sigprint();
169
170 out = X.m;
171 }
172
173
174
175 //! @}