HILA
Loading...
Searching...
No Matches
wilson_vector.h
1#ifndef WILSON_VECTOR_H
2#define WILSON_VECTOR_H
3
4#include "datatypes/cmplx.h"
5#include "datatypes/matrix.h"
6#include "datatypes/sun.h"
8#include "plumbing/random.h"
9#include "datatypes/compoundvector.h"
10
11#if (NDIM == 5 || NDIM == 4)
12#define Gammadim 4
13#define NGamma 5
14enum class GammaMatrix : int { g0 = 0, g1, g2, g3, g5 };
15
16constexpr GammaMatrix gamma0 = GammaMatrix::g0;
17constexpr GammaMatrix gamma1 = GammaMatrix::g1;
18constexpr GammaMatrix gamma2 = GammaMatrix::g2;
19constexpr GammaMatrix gamma3 = GammaMatrix::g3;
20constexpr GammaMatrix gamma5 = GammaMatrix::g5;
21
22// List order of directions for conveniance
23GammaMatrix gamma_matrix[5] = {gamma1, gamma2, gamma3, gamma0, gamma5};
24
25#elif (NDIM == 3 || NDIM == 2)
26#define Gammadim 2
27#define NGamma 3
28enum class GammaMatrix : unsigned { g0 = 0, g1, g2 };
29
30constexpr GammaMatrix gamma0 = GammaMatrix::g0;
31constexpr GammaMatrix gamma1 = GammaMatrix::g1;
32constexpr GammaMatrix gamma2 = GammaMatrix::g2;
33
34// List order of directions for conveniance
35GammaMatrix gamma_matrix[3] = {gamma0, gamma1, gamma2};
36
37#else
38static_assert(false, "Wilson fermions only implemented for 1 < NDIM < 6");
39#endif
40
41
42/// Wilson_vector contains the data for a single pseudofermion with the
43/// Wilson action. For each gamma dimension, contains a SU(N) vector.
44/// Wilson fermions can be multiplied by the gamma matrices gamma0, gamma1
45/// ... gamma5 (or up to gamma 2 for 2 and 3 dimensions).
46///
47/// A gamma matrix can also be projected to a half_Wilson_vector using the
48/// constructor half_Wilson_vector(wilson_vector, dir, sign). This multiplies
49/// the vector with 0.5*(1-sign*gamma_dir), leaving half the degrees of freedom.
50/// A full Wilson vector can be recovered using half_Wilson_vector::grow.
51///
52/// use type WilsonVector_t, which can be used to define WilsonVector
53/// and HalfWilsonVector -types
54
55
56template <int Nvectors, int N, typename T>
58
59 public:
60 using base_type = T;
62
63 Vector<N, Complex<T>> c[Nvectors];
64
65 WilsonVector_t() = default;
66 WilsonVector_t(const WilsonVector_t &m) = default;
67 ~WilsonVector_t() = default;
68
69 // construct from 0
70 WilsonVector_t(std::nullptr_t n) out_only {
71 for (int i = 0; i < Nvectors; i++)
72 c[i] = 0;
73 }
74
75 // and different type WilsonVector
76 template <typename A>
78 for (int i = 0; i < Nvectors; i++) {
79 c[i] = m.c[i];
80 }
81 }
82
83 // Define constant methods rows(), columns() - may be useful in template code
84 static constexpr int rows() const {
85 return N * Nvectors;
86 }
87 static constexpr int columns() const {
88 return 1;
89 }
90
91 /// unary -
92 inline WilsonVector_t operator-() const {
94 for (int i = 0; i < Nvectors; i++) {
95 res.c[i] = -c[i];
96 }
97 return res;
98 }
99
100 /// unary +
101 inline const WilsonVector_t &operator+() const {
102 return *this;
103 }
104
105 /// assign from 0
106 inline WilsonVector_t &operator=(const std::nullptr_t &z) out_only {
107 for (int i = 0; i < Nvectors; i++) {
108 c[i] = 0;
109 }
110 return *this;
111 }
112
113 /// Assign from WilsonVector
114 template <typename S>
116 for (int i = 0; i < Nvectors; i++) {
117 c[i] = rhs.c[i];
118 }
119 return *this;
120 }
121
122 /// Add assign from Wvec
123 template <typename S>
125 for (int i = 0; i < Nvectors; i++) {
126 c[i] += rhs.c[i];
127 }
128 return *this;
129 }
130
131 /// Sub assign from Wvec
132 template <typename S>
134 for (int i = 0; i < Nvectors; i++) {
135 c[i] -= rhs.c[i];
136 }
137 return *this;
138 }
139
140 /// Mul assign by scalar
141 template <typename S, std::enable_if_t<hila::is_complex_or_arithmetic<S>::value> = 0>
142 inline WilsonVector_t &operator*=(const S rhs) {
143 for (int i = 0; i < Nvectors; i++) {
144 c[i] *= rhs;
145 }
146 return *this;
147 }
148
149 /// Div assign by scalar
150 template <typename S, std::enable_if_t<hila::is_complex_or_arithmetic<S>::value> = 0>
151 inline WilsonVector_t &operator/=(const S rhs) {
152 for (int i = 0; i < Nvectors; i++) {
153 c[i] /= rhs;
154 }
155 return *this;
156 }
157
158 /// fill method
159 template <typename S, std::enable_if_t<hila::is_complex_or_arithmetic<S>::value> = 0>
160 inline WilsonVector_t &fill(const S rhs) out_only {
161 for (int i = 0; i < Nvectors; i++) {
162 c[i].fill(S);
163 }
164 return *this;
165 }
166
167 /// cast to Array
168 inline Array<N * Nvectors, 1, T> &asArray() const_function {
169 return *reinterpret_cast<Array<N * Nvectors, 1, T> *>(this);
170 }
171 const Array<N * Nvectors, 1, T> &asArray() const {
172 return *reinterpret_cast<const Array<N * Nvectors, 1, T> *>(this);
173 }
174
175 // do we need dagger?
176 // /// dagger() casts WilsonVector to WilsonVector_dagger type
177 // inline const WilsonVector_dagger<N,T> &dagger() const {
178 // return *reinterpret_cast<const WilsonVector_dagger<N,T> *>(this);
179 // }
180
181 /// complex conjugate
182 inline WilsonVector_t conj() const {
183 WilsonVector_t res;
184 for (int i = 0; i < Nvectors; i++) {
185 res.c[i] = c[i].conj();
186 }
187 return res;
188 }
189
190 // /// transpose = conj() + dagger()
191 // inline const WilsonVector_dagger<N,T> & transpose() const {
192 // return (this->conj()).dagger();
193 // }
194
195 /// gaussian random
196 void gaussian_random(T width = 1.0) {
197 for (int i = 0; i < Nvectors; i++) {
198 c[i].gaussian_random(width);
199 }
200 }
201
202 /// norms
203 inline T squarenorm() const {
204 T r = 0;
205 for (int i = 0; i < Nvectors; i++) {
206 r += c[i].squarenorm();
207 }
208 return r;
209 }
210
211 inline T norm() const {
212 return sqrt(this->squarenorm());
213 }
214
215 // dot is this.dagger() * (rhs)
216 template <typename S>
217 inline auto dot(const Wilson_vector_t<Nvectors, N, S> &rhs) const {
218 auto r = c[0].dot(rhs.c[0]);
219 for (int i = 1; i < Nvectors; i++) {
220 r += c[i].dot(rhs.c[i]);
221 }
222 return r;
223 }
224
225 /// Returns a square matrix, cast into the Matrix<N,N,Complex<T>> -type,
226 /// which is the sum of the outer products of the colour vectors
227 /// in this Wilson vector and the argument
228 template <typename S>
229 inline auto outer_product(const Wilson_vector_t<Nvectors, N, S> &rhs) const {
230 auto r = c[0].outer_product(rhs.c[0]);
231 for (int i = 1; i < Nvectors; i++) {
232 r += c[i].outer_product(rhs.c[i]);
233 }
234 return r;
235 }
236
237 std::string str() const {
238 std::string text = "";
239 for (int i = 0; i < Nvectors; i++) {
240 text += c[i].str() + "\n";
241 }
242 text += "\n";
243 return text;
244 }
245};
246
247
248/// Define WilsonVector and HalfWilsonVector as aliases
249template <int N, typename T>
251
252template <int N, typename T>
253using HalfWilsonVector = WilsonVector_t<Gammadim / 2, N, T>;
254
255
256/// lhs * Wvec = Wvec
257/// Multiplying with a matrix should multiply each element, not the gamma-
258/// dimension. Last template parameter finds only types which can be multiplied
259/// (we'll keep Wvec type nevertheless)
260template <int Nv, int N, typename T, typename M, typename R = hila::type_mul<M, T>>
261inline WilsonVector_t<Nv, N, T> operator*(const T &lhs, WilsonVector_t<Nv, N, T> rhs) {
262 for (int i = 0; i < Nv; i++) {
263 rhs.c[i] = lhs * rhs.c[i];
264 }
265 return rhs;
266}
267
268/// Mult with a scalar from right
269template <int Nv, int N, typename T, typename M,
270 std::enable_if_t<hila::is_complex_or_arithmetic<M>::value, int> = 0>
271inline WilsonVector_t<Nv, N, T> operator*(const WilsonVector_t<Nv, N, T> lhs, const M rhs) {
272 lhs *= rhs;
273 return lhs;
274}
275
276/// Div by scalar
277template <int Nv, int N, typename T, typename M,
278 std::enable_if_t<hila::is_complex_or_arithmetic<M>::value, int> = 0>
279inline WilsonVector_t<Nv, N, T> operator/(const WilsonVector_t<Nv, N, T> lhs, const M rhs) {
280 lhs /= rhs;
281 return lhs;
282}
283
284/// add 2 wvects
285template <int Nv, int N, typename T, typename M, typename R = hila::type_plus<T, M>>
286inline WilsonVector_t<Nv, N, R> operator+(const WilsonVector_t<Nv, N, T> &lhs,
287 const WilsonVector_t<Nv, N, M> &rhs) {
289 for (int i = 0; i < Nv; i++) {
290 r.c[i] = lhs.c[i] + rhs.c[i];
291 }
292 return r;
293}
294
295/// sub wvects
296template <int Nv, int N, typename T, typename M, typename R = hila::type_minus<T, M>>
297inline WilsonVector_t<Nv, N, R> operator-(const WilsonVector_t<Nv, N, T> &lhs,
298 const WilsonVector_t<Nv, N, M> &rhs) {
300 for (int i = 0; i < Nv; i++) {
301 r.c[i] = lhs.c[i] - rhs.c[i];
302 }
303 return r;
304}
305
306
307/// Multiplication with gamma matrices
308
309#if (Gammadim == 4)
310
311template <int N, typename T>
312WilsonVector<N, T> operator*(const GammaMatrix gamma, const WilsonVector<N, T> &rhs) {
314 switch (gamma) {
315 case gamma0:
316 r.c[0] = rhs.c[2];
317 r.c[1] = rhs.c[3];
318 r.c[2] = rhs.c[0];
319 r.c[3] = rhs.c[1];
320 break;
321 case gamma1:
322 r.c[0] = I * rhs.c[3];
323 r.c[1] = I * rhs.c[2];
324 r.c[2] = -I * rhs.c[1];
325 r.c[3] = -I * rhs.c[0];
326 break;
327 case gamma2:
328 r.c[0] = -rhs.c[3];
329 r.c[1] = rhs.c[2];
330 r.c[2] = rhs.c[1];
331 r.c[3] = -rhs.c[0];
332 break;
333 case gamma3:
334 r.c[0] = I * rhs.c[2];
335 r.c[1] = -I * rhs.c[3];
336 r.c[2] = -I * rhs.c[0];
337 r.c[3] = I * rhs.c[1];
338 break;
339 case gamma5:
340 r.c[0] = rhs.c[0];
341 r.c[1] = rhs.c[1];
342 r.c[2] = -rhs.c[2];
343 r.c[3] = -rhs.c[3];
344 break;
345 }
346 return r;
347}
348
349#elif (Gammadim == 2)
350
351template <int N, typename T>
352WilsonVector<N, T> operator*(const GammaMatrix gamma, const WilsonVector<N, T> &rhs) {
354 switch (gamma) {
355 case gamma0:
356 r.c[0] = rhs.c[1];
357 r.c[1] = rhs.c[0];
358 break;
359 case gamma1:
360 r.c[0] = Complex<T>(0, -1) * rhs.c[1];
361 r.c[1] = Complex<T>(0, 1) * rhs.c[0];
362 break;
363 case gamma2:
364 r.c[0] = rhs.c[0];
365 r.c[1] = -rhs.c[1];
366 break;
367 }
368 return r;
369}
370
371#endif
372
373///////////////////////////////////////////////////////////////////////////////////
374/// half_Wilson_vector is a Wilson vector projected by
375/// 1 +- gamma_j and contains half the degrees of freedom
376///
377/// (1 +- gamma_j) is a projection operator. We will apply the projection
378/// to a Wilson_vector and store the result in a half_Wilson_vector. This
379/// will store all necessary information in half the amount of data
380/// and reduce the effort of multiplying with gauge matrices by half.
381///
382/// The constructor half_Wilson_vector(Wilson_vector<n, radix> w, Direction d)
383/// will take the projection automatically. A positive Direction d corresponds
384/// to 1+gamma_j and a negative Direction d corresponds to 1-gamma_j.
385///
386/// A half_Wilson_vector can be expanded to a full Wilson_vector using the
387/// method expand(Direction d). Notice that this requires knowing the Direction
388/// that was used to project it. The Direction is not stored.
389///
390/// Note that the eigenvectors below are normalized to sqrt(2), or |v*v| = 2.
391/// This is why we don't explicitly multiply by 2 when expanding to full
392/// Wilson_vector.
393///
394/// gamma(XUP) eigenvectors eigenvalue
395/// 0 0 0 i ( 1, 0, 0,-i) +1
396/// 0 0 i 0 ( 0, 1,-i, 0) +1
397/// 0 -i 0 0 ( 1, 0, 0,+i) -1
398/// -i 0 0 0 ( 0, 1,+i, 0) -1
399///
400/// gamma(YUP) eigenvectors eigenvalue
401/// 0 0 0 -1 ( 1, 0, 0,-1) +1
402/// 0 0 1 0 ( 0, 1, 1, 0) +1
403/// 0 1 0 0 ( 1, 0, 0, 1) -1
404/// -1 0 0 0 ( 0, 1,-1, 0) -1
405///
406/// gamma(ZUP) eigenvectors eigenvalue
407/// 0 0 i 0 ( 1, 0,-i, 0) +1
408/// 0 0 0 -i ( 0, 1, 0,+i) +1
409/// -i 0 0 0 ( 1, 0,+i, 0) -1
410/// 0 i 0 0 ( 0, 1, 0,-i) -1
411///
412/// gamma(TUP) eigenvectors eigenvalue
413/// 0 0 1 0 ( 1, 0, 1, 0) +1
414/// 0 0 0 1 ( 0, 1, 0, 1) +1
415/// 1 0 0 0 ( 1, 0,-1, 0) -1
416/// 0 1 0 0 ( 0, 1, 0,-1) -1
417///
418/// gamma(FIVE) eigenvectors eigenvalue
419/// 1 0 0 0 sq2( 1, 0, 0, 0) +1
420/// 0 1 0 0 sq2( 0, 1, 0, 0) +1
421/// 0 0 -1 0 sq2( 0, 0, 1, 0) -1
422/// 0 0 0 -1 sq2( 0, 0, 0, 1) -1
423//////////////////////////////////////////////////////////////////////////////////
424
425template <int N, typename T>
427 public:
428 using base_type = T;
430
431 Vector<N, Complex<T>> c[Gammadim / 2];
432
433 HalfWilsonVector() = default;
434 HalfWilsonVector(const HalfWilsonVector &v) = default;
435 ~HalfWilsonVector() = default;
436
437 // This will take the projection 1 +- gamma_j
438#if (Gammadim == 4)
440 switch (dir) {
441 case e_x:
442 if (sign == 1) {
443 c[0] = w.c[0] + I * w.c[3];
444 c[1] = w.c[1] + I * w.c[2];
445 } else {
446 c[0] = w.c[0] - I * w.c[3];
447 c[1] = w.c[1] - I * w.c[2];
448 }
449 break;
450 case e_y:
451 if (sign == 1) {
452 c[0] = w.c[0] - w.c[3];
453 c[1] = w.c[1] + w.c[2];
454 } else {
455 c[0] = w.c[0] + w.c[3];
456 c[1] = w.c[1] - w.c[2];
457 }
458 break;
459 case e_z:
460 if (sign == 1) {
461 c[0] = w.c[0] + I * w.c[2];
462 c[1] = w.c[1] - I * w.c[3];
463 } else {
464 c[0] = w.c[0] - I * w.c[2];
465 c[1] = w.c[1] + I * w.c[3];
466 }
467 break;
468 case e_t:
469 if (sign == 1) {
470 c[0] = w.c[0] + w.c[2];
471 c[1] = w.c[1] + w.c[3];
472 } else {
473 c[0] = w.c[0] - w.c[2];
474 c[1] = w.c[1] - w.c[3];
475 }
476 break;
477#if NDIM == 5
478 case 4:
479 if (sign == 1) {
480 c[0] = sqrt(2.0) * w.c[0];
481 c[1] = sqrt(2.0) * w.c[1];
482 } else {
483 c[0] = sqrt(2.0) * w.c[2];
484 c[1] = sqrt(2.0) * w.c[3];
485 }
486 break;
487#endif
488 default:
489 assert(false && "ERROR: Half Wilson vector projection called incorrectly \n");
490 }
491 }
492
493 WilsonVector<N, T> expand(Direction dir, int sign) const {
495 switch (dir) {
496 case e_x:
497 if (sign == 1) {
498 r.c[0] = c[0];
499 r.c[1] = c[1];
500 r.c[2] = -I * c[1];
501 r.c[3] = -I * c[0];
502 } else {
503 r.c[0] = c[0];
504 r.c[1] = c[1];
505 r.c[2] = I * c[1];
506 r.c[3] = I * c[0];
507 }
508 break;
509 case e_y:
510 if (sign == 1) {
511 r.c[0] = c[0];
512 r.c[1] = c[1];
513 r.c[2] = c[1];
514 r.c[3] = -c[0];
515 } else {
516 r.c[0] = c[0];
517 r.c[1] = c[1];
518 r.c[2] = -c[1];
519 r.c[3] = c[0];
520 }
521 break;
522 case e_z:
523 if (sign == 1) {
524 r.c[0] = c[0];
525 r.c[1] = c[1];
526 r.c[2] = -I * c[0];
527 r.c[3] = I * c[1];
528 } else {
529 r.c[0] = c[0];
530 r.c[1] = c[1];
531 r.c[2] = I * c[0];
532 r.c[3] = -I * c[1];
533 }
534 break;
535 case e_t:
536 if (sign == 1) {
537 r.c[0] = c[0];
538 r.c[1] = c[1];
539 r.c[2] = c[0];
540 r.c[3] = c[1];
541 } else {
542 r.c[0] = c[0];
543 r.c[1] = c[1];
544 r.c[2] = -c[0];
545 r.c[3] = -c[1];
546 }
547 break;
548#if NDIM == 5
549 case 4:
550 if (sign == 1) {
551 r.c[0] = sqrt(2.0) * c[0];
552 r.c[1] = sqrt(2.0) * c[1];
553 r.c[2] = 0;
554 r.c[3] = 0;
555 } else {
556 r.c[0] = 0;
557 r.c[1] = 0;
558 r.c[2] = sqrt(2.0) * c[0];
559 r.c[3] = sqrt(2.0) * c[1];
560 }
561 break;
562#endif
563 default:
564 assert(false && "ERROR: Half Wilson vector projection called incorrectly \n");
565 }
566 return r;
567 }
568
569#elif (Gammadim == 2)
570 /*
571 gamma(e_x) eigenvectors eigenvalue
572 0 1 ( 1, 1) +1
573 1 0 ( 1,-1) -1
574
575 gamma(e_y) eigenvectors eigenvalue
576 0 i ( 1, i) +1
577 -i 0 ( 1,-i) -1
578
579 gamma(e_z) eigenvectors eigenvalue
580 1 0 ( 1, 0) +1
581 0 -1 ( 0, 1) -1
582 */
584 Complex<T> I(0, 1);
585 switch (dir) {
586 case e_x:
587 if (sign == 1) {
588 c[0] = w.c[0] + w.c[1];
589 } else {
590 c[0] = w.c[0] - w.c[1];
591 }
592 break;
593 case e_y:
594 if (sign == 1) {
595 c[0] = w.c[0] - I * w.c[1];
596 } else {
597 c[0] = w.c[0] + I * w.c[1];
598 }
599 break;
600#if NDIM == 3
601 case e_z:
602 if (sign == 1) {
603 c[0] = sqrt(2.0) * w.c[0];
604 } else {
605 c[0] = sqrt(2.0) * w.c[1];
606 }
607 break;
608#endif
609 default:
610 assert(false && "ERROR: Half Wilson vector projection called incorrectly \n");
611 }
612
613 WilsonVector<N, T> expand(Direction dir, int sign) const {
615 Complex<T> I(0, 1);
616 switch (dir) {
617 case e_x:
618 if (sign == 1) {
619 r.c[0] = c[0];
620 r.c[1] = c[0];
621 } else {
622 r.c[0] = c[0];
623 r.c[1] = -c[0];
624 }
625 break;
626 case e_y:
627 if (sign == 1) {
628 r.c[0] = c[0];
629 r.c[1] = I * c[0];
630 } else {
631 r.c[0] = c[0];
632 r.c[1] = -I * c[0];
633 }
634 break;
635#if NDIM == 3
636 case e_z:
637 if (sign == 1) {
638 r.c[0] = sqrt(2.0) * c[0];
639 r.c[1] = 0;
640 } else {
641 r.c[0] = 0;
642 r.c[1] = sqrt(2.0) * c[0];
643 }
644 break;
645#endif
646 default:
647 assert(false && "ERROR: Half Wilson vector projection called incorrectly \n");
648 }
649 return r;
650 }
651
652#endif
653
654 /// Returns the norm squared of (1+-gamma_j) * wilson_vector.
655 /// Thus the factor 2.
656 inline T squarenorm() {
657 T r = 0;
658 for (int i = 0; i < Gammadim / 2; i++) {
659 r += c[i].squarenorm();
660 }
661 return r;
662 }
663
664 HalfWilsonVector &operator+=(const HalfWilsonVector &rhs) {
665 for (int i = 0; i < Gammadim / 2; i++) {
666 c[i] += rhs.c[i];
667 }
668 return *this;
669 }
670
671 HalfWilsonVector &operator-=(const HalfWilsonVector &rhs) {
672 for (int i = 0; i < Gammadim / 2; i++) {
673 c[i] -= rhs.c[i];
674 }
675 return *this;
676 }
677
678 HalfWilsonVector operator-() const {
680 for (int i = 0; i < Gammadim / 2; i++) {
681 r.c[i] = -c[i];
682 }
683 return r;
684 }
685
686 std::string str() const {
687 std::string text = "";
688 for (int i = 0; i < Gammadim / 2; i++) {
689 text += c[i].str() + "\n";
690 }
691 text += "\n";
692 return text;
693 }
694};
695
696template <int N, typename S, typename T>
697HalfWilsonVector<N, T> operator*(const S lhs, HalfWilsonVector<N, T> rhs) {
698 for (int i = 0; i < Gammadim / 2; i++) {
699 rhs.c[i] *= lhs;
700 }
701 return rhs;
702}
703
704template <int N, typename T, typename S>
705HalfWilsonVector<N, T> operator*(HalfWilsonVector<N, T> lhs, const S rhs) {
706 for (int i = 0; i < Gammadim / 2; i++) {
707 lhs.c[i] *= rhs;
708 }
709 return lhs;
710}
711
712template <int N, typename T, typename S>
713HalfWilsonVector<N, T> operator/(HalfWilsonVector<N, T> lhs, const S rhs) {
714 for (int i = 0; i < Gammadim / 2; i++) {
715 lhs.c[i] /= rhs;
716 }
717 return lhs;
718}
719
720
721template <int N, typename T, typename P, typename R = hila::type_plus<T, P>>
723 const HalfWilsonVector<N, P> &rhs) {
725 for (int i = 0; i < Gammadim / 2; i++) {
726 r.c[i] = lhs.c[i] + rhs.c[i];
727 }
728 return r;
729}
730
731template <int N, typename T, typename P, typename R = hila::type_plus<T, P>>
733 const HalfWilsonVector<N, P> &rhs) {
735 for (int i = 0; i < Gammadim / 2; i++) {
736 r.c[i] = lhs.c[i] - rhs.c[i];
737 }
738 return r;
739}
740
741
742#endif
Array type
Definition array.h:43
Complex definition.
Definition cmplx.h:50
const Mtype & fill(const S rhs)
Matrix fill.
Definition matrix.h:980
Mtype & gaussian_random(double width=1.0)
Fills Matrix with gaussian random elements from gaussian distribution.
Definition matrix.h:1352
Mtype conj() const
Returns complex conjugate of Matrix.
Definition matrix.h:1036
Matrix< n, p, R > outer_product(const Matrix< p, q, S > &rhs) const
Outer product.
Definition matrix.h:1294
T c[n *m]
The data as a one dimensional array.
Definition matrix.h:106
R dot(const Matrix< p, q, S > &rhs) const
Dot product.
Definition matrix.h:1251
std::string str(int prec=8, char separator=' ') const
Definition matrix.h:1646
hila::arithmetic_type< T > squarenorm() const
Calculate square norm - sum of squared elements.
Definition matrix.h:1167
Matrix class which defines matrix operations.
Definition matrix.h:1679
void gaussian_random(T width=1.0)
gaussian random
const WilsonVector_t & operator+() const
unary +
auto outer_product(const Wilson_vector_t< Nvectors, N, S > &rhs) const
WilsonVector_t conj() const
complex conjugate
WilsonVector_t & fill(const S rhs)
fill method
WilsonVector_t & operator*=(const S rhs)
Mul assign by scalar.
T squarenorm() const
norms
Array< N *Nvectors, 1, T > & asArray()
cast to Array
WilsonVector_t & operator-=(const WilsonVector_t< Nvectors, N, S > &rhs)
Sub assign from Wvec.
WilsonVector_t & operator+=(const WilsonVector_t< Nvectors, N, S > &rhs)
Add assign from Wvec.
WilsonVector_t & operator=(const std::nullptr_t &z)
assign from 0
WilsonVector_t operator-() const
unary -
WilsonVector_t & operator=(const WilsonVector_t< Nvectors, N, S > &rhs)
Assign from WilsonVector.
WilsonVector_t & operator/=(const S rhs)
Div assign by scalar.
Definition of Complex types.
constexpr Imaginary_t< double > I(1.0)
Imaginary unit I - global variable.
This header file defines:
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
Definition coordinates.h:34
Definition of Matrix types.