Introduction
Latest Julia version is v0.2.9
View source on github
Documentation for the Julia version
Latest C++ version is v3.1.10
Clone from github (preferred)
Download: tar.gz or zip
On Twitter@ITensorLib
Sign up for email newsletters
ITensor—Intelligent Tensor—is a library for implementing
tensor network calculations. See the list of recent papers using ITensor.
Features include:
 Permuting indices is handled automatically when adding or contracting tensors
 Fullfeatured matrix product state / tensor train and DMRG layer
 Quantum number conserving (blocksparse) tensors; same interface as dense tensors
 Complex numbers handled automatically and efficiently
 Easy to install, with a friendly and productive interface
 Multithreaded contraction over sparse tensor blocks
 Automatically convert sums of local operators to MPOs (AutoMPO)
 Efficiently apply local operators to MPS (quantum circuits, time evolution)
ITensors have an interface resembling tensor diagram notation, making them nearly as easy to multiply as scalars: tensors indices have unique identities and matching indices automatically contract when two ITensors are multiplied. This type of interface makes it simple to transcribe tensor network diagrams into correct, efficient code.
For example, the diagram below (resembling the overlap of matrix product states) can be converted to code as
Installing ITensor (Julia Version):
 Install the Julia language
 Enter the command
julia
to start an interactive Julia session  Inside this session, type
]
to enter the package manager  Enter the command
add ITensors
 [Optional but Recommended] Enter the command
using ITensors; ITensors.compile()
 For more details, see our installation guide and read about getting started with ITensor.
Browse the indepth documentation pages for the Julia version to learn more.
Note that you can use Julia ITensor on a supercomputing cluster even if Julia is not installed systemwide. To do so, just install Julia locally into your personal account.
Installing ITensor (C++ version):
 Make sure you have an uptodate C++17 compiler and LAPACK installed. On UNIX systems, use your package manager; on Mac OS install the free Xcode app from the app store; for Windows install cygwin.
 Clone the latest version of ITensor:
(Or download the zip file if you do not have git.)git clone https://github.com/ITensor/ITensor itensor
Cloning with git allows you to track changes to ITensor and is the preferred method; for more see our git quick start guide.  Create the options.mk file:
cp options.mk.sample options.mk
. Follow the instructions in this file to customize for your machine.  Type
make
to build ITensor.  The compiled library files remain inside the ITensor source folder and are not put anywhere else on your machine. To create a program using ITensor, use the files in the "tutorial/project_template" folder as a starting point for making your own code.
For more details, read the full C++ installation instructions.
Browse the documentation pages for the C++ version to learn more about ITensor.
Citing ITensor
Please cite the ITensor paper if you use the C++ or Julia version to produce data or other results for a publication. You may use the following BibTex entry to cite in LaTeX documents:
title={The \mbox{ITensor} Software Library for Tensor Network Calculations},
author={Matthew Fishman and Steven R. White and E. Miles Stoudenmire},
year={2020},
eprint={2007.14822},
archivePrefix={arXiv}
}
We are grateful for ongoing support from the Simons Foundation. 

