annotate armadillo-2.4.4/include/armadillo_bits/op_cx_scalar_meat.hpp @ 5:79b343f3e4b8

In thi version the problem of letters assigned to each segment has been solved.
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 13:48:13 +0100
parents 8b6102e2a9b0
children
rev   line source
max@0 1 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
max@0 2 // Copyright (C) 2008-2010 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 op_cx_scalar
max@0 15 //! @{
max@0 16
max@0 17
max@0 18
max@0 19 template<typename T1>
max@0 20 inline
max@0 21 void
max@0 22 op_cx_scalar_times::apply
max@0 23 (
max@0 24 Mat< typename std::complex<typename T1::pod_type> >& out,
max@0 25 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_times>& X
max@0 26 )
max@0 27 {
max@0 28 arma_extra_debug_sigprint();
max@0 29
max@0 30 typedef typename std::complex<typename T1::pod_type> eT;
max@0 31 typedef typename T1::pod_type T;
max@0 32
max@0 33 const Proxy<T1> A(X.m);
max@0 34
max@0 35 out.set_size(A.get_n_rows(), A.get_n_cols());
max@0 36
max@0 37 const eT k = X.aux_out_eT;
max@0 38 const uword n_elem = out.n_elem;
max@0 39 eT* out_mem = out.memptr();
max@0 40
max@0 41 for(uword i=0; i<n_elem; ++i)
max@0 42 {
max@0 43 out_mem[i] = A[i] * k;
max@0 44 }
max@0 45 }
max@0 46
max@0 47
max@0 48
max@0 49 template<typename T1>
max@0 50 inline
max@0 51 void
max@0 52 op_cx_scalar_plus::apply
max@0 53 (
max@0 54 Mat< typename std::complex<typename T1::pod_type> >& out,
max@0 55 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus>& X
max@0 56 )
max@0 57 {
max@0 58 arma_extra_debug_sigprint();
max@0 59
max@0 60 typedef typename std::complex<typename T1::pod_type> eT;
max@0 61 typedef typename T1::pod_type T;
max@0 62
max@0 63 const Proxy<T1> A(X.m);
max@0 64
max@0 65 out.set_size(A.get_n_rows(), A.get_n_cols());
max@0 66
max@0 67 const eT k = X.aux_out_eT;
max@0 68 const uword n_elem = out.n_elem;
max@0 69 eT* out_mem = out.memptr();
max@0 70
max@0 71 for(uword i=0; i<n_elem; ++i)
max@0 72 {
max@0 73 out_mem[i] = A[i] + k;
max@0 74 }
max@0 75 }
max@0 76
max@0 77
max@0 78
max@0 79 template<typename T1>
max@0 80 inline
max@0 81 void
max@0 82 op_cx_scalar_minus_pre::apply
max@0 83 (
max@0 84 Mat< typename std::complex<typename T1::pod_type> >& out,
max@0 85 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_pre>& X
max@0 86 )
max@0 87 {
max@0 88 arma_extra_debug_sigprint();
max@0 89
max@0 90 typedef typename std::complex<typename T1::pod_type> eT;
max@0 91 typedef typename T1::pod_type T;
max@0 92
max@0 93 const Proxy<T1> A(X.m);
max@0 94
max@0 95 out.set_size(A.get_n_rows(), A.get_n_cols());
max@0 96
max@0 97 const eT k = X.aux_out_eT;
max@0 98 const uword n_elem = out.n_elem;
max@0 99 eT* out_mem = out.memptr();
max@0 100
max@0 101 for(uword i=0; i<n_elem; ++i)
max@0 102 {
max@0 103 out_mem[i] = k - A[i];
max@0 104 }
max@0 105 }
max@0 106
max@0 107
max@0 108
max@0 109 template<typename T1>
max@0 110 inline
max@0 111 void
max@0 112 op_cx_scalar_minus_post::apply
max@0 113 (
max@0 114 Mat< typename std::complex<typename T1::pod_type> >& out,
max@0 115 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_post>& X
max@0 116 )
max@0 117 {
max@0 118 arma_extra_debug_sigprint();
max@0 119
max@0 120 typedef typename std::complex<typename T1::pod_type> eT;
max@0 121 typedef typename T1::pod_type T;
max@0 122
max@0 123 const Proxy<T1> A(X.m);
max@0 124
max@0 125 out.set_size(A.get_n_rows(), A.get_n_cols());
max@0 126
max@0 127 const eT k = X.aux_out_eT;
max@0 128 const uword n_elem = out.n_elem;
max@0 129 eT* out_mem = out.memptr();
max@0 130
max@0 131 for(uword i=0; i<n_elem; ++i)
max@0 132 {
max@0 133 out_mem[i] = A[i] - k;
max@0 134 }
max@0 135 }
max@0 136
max@0 137
max@0 138
max@0 139 template<typename T1>
max@0 140 inline
max@0 141 void
max@0 142 op_cx_scalar_div_pre::apply
max@0 143 (
max@0 144 Mat< typename std::complex<typename T1::pod_type> >& out,
max@0 145 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_pre>& X
max@0 146 )
max@0 147 {
max@0 148 arma_extra_debug_sigprint();
max@0 149
max@0 150 typedef typename std::complex<typename T1::pod_type> eT;
max@0 151 typedef typename T1::pod_type T;
max@0 152
max@0 153 const Proxy<T1> A(X.m);
max@0 154
max@0 155 out.set_size(A.get_n_rows(), A.get_n_cols());
max@0 156
max@0 157 const eT k = X.aux_out_eT;
max@0 158 const uword n_elem = out.n_elem;
max@0 159 eT* out_mem = out.memptr();
max@0 160
max@0 161 for(uword i=0; i<n_elem; ++i)
max@0 162 {
max@0 163 out_mem[i] = k / A[i];
max@0 164 }
max@0 165 }
max@0 166
max@0 167
max@0 168
max@0 169 template<typename T1>
max@0 170 inline
max@0 171 void
max@0 172 op_cx_scalar_div_post::apply
max@0 173 (
max@0 174 Mat< typename std::complex<typename T1::pod_type> >& out,
max@0 175 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_post>& X
max@0 176 )
max@0 177 {
max@0 178 arma_extra_debug_sigprint();
max@0 179
max@0 180 typedef typename std::complex<typename T1::pod_type> eT;
max@0 181 typedef typename T1::pod_type T;
max@0 182
max@0 183 const Proxy<T1> A(X.m);
max@0 184
max@0 185 out.set_size(A.get_n_rows(), A.get_n_cols());
max@0 186
max@0 187 const eT k = X.aux_out_eT;
max@0 188 const uword n_elem = out.n_elem;
max@0 189 eT* out_mem = out.memptr();
max@0 190
max@0 191 for(uword i=0; i<n_elem; ++i)
max@0 192 {
max@0 193 out_mem[i] = A[i] / k;
max@0 194 }
max@0 195 }
max@0 196
max@0 197
max@0 198
max@0 199 //
max@0 200 //
max@0 201 //
max@0 202
max@0 203
max@0 204
max@0 205 template<typename T1>
max@0 206 inline
max@0 207 void
max@0 208 op_cx_scalar_times::apply
max@0 209 (
max@0 210 Cube< typename std::complex<typename T1::pod_type> >& out,
max@0 211 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_times>& X
max@0 212 )
max@0 213 {
max@0 214 arma_extra_debug_sigprint();
max@0 215
max@0 216 typedef typename std::complex<typename T1::pod_type> eT;
max@0 217 typedef typename T1::pod_type T;
max@0 218
max@0 219 const ProxyCube<T1> A(X.m);
max@0 220
max@0 221 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
max@0 222
max@0 223 const eT k = X.aux_out_eT;
max@0 224 const uword n_elem = out.n_elem;
max@0 225 eT* out_mem = out.memptr();
max@0 226
max@0 227 for(uword i=0; i<n_elem; ++i)
max@0 228 {
max@0 229 out_mem[i] = A[i] * k;
max@0 230 }
max@0 231 }
max@0 232
max@0 233
max@0 234
max@0 235 template<typename T1>
max@0 236 inline
max@0 237 void
max@0 238 op_cx_scalar_plus::apply
max@0 239 (
max@0 240 Cube< typename std::complex<typename T1::pod_type> >& out,
max@0 241 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus>& X
max@0 242 )
max@0 243 {
max@0 244 arma_extra_debug_sigprint();
max@0 245
max@0 246 typedef typename std::complex<typename T1::pod_type> eT;
max@0 247 typedef typename T1::pod_type T;
max@0 248
max@0 249 const ProxyCube<T1> A(X.m);
max@0 250
max@0 251 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
max@0 252
max@0 253 const eT k = X.aux_out_eT;
max@0 254 const uword n_elem = out.n_elem;
max@0 255 eT* out_mem = out.memptr();
max@0 256
max@0 257 for(uword i=0; i<n_elem; ++i)
max@0 258 {
max@0 259 out_mem[i] = A[i] + k;
max@0 260 }
max@0 261 }
max@0 262
max@0 263
max@0 264
max@0 265 template<typename T1>
max@0 266 inline
max@0 267 void
max@0 268 op_cx_scalar_minus_pre::apply
max@0 269 (
max@0 270 Cube< typename std::complex<typename T1::pod_type> >& out,
max@0 271 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_pre>& X
max@0 272 )
max@0 273 {
max@0 274 arma_extra_debug_sigprint();
max@0 275
max@0 276 typedef typename std::complex<typename T1::pod_type> eT;
max@0 277 typedef typename T1::pod_type T;
max@0 278
max@0 279 const ProxyCube<T1> A(X.m);
max@0 280
max@0 281 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
max@0 282
max@0 283 const eT k = X.aux_out_eT;
max@0 284 const uword n_elem = out.n_elem;
max@0 285 eT* out_mem = out.memptr();
max@0 286
max@0 287 for(uword i=0; i<n_elem; ++i)
max@0 288 {
max@0 289 out_mem[i] = k - A[i];
max@0 290 }
max@0 291 }
max@0 292
max@0 293
max@0 294
max@0 295 template<typename T1>
max@0 296 inline
max@0 297 void
max@0 298 op_cx_scalar_minus_post::apply
max@0 299 (
max@0 300 Cube< typename std::complex<typename T1::pod_type> >& out,
max@0 301 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_post>& X
max@0 302 )
max@0 303 {
max@0 304 arma_extra_debug_sigprint();
max@0 305
max@0 306 typedef typename std::complex<typename T1::pod_type> eT;
max@0 307 typedef typename T1::pod_type T;
max@0 308
max@0 309 const ProxyCube<T1> A(X.m);
max@0 310
max@0 311 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
max@0 312
max@0 313 const eT k = X.aux_out_eT;
max@0 314 const uword n_elem = out.n_elem;
max@0 315 eT* out_mem = out.memptr();
max@0 316
max@0 317 for(uword i=0; i<n_elem; ++i)
max@0 318 {
max@0 319 out_mem[i] = A[i] - k;
max@0 320 }
max@0 321 }
max@0 322
max@0 323
max@0 324
max@0 325 template<typename T1>
max@0 326 inline
max@0 327 void
max@0 328 op_cx_scalar_div_pre::apply
max@0 329 (
max@0 330 Cube< typename std::complex<typename T1::pod_type> >& out,
max@0 331 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_pre>& X
max@0 332 )
max@0 333 {
max@0 334 arma_extra_debug_sigprint();
max@0 335
max@0 336 typedef typename std::complex<typename T1::pod_type> eT;
max@0 337 typedef typename T1::pod_type T;
max@0 338
max@0 339 const ProxyCube<T1> A(X.m);
max@0 340
max@0 341 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
max@0 342
max@0 343 const eT k = X.aux_out_eT;
max@0 344 const uword n_elem = out.n_elem;
max@0 345 eT* out_mem = out.memptr();
max@0 346
max@0 347 for(uword i=0; i<n_elem; ++i)
max@0 348 {
max@0 349 out_mem[i] = k / A[i];
max@0 350 }
max@0 351 }
max@0 352
max@0 353
max@0 354
max@0 355 template<typename T1>
max@0 356 inline
max@0 357 void
max@0 358 op_cx_scalar_div_post::apply
max@0 359 (
max@0 360 Cube< typename std::complex<typename T1::pod_type> >& out,
max@0 361 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_post>& X
max@0 362 )
max@0 363 {
max@0 364 arma_extra_debug_sigprint();
max@0 365
max@0 366 typedef typename std::complex<typename T1::pod_type> eT;
max@0 367 typedef typename T1::pod_type T;
max@0 368
max@0 369 const ProxyCube<T1> A(X.m);
max@0 370
max@0 371 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
max@0 372
max@0 373 const eT k = X.aux_out_eT;
max@0 374 const uword n_elem = out.n_elem;
max@0 375 eT* out_mem = out.memptr();
max@0 376
max@0 377 for(uword i=0; i<n_elem; ++i)
max@0 378 {
max@0 379 out_mem[i] = A[i] / k;
max@0 380 }
max@0 381 }
max@0 382
max@0 383
max@0 384
max@0 385 //! @}