QUDA  1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
max_clover.cu
Go to the documentation of this file.
1 #include <clover_field_order.h>
2 
3 namespace quda {
4 
5  using namespace clover;
6 
7  enum norm_type_ {
12  };
13 
14  template<typename real, int Nc, QudaCloverFieldOrder order>
15  double norm(const CloverField &u, norm_type_ type) {
16  constexpr int Ns = 4;
17  typedef typename mapper<real>::type reg_type;
18  double norm_ = 0.0;
19  switch(type) {
20  case NORM1: norm_ = FieldOrder<reg_type,Nc,Ns,order>(const_cast<CloverField &>(u)).norm1(); break;
21  case NORM2: norm_ = FieldOrder<reg_type,Nc,Ns,order>(const_cast<CloverField &>(u)).norm2(); break;
22  case ABS_MAX: norm_ = FieldOrder<reg_type,Nc,Ns,order>(const_cast<CloverField &>(u)).abs_max(); break;
23  case ABS_MIN: norm_ = FieldOrder<reg_type,Nc,Ns,order>(const_cast<CloverField &>(u)).abs_min(); break;
24  }
25  return norm_;
26  }
27 
28  template<typename real, int Nc>
29  double norm(const CloverField &u, norm_type_ type) {
30  double norm_ = 0.0;
31  switch (u.Order()) {
32  case QUDA_FLOAT2_CLOVER_ORDER: norm_ = norm<real,Nc,QUDA_FLOAT2_CLOVER_ORDER>(u, type); break;
33  case QUDA_FLOAT4_CLOVER_ORDER: norm_ = norm<real,Nc,QUDA_FLOAT4_CLOVER_ORDER>(u, type); break;
34  default: errorQuda("Clover field %d order not supported", u.Order());
35  }
36  return norm_;
37  }
38 
39  template<typename real>
40  double _norm(const CloverField &u, norm_type_ type) {
41  double norm_ = 0.0;
42  switch(u.Ncolor()) {
43  case 3: norm_ = norm<real, 3>(u, type); break;
44  default: errorQuda("Unsupported color %d", u.Ncolor());
45  }
46  return norm_;
47  }
48 
49  double CloverField::norm1() const {
50  double nrm1 = 0.0;
51  switch(precision) {
52  case QUDA_DOUBLE_PRECISION: nrm1 = _norm<double>(*this, NORM1); break;
53  case QUDA_SINGLE_PRECISION: nrm1 = _norm< float>(*this, NORM1); break;
54  default: errorQuda("Unsupported precision %d", precision);
55  }
56  return nrm1;
57  }
58 
59  double CloverField::norm2() const {
60  double nrm2 = 0.0;
61  switch(precision) {
62  case QUDA_DOUBLE_PRECISION: nrm2 = _norm<double>(*this, NORM2); break;
63  case QUDA_SINGLE_PRECISION: nrm2 = _norm< float>(*this, NORM2); break;
64  default: errorQuda("Unsupported precision %d", precision);
65  }
66  return nrm2;
67  }
68 
69  double CloverField::abs_max() const {
70  double max = 0.0;
71  switch(precision) {
72  case QUDA_DOUBLE_PRECISION: max = _norm<double>(*this, ABS_MAX); break;
73  case QUDA_SINGLE_PRECISION: max = _norm< float>(*this, ABS_MAX); break;
74  default: errorQuda("Unsupported precision %d", precision);
75  }
76  return max;
77  }
78 
79  double CloverField::abs_min() const {
80  double min = 0.0;
81  switch(precision) {
82  case QUDA_DOUBLE_PRECISION: min = _norm<double>(*this, ABS_MIN); break;
83  case QUDA_SINGLE_PRECISION: min = _norm< float>(*this, ABS_MIN); break;
84  default: errorQuda("Unsupported precision %d", precision);
85  }
86  return min;
87  }
88 
89 } // namespace quda
norm_type_
Definition: max_clover.cu:7
__host__ __device__ ValueType norm(const complex< ValueType > &z)
Returns the magnitude of z squared.
#define errorQuda(...)
Definition: util_quda.h:121
double norm2() const
Compute the L2 norm squared of the field.
Definition: max_clover.cu:59
QudaCloverFieldOrder Order() const
Definition: clover_field.h:93
Main header file for host and device accessors to CloverFields.
int Ncolor() const
Definition: clover_field.h:108
__host__ double abs_max(int dim=-1, bool global=true) const
Returns the Linfinity norm of the field.
__host__ double norm2(int dim=-1, bool global=true) const
Returns the L2 norm suared of the field.
__host__ double norm1(int dim=-1, bool global=true) const
Returns the L1 norm of the field.
double _norm(const CloverField &u, norm_type_ type)
Definition: max_clover.cu:40
double abs_min() const
Compute the absolute minimum of the field.
Definition: max_clover.cu:79
double norm1() const
Compute the L1 norm of the field.
Definition: max_clover.cu:49
__host__ double abs_min(int dim=-1, bool global=true) const
Returns the minimum absolute value of the field.
double abs_max() const
Compute the absolute maximum of the field (Linfinity norm)
Definition: max_clover.cu:69