/
Sparse_HTST.hpp
60 lines (51 loc) · 2 KB
/
Sparse_HTST.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#ifndef SPARSE_HTST_H
#define SPARSE_HTST_H
#ifndef SPIRIT_SKIP_HTST
#include "Spirit_Defines.h"
#include <iostream>
#include <fstream>
#include <data/Spin_System.hpp>
#include <data/Spin_System_Chain.hpp>
#include <engine/Vectormath_Defines.hpp>
namespace Engine
{
namespace Sparse_HTST
{
// A small function for debugging purposes
inline void saveMatrix(std::string fname, const SpMatrixX & matrix)
{
std::cout << "Saving matrix to file: " << fname << "\n";
std::ofstream file(fname);
if(file && file.is_open())
{
file << matrix;
} else {
std::cerr << "Could not save matrix!";
}
}
template<typename Field_Like>
inline void saveField(std::string fname, const Field_Like & field)
{
int n = field.size();
std::cout << "Saving field to file: " << fname << "\n";
std::ofstream file(fname);
if(file && file.is_open())
{
for(int i=0; i<n; i++)
file << field[i] << "\n";
} else {
std::cerr << "Could not save field!";
}
}
// Note the two images should correspond to one minimum and one saddle point
void Calculate(Data::HTST_Info & htst_info);
// Calculate the sparse Velocity matrix
void Sparse_Calculate_Dynamical_Matrix(const vectorfield & spins, const scalarfield & mu_s, const SpMatrixX & hessian, SpMatrixX & velocity);
void Sparse_Geodesic_Eigen_Decomposition(const vectorfield & image, const vectorfield & gradient, const SpMatrixX & hessian,
SpMatrixX & hessian_geodesic_3N, SpMatrixX & hessian_geodesic_2N, SpMatrixX & tangent_basis, VectorX & eigenvalues, MatrixX & eigenvectors);
void sparse_hessian_bordered_3N(const vectorfield & image, const vectorfield & gradient, const SpMatrixX & hessian, SpMatrixX & hessian_out);
};
}
#endif
#endif