Skip to content

Conversation

@mtfishman
Copy link
Member

This enables more compact printing of ITensors, such as:

using ITensors: Index, random_itensor
d = 100
i, j = Index.((d, d))
a = random_itensor(i, j)
julia> show(a)
ITensor ord=2
Dim 1: (dim=100|id=386)
Dim 2: (dim=100|id=806)
NDTensors.Dense{Float64, Vector{Float64}}
 100×100
  1.1065511218675492    0.25558343779457593    -0.7563918255048953
 -0.19087995131196725   0.10936665763661539     -0.9511317856005679
 -0.1339119679780238   -0.9824888504596919      -0.8297798433753355
 -0.3380376950048613   -0.22502109940735232      1.238562637784077
                                              
  0.569878151816781     0.9722889212769971       0.15625262885769123
 -0.6617584401784992    1.1133126735067624       1.1441043736020045
 -1.2613730025434786   -0.3896145241325943       0.5647941511581129

which is achieved by setting limit = true when printing the tensor data as an array (see https://docs.julialang.org/en/v1/base/io-network/#Base.IOContext-Tuple{IO,%20Pair}).

Previously, all of the elements of the tensor were being printing, which filled the screen with output for larger tensors. This was an issue I came across in the ITensor CCQ school.

@mtfishman
Copy link
Member Author

In the latest I also made some printing of ITensors from within arrays more compact by just printing the indices in those cases:

julia> [a a; a a]
2×2 Matrix{ITensor}:
 ((dim=100|id=386), (dim=100|id=806))    ((dim=100|id=386), (dim=100|id=806))
 ((dim=100|id=386), (dim=100|id=806))     ((dim=100|id=386), (dim=100|id=806))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants