https://github.com/cometscome/rscg_cpp
The Reduced-Shifted Conjugate-Gradient Method method to calculate the element of the Green's function matrix. See, Y. Nagai, Y. Shinohara, Y. Futamura, and T. Sakurai,[arXiv:1607.03992v2 or DOI:10.7566/JPSJ.86.014708]. http://dx.doi.org/10.7566/JPSJ.86.014708
https://github.com/cometscome/rscg_cpp
Last synced: over 1 year ago
JSON representation
The Reduced-Shifted Conjugate-Gradient Method method to calculate the element of the Green's function matrix. See, Y. Nagai, Y. Shinohara, Y. Futamura, and T. Sakurai,[arXiv:1607.03992v2 or DOI:10.7566/JPSJ.86.014708]. http://dx.doi.org/10.7566/JPSJ.86.014708
- Host: GitHub
- URL: https://github.com/cometscome/rscg_cpp
- Owner: cometscome
- Created: 2019-05-23T09:10:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-02T11:39:00.000Z (about 7 years ago)
- Last Synced: 2025-01-21T10:08:28.199Z (over 1 year ago)
- Language: C++
- Size: 70.3 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RSCG_cpp
This is made for c++11.
This package can calculate the elements of the Green's function:
```math
G_ij(σk) = ([σj I - A]^-1)_{ij},
```
with the use of the reduced-shifted conjugate gradient method
(See, Y. Nagai, Y. Shinohara, Y. Futamura, and T. Sakurai,[arXiv:1607.03992v2 or DOI:10.7566/JPSJ.86.014708]).
One can obtain ``G_{ij}(\sigma_k)`` with different frequencies ``\sigma_k``, simultaneously.
The matrix should be symmetric or hermitian.
This is to understand the method.
I do not guarantee result with the use of this code.
```c++
#include
#include
#include
#include
#include "rscg.cpp"
using namespace std;
template
vector matmul(const std::array,N> &H, vector &x){
vector Ax(N);
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
Ax[i] += H[i][j]*x[j];
};
};
return Ax;
};
int main() {
std::array, 3> H{ {
{ 1, 0, 3 },
{ 0, 2, 0 },
{ 3, 0, 5 }
} };
vector x(3,1.0);
auto f = std::bind(matmul<3>,H,std::placeholders::_1);
RSCG* rscg;
rscg = new RSCG(3,f);
vector > vec_z(2,0.2);
vec_z[0] = 0.2*1i;
vec_z[1] = 4.0 + 0.5*1i;
cout << vec_z[0] << std::endl;
vector > Gij = rscg->calc_greenfunction_realH(0,0,vec_z);
cout << "RSCG" << Gij[0] << " exact: 1.12377 - 0.383299 I" << std::endl;
cout << "RSCG" << Gij[1] << " exact: 0.0844022 - 0.0339264 I" <