eigenvectors.size() gives the number of eigenvectors that were calculated, not the size of one. To print the size, print e.g. eigenvectors[0].size(). I hope this helps.
Matthias
Sent from my iPad
On Sep 2, 2010, at 4:51, rexlundgren@mail.utexas.edu wrote:
Hello,
Sorry to ask another question so soon. I am trying to print out the =20 groundstate eigenvector to study entanglement by modifying the =20 sparsediag program. I put a simple For loop in the sparsediag.h file =20 as shown below,
template <class T> void SparseDiagMatrix<T>::do_subspace() { typedef ietl::vectorspace<vector_type> vectorspace_type; boost::lagged_fibonacci607 generator; mag_vector_type ev; this->build(); if (this->dimension()=3D=3D0) return;
vectorspace_type vec(this->dimension()); ietl::lanczos<matrix_type,vectorspace_type> lanczos(this->matrix(),vec); int n;
if (this->dimension()>1) { int max_iter =3D =20 this->parms.value_or_default("MAX_ITERATIONS",std::min(int(10*this->dimensio= n()),1000)); int num_eigenvalues =3D =20 this->parms.value_or_default("NUMBER_EIGENVALUES",1); ietl::lanczos_iteration_nlowest<double> iter(max_iter,num_eigenvalues); std::cerr << "Starting Lanczos \n"; lanczos.calculate_eigenvalues(iter,generator); std::cerr << "Finished Lanczos\n"; n=3Dstd::min(num_eigenvalues,int(lanczos.eigenvalues().size())); ev.resize(n); for (int i=3D0;i<n;++i) ev[i]=3Dlanczos.eigenvalues()[i]; } else { ev.resize(1); ev[0]=3Dalps::real(value_type(this->matrix()(0,0))); } if (this->calc_averages()) { if (this->dimension()>1) { // calculate eigen vectors ietl::Info<magnitude_type> info; // (m1, m2, ma, eigenvalue, =20 residualm, status).
try { eigenvectors.clear(); =20
lanczos.eigenvectors(lanczos.eigenvalues().begin(),lanczos.eigenvalues().beg= in()+n, std::back_inserter(eigenvectors),info,generato= r);
=09=09 //code to print eigenvectors =09=09 for (int i=3D0;i<eigenvectors.size();++i) =09=09 { =09=09=09 std::cout << eigenvectors[i] << "\n";
=09=09 }
} catch (std::runtime_error& e) { std::cout <<"Exception during eigenvector calculation: " << =20
e.what() << "\n";
} }
=09 else { vector_type v(1); v[0]=3D1.; eigenvectors.push_back(v);
}
}
this->perform_measurements(); eigenvectors.clear(); =20 std::copy(ev.begin(),ev.end(),std::back_inserter(this->measurements_.rbegin(= )->average_values["Energy"])); this->eigenvalues_.push_back(ev);
}
the following output is given for a 4 site spin 1/2 chain with J=3D1,
Starting task 1. Quantumnumber Sz going from -2 to 2 with increment 1 Starting Lanczos Finished Lanczos [2]((-0.57735,0),(0.816497,0)) Starting Lanczos Finished Lanczos [2]((1.11022e-16,-8.65927e-17),(1,-4.98226e-17))
The problem is these numbers don't make sense at all, and when I try =20 to get the size of the eigenvector with eigenvector.size() it gives 1. =20 Any help or hints would be gratefully appreciated. Also any help or =20 hints about my other question about combining print_numeric and =20 sparsediag to get the ground state vector would be much appreciated.
Thanks