11                      const double mean, 
const double dev) {
 
   12  int N = (
Li+1) * (
Li+1);
 
   13  field = MatrixXcd::Zero(N, num_col);
 
   14  std::random_device rnd;
 
   15  std::normal_distribution<> gauss(mean, dev);
 
   16  for (
int i = 0; i < N; ++i) {
 
   17    for (
int j = 0; j < num_col; ++j) {
 
   18      field(i, j) = std::complex<double>(gauss(rnd), gauss(rnd));
 
 
   28                        const double mean, 
const double dev) {
 
   29  int N = (
Li+1) * (
Li+1);
 
   30  field = MatrixXcd::Zero(N, num_col);
 
   31  std::random_device rnd;
 
   32  std::mt19937_64 mt(rnd());
 
   33  std::normal_distribution<> gauss(mean, dev);
 
   34  for (
int i = 0; i < N; ++i) {
 
   35    for (
int j = 0; j < num_col; ++j) {
 
   36      field(i, j) = std::complex<double>(gauss(mt), gauss(mt));
 
 
   47                     const double mean, 
const double dev) {
 
   49    if (
Li < 1 || 
num_f < 1 || num_col < 1)
 
   50      throw "ERROR<Field::setconf> Some parameters are not positive.";
 
   61      field = MatrixXcd::Zero( (
Li+1)*(
Li+1), num_col );
 
   63  } 
catch (
const char *str) {cerr << str << endl;
 
   65    field = MatrixXcd::Zero( (
Li+1)*(
Li+1), 1);}
 
 
   71  Li = (int)sqrt(N) - 1;
 
   73    if (N != (
Li+1)*(
Li+1))
 
   74      throw "ERROR<Field::setconf> Mismatched size of VectorXcd.";
 
   76    for (
int i = 0; i < N; ++i) {
field(i, 0) = v(i);}
 
   77  } 
catch (
const char *str) {
 
   79    ++
Li; 
int Nnew = (
Li+1)*(
Li+1);
 
   80    field = MatrixXcd::Zero(Nnew, 1);
 
   81    for (
int i = 0; i < N; ++i) {
field(i, 0) = v(i);}
 
 
   86  int Ntotal = v.size();
 
   87  int Nunit  = int(Ntotal / 
num_f);
 
   88  int N      = int(Nunit / 2);
 
   89  Li = (int)sqrt(N) - 1;
 
   90  MatrixXcd m(N, 
num_f);
 
   91  for (
int j = 0; j < 
num_f; ++j) {
 
   93    for (
int i = 0; i < N; ++i) {
 
   94      m(i, j) = v(tmp + i) + 
IM * v(tmp + i + N);
 
   98    if (N != (
Li+1)*(
Li+1))
 
   99      throw "ERROR<Field::setconf> Mismatched size of VectorXd.";
 
  101  } 
catch (
const char *str) {
 
  103    ++
Li; 
int Nnew = (
Li+1)*(
Li+1);
 
 
  111  Li = (int)sqrt(N) - 1;
 
  113    if (N != (
Li+1)*(
Li+1))
 
  114      throw "ERROR<Field::Field> Mismatched size of MatrixXcd.";
 
  116  } 
catch (
const char *str) {
 
  118    ++
Li; 
int Nnew = (
Li+1)*(
Li+1);
 
 
  125  int num_col = m.cols();
 
  127  Li = (int)sqrt(N) - 1;
 
  129    if (N != (
Li+1)*(
Li+1))
 
  130      throw "ERROR<Field::Field> Mismatched size of MatrixXcd.";
 
  132  } 
catch (
const char *str) {
 
  134    ++
Li; 
int Nnew = (
Li+1)*(
Li+1);
 
  135    field = MatrixXcd::Zero(Nnew, num_col);
 
  136    field.block(0,0, N,num_col) = m;
 
 
  143    if (n < 0 || n >= 
num_f)
 
  144      throw "ERROR<Field::vector2matrix> Column number is not in [0, num_f).";
 
  146    for (
int i = 0; i < L; ++i) {
 
  147      for (
int j = 0; j < L; ++j) {
 
  148        M(i, j) = 
field(L * i + j, n);
 
  152  } 
catch (
const char *str) {cerr << str << endl; 
return MatrixXcd::Zero(L, L);}
 
 
  155  int N = (
Li+1) * (
Li+1);
 
  157    if (n < 0 || n >= 
field.cols())
 
  158      throw "ERROR<Field::field2matrix> Column number is out of range.";
 
  160      throw "ERROR<Field::field2matrix> Size of VectorXcd is not ODD.";
 
  162    MatrixXcd M = MatrixXcd::Zero(N, N);
 
  163    for (
int i = 0; i < N; ++i) {
 
  164      for (
int j = 0; j < N; ++j) {
 
  165        int ind_0 = L/2 + i/L - j/L;
 
  166        int ind_1 = L/2 + i%L - j%L;
 
  167        if (0 <= ind_0 && ind_0 < L && 0 <= ind_1 && ind_1 < L) {
 
  168          M(i, j) = 
field(L*ind_0 + ind_1, n);
 
  173  } 
catch (
const char *str) {cerr << str << endl; 
return MatrixXcd::Zero(N, N);}
 
 
  176  int N = (
Li+1) * (
Li+1);
 
  178    if (n < 0 || n >= 
field.cols())
 
  179      throw "ERROR<Field::dfield2matrix> Column number is out of range.";
 
  181      throw "ERROR<Field::dfield2matrix> Size of VectorXcd is not ODD.";
 
  182    VectorXcd v = 
conf(n);
 
  183    return v * v.transpose().reverse() / v(N/2);
 
  184  } 
catch (
const char *str) {cerr << str << endl; 
return MatrixXcd::Zero(N, N);}
 
 
  189    int num_col = 
field.cols();
 
  190    if (n1 < 0 || n1 >= num_col || n2 < 0 || n2 >= num_col)
 
  191      throw "ERROR<Field::conv> Column numbers are out of range.";
 
  192    int N = (
Li+1) * (
Li+1);
 
  194      throw "ERROR<Field::conv> Size of VectorXcd is not ODD.";
 
  197    cnv = mat * 
field.col(n2) / double(
Li * 
Li);
 
  199  } 
catch (
const char *str) {cerr << str << endl; 
return Field::Zero(
Li, 1);}
 
 
  203    int num_col = 
field.cols();
 
  204    if (n < 0 || n >= num_col)
 
  205      throw "ERROR<Field::conjconv> Column number is out of range.";
 
  206    int N = (
Li+1) * (
Li+1);
 
  208      throw "ERROR<Field::conjconv> Size of VectorXcd is not ODD.";
 
  210    VectorXcd frev = 
conf(n).conjugate().reverse();
 
  211    for (
int i = 0; i < N; ++i) {
 
  212      m(i, 0) = 
field(i, n);
 
  217  } 
catch (
const char *str) {cerr << str << endl; 
return Field::Zero(
Li, 1);}
 
 
  221    int num_col = 
field.cols();
 
  223    if (n < 0 || n >= num_col)
 
  224      throw "ERROR<Field::conv_pw> Column number is out of range.";
 
  225    int N = (
Li+1) * (
Li+1);
 
  227      throw "ERROR<Field::conv_pw> Size of VectorXcd is not ODD.";
 
  229      throw "ERROR<Field::conv_pw> Number of convolutions is negative.";
 
  232      int N = (
Li+1) * (
Li+1);
 
  233      VectorXcd v = VectorXcd::Zero(N); v(N/2) = 
Li * 
Li;
 
  235    } 
else if (pw == 1) {
 
  237    } 
else if (pw == 2) { 
return conv(n, n); }
 
  242    Mp = MatrixXcd::Identity(N, N);
 
  243    for (
int i = 0; i < pw-2; ++i) { Mp = M * Mp; }
 
  245    for (
int i = 0; i < pw-1; ++i) { Ln *= 
Li * 
Li; }
 
  247    cnv = M * Mp * 
field.col(n) / Ln;
 
  249  } 
catch (
const char *str) {cerr << str << endl; 
return Field::Zero(
Li, 1);}
 
 
  254    if (
field.rows()==0) {*
this = f; 
return *
this;}
 
  256      throw "ERROR<Field::combine_with> Sizes of Fields are not same .";
 
  257    int num_col1 = 
field.cols();
 
  258    int num_col2 = f.
field.cols();
 
  259    int num_col_total = num_col1 + num_col2;
 
  260    int N = 
field.rows();
 
  261    MatrixXcd m(N, num_col_total);
 
  262    m.block(0,0,        N, num_col1) = 
field;
 
  263    m.block(0,num_col1, N, num_col2) = f.
field;
 
  266  catch (
const char *str) {cerr << str << endl; 
return *
this;}
 
 
  270  cout << 
"# class Field" << endl
 
  271       << 
"Li     = " << 
Li << endl
 
  272       << 
"field = " << endl
 
 
Generate normal distributions; Compute convolutions.
Field conjconv(const int n) const
Convolution field(:,n)*conf(field(:,n))
MatrixXcd field
Superfields.
void setgaussl(const int num_col, const double mean=0.0)
MatrixXcd field2matrix(const int n) const
void setgauss(const int num_col, const double mean=0.0, const double dev=1.0)
void setgaussmtl(const int num_col, const double mean=0.0)
Field combine_with(const Field &f)
Combine with another Field object; Mutate field (Li and num_f are unchaged) except for the case that ...
void setconf(const int num_col, const Distribution n, const double mean=0.0, const double dev=1.0)
int Li
Physical box size, N_0=N_1.
MatrixXcd dfield2matrix(const int n) const
Field conv(const int n1, const int n2) const
Convolution field(:,n1)*field(:,n2)
Field conv_pw(const int pw, const int n=0) const
Convolution field(:,n)*field(:,n)*...*field(:,n)
int num_f
Number of superfields.
virtual void show() const
Output Li, field.
void setgaussmt(const int num_col, const double mean=0.0, const double dev=1.0)
static Field Zero(const int n1, const int n2)
MatrixXcd vector2matrix(const int n) const
Definition of the class Field.
const std::complex< double > IM(0, 1.0)
Imaginary unit.
Distribution
Types of normal distributions.