File: testLanczos.cpp

package info (click to toggle)
dmrgpp 6.06-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 113,900 kB
  • sloc: cpp: 80,986; perl: 14,772; ansic: 2,923; makefile: 83; sh: 17
file content (39 lines) | stat: -rw-r--r-- 957 bytes parent folder | download
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
#include "CrsMatrix.h"
#include "LanczosSolver.h"
#include "Matrix.h"
#include "PsimagLite.h"

int main()
{
	typedef std::complex<double> ComplexType;
	typedef PsimagLite::ParametersForSolver<double> SolverParametersType;
	typedef PsimagLite::Vector<ComplexType>::Type VectorType;

	int n = 8;
	PsimagLite::Matrix<ComplexType> m(n, n);
	// fill m
	for (int i = 0; i < n; ++i)
		m(i, i) = 1.0;
	m(1, 2) = ComplexType(0.0, 0.5);
	m(2, 1) = PsimagLite::conj(m(1, 2));
	m(3, 5) = m(5, 3) = -1.5;

	PsimagLite::CrsMatrix<ComplexType> msparse(m);

	SolverParametersType params;
	params.lotaMemory = true;

	PsimagLite::LanczosSolver<SolverParametersType,
	    PsimagLite::CrsMatrix<ComplexType>,
	    VectorType>
	    lanczosSolver(msparse, params);

	double e = 0;
	VectorType z(n, 0.0);
	VectorType initial(n);
	PsimagLite::fillRandom(initial);
	lanczosSolver.computeOneState(e, z, initial, 0);

	std::cout << "energy=" << e << "\n";
	std::cout << z << "\n";
}