.. _Functions:

#########
Functions
#########

We collect different Functions that are **not** part of any class. 
They belong to the name space ``danceq::``.

Lanczos
-------

This function uses the `Lanczos algorithm <https://en.wikipedia.org/wiki/Lanczos_algorithm>`_ to compute the ground state and excitations using the **matrix-free** multiplication provided by :ref:`ShellMatrix class<ShellMatrix>`.
It is compatible with :ref:`MPI<MPI_docs>` and :ref:`openMP<openMP_docs>`.

.. _Functions_lanczos:

.. doxygenfunction:: lanczos(const Op& H, uint64_t number_of_states = 1, std::vector<danceq::internal::Vector<typename Op::scalartype>>* states = nullptr, uint32_t seed = -1, double overhead_in_GB_per_core = 4., double conv = 1e-11, uint64_t iter_max = 500, bool quiet = false)


Basic functions
---------------


The other functions are generic and used by different classes.


.. _Functions_is_complex:

.. doxygenfunction:: is_complex(void)

.. _Functions_get_mpi_type:

.. doxygenfunction:: get_mpi_type(void)

.. _Functions_uniform_dist_mpi:

.. doxygenfunction:: uniform_dist_mpi(T dim)

Petsc functions
---------------

The following functions are only available if :ref:`Petsc<Petsc_setup>` is included.


.. _Functions_von_Neumann_entropy_from_PetscVec:

.. doxygenfunction:: von_Neumann_entropy_from_PetscVec(const Vec& vec, const int32_t root = 0)

.. doxygenfunction:: get_density_matrix_in_eigen_from_PetscVec(const Vec& vec, const int32_t root = 0)

.. doxygenfunction:: get_dim_from_PetscVec(const Vec& v)

.. doxygenfunction:: get_ownership_per_rank_PetscVec(const Vec& v)

.. doxygenfunction:: get_dim_from_PetscMat(const Mat& mat)

.. doxygenfunction:: get_ownership_per_rank_PetscMat(const Mat& mat)