Skip to content

Commit

Permalink
scale MPS
Browse files Browse the repository at this point in the history
  • Loading branch information
hczhai committed Sep 25, 2024
1 parent ce6d196 commit 74d18d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/dmrg/mps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,12 @@ template <typename S, typename FL> struct MPS {
for (int i = 0; i < n_sites; i++)
random_canonicalize_tensor(i);
}
virtual void iscale(FL d) {
load_tensor(center);
tensors[center]->iscale(d);
save_tensor(center);
unload_tensor(center);
}
virtual void set_inact_ext_identity(int n_inactive, int n_external) {
for (int i = 0; i < n_inactive; i++)
if (tensors[i] != nullptr && i < center) {
Expand Down
1 change: 1 addition & 0 deletions src/pybind/pybind_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ template <typename S, typename FL> void bind_fl_sparse(py::module &m) {
py::arg("length"))
.def("trace", &SparseMatrix<S, FL>::trace)
.def("norm", &SparseMatrix<S, FL>::norm)
.def("iscale", &SparseMatrix<S, FL>::iscale)
.def("conjugate", &SparseMatrix<S, FL>::conjugate)
.def("__getitem__",
[](SparseMatrix<S, FL> *self, int idx) { return (*self)[idx]; })
Expand Down
1 change: 1 addition & 0 deletions src/pybind/pybind_dmrg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ template <typename S, typename FL> void bind_fl_mps(py::module &m) {
.def("canonicalize", &MPS<S, FL>::canonicalize)
.def("dynamic_canonicalize", &MPS<S, FL>::dynamic_canonicalize)
.def("random_canonicalize", &MPS<S, FL>::random_canonicalize)
.def("iscale", &MPS<S, FL>::iscale)
.def("set_inact_ext_identity", &MPS<S, FL>::set_inact_ext_identity)
.def("from_singlet_embedding_wfn",
&MPS<S, FL>::from_singlet_embedding_wfn, py::arg("cg"),
Expand Down

0 comments on commit 74d18d2

Please sign in to comment.