Skip to content

Commit

Permalink
Extended documentation with MPS example.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpp977 committed Jun 15, 2023
1 parent 73124e1 commit ccf926a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ If the intel math kernel library should be integrated, one can switch on the par

## Cyclops tensor framework (ctf)

[ctf](https://ctf.org) is a tensor framework for distributed parallelism.
[ctf](https://solomon2.web.engr.illinois.edu/ctf/) is a tensor framework for distributed parallelism.
This allows the computations to spread over several different compute cores and allows to use the hardware more efficient.
It has an overhead for small tensors but allows to scale the compute power with very large tensors.

Expand Down
33 changes: 33 additions & 0 deletions docs/snippets/s_mps.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "Xped/MPS/Mps.hpp"
#include "Xped/MPS/MpsAlgebra.hpp"

int main()
{
// Alias for the symmetry
using Symmetry = Xped::Sym::SU2<Xped::Sym::SpinSU2>;

// Number of sites in the MPS
std::size_t L = 100;

// Amount of quantum number blocks
std::size_t Qinit = 10;

// Amount of basis states per quantum number block
std::size_t Minit = 100;

// Target quantum number of the MPS
Symmetry::qType Qtarget = Symmetry::qvacuum();

// local (physical) basis of the MPS. In this case one spin 1/2
Xped::Qbasis<Symmetry, /*depth=*/1> qloc;
qloc.push_back({2}, 1);

// Contruct the MPS (with random entries)
Xped::Mps<double, Symmetry> Psi(L, qloc, Qtot, Minit, Qinit);

// Compute the norm
auto norm = Xped::dot(Psi, Psi);

// Sweep from left to put all A-tensors into right-canonical form
for(std::size_t l = 0; l < L; ++l) { Psi.rightSweepStep(l, Xped::DMRG::BROOM::SVD); }
}

0 comments on commit ccf926a

Please sign in to comment.