# ITensor C++ Questions

**URL:** https://itensor.discourse.group/c/itensor-c-questions/6.md?page=1

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

**Page:** 2

---

## [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

---

## [how to construct a one-dimensional two component bose-hubbard model](https://itensor.discourse.group/t/how-to-construct-a-one-dimensional-two-component-bose-hubbard-model/112)

<div class="topic-metadata">

**Author:** [@Wang](https://itensor.discourse.group/u/Wang)\
**Replies:** 5\
**Last updated:** [May 6, 2022, 4:26pm UTC](https://itensor.discourse.group/t/how-to-construct-a-one-dimensional-two-component-bose-hubbard-model/112 "2022-05-06T16:26:25Z")

</div>

Hello everyone! Recently, I was doing something related to one-dimensional two component bose-hubbard model. I need its density distribution and correlators at various two points. With the guide in this post ( Two-com…

---

## [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…

---

## [About bondgate and beyond nearest neigbor](https://itensor.discourse.group/t/about-bondgate-and-beyond-nearest-neigbor/1384)

<div class="topic-metadata">

**Author:** [@cbdag](https://itensor.discourse.group/u/cbdag)\
**Replies:** 0\
**Last updated:** [January 1, 2024, 9:01pm UTC](https://itensor.discourse.group/t/about-bondgate-and-beyond-nearest-neigbor/1384 "2024-01-01T21:01:58Z")

</div>

Hi, I’m trying to do time evolution for a 1D chain with next nearest neighbor interactions. The following code worked for me, but I want to make sure that this is indeed doing what I am intending. This term is supposed …

---

## [add sites to MPS/MPO in C++](https://itensor.discourse.group/t/add-sites-to-mps-mpo-in-c/1347)

<div class="topic-metadata">

**Author:** [@TrudySun](https://itensor.discourse.group/u/TrudySun)\
**Replies:** 0\
**Last updated:** [December 10, 2023, 9:47am UTC](https://itensor.discourse.group/t/add-sites-to-mps-mpo-in-c/1347 "2023-12-10T09:47:17Z")

</div>

Dear ITensor, Hi! I’m using ITensor C++ version. I noticed that in Julia ver, we can extend an MPS/MPO by adding a site, i was wondering if this operation can be done in C++? What I’m planning to do is basically as fo…

---

## [ITensor to MPS/MPO in C++](https://itensor.discourse.group/t/itensor-to-mps-mpo-in-c/1294)

<div class="topic-metadata">

**Author:** [@TrudySun](https://itensor.discourse.group/u/TrudySun)\
**Replies:** 1\
**Last updated:** [November 24, 2023, 12:41pm UTC](https://itensor.discourse.group/t/itensor-to-mps-mpo-in-c/1294 "2023-11-24T12:41:45Z")

</div>

Dear ITensor, I’m considering construct TT-approximation in C++. I notice in Julia version, there is a “MPS” function that can construct the MPS from an ITensor, e.g. using ITensors cutoff = 1E-8 maxdim = 10 T = rand…

---

## [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 \\…

---

## [Calculation time for time dependent observable](https://itensor.discourse.group/t/calculation-time-for-time-dependent-observable/1212)

<div class="topic-metadata">

**Author:** [@vrushali.k](https://itensor.discourse.group/u/vrushali.k)\
**Replies:** 9\
**Last updated:** [October 20, 2023, 4:31am UTC](https://itensor.discourse.group/t/calculation-time-for-time-dependent-observable/1212 "2023-10-20T04:31:17Z")

</div>

Hello, I am using trotter gate for time dependent calculations of one dimensional spin chain. I am calculating time dependent spin correlations up to final time 12, with tau=0.005 and measurement done after each 0.2 tim…

---

## [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…

---

## [Related to trotter gates](https://itensor.discourse.group/t/related-to-trotter-gates/115)

<div class="topic-metadata">

**Author:** [@vrushali.k](https://itensor.discourse.group/u/vrushali.k)\
**Replies:** 17\
**Last updated:** [October 5, 2023, 1:40am UTC](https://itensor.discourse.group/t/related-to-trotter-gates/115 "2023-10-05T01:40:50Z")

</div>

Hi, In C++ documentation time evolving MPS with trotter gate has written as shown below. My question is If I have hamiltonian which is same as shown below with extra site term e.g. B\*S^z\_j where B is applied magnetic fi…

---

## [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…

---

## [Measurement of local obervables](https://itensor.discourse.group/t/measurement-of-local-obervables/1090)

<div class="topic-metadata">

**Author:** [@vrushali.k](https://itensor.discourse.group/u/vrushali.k)\
**Replies:** 5\
**Last updated:** [August 21, 2023, 3:54am UTC](https://itensor.discourse.group/t/measurement-of-local-obervables/1090 "2023-08-21T03:54:54Z")

</div>

Hello, I am using heisenberg AFM spin-\\frac{1}{2} model. I calculated expectation values of all spin components. I expect \<S^x\_j\>=\<S^y\_j\>=\<S^z\_j\> at j^{th} site. Following is the part of code. for(int j = 1; j \< …

---

## [How to create an array to store a variable h ?](https://itensor.discourse.group/t/how-to-create-an-array-to-store-a-variable-h/1089)

<div class="topic-metadata">

**Author:** [@Tan](https://itensor.discourse.group/u/Tan)\
**Replies:** 1\
**Last updated:** [August 15, 2023, 4:11pm UTC](https://itensor.discourse.group/t/how-to-create-an-array-to-store-a-variable-h/1089 "2023-08-15T16:11:39Z")

</div>

I want to calculate the eigenvalues of a model under different variables, For example, in the xxz model,h can change. What do I need to do to get a series of intrinsic energies under different parameters? I tried to cr…

---

## [To find ground state energy for a fixed "Sz\_total"](https://itensor.discourse.group/t/to-find-ground-state-energy-for-a-fixed-sz-total/222)

<div class="topic-metadata">

**Author:** [@vrushali.k](https://itensor.discourse.group/u/vrushali.k)\
**Replies:** 9\
**Last updated:** [August 1, 2023, 5:50am UTC](https://itensor.discourse.group/t/to-find-ground-state-energy-for-a-fixed-sz-total/222 "2023-08-01T05:50:22Z")

</div>

Hi, I am interested to find ground state energy for a spin chain using DMRG for a fixed Sz\_total=0,1,2. How to do that?

---

## [Segmentation fault with QNs](https://itensor.discourse.group/t/segmentation-fault-with-qns/1003)

<div class="topic-metadata">

**Author:** [@aqubit](https://itensor.discourse.group/u/aqubit)\
**Replies:** 2\
**Last updated:** [July 6, 2023, 3:22pm UTC](https://itensor.discourse.group/t/segmentation-fault-with-qns/1003 "2023-07-06T15:22:26Z")

</div>

Hi! I’ve encountered a strange bug I can’t seem to get rid of. It could just be me doing something silly so I figured it would be best to ask here and find out. Specifically, when using different spins and quantum numb…

---

## [Exponential of MPO (2)](https://itensor.discourse.group/t/exponential-of-mpo-2/724)

<div class="topic-metadata">

**Author:** [@ap73](https://itensor.discourse.group/u/ap73)\
**Replies:** 1\
**Last updated:** [June 19, 2023, 3:42pm UTC](https://itensor.discourse.group/t/exponential-of-mpo-2/724 "2023-06-19T15:42:27Z")

</div>

Follow up on this thread. The main difference with the previous thread is that now, instead of having a one-body operator, I have a two-body: \\sum\_{i,j}S\_z^iS\_z^j, where i and j are site indices. I can store it as an M…

---

## [How create a mps like (|up\>+|Dn\>)\_1(|up\>-|Dn\>)\_2|up\>+|Dn\>)\_3(|up\>-|Dn\>)\_4....](https://itensor.discourse.group/t/how-create-a-mps-like-up-dn-1-up-dn-2-up-dn-3-up-dn-4/849)

<div class="topic-metadata">

**Author:** [@Jren](https://itensor.discourse.group/u/Jren)\
**Replies:** 5\
**Last updated:** [May 20, 2023, 9:12am UTC](https://itensor.discourse.group/t/how-create-a-mps-like-up-dn-1-up-dn-2-up-dn-3-up-dn-4/849 "2023-05-20T09:12:52Z")

</div>

Dear evergone， I need to generate a state in the form MPS. The state is (|up\>+|dn\>)\_1 (|up\>-|dn\>)\_2 (|up\>+|dn\>)\_3 (|up\>-|dn\>)\_4....(|up\>+|dn\>)\_{N-1} (|up\>-|dn\>)\_N. Looking forward to your reply Thanks

---

## [DMRG for time dependent Hamiltonian](https://itensor.discourse.group/t/dmrg-for-time-dependent-hamiltonian/856)

<div class="topic-metadata">

**Author:** [@aslam23](https://itensor.discourse.group/u/aslam23)\
**Replies:** 1\
**Last updated:** [May 12, 2023, 1:09pm UTC](https://itensor.discourse.group/t/dmrg-for-time-dependent-hamiltonian/856 "2023-05-12T13:09:15Z")

</div>

Hello All, I have one question regarding implementation of a time dependent spin Hamiltonian in one dimension. I would like to know in C++ how to implement this and also calculate any observable at each time. So, it wou…

---

## [Exponential of MPO](https://itensor.discourse.group/t/exponential-of-mpo/422)

<div class="topic-metadata">

**Author:** [@ap73](https://itensor.discourse.group/u/ap73)\
**Replies:** 10\
**Last updated:** [March 24, 2023, 2:47am UTC](https://itensor.discourse.group/t/exponential-of-mpo/422 "2023-03-24T02:47:46Z")

</div>

Hi, So I’ve been trying to use this function: expHermitian(ITensor H, Cplx tau = 1) but the operator that I want to exponentiate is the total Sz. Here is the code that I have so far: auto ampo2 = AutoMPO(sites); for(a…

---

## [Computing out-of-time correlation function](https://itensor.discourse.group/t/computing-out-of-time-correlation-function/711)

<div class="topic-metadata">

**Author:** [@Fazekas](https://itensor.discourse.group/u/Fazekas)\
**Replies:** 0\
**Last updated:** [March 20, 2023, 3:04pm UTC](https://itensor.discourse.group/t/computing-out-of-time-correlation-function/711 "2023-03-20T15:04:20Z")

</div>

Hi everybody! My goal is to compute a density-density correlation, \\langle \\hat n(t) \\hat n(0) \\rangle, where \\hat n is a number operator at a given site. First I have obtained a wave function psi using DMRG. Now I wou…

---

## [How to calculate string operator in the S=1 Heisenberg antiferromagnetic chain in ITensor C++ version ?](https://itensor.discourse.group/t/how-to-calculate-string-operator-in-the-s-1-heisenberg-antiferromagnetic-chain-in-itensor-c-version/666)

<div class="topic-metadata">

**Author:** [@SugarYu](https://itensor.discourse.group/u/SugarYu)\
**Replies:** 0\
**Last updated:** [February 27, 2023, 10:09am UTC](https://itensor.discourse.group/t/how-to-calculate-string-operator-in-the-s-1-heisenberg-antiferromagnetic-chain-in-itensor-c-version/666 "2023-02-27T10:09:14Z")

</div>

Dear ITensor teams, Thanks for the reply. I have a question about ITensor C++ version: How to calculate string operator in the S=1 Heisenberg antiferromagnetic chain ? e.g. \<\\psi\_{0}|S^{z}{1}exp(i \\pi \\sum{l=2}^{L-1}S^{…

---

## [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…

---

## [ITensor for Open quantum systems](https://itensor.discourse.group/t/itensor-for-open-quantum-systems/271)

<div class="topic-metadata">

**Author:** [@Fra\_perciavalle](https://itensor.discourse.group/u/Fra_perciavalle)\
**Replies:** 7\
**Last updated:** [January 23, 2023, 12:10pm UTC](https://itensor.discourse.group/t/itensor-for-open-quantum-systems/271 "2023-01-23T12:10:13Z")

</div>

Hi, I am new of ITensor and its C++ version. I have seen that the package is complete and efficient for the study of closed quantum systems with DMRG and MPS. Anyway, I didn’t seen anything about open quantum systems. A…

---

## [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 …

---

## [Hole doping in next-neighbor tJ model system](https://itensor.discourse.group/t/hole-doping-in-next-neighbor-tj-model-system/594)

<div class="topic-metadata">

**Author:** [@Shraddha](https://itensor.discourse.group/u/Shraddha)\
**Replies:** 2\
**Last updated:** [January 13, 2023, 12:41am UTC](https://itensor.discourse.group/t/hole-doping-in-next-neighbor-tj-model-system/594 "2023-01-13T00:41:09Z")

</div>

Hello Everyone! I am working on a next-neighbor tJ model system and was trying to calculate the total density of the system. I was now trying to vary the hole doping or assign number electrons but I am not entirely sure…

---

## [Multithreading in C++](https://itensor.discourse.group/t/multithreading-in-c/553)

<div class="topic-metadata">

**Author:** [@vrushali.k](https://itensor.discourse.group/u/vrushali.k)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 3:57pm UTC](https://itensor.discourse.group/t/multithreading-in-c/553 "2022-12-07T15:57:03Z")

</div>

Hi, I am using MKL platform. To use multithreading that I have followed following steps in option.mk file, 1.set ITENSOR\_USE\_OMP=1 2.set export MKL\_NUM\_THREADS=1 by calling following commands for same program OMP…

---

## [SVD for non-contiguous bipartitions (repost)](https://itensor.discourse.group/t/svd-for-non-contiguous-bipartitions-repost/255)

<div class="topic-metadata">

**Author:** [@SSR](https://itensor.discourse.group/u/SSR)\
**Replies:** 4\
**Last updated:** [December 2, 2022, 5:35am UTC](https://itensor.discourse.group/t/svd-for-non-contiguous-bipartitions-repost/255 "2022-12-02T05:35:14Z")

</div>

Hi, I am looking for SVD for non-contiguous bipartitions of an MPS. However, even before that if I wish to compute entropy for 2:rest bipartition (i.e., 2:1,3,4,5…N), one way to do that is by applying a swap gate that …

---

## [Probability of a POVM](https://itensor.discourse.group/t/probability-of-a-povm/525)

<div class="topic-metadata">

**Author:** [@fra](https://itensor.discourse.group/u/fra)\
**Replies:** 3\
**Last updated:** [November 24, 2022, 4:32pm UTC](https://itensor.discourse.group/t/probability-of-a-povm/525 "2022-11-24T16:32:59Z")

</div>

Hi everyone, I don’t k ow if it’s a naive question,but here it is my doubt. If I have my physical system encoded into an MPS \\ket{\\psi\_0},how can measure a POVM, constructed by local operator acting on a single site? …

---

## [A naive MPS problem of idmrg](https://itensor.discourse.group/t/a-naive-mps-problem-of-idmrg/510)

<div class="topic-metadata">

**Author:** [@kevinh](https://itensor.discourse.group/u/kevinh)\
**Replies:** 0\
**Last updated:** [November 10, 2022, 12:58pm UTC](https://itensor.discourse.group/t/a-naive-mps-problem-of-idmrg/510 "2022-11-10T12:58:59Z")

</div>

Hi,ITensor I have confirmed that I need to use infinite dmrg.Because idmrg is simpler than vumps, I have studied the relevant parts of the ITensor idmrg c++ version, and now I understand some of the principles, and will…

---

## [Expecatation value of a string of operator](https://itensor.discourse.group/t/expecatation-value-of-a-string-of-operator/494)

<div class="topic-metadata">

**Author:** [@fra](https://itensor.discourse.group/u/fra)\
**Replies:** 1\
**Last updated:** [November 10, 2022, 4:09am UTC](https://itensor.discourse.group/t/expecatation-value-of-a-string-of-operator/494 "2022-11-10T04:09:25Z")

</div>

Hi everyone, I am trying to compute the expectation value of strings of operators, something like : C\_z=\\langle\\sigma^1\_z\\otimes\\sigma^2\_z\\otimes\\sigma^3\_z\\otimes\\sigma^4\_z\\otimes\\sigma^5\_z\\otimes\\sigma^6\_z\\rangle w…

[Previous page](https://itensor.discourse.group/c/itensor-c-questions/6.md)

[Next page](https://itensor.discourse.group/c/itensor-c-questions/6.md?page=2)
