## Introduction

#### Clone via github.

(this is the preferred method—see our git quickstart guide.)

Or download latest

version v1.1.1
(changelog)

ITensor—Intelligent Tensor—is a C++ library for implementing tensor product wavefunction calculations.
It is efficient and flexible enough to be used for research-grade simulations.

Features include:

- A complete DMRG code
- Efficient matrix product state class
- Quantum number conserving tensors
- Complex numbers (handled lazily: no efficiency loss if real)
- Easy install: only dependencies are BLAS/Lapack and C++11

## Recent News

- ITensor 1.1 (May 2015)
- Article: Should you use Periodic Boundary Conditions in DMRG?
- ITensor at 2014 Sherbrooke Summer School

ITensors are nearly as easy to multiply as scalars: all tensors indices are stamped with a unique internal id number; matching indices automatically contract when two ITensors are multiplied, making it simple to transcribe tensor network diagrams into correct, efficient code.

For example, the diagram below (resembling the partial overlap of two matrix product states) can be converted to code as

**Installing ITensor:**

- Clone the latest version:

Or download 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 quickstart guide.) - Read the installation instructions.
- Learn more from the documentation.

## Code Samples

## Perform a DMRG Calculation

int N = 100;
//Define Hilbert space of N=100 spin-lattice sites
SpinOne sites(N);
//Create 1d Heisenberg Hamiltonian
AutoMPO ampo(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 = MPO(ampo);
//Set up random initial wavefunction
MPS psi(sites);
//Perform 5 sweeps of DMRG
Sweeps sweeps(5);
//Specify max number of states kept each sweep
sweeps.maxm() = 50, 50, 100, 100, 200;
//Run the DMRG algorithm
dmrg(psi,H,sweeps);
//Continue to analyze wavefunction afterward
Real energy = psiHphi(psi,H,psi);
for(int j = 1; j <= N; ++j)
{
//make site j the MPS "orthogonality center"
psi.position(j);
//Measure magnetization
Real Szj = toReal(psi.A(j)
* sites.op("Sz",j)
* dag(prime(psi.A(j),Site)));
println("Sz_",j," = ",Szj);
}

## Multiply Two ITensors

Index a("a",2), b("b",2), c("c",2); ITensor Z(a,b), X(c,b); commaInit(Z,a,b) = 1, 0, 0,-1; commaInit(X,b,c) = 0, 1, 1, 0; //the * operator finds and //contracts common index 'b' //regardless of index order: ITensor R = Z * X; Print( R(a(1),c(2)) ); //Prints: R(a(1),c(2)) = 1 Print( R(a(2),c(1)) ); //Prints: R(a(1),c(2)) = -1