Vector
This class simply represent a vector and provides basic linear algebra routines. If MPI is available the vector is distributed across all processes, otherwise not. In the case of shared memory (MPI has not been found), routines are parallelized using openMP if possible.
Note
The syntax is equivalent for all cases.
The class is mainly used by the ShellMatrix to make matrix-free multiplication possible.
Here is a brief example of some features:
/* Defining the type */
using Vector=danceq::internal::Vector<double>;
/* Initializing two vectors with are random values */
Vector A(10);
Vector B(10);
A.make_random();
B.make_random();
std::cout << "A: " << A << std::endl;
std::cout << "A[0] = " << A[0] << " || B[0] = " << B[0] << std::endl;
/* Vectors can be added */
auto C = A + B;
std::cout << "C[0] = " << C[0] << std::endl;
/* Vector can be scaled */
auto D = 2. * A;
std::cout << "D[0] = " << D[0] << std::endl;
/* Vector can be scaled */
auto scalar = A*A;
std::cout << "scalar = " << scalar << std::endl;
The vector class can interact with Petsc if included:
/* Defining the type */
using Vector=danceq::internal::Vector<double>;
/* Some Operator Hamiltonian H */
Hamiltonian_U1 H(L,n);
/* Retrieve Petsc Mat from H */
Mat H_mat = H.create_PetscSparseMatrix();
/* Retrieve Vector class from H_Mat */
Vector V_from_mat(H_mat);
Operators that are a Lindbladian OperatorType act on the space density matrices which are represented with this Vector class. In this case, the class allows you to directly extract the density matrix via: get_density_matrix(…) and get_density_matrix_in_eigen(…).