mptensor v0.4.0
Parallel Library for Tensor Network Methods
Loading...
Searching...
No Matches
functions.hpp
Go to the documentation of this file.
1/*
2 mptensor - Parallel Library for Tensor Network Methods
3
4 Copyright 2016 Satoshi Morita
5
6 mptensor is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation, either version 3 of the
9 License, or (at your option) any later version.
10
11 mptensor is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with mptensor. If not, see
18 <https://www.gnu.org/licenses/>.
19*/
20
28#ifndef _FUNCTIONS_HPP_
29#define _FUNCTIONS_HPP_
30
31#include <cmath>
32
33#include <mptensor/mptensor.hpp>
34
36using mptensor::Index;
37using mptensor::Shape;
38
39namespace tests {
42
43/* Example of matrix element */
44inline double func2_1(Index idx, Shape shape) {
45 double x0 = double(idx[0]) / double(shape[0]);
46 double x1 = double(idx[1]) / double(shape[1]);
47 return 1.0 / (1.0 + std::abs(x0 - std::sqrt(x1)));
48}
49
50inline complex cfunc2_1(Index idx, Shape shape) {
51 double x0 = double(idx[0]) / double(shape[0]);
52 double x1 = double(idx[1]) / double(shape[1]);
53 return 1.0 / (1.0 + complex(x0, std::sqrt(x1)));
54}
55
56inline double func4_1(Index idx, Shape shape) {
57 double x0 = double(idx[0]) / double(shape[0]);
58 double x1 = double(idx[1]) / double(shape[1]);
59 double x2 = double(idx[2]) / double(shape[2]);
60 double x3 = double(idx[3]) / double(shape[3]);
61 return (x0 + x1) / (1.0 + std::abs(x2 - x3));
62}
63
64inline double func4_2(Index idx, Shape shape) {
65 double x0 = double(idx[0]) / double(shape[0]);
66 double x1 = double(idx[1]) / double(shape[1]);
67 double x2 = double(idx[2]) / double(shape[2]);
68 double x3 = double(idx[3]) / double(shape[3]);
69 return std::cos(x0 * x3) + std::sin(x1 / (x2 + 1.0));
70}
71
72inline complex cfunc4_1(Index idx, Shape shape) {
73 double x0 = double(idx[0]) / double(shape[0]);
74 double x1 = double(idx[1]) / double(shape[1]);
75 double x2 = double(idx[2]) / double(shape[2]);
76 double x3 = double(idx[3]) / double(shape[3]);
77 return complex(x0, x1) / complex(1.0 + x2, -x3);
78}
79
80inline complex cfunc4_2(Index idx, Shape shape) {
81 double x0 = double(idx[0]) / double(shape[0]);
82 double x1 = double(idx[1]) / double(shape[1]);
83 double x2 = double(idx[2]) / double(shape[2]);
84 double x3 = double(idx[3]) / double(shape[3]);
85 return complex(std::cos(x0 * x3), std::sin(x1 / (x2 + 1.0)));
86}
88
89} // namespace tests
90
91#endif // _FUNCTIONS_HPP_
Definition index.hpp:39
std::complex< double > complex
Definition complex.hpp:38
Top header file of mptensor.
Test codes for Tensor.
Definition arithmetic.cc:42
complex cfunc4_1(Index idx, Shape shape)
Definition functions.hpp:72
double func2_1(Index idx, Shape shape)
Definition functions.hpp:44
double func4_2(Index idx, Shape shape)
Definition functions.hpp:64
complex cfunc2_1(Index idx, Shape shape)
Definition functions.hpp:50
double func4_1(Index idx, Shape shape)
Definition functions.hpp:56
complex cfunc4_2(Index idx, Shape shape)
Definition functions.hpp:80