35template <
typename _Scalar>
62 Base(dim, dim, dim, dim) {}
74 auto dims = this->dimensions();
75 if ((dims[0] != dims[1]) || (dims[1] != dims[2]) || (dims[2] != dims[3])) {
76 throw std::invalid_argument(
"SquareRankFourTensor(Eigen::TensorBase<OtherDerived, AccessLevel>): The given tensor should have equal dimensions in every rank.");
89 template <
typename ExpDerived,
int AccessLevel>
109 std::ifstream file {filename};
110 if (file.is_open()) {
112 while (std::getline(file, line)) {
113 std::vector<std::string> splitted_line;
116 boost::split(splitted_line, line, boost::is_any_of(
" \t"), boost::token_compress_on);
118 if (splitted_line.size() != 5) {
119 throw std::runtime_error(
"SquareRankFourTensor::FromFile(std::string, size_t): Found a line that doesn't contain exactly 5 fields delimited by whitespace.");
122 auto i = std::stoi(splitted_line[0]);
123 auto j = std::stoi(splitted_line[1]);
124 auto k = std::stoi(splitted_line[2]);
125 auto l = std::stoi(splitted_line[3]);
126 auto value = std::stod(splitted_line[4]);
128 result(i, j, k, l) = value;
133 throw std::runtime_error(
"SquareRankFourTensor::FromFile(std::string, size_t): Cannot open the given file. Maybe you specified a wrong path?");
168 for (
size_t i = 0; i < dim; i++) {
169 for (
size_t j = 0; j < dim; j++) {
170 for (
size_t k = 0; k < dim; k++) {
171 for (
size_t l = 0; l < dim; l++) {
172 T(i, j, k, l) = 2 * T(i, j, k, l) - 1;
193 template <
typename ExpDerived,
int AccessLevel>
195 this->Base::operator=(exp);
204 using Base::dimension;
225 size_t row_index = 0;
226 for (
size_t j = 0; j < K; j++) {
227 for (
size_t i = j + 1; i < K; i++) {
230 size_t column_index = 0;
231 for (
size_t l = 0; l < K; l++) {
232 for (
size_t k = l + 1; k < K; k++) {
235 M(row_index, column_index) = this->operator()(i, j, k, l);
Definition: SquareMatrix.hpp:39
static Self Zero(const size_t dim)
Definition: SquareMatrix.hpp:289
Definition: SquareRankFourTensor.hpp:36
SquareMatrix< double > pairWiseStrictReduced() const
Definition: SquareRankFourTensor.hpp:218
static Self FromFile(const std::string &filename, size_t dim)
Definition: SquareRankFourTensor.hpp:104
Self & operator=(const Eigen::TensorBase< ExpDerived, AccessLevel > &exp)
Definition: SquareRankFourTensor.hpp:194
static Self Random(const size_t dim)
Definition: SquareRankFourTensor.hpp:162
SquareRankFourTensor()
Definition: SquareRankFourTensor.hpp:52
SquareRankFourTensor(const Eigen::TensorBase< ExpDerived, AccessLevel > &exp)
Definition: SquareRankFourTensor.hpp:90
size_t dimension() const
Definition: SquareRankFourTensor.hpp:209
SquareRankFourTensor(const size_t dim)
Definition: SquareRankFourTensor.hpp:61
static Self Zero(const size_t dim)
Definition: SquareRankFourTensor.hpp:147
_Scalar Scalar
Definition: SquareRankFourTensor.hpp:38
SquareRankFourTensor(const Base &tensor)
Definition: SquareRankFourTensor.hpp:70
Definition: Tensor.hpp:46
Definition: BaseOneElectronIntegralBuffer.hpp:25