# \#cpp

**URL:** https://itensor.discourse.group/tag/cpp/2.md

[Latest](https://itensor.discourse.group/latest.md) · [Categories](https://itensor.discourse.group/categories.md) · [Tags](https://itensor.discourse.group/tags.md)

---

## [Memory error (bad\_alloc) with MPS/density matrix](https://itensor.discourse.group/t/memory-error-bad-alloc-with-mps-density-matrix/2499)

<div class="topic-metadata">

**Author:** [@DavideBianchin4](https://itensor.discourse.group/u/DavideBianchin4)\
**Replies:** 0\
**Last updated:** [September 22, 2025, 3:23pm UTC](https://itensor.discourse.group/t/memory-error-bad-alloc-with-mps-density-matrix/2499 "2025-09-22T15:23:25Z")

</div>

Hello all, I’m working on a Guassian Boson Sampling setup from scratch, where I apply beam splitter 2-mode gates to an MPS state, and calculate the density matrix at the end to make local measurements. I am following th…

---

## [Swap-gate, SVD applied to MPS](https://itensor.discourse.group/t/swap-gate-svd-applied-to-mps/2489)

<div class="topic-metadata">

**Author:** [@DavideBianchin4](https://itensor.discourse.group/u/DavideBianchin4)\
**Replies:** 0\
**Last updated:** [September 8, 2025, 12:28pm UTC](https://itensor.discourse.group/t/swap-gate-svd-applied-to-mps/2489 "2025-09-08T12:28:57Z")

</div>

Hello, I am building an MPS alternating physical sites with “virtual” ancillary sites (vacuum modes); the goal is to simulate Beam Splitter interactions between physical modes in a Gaussian Boson Sampling scheme, where …

---

## [Two-site gate to MPS](https://itensor.discourse.group/t/two-site-gate-to-mps/2484)

<div class="topic-metadata">

**Author:** [@DavideBianchin4](https://itensor.discourse.group/u/DavideBianchin4)\
**Replies:** 1\
**Last updated:** [September 3, 2025, 1:52pm UTC](https://itensor.discourse.group/t/two-site-gate-to-mps/2484 "2025-09-03T13:52:45Z")

</div>

Hello! I’ll start by saying I’ve never worked with MPS or ITensor before, and I’m doing so for my bachelor’s thesis now, so excuse my ignorance. I am following the official ITensor C++ documentation for applying a two-…

---

## [eltC function generates wrong answer when calculating inner product](https://itensor.discourse.group/t/eltc-function-generates-wrong-answer-when-calculating-inner-product/2176)

<div class="topic-metadata">

**Author:** [@StrongCC](https://itensor.discourse.group/u/StrongCC)\
**Replies:** 2\
**Last updated:** [December 19, 2024, 7:43am UTC](https://itensor.discourse.group/t/eltc-function-generates-wrong-answer-when-calculating-inner-product/2176 "2024-12-19T07:43:17Z")

</div>

Hello, I wonder why the eltC function and the innerC function generate the different results of the norm of the wave function. tJ sitesold; readFromFile("sites\_file",sitesold); MPS psi(sitesold); …

---

## [How to use AutoMPO with a matrix prefactor?](https://itensor.discourse.group/t/how-to-use-autompo-with-a-matrix-prefactor/1971)

<div class="topic-metadata">

**Author:** [@zomal](https://itensor.discourse.group/u/zomal)\
**Replies:** 6\
**Last updated:** [September 19, 2024, 2:04am UTC](https://itensor.discourse.group/t/how-to-use-autompo-with-a-matrix-prefactor/1971 "2024-09-19T02:04:01Z")

</div>

Hi, I want to add a term into my mpo using the AutoMPO function, and the term is a matrix multiplied by a S=\\frac{1}{2} operator. Specifically, in my code I include it as: for (int j=1;j\<N;j++){ mpo += matrix,"Sx",j; …

---

## [Is there a sample function in c++ version?](https://itensor.discourse.group/t/is-there-a-sample-function-in-c-version/1927)

<div class="topic-metadata">

**Author:** [@cbdag](https://itensor.discourse.group/u/cbdag)\
**Replies:** 5\
**Last updated:** [August 30, 2024, 6:05pm UTC](https://itensor.discourse.group/t/is-there-a-sample-function-in-c-version/1927 "2024-08-30T18:05:55Z")

</div>

Hi, a quick search in c++ documentation did not help: is there an MPS sampling function in c++ like in julia the “sample” command? Thanks for the information! Ceren.

---

## [Discrepancy in Calculating Correlation Function Using iTensor TDVP](https://itensor.discourse.group/t/discrepancy-in-calculating-correlation-function-using-itensor-tdvp/1705)

<div class="topic-metadata">

**Author:** [@subhajyoti.pal](https://itensor.discourse.group/u/subhajyoti.pal)\
**Replies:** 2\
**Last updated:** [June 9, 2024, 6:45am UTC](https://itensor.discourse.group/t/discrepancy-in-calculating-correlation-function-using-itensor-tdvp/1705 "2024-06-09T06:45:18Z")

</div>

Hi, I have been utilizing the iTensor C++ version for the past three months, working on solving a t-J model with next-nearest-neighbor interaction. Specifically, the Hamiltonian I am dealing with is given by: H = \\sum\_…

---

## [Measure an operator that is a product of many local operators?](https://itensor.discourse.group/t/measure-an-operator-that-is-a-product-of-many-local-operators/1718)

<div class="topic-metadata">

**Author:** [@sysy](https://itensor.discourse.group/u/sysy)\
**Replies:** 1\
**Last updated:** [May 16, 2024, 7:41am UTC](https://itensor.discourse.group/t/measure-an-operator-that-is-a-product-of-many-local-operators/1718 "2024-05-16T07:41:45Z")

</div>

Dear itensor: I want to measure the following operator: \\prod\_{m=1}^{N\_o}{\\left( c\_{m,1}^{\\dagger}c\_{m,2}+c\_{m,2}^{\\dagger}c\_{m,1} \\right)} the operator c^\\dagger,c represents the spinless fermion creation or annihi…

---

## [how to obtain more than one eigen energy of local MPO during sweep?](https://itensor.discourse.group/t/how-to-obtain-more-than-one-eigen-energy-of-local-mpo-during-sweep/1589)

<div class="topic-metadata">

**Author:** [@sysy](https://itensor.discourse.group/u/sysy)\
**Replies:** 4\
**Last updated:** [April 1, 2024, 2:52am UTC](https://itensor.discourse.group/t/how-to-obtain-more-than-one-eigen-energy-of-local-mpo-during-sweep/1589 "2024-04-01T02:52:13Z")

</div>

Dear itensor: ITensor/itensor/mps/dmrg.h at 98fc7022eb812fe68640e662f4051dfd2348e4e9 · ITensor/ITensor (github.com) May I ask if I want to output more eigenenergy for each effective Hamiltonian (local MPO) during the D…

---

## [Frobenius norm of an MPO](https://itensor.discourse.group/t/frobenius-norm-of-an-mpo/1511)

<div class="topic-metadata">

**Author:** [@scapponi](https://itensor.discourse.group/u/scapponi)\
**Replies:** 1\
**Last updated:** [March 2, 2024, 3:10am UTC](https://itensor.discourse.group/t/frobenius-norm-of-an-mpo/1511 "2024-03-02T03:10:44Z")

</div>

I am looking for a function to compute the Frobenius norm of a complex MPO, i.e. the sum of squared modulus of all elements. Thanks in advance for your help, Sylvain

---

## [Convergence issue in TDVP](https://itensor.discourse.group/t/convergence-issue-in-tdvp/1398)

<div class="topic-metadata">

**Author:** [@debamalya](https://itensor.discourse.group/u/debamalya)\
**Replies:** 0\
**Last updated:** [January 8, 2024, 4:23pm UTC](https://itensor.discourse.group/t/convergence-issue-in-tdvp/1398 "2024-01-08T16:23:13Z")

</div>

Hi, I am trying to calculate the spectral function. There are several methods for that, like the correction vector method, and another is to find the Greens function in time space and then do the FFT of its imaginary par…

---

## [Calculation of two-point correlator in the quantum number conservation framework](https://itensor.discourse.group/t/calculation-of-two-point-correlator-in-the-quantum-number-conservation-framework/1349)

<div class="topic-metadata">

**Author:** [@navnishu2010](https://itensor.discourse.group/u/navnishu2010)\
**Replies:** 3\
**Last updated:** [December 28, 2023, 7:00pm UTC](https://itensor.discourse.group/t/calculation-of-two-point-correlator-in-the-quantum-number-conservation-framework/1349 "2023-12-28T19:00:42Z")

</div>

Hi all I am trying to calculate the two-point correlator of the following form in the context of a chain of spin-half particles C(x,t)=\\langle\[\\sigma\_x^+(t), \\sigma\_x^-(0)\]\\rangle I am doing calculations for XXX chain…

---

## [Does ITensor welcome links to open source libraries based on ITensor?](https://itensor.discourse.group/t/does-itensor-welcome-links-to-open-source-libraries-based-on-itensor/741)

<div class="topic-metadata">

**Author:** [@haggaila](https://itensor.discourse.group/u/haggaila)\
**Replies:** 10\
**Last updated:** [December 20, 2023, 10:05am UTC](https://itensor.discourse.group/t/does-itensor-welcome-links-to-open-source-libraries-based-on-itensor/741 "2023-12-20T10:05:10Z")

</div>

Hi, I wish to ask whether you currently support/agree to post links to open source packages based on ITensor, perhaps in the Community Codes section of the Codes page? If so, what would be the way to proceed with reque…

---

## [Time Evolution of wave function when Hamiltonian is time dependent](https://itensor.discourse.group/t/time-evolution-of-wave-function-when-hamiltonian-is-time-dependent/1278)

<div class="topic-metadata">

**Author:** [@debamalya](https://itensor.discourse.group/u/debamalya)\
**Replies:** 4\
**Last updated:** [November 14, 2023, 7:06am UTC](https://itensor.discourse.group/t/time-evolution-of-wave-function-when-hamiltonian-is-time-dependent/1278 "2023-11-14T07:06:24Z")

</div>

Consider I have a Hamiltonian(H(t)) which is time-dependent. I want to find the time evolution of a wave function which has the initial condition that is the ground state(\\psi(0)) of the Hamiltonian(H(0)). How do I find \\…

---

## [Time Evolution of wave function when Hamiltonian is time dependent.](https://itensor.discourse.group/t/time-evolution-of-wave-function-when-hamiltonian-is-time-dependent/1275)

<div class="topic-metadata">

**Author:** [@debamalya](https://itensor.discourse.group/u/debamalya)\
**Replies:** 0\
**Last updated:** [November 10, 2023, 7:09am UTC](https://itensor.discourse.group/t/time-evolution-of-wave-function-when-hamiltonian-is-time-dependent/1275 "2023-11-10T07:09:27Z")

</div>

Consider I have a Hamiltonian(H(t)) which is time-dependent. I want to find the time evolution of a wave function which has the initial condition that is the ground state(\\psi(0)) of the Hamiltonian(H(0)). How do I find \\…

---

## [How can I separately conserve QNs which have the same name (c++)?](https://itensor.discourse.group/t/how-can-i-separately-conserve-qns-which-have-the-same-name-c/1222)

<div class="topic-metadata">

**Author:** [@Wenqi](https://itensor.discourse.group/u/Wenqi)\
**Replies:** 0\
**Last updated:** [October 16, 2023, 8:15am UTC](https://itensor.discourse.group/t/how-can-i-separately-conserve-qns-which-have-the-same-name-c/1222 "2023-10-16T08:15:48Z")

</div>

Hello, I have read the instruction on the website “Quantum Number (QN) FAQs · ITensors.jl”. It works well for the Julia version. These days, I find the runtime of ITensor C++ is much shorter than ITensor Julia for my cl…

---

## [MPS time evolution, apply function (julia) much slower than gateTEvol (c++)](https://itensor.discourse.group/t/mps-time-evolution-apply-function-julia-much-slower-than-gatetevol-c/1131)

<div class="topic-metadata">

**Author:** [@iChaker](https://itensor.discourse.group/u/iChaker)\
**Replies:** 8\
**Last updated:** [October 6, 2023, 2:46pm UTC](https://itensor.discourse.group/t/mps-time-evolution-apply-function-julia-much-slower-than-gatetevol-c/1131 "2023-10-06T14:46:33Z")

</div>

I am trying to run time evolution on an MPS, but I noticed that Julia is much slower than c++. To confirm this I used the example codes provided in the documentation that implement TEBD on a one-dimensional Heisenberg mo…

---

## [Sweeps and bond dimension in TDVP](https://itensor.discourse.group/t/sweeps-and-bond-dimension-in-tdvp/1100)

<div class="topic-metadata">

**Author:** [@debamalya](https://itensor.discourse.group/u/debamalya)\
**Replies:** 3\
**Last updated:** [September 5, 2023, 3:09pm UTC](https://itensor.discourse.group/t/sweeps-and-bond-dimension-in-tdvp/1100 "2023-09-05T15:09:36Z")

</div>

Hi, It is generally recommended that for DMRG calculation to use larger sweeps start with smaller bond dimensions and then increase slowly for better convergence. But I am confused about TDVP. Because of the GitHub exa…

---

## [Unable to reproduce DMRG calculations using ITensor](https://itensor.discourse.group/t/unable-to-reproduce-dmrg-calculations-using-itensor/1035)

<div class="topic-metadata">

**Author:** [@debamalya](https://itensor.discourse.group/u/debamalya)\
**Replies:** 1\
**Last updated:** [July 20, 2023, 2:57am UTC](https://itensor.discourse.group/t/unable-to-reproduce-dmrg-calculations-using-itensor/1035 "2023-07-20T02:57:18Z")

</div>

Hi, I am a beginner to DMRG, and for the learning purpose, I have started with the paper(Phase diagram of the extended Bose–Hubbard model; DOI 10.1088/1367-2630/14/6/065012), which I intend to reproduce using ITensor. T…

---

## [Mismatch of results in two different machine](https://itensor.discourse.group/t/mismatch-of-results-in-two-different-machine/1026)

<div class="topic-metadata">

**Author:** [@debamalya](https://itensor.discourse.group/u/debamalya)\
**Replies:** 8\
**Last updated:** [July 18, 2023, 5:34am UTC](https://itensor.discourse.group/t/mismatch-of-results-in-two-different-machine/1026 "2023-07-18T05:34:23Z")

</div>

Hi, I am trying to reproduce the paper Phase diagram of the extended Bose–Hubbard model. For which I am using the following code //test.cpp #include \<iostream\> #include \<cmath\> #include \<iomanip\> #include \<cmath\> #inc…

---

## [Read psi from idmrg into ITensorInfiniteMPS.jl](https://itensor.discourse.group/t/read-psi-from-idmrg-into-itensorinfinitemps-jl/890)

<div class="topic-metadata">

**Author:** [@L\_Zhang](https://itensor.discourse.group/u/L_Zhang)\
**Replies:** 0\
**Last updated:** [May 21, 2023, 7:12pm UTC](https://itensor.discourse.group/t/read-psi-from-idmrg-into-itensorinfinitemps-jl/890 "2023-05-21T19:12:54Z")

</div>

Can the wave function obtained from iDMRG be loaded into ITensorInfiniteMPS.jl to do the transfer matrix spectrum calculation? Because of my poor coding skill, I try to avoid the difficulty of arnoldi algorithm in C++…

---

## [CMake support for iTensor cpp package](https://itensor.discourse.group/t/cmake-support-for-itensor-cpp-package/708)

<div class="topic-metadata">

**Author:** [@fracton](https://itensor.discourse.group/u/fracton)\
**Replies:** 1\
**Last updated:** [March 18, 2023, 5:18pm UTC](https://itensor.discourse.group/t/cmake-support-for-itensor-cpp-package/708 "2023-03-18T17:18:44Z")

</div>

Hi, I just started out with iTensor for some simple DMRG calculations. I was just wondering, why the installation for C++ code base uses gnu make and not CMake? Are there any plans to migrate to a CMake installation.

---

## [Coupling fermionic operators with bosonic operators](https://itensor.discourse.group/t/coupling-fermionic-operators-with-bosonic-operators/636)

<div class="topic-metadata">

**Author:** [@AJVargas](https://itensor.discourse.group/u/AJVargas)\
**Replies:** 0\
**Last updated:** [February 12, 2023, 2:47am UTC](https://itensor.discourse.group/t/coupling-fermionic-operators-with-bosonic-operators/636 "2023-02-12T02:47:15Z")

</div>

Hi! We are working with a model that couples fermionic operators with bosonic operators such that our Hamiltonian looks something like: H = (a^{\\dagger}+a)\\sum\_i c^{\\dagger}\_i c\_{i+1} +h.c. Every time one of our ferm…

---

## [Entanglement Spectrum with momentum](https://itensor.discourse.group/t/entanglement-spectrum-with-momentum/567)

<div class="topic-metadata">

**Author:** [@L\_Zhang](https://itensor.discourse.group/u/L_Zhang)\
**Replies:** 7\
**Last updated:** [February 8, 2023, 3:31pm UTC](https://itensor.discourse.group/t/entanglement-spectrum-with-momentum/567 "2023-02-08T15:31:56Z")

</div>

To charactorize the topological property of a certain state, the entanglement in k-space are often calculated. But I haven’t found an detailed instruction about it. How can we get entanglement spectrum seperated with mo…

---

## [Obtaining transfer matrix using diagHermitian in iDMRG](https://itensor.discourse.group/t/obtaining-transfer-matrix-using-diaghermitian-in-idmrg/420)

<div class="topic-metadata">

**Author:** [@terger](https://itensor.discourse.group/u/terger)\
**Replies:** 15\
**Last updated:** [January 27, 2023, 7:40pm UTC](https://itensor.discourse.group/t/obtaining-transfer-matrix-using-diaghermitian-in-idmrg/420 "2023-01-27T19:40:11Z")

</div>

Hello, I am studying a spin system using the idmrg.h file and trying to construct the transfer matrix to determine the correlation length of the system. I can construct the transfer matrix (bond dimension is around 50…

---

## [DMRG 2D Hubbard slow convergence](https://itensor.discourse.group/t/dmrg-2d-hubbard-slow-convergence/580)

<div class="topic-metadata">

**Author:** [@Polat](https://itensor.discourse.group/u/Polat)\
**Replies:** 3\
**Last updated:** [January 26, 2023, 9:11am UTC](https://itensor.discourse.group/t/dmrg-2d-hubbard-slow-convergence/580 "2023-01-26T09:11:35Z")

</div>

Hello together, in my Phd research of the 2D Hubbard Model for cuprades I use the C++ DMRG of iTensor. I use the Cluster Model with one d- and four p-Orbitals. Currently I try to calculate the Cluster as a ladder like…

---

## [MixedSiteSet in TEBD and DMRG](https://itensor.discourse.group/t/mixedsiteset-in-tebd-and-dmrg/538)

<div class="topic-metadata">

**Author:** [@Riku](https://itensor.discourse.group/u/Riku)\
**Replies:** 1\
**Last updated:** [January 22, 2023, 8:25am UTC](https://itensor.discourse.group/t/mixedsiteset-in-tebd-and-dmrg/538 "2023-01-22T08:25:37Z")

</div>

Dear ITensor developers and users, Thank you for wonderful and useful library. I do DMRG and want to do TEBD with ITensor in C++ version. In my model, the system consists of the conduction electron subsystem and local …

---

## [Get the wrong information of psi in idmrg](https://itensor.discourse.group/t/get-the-wrong-information-of-psi-in-idmrg/565)

<div class="topic-metadata">

**Author:** [@hui-yang2020](https://itensor.discourse.group/u/hui-yang2020)\
**Replies:** 8\
**Last updated:** [January 16, 2023, 9:36pm UTC](https://itensor.discourse.group/t/get-the-wrong-information-of-psi-in-idmrg/565 "2023-01-16T21:36:30Z")

</div>

I using idmrg to calculate the wave functions psi. But when I use Print(psi(n\_1)), I found that for odd number of sweeps, in the result n\\neq n\_1, while for even number of sweep, it is right. I using idmrg to calculate …

---

## [transfer the idmrg wave function into the initial wave function](https://itensor.discourse.group/t/transfer-the-idmrg-wave-function-into-the-initial-wave-function/574)

<div class="topic-metadata">

**Author:** [@hui-yang2020](https://itensor.discourse.group/u/hui-yang2020)\
**Replies:** 1\
**Last updated:** [January 6, 2023, 7:52pm UTC](https://itensor.discourse.group/t/transfer-the-idmrg-wave-function-into-the-initial-wave-function/574 "2023-01-06T19:52:56Z")

</div>

I save the wave function \\psi generated by idmrg, and then import it as an initial wave function. But it said error when I am running the new idmrg. So How can I transfer the wave function generated by idmrg into the MPS…

---

## [Future of C++ version of ITensor](https://itensor.discourse.group/t/future-of-c-version-of-itensor/345)

<div class="topic-metadata">

**Author:** [@raffaele](https://itensor.discourse.group/u/raffaele)\
**Replies:** 2\
**Last updated:** [August 29, 2022, 8:51am UTC](https://itensor.discourse.group/t/future-of-c-version-of-itensor/345 "2022-08-29T08:51:02Z")

</div>

Dear ITensor Developers, I have read some comments in which ITensor users have been suggested to use the Julia version of the library, rather than the C++. Indeed, it seems that the Julia version, albeit much younger th…

[Next page](https://itensor.discourse.group/tag/cpp/2.md?match_all_tags=true&page=1&tags%5B%5D=cpp)