ITensor was initiated with generous support from the United States Department of Energy. 
Code Samples (Julia Version)
Contract Two MatrixLike ITensors
using ITensors a = Index(2) b = Index(2) c = Index(2) Z = ITensor(a,b) X = ITensor(c,b) Z[a=>1,b=>1] = 1.0 Z[a=>2,b=>2] = 1.0 X[b=>1,c=>2] = 1.0 X[b=>2,c=>1] = 1.0# The * operator finds and # contracts common index 'b' # regardless of index order:R = Z * X @show R[a=>2,c=>1]# Output: # R[a=>2,c=>1] = 1
Contract and Add ITensors
i = Index(3) j = Index(5) k = Index(2) l = Index(7) A = ITensor(i,j,k) B = ITensor(l,j) A[i=>1,j=>1,k=>1] = 11.1 A[i=>2,j=>1,k=>2] = 21.2 A[k=>1,i=>3,j=>1] = 31.1 A[k=>1,i=>1,j=>2] = 11.2 B[j=>2,l=>4] = 2+4im C = A * B; @show C D = randomITensor(k,j,i) R = A + D
Factorize an ITensor (Using SVD)
i = Index(3,"i") j = Index(7,"j") k = Index(2,"k") l = Index(4,"l") T = randomITensor(i,j,k,l) U,S,V = svd(T,i,k) @show norm(T  U*S*V)# Output: # norm(T  U*S*V) = 4.7458E14
Perform a DMRG Calculation
DMRG is a powerful algorithm for finding dominant eigenvectors of exponentially large matrices (such as quantum Hamiltonians) in matrix product state (MPS) form. It is adaptive and converges very quickly and to high precision.
In addition to stateoftheart DMRG codes, ITensor features the AutoMPO system, which is a powerful domainspecific language for creating matrix product operator (MPO) tensor networks as a sum of local terms, which is especially useful for quantum mechanics applications.
# Define Hilbert space of N spinone sites N = 100 sites = siteinds("S=1",N; conserve_qns=true) # Create 1d Heisenberg Hamiltonian ampo = AutoMPO() for j = 1:N1 ampo += 1/2,"S+",j,"S",j+1 ampo += 1/2,"S",j,"S+",j+1 ampo += "Sz",j,"Sz",j+1 end H = MPO(ampo,sites) # Choose initial wavefunction # to be a product state psi0 = productMPS(sites,n>isodd(n) ? "Up" : "Dn") # Perform 5 sweeps of DMRG sweeps = Sweeps(5) # Specify max number of states kept each sweep setmaxdim!(sweeps,50,50,100,100,200) # Run the DMRG algorithm energy,psi = dmrg(H,psi0,sweeps) # Continue to analyze wavefunction afterward @show inner(psi,H,psi) # <psiHpsi> # Measure "Sz" operator on every site sz = expect(psi,"Sz") for j=1:N println("Sz_$j = ",sz[j]) end
Code Samples (C++ Version)
Contract Two MatrixLike ITensors
auto a = Index(2), auto b = Index(2), auto c = Index(2); auto Z = ITensor(a,b), auto X = ITensor(c,b); Z.set(a=1,b=1, +1.0); Z.set(a=2,b=2, 1.0); X.set(b=1,c=2, +1.0); X.set(b=2,c=1, +1.0);//the * operator finds and //contracts common index 'b' //regardless of index order:ITensor R = Z * X; Print( elt(R,a=2,c=1) );//output: // elt(R,a=2,c=1) = 1
Contract and Add ITensors
auto i = Index(3); auto j = Index(5); auto k = Index(2); auto l = Index(7); auto A = ITensor(i,j,k); auto B = ITensor(l,j); A.set(i=1,j=1,k=1, 11.1); A.set(i=2,j=1,k=2, 21.2); A.set(k=1,i=3,j=1, 31.1); A.set(k=1,i=1,j=2, 11.2); B.set(j=2,l=4, 2.+4._i); auto C = A * B; PrintData(C); auto D = randomITensor(k,j,i); auto R = A + D;
Factorize an ITensor (Using SVD)
auto i = Index(3,"i"); auto j = Index(7,"j"); auto k = Index(2,"k"); auto l = Index(4,"l"); auto T = randomITensor(i,j,k,l); auto [U,S,V] = svd(T,i,k); Print(norm(T  U*S*V));//output: // norm(T  U*S*V) = 4.7458E14
Perform a DMRG Calculation
DMRG is a powerful algorithm for finding dominant eigenvectors of exponentially large matrices (such as quantum Hamiltonians) in matrix product state (MPS) form. It is adaptive and converges very quickly and to high precision.
In addition to stateoftheart DMRG codes, ITensor features the AutoMPO system, which is a powerful domainspecific language for creating matrix product operator (MPO) tensor networks as a sum of local terms, which is especially useful for quantum mechanics applications.
//Define Hilbert space of N spinone sites int N = 100; auto sites = SpinOne(N); //Create 1d Heisenberg Hamiltonian auto ampo = AutoMPO(sites); for(int j = 1; j < N; ++j) { ampo += 0.5,"S+",j,"S",j+1; ampo += 0.5,"S",j,"S+",j+1; ampo += "Sz",j,"Sz",j+1; } auto H = toMPO(ampo); //Choose initial wavefunction //to be a product state auto psi0 = MPS(InitState(sites,"Z0")); //Perform 5 sweeps of DMRG auto sweeps = Sweeps(5); //Specify max number of states kept each sweep sweeps.maxdim() = 50, 50, 100, 100, 200; //Run the DMRG algorithm auto [energy,psi] = dmrg(H,psi0,sweeps,"Quiet"); //Continue to analyze wavefunction afterward Print(inner(psi,H,psi)); //<psiHpsi> for(int j = 1; j <= N; ++j) { //Make site j the MPS "orthogonality center" psi.position(j); //Measure magnetization on site j Real Szj = elt(psi(j) * op(sites,"Sz",j) * dag(prime(psi(j),"Site"))); println("Sz_",j," = ",Szj); }