mxnet
complex.h
Go to the documentation of this file.
1 
7 #ifndef MSHADOW_EXTENSION_COMPLEX_H_
8 #define MSHADOW_EXTENSION_COMPLEX_H_
9 #include <algorithm>
10 #include "../extension.h"
11 
12 namespace mshadow {
13 namespace op {
14 namespace complex {
17 struct mul {
19  template<typename DType>
20  MSHADOW_XINLINE static DType RealMap(DType a_real, DType a_imag,
21  DType b_real, DType b_imag) {
22  return a_real * b_real - a_imag * b_imag;
23  }
24  template<typename DType>
25  MSHADOW_XINLINE static DType ImagMap(DType a_real, DType a_imag,
26  DType b_real, DType b_imag) {
27  return a_real * b_imag + b_real * a_imag;
28  }
29 };
30 
31 struct div {
33  template<typename DType>
34  MSHADOW_XINLINE static DType RealMap(DType a_real, DType a_imag,
35  DType b_real, DType b_imag) {
36  return (a_real * b_real + a_imag * b_imag) / (b_real * b_real + b_imag * b_imag);
37  }
38  template<typename DType>
39  MSHADOW_XINLINE static DType ImagMap(DType a_real, DType a_imag,
40  DType b_real, DType b_imag) {
41  return (b_real * a_imag - a_real * b_imag) / (b_real * b_real + b_imag * b_imag);
42  }
43 };
44 
45 struct conjugate {
46  template<typename TA, typename DType>
47  MSHADOW_XINLINE static DType RealMap(const expr::Plan<TA, DType> &src_,
48  index_t real_i, index_t real_j, index_t imag_i, index_t imag_j) {
49  return src_.Eval(real_i, real_j);
50  }
51  template<typename TA, typename DType>
52  MSHADOW_XINLINE static DType ImagMap(const expr::Plan<TA, DType> &src_,
53  index_t real_i, index_t real_j, index_t imag_i, index_t imag_j) {
54  return -src_.Eval(imag_i, imag_j);
55  }
56 };
57 
58 struct exchange {
59  template<typename TA, typename DType>
60  MSHADOW_XINLINE static DType RealMap(const expr::Plan<TA, DType> &src_,
61  index_t real_i, index_t real_j, index_t imag_i, index_t imag_j) {
62  return src_.Eval(imag_i, imag_j);
63  }
64  template<typename TA, typename DType>
65  MSHADOW_XINLINE static DType ImagMap(const expr::Plan<TA, DType> &src_,
66  index_t real_i, index_t real_j, index_t imag_i, index_t imag_j) {
67  return src_.Eval(real_i, real_j);
68  }
69 };
70 
71 // r2c operator
72 struct pad_imag {
73  template<typename TA, typename DType>
74  MSHADOW_XINLINE static DType RealMap(const expr::Plan<TA, DType> &src_,
75  index_t real_i, index_t real_j) {
76  return src_.Eval(real_i, real_j);
77  }
78  template<typename TA, typename DType>
79  MSHADOW_XINLINE static DType ImagMap(const expr::Plan<TA, DType> &src_,
80  index_t real_i, index_t real_j) {
81  return 0;
82  }
83 };
84 
85 // c2r operator
86 struct toreal {
87  template<typename TA, typename DType>
88  MSHADOW_XINLINE static DType RealMap(const expr::Plan<TA, DType> &src_,
89  index_t real_i, index_t real_j, index_t imag_i, index_t imag_j) {
90  DType real_val = src_.Eval(real_i, real_j);
91  return real_val;
92  }
93 };
94 
95 struct abs_square {
96  template<typename TA, typename DType>
97  MSHADOW_XINLINE static DType RealMap(const expr::Plan<TA, DType> &src_,
98  index_t real_i, index_t real_j, index_t imag_i, index_t imag_j) {
99  DType real_val = src_.Eval(real_i, real_j);
100  DType image_val = src_.Eval(imag_i, imag_j);
101  return real_val * real_val + image_val * image_val;
102  }
103 };
104 
106  template<typename TA, typename DType>
108  index_t real_i, index_t real_j, index_t imag_i, index_t imag_j) {
109  DType real_val = src_.Eval(real_i, real_j);
110  DType image_val = src_.Eval(imag_i, imag_j);
111  return real_val + image_val;
112  }
113 };
114 } // namespace complex
115 } // namespace op
116 
117 namespace expr {
118 //--------------------
119 // ComplexBinaryMapExp
120 //--------------------
129 template<int calctype, typename OP, typename TA, typename TB, typename DType, int etype>
130 struct ComplexBinaryMapExp : public Exp<ComplexBinaryMapExp<calctype, OP, TA, TB, DType, etype>,
131  DType, etype> {
133  const TA &lhs_;
135  const TB &rhs_;
137  explicit ComplexBinaryMapExp(const TA &lhs, const TB &rhs)
138  :lhs_(lhs), rhs_(rhs) {}
139 };
140 
141 //-------------------
142 // ComplexConjExp
143 //-------------------
149 template<int calctype, typename OP, typename TA, typename DType, int etype>
150 struct ComplexUnitaryExp : public Exp<ComplexUnitaryExp<calctype, OP, TA, DType, etype>,
151  DType, etype> {
153  const TA &src_;
155  explicit ComplexUnitaryExp(const TA &src) : src_(src) {}
156 };
157 
158 
159 
160 template<int calctype, typename OP, typename TA, typename TB, typename DType, int ta, int tb>
163  return ComplexBinaryMapExp<calctype, OP, TA, TB, DType,
164  (ta | tb | type::kMapper)>(lhs.self(), rhs.self());
165 }
166 
172 template<int calctype, typename OP, typename SrcExp, typename DType, int e1>
176 }
177 
181 template<typename TA, typename TB, typename DType, int ta, int tb>
183  TA, TB, DType, (ta | tb | type::kMapper)>
185  return ComplexF<op::complex::kBinaryCC, op::complex::mul>(lhs, rhs);
186 }
187 
191 template<typename TA, typename TB, typename DType, int ta, int tb>
192 inline ComplexBinaryMapExp<op::complex::kBinaryCR, op::complex::mul,
193  TA, TB, DType, (ta | tb | type::kMapper)>
195  return ComplexF<op::complex::kBinaryCR, op::complex::mul>(lhs, rhs);
196 }
197 
201 template<typename TA, typename TB, typename DType, int ta, int tb>
202 inline ComplexBinaryMapExp<op::complex::kBinaryRC, op::complex::mul,
203  TA, TB, DType, (ta | tb | type::kMapper)>
205  return ComplexF<op::complex::kBinaryRC, op::complex::mul>(lhs, rhs);
206 }
207 
211 template<typename TA, typename TB, typename DType, int ta, int tb>
213  TA, TB, DType, (ta | tb | type::kMapper)>
215  return ComplexF<op::complex::kBinaryCC, op::complex::div>(lhs, rhs);
216 }
217 
221 template<typename TA, typename TB, typename DType, int ta, int tb>
222 inline ComplexBinaryMapExp<op::complex::kBinaryCR, op::complex::div,
223  TA, TB, DType, (ta | tb | type::kMapper)>
225  return ComplexF<op::complex::kBinaryCR, op::complex::div>(lhs, rhs);
226 }
227 
231 template<typename TA, typename TB, typename DType, int ta, int tb>
232 inline ComplexBinaryMapExp<op::complex::kBinaryRC, op::complex::div,
233  TA, TB, DType, (ta | tb | type::kMapper)>
235  return ComplexF<op::complex::kBinaryRC, op::complex::div>(lhs, rhs);
236 }
237 
243 template<typename SrcExp, typename DType, int e1>
245  SrcExp, DType, (e1|type::kMapper)>
247  return ComplexF<op::complex::kUnitaryC2C, op::complex::conjugate>(src);
248 }
249 
255 template<typename SrcExp, typename DType, int e1>
257  SrcExp, DType, (e1|type::kMapper)>
259  return ComplexF<op::complex::kUnitaryC2C, op::complex::exchange>(src);
260 }
261 
267 template<typename SrcExp, typename DType, int e1>
269  SrcExp, DType, (e1|type::kMapper)>
271  return ComplexF<op::complex::kUnitaryR2C, op::complex::pad_imag>(src);
272 }
273 
279 template<typename SrcExp, typename DType, int e1>
281  SrcExp, DType, (e1 | type::kMapper)>
283  return ComplexF<op::complex::kUnitaryC2R, op::complex::toreal>(src);
284 }
285 
291 template<typename SrcExp, typename DType, int e1>
293  SrcExp, DType, (e1 | type::kMapper)>
295  return ComplexF<op::complex::kUnitaryC2R, op::complex::abs_square>(src);
296 }
297 
298 template<typename SrcExp, typename DType, int e1>
300  SrcExp, DType, (e1 | type::kMapper)>
302  return ComplexF<op::complex::kUnitaryC2R, op::complex::sum_real_imag>(src);
303 }
304 
305 template<int dim, int calctype, typename OP, typename TA, typename TB,
306  typename DType, int etype>
307 struct ShapeCheck<dim, ComplexBinaryMapExp<calctype, OP, TA, TB, DType, etype> > {
308  inline static Shape<dim>
312  if (shape1[0] == 0) return shape2;
313  if (shape2[0] == 0) return shape1;
314  if (calctype == op::complex::kBinaryCC) {
315  CHECK_EQ(shape1, shape2) << "ComplexBinaryMapExp (CC): Shapes of operands are not the same.";
316  CHECK_EQ(shape1[dim - 1] % 2, 0) <<
317  "ComplexBinaryMapExp (CC): Shape of the last dimension is not even. "
318  "We must have real part + imaginary part.";
319  return shape1;
320  } else if (calctype == op::complex::kBinaryCR) {
321  for (int i = 0; i < dim - 1; ++i) {
322  CHECK_EQ(shape1.shape_[i], shape2.shape_[i]) <<
323  "ComplexBinaryMapExp (CR): Shapes of operands are not the same.";
324  }
325  CHECK_EQ(shape1[dim - 1], shape2[dim - 1] * 2) <<
326  "ComplexBinaryMapExp (CR): Shapes of operands do not match.";
327  return shape1;
328  } else if (calctype == op::complex::kBinaryRC) {
329  for (int i = 0; i < dim - 1; ++i) {
330  CHECK_EQ(shape1.shape_[i], shape2.shape_[i]) <<
331  "ComplexBinaryMapExp (RC): Shapes of operands are not the same.";
332  }
333  CHECK_EQ(shape2[dim - 1], shape1[dim - 1] * 2) <<
334  "ComplexBinaryMapExp (RC): Shapes of operands do not match.";
335  return shape2;
336  } else {
337  LOG(FATAL) << "ComplexBinaryMapExp: Unexpected Calculation Type!";
338  return shape1;
339  }
340  }
341 };
342 
343 template<int dim, int calctype, typename OP, typename TA, typename DType, int etype>
344 struct ShapeCheck<dim, ComplexUnitaryExp<calctype, OP, TA, DType, etype> > {
347  CHECK_EQ(s[dim - 1] % 2, 0) << "ComplexUnitaryExp: Shape of the last dimension is not even. "
348  "We must have real + imaginary.";
349  if (calctype == op::complex::kUnitaryC2C) {
350  return s;
351  } else if (calctype == op::complex::kUnitaryC2R) {
352  Shape<dim> s_ret = s;
353  s_ret[dim - 1] /= 2;
354  return s_ret;
355  } else if (calctype == op::complex::kUnitaryR2C) {
356  Shape<dim> s_ret = s;
357  s_ret[dim-1] *= 2;
358  return s_ret;
359  } else {
360  LOG(FATAL) << "ComplexUnitaryExp: Unexpected Calculation Type!";
361  return s;
362  }
363  }
364 };
365 
366 
367 
368 // complex binary expression (cc)
369 template<typename OP, typename TA, typename TB, int etype, typename DType>
370 class Plan<ComplexBinaryMapExp<op::complex::kBinaryCC, OP, TA, TB, DType, etype>, DType> {
371  public:
372  explicit Plan(const Plan<TA, DType> &lhs, const Plan<TB, DType> &rhs)
373  : lhs_(lhs), rhs_(rhs) {}
374  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
375  const index_t base_x = static_cast<index_t>(x / 2) * 2;
376  if (x % 2 == 0) {
377  return OP::RealMap(lhs_.Eval(y, base_x), lhs_.Eval(y, base_x + 1),
378  rhs_.Eval(y, base_x), rhs_.Eval(y, base_x + 1));
379  } else {
380  return OP::ImagMap(lhs_.Eval(y, base_x), lhs_.Eval(y, base_x + 1),
381  rhs_.Eval(y, base_x), rhs_.Eval(y, base_x + 1));
382  }
383  }
384 
385  private:
386  Plan<TA, DType> lhs_;
387  Plan<TB, DType> rhs_;
388 };
389 
390 // complex binary expression (cr)
391 template<typename OP, typename TA, typename TB, int etype, typename DType>
392 class Plan<ComplexBinaryMapExp<op::complex::kBinaryCR, OP, TA, TB, DType, etype>, DType> {
393  public:
394  explicit Plan(const Plan<TA, DType> &lhs, const Plan<TB, DType> &rhs)
395  : lhs_(lhs), rhs_(rhs) {}
396  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
397  const index_t base_x = static_cast<index_t>(x / 2) * 2;
398  if (x % 2 == 0) {
399  return OP::RealMap(lhs_.Eval(y, base_x), lhs_.Eval(y, base_x + 1),
400  rhs_.Eval(y, base_x / 2), static_cast<DType>(0));
401  } else {
402  return OP::ImagMap(lhs_.Eval(y, base_x), lhs_.Eval(y, base_x + 1),
403  rhs_.Eval(y, base_x / 2), static_cast<DType>(0));
404  }
405  }
406 
407  private:
408  Plan<TA, DType> lhs_;
409  Plan<TB, DType> rhs_;
410 };
411 
412 
413 // complex binary expression (rc)
414 template<typename OP, typename TA, typename TB, int etype, typename DType>
415 class Plan<ComplexBinaryMapExp<op::complex::kBinaryRC, OP, TA, TB, DType, etype>, DType> {
416  public:
417  explicit Plan(const Plan<TA, DType> &lhs, const Plan<TB, DType> &rhs)
418  : lhs_(lhs), rhs_(rhs) {}
419  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
420  const index_t base_x = static_cast<index_t>(x / 2) * 2;
421  if (x % 2 == 0) {
422  return OP::RealMap(lhs_.Eval(y, base_x / 2), static_cast<DType>(0),
423  rhs_.Eval(y, base_x), rhs_.Eval(y, base_x + 1));
424  } else {
425  return OP::ImagMap(lhs_.Eval(y, base_x / 2), static_cast<DType>(0),
426  rhs_.Eval(y, base_x), rhs_.Eval(y, base_x + 1));
427  }
428  }
429 
430  private:
431  Plan<TA, DType> lhs_;
432  Plan<TB, DType> rhs_;
433 };
434 
435 
436 // complex unitary expression (c2c)
437 template<typename OP, typename TA, int etype, typename DType>
438 class Plan<ComplexUnitaryExp<op::complex::kUnitaryC2C, OP, TA, DType, etype>, DType> {
439  public:
440  explicit Plan(const Plan<TA, DType> &src) : src_(src) {}
441  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
442  const index_t base_x = static_cast<index_t>(x / 2) * 2;
443  if (0 == x % 2) {
444  return OP::RealMap(src_, y, base_x, y, base_x + 1);
445  } else {
446  return OP::ImagMap(src_, y, base_x, y, base_x + 1);
447  }
448  }
449 
450  private:
451  Plan<TA, DType> src_;
452 };
453 
454 // complex unitary expression (r2c)
455 template<typename OP, typename TA, int etype, typename DType>
456 class Plan<ComplexUnitaryExp<op::complex::kUnitaryR2C, OP, TA, DType, etype>, DType> {
457  public:
458  explicit Plan(const Plan<TA, DType> &src) : src_(src) {}
459  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
460  const index_t real_x = static_cast<index_t>(x / 2);
461  if (0 == x%2) {
462  // x,y should be coordinates in the complex matrix
463  // this defines how we will give value to the real part from the real matrix src_,
464  // thus the index has only 2 dimensions
465  return OP::RealMap(src_, y, real_x);
466  } else {
467  return OP::ImagMap(src_, y, real_x);
468  }
469  }
470 
471  private:
472  Plan<TA, DType> src_;
473 };
474 
475 // complex unitary expression (c2r)
476 template<typename OP, typename TA, int etype, typename DType>
477 class Plan<ComplexUnitaryExp<op::complex::kUnitaryC2R, OP, TA, DType, etype>, DType> {
478  public:
479  explicit Plan(const Plan<TA, DType> &src) : src_(src) {}
480  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
481  return OP::RealMap(src_, y, x * 2, y, x * 2 + 1);
482  }
483 
484  private:
485  Plan<TA, DType> src_;
486 };
487 
488 
489 
490 template<int calctype, typename OP, typename TA, typename TB, typename DType, int etype>
493  return Plan<ComplexBinaryMapExp<calctype, OP, TA, TB, DType, etype>,
494  DType>(MakePlan(e.lhs_), MakePlan(e.rhs_));
495 }
496 
497 template<int calctype, typename OP, typename TA, typename DType, int etype>
500  return Plan<ComplexUnitaryExp<calctype, OP, TA, DType, etype>,
501  DType>(MakePlan(e.src_));
502 }
503 
504 
505 
506 template<int calctype, typename OP, typename TA, typename TB, typename DType, int etype>
507 struct ExpInfo<ComplexBinaryMapExp<calctype, OP, TA, TB, DType, etype> > {
508  static const int kDimLhs = ExpInfo<TA>::kDim;
509  static const int kDimRhs = ExpInfo<TB>::kDim;
510  static const int kDim = (kDimLhs >= 0 && kDimRhs >= 0) ? \
511  (kDimLhs == 0 ? \
512  kDimRhs : \
513  ((kDimRhs == 0 || kDimLhs == kDimRhs) ? kDimLhs : -1)) : -1;
514  static const int kDevMask = ExpInfo<TA>::kDevMask & ExpInfo<TB>::kDevMask;
515 };
516 
517 template<int calctype, typename OP, typename TA, typename DType, int etype>
518 struct ExpInfo<ComplexUnitaryExp<calctype, OP, TA, DType, etype> > {
519  static const int kDim = ExpInfo<TA>::kDim;
520  static const int kDevMask = ExpInfo<TA>::kDevMask;
521 };
522 
523 } // namespace expr
524 } // namespace mshadow
525 #endif // MSHADOW_EXTENSION_COMPLEX_H_
ComplexBinaryMapExp< op::complex::kBinaryRC, op::complex::mul, TA, TB, DType,(ta|tb|type::kMapper)> complex_mul_rc(const Exp< TA, DType, ta > &lhs, const Exp< TB, DType, tb > &rhs)
complex_mul_rc Complex multipilication of a real tensor B and a complex tensor A
Definition: complex.h:204
static MSHADOW_XINLINE DType RealMap(DType a_real, DType a_imag, DType b_real, DType b_imag)
map a_real, a_imag, b_real, b_imag to result using defined operation
Definition: complex.h:34
Plan< ComplexUnitaryExp< calctype, OP, TA, DType, etype >, DType > MakePlan(const ComplexUnitaryExp< calctype, OP, TA, DType, etype > &e)
Definition: complex.h:499
static MSHADOW_XINLINE DType ImagMap(const expr::Plan< TA, DType > &src_, index_t real_i, index_t real_j, index_t imag_i, index_t imag_j)
Definition: complex.h:65
static MSHADOW_XINLINE DType ImagMap(const expr::Plan< TA, DType > &src_, index_t real_i, index_t real_j, index_t imag_i, index_t imag_j)
Definition: complex.h:52
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: complex.h:374
Definition: complex.h:15
const int kMapper
expression contains element-wise tensor operations, map a expression to same shape ...
Definition: expression.h:32
ComplexUnitaryExp(const TA &src)
constructor
Definition: complex.h:155
Definition: complex.h:15
ComplexUnitaryExp< op::complex::kUnitaryC2R, op::complex::abs_square, SrcExp, DType,(e1|type::kMapper)> complex_abs_square(const Exp< SrcExp, DType, e1 > &src)
complex_abs_square calculate the square of the modulus of A where A is a complex tensor ...
Definition: complex.h:294
static MSHADOW_XINLINE DType RealMap(const expr::Plan< TA, DType > &src_, index_t real_i, index_t real_j, index_t imag_i, index_t imag_j)
Definition: complex.h:107
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
evaluate the expression at index [y][x] to be implemented by SubType, for RValue, the return type wil...
UnitaryCalculationType
Definition: complex.h:16
const TB & rhs_
right operand
Definition: complex.h:135
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: complex.h:480
ComplexUnitaryExp< calctype, OP, SrcExp, DType,(e1|type::kMapper)> ComplexF(const Exp< SrcExp, DType, e1 > &src)
conj Negation the imaginary part of A where A is a complex tensor
Definition: complex.h:174
static MSHADOW_XINLINE DType RealMap(const expr::Plan< TA, DType > &src_, index_t real_i, index_t real_j, index_t imag_i, index_t imag_j)
Definition: complex.h:88
ComplexUnitaryExp< op::complex::kUnitaryR2C, op::complex::pad_imag, SrcExp, DType,(e1|type::kMapper)> complex_pad_imag(const Exp< SrcExp, DType, e1 > &src)
complex_pad_imag Transform real matrix into complex matrix
Definition: complex.h:270
static MSHADOW_XINLINE DType ImagMap(const expr::Plan< TA, DType > &src_, index_t real_i, index_t real_j)
Definition: complex.h:79
Definition: complex.h:17
static Shape< dim > Check(const ComplexBinaryMapExp< calctype, OP, TA, TB, DType, etype > &t)
Definition: complex.h:309
Definition: complex.h:15
BinaryCalculationType
Definition: complex.h:15
Definition: complex.h:105
const TA & lhs_
left operand
Definition: complex.h:133
ComplexBinaryMapExp< op::complex::kBinaryCC, op::complex::mul, TA, TB, DType,(ta|tb|type::kMapper)> complex_mul_cc(const Exp< TA, DType, ta > &lhs, const Exp< TB, DType, tb > &rhs)
complex_mul_cc Complex multipilication two complex tensors, A * B
Definition: complex.h:184
ComplexUnitaryExp< op::complex::kUnitaryC2C, op::complex::conjugate, SrcExp, DType,(e1|type::kMapper)> conj(const Exp< SrcExp, DType, e1 > &src)
conj Negation the imaginary part of A where A is a complex tensor
Definition: complex.h:246
#define MSHADOW_XINLINE
Definition: base.h:204
static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...
Definition: expr_engine-inl.h:244
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: complex.h:419
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: complex.h:441
const TA & src_
source expression
Definition: complex.h:153
int32_t index_t
type that will be used for index
Definition: base.h:291
static Shape< dim > Check(const ComplexUnitaryExp< calctype, OP, TA, DType, etype > &t)
Definition: complex.h:345
static MSHADOW_XINLINE DType RealMap(const expr::Plan< TA, DType > &src_, index_t real_i, index_t real_j)
Definition: complex.h:74
Definition: complex.h:16
ComplexBinaryMapExp< op::complex::kBinaryCC, op::complex::div, TA, TB, DType,(ta|tb|type::kMapper)> complex_div_cc(const Exp< TA, DType, ta > &lhs, const Exp< TB, DType, tb > &rhs)
complex_mul_cc Complex multipilication two complex tensors, A * B
Definition: complex.h:214
static MSHADOW_XINLINE DType RealMap(DType a_real, DType a_imag, DType b_real, DType b_imag)
map a_real, a_imag, b_real, b_imag to result using defined operation
Definition: complex.h:20
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: complex.h:459
Definition: complex.h:16
Definition: complex.h:72
Plan(const Plan< TA, DType > &lhs, const Plan< TB, DType > &rhs)
Definition: complex.h:417
index_t shape_[kDimension]
storing the dimension information
Definition: tensor.h:57
runtime shape checking template get the shape of an expression, report error if shape mismatch ...
Definition: expr_engine-inl.h:346
static MSHADOW_XINLINE DType RealMap(const expr::Plan< TA, DType > &src_, index_t real_i, index_t real_j, index_t imag_i, index_t imag_j)
Definition: complex.h:47
static MSHADOW_XINLINE DType RealMap(const expr::Plan< TA, DType > &src_, index_t real_i, index_t real_j, index_t imag_i, index_t imag_j)
Definition: complex.h:97
ComplexUnitaryExp< op::complex::kUnitaryC2C, op::complex::exchange, SrcExp, DType,(e1|type::kMapper)> complex_exchange(const Exp< SrcExp, DType, e1 > &src)
complex_exchange Exchange the real and imaginary part of A where A is a complex tensor ...
Definition: complex.h:258
static MSHADOW_XINLINE DType ImagMap(DType a_real, DType a_imag, DType b_real, DType b_imag)
Definition: complex.h:39
Plan(const Plan< TA, DType > &lhs, const Plan< TB, DType > &rhs)
Definition: complex.h:372
ComplexBinaryMapExp< op::complex::kBinaryCR, op::complex::mul, TA, TB, DType,(ta|tb|type::kMapper)> complex_mul_cr(const Exp< TA, DType, ta > &lhs, const Exp< TB, DType, tb > &rhs)
complex_mul_cr Complex multipilication a complex tensor A and a real tensor B
Definition: complex.h:194
Plan(const Plan< TA, DType > &lhs, const Plan< TB, DType > &rhs)
Definition: complex.h:394
Definition: complex.h:86
ComplexBinaryMapExp(const TA &lhs, const TB &rhs)
constructor
Definition: complex.h:137
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:61
ComplexUnitaryExp< op::complex::kUnitaryC2R, op::complex::sum_real_imag, SrcExp, DType,(e1|type::kMapper)> complex_sum_real_imag(const Exp< SrcExp, DType, e1 > &src)
Definition: complex.h:301
const SubType & self(void) const
Definition: expression.h:64
static MSHADOW_XINLINE DType ImagMap(DType a_real, DType a_imag, DType b_real, DType b_imag)
Definition: complex.h:25
ComplexUnitaryExp< op::complex::kUnitaryC2R, op::complex::toreal, SrcExp, DType,(e1|type::kMapper)> complex_toreal(const Exp< SrcExp, DType, e1 > &src)
complex_toreal convert complex matrix to real matrix, keep only real part
Definition: complex.h:282
Definition: complex.h:45
namespace for mshadow
Definition: base.h:282
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: complex.h:396
Definition: complex.h:58
Definition: complex.h:16
static MSHADOW_XINLINE DType RealMap(const expr::Plan< TA, DType > &src_, index_t real_i, index_t real_j, index_t imag_i, index_t imag_j)
Definition: complex.h:60
ComplexBinaryMapExp< op::complex::kBinaryRC, op::complex::div, TA, TB, DType,(ta|tb|type::kMapper)> complex_div_rc(const Exp< TA, DType, ta > &lhs, const Exp< TB, DType, tb > &rhs)
complex_mul_rc Complex multipilication of a real tensor A and a complex tensor B
Definition: complex.h:234
Definition: complex.h:95
compute conj(src) where src is a complex tensor
Definition: complex.h:150
Definition: complex.h:31
ComplexBinaryMapExp< op::complex::kBinaryCR, op::complex::div, TA, TB, DType,(ta|tb|type::kMapper)> complex_div_cr(const Exp< TA, DType, ta > &lhs, const Exp< TB, DType, tb > &rhs)
complex_mul_cr Complex multipilication a complex tensor A and a real tensor B
Definition: complex.h:224
binary map expression lhs [op] rhs where lhs and rhs are complex tensors
Definition: complex.h:130