Comments (6)
Good question. The way this is handled in the Julia version right now is:
using ITensors
s = siteinds("S=1/2", 4)
T = randomITensor(QN("Sz", 1), s...)
@assert store(T) isa NDTensors.BlockSparse
@assert iszero(nnzblocks(T))
@assert isnothing(flux(T))
so it handles it in a similar way (makes an ITensor with no blocks), however for that case flux
returns nothing
.
Perhaps trying to make that ITensor should error (or at least give a warning), since likely it is a mistake to try to make it in the first place. At least in Julia, the "correct" way to make an ITensor with no blocks is:
T = emptyITensor(s...)
@assert store(T) isa NDTensors.Empty
but I forget if there is an equivalent thing in the C++ version.
On a related note, to explicitly make an ITensor with zero blocks but with an actual BlockSparse
storage (instead of Empty
storage), I was considering a notation like:
T = ITensor(Block[], s...)
which would generalize to being able to specify a list of flux-consistent nonzero blocks, i.e.:
T = ITensor([Block(2, 2, 1, 1), Block(1, 1, 2, 2)], s...)
from itensor.
So I would lean towards it being an error to try to make the tensor randomITensor(QN("Sz", 1), s...)
in the first place, since probably it is a mistake to do that and if you want an ITensor with empty blocks, you should use a different constructor.
from itensor.
I agree. There is the small issue that randomITensor
works by calling a specific, fairly general-purpose QDense
constructor so it could interfere with other functions that call that constructor and rely on it to just silently create a QDense with no blocks. But I think we'll just have to run the tests we have and if those pass then assume it's not breaking any other code and/or wait for a user to raise an issue if it errors in theirs.
from itensor.
Yeah. I think in terms of it being a breaking change, I would say that right now it is ill-defined behavior so it is ok to break it. We can also have the error message point users to the "correct" way to make a QN ITensor with no blocks (so in Julia, emptyITensor
, and in C++, I guess the plain ITensor
constructor with no QNs specified?).
from itensor.
Oh I see what you are saying. I guess it depends on where we implement it. We could just implement this at the level of randomITensor
and ITensor
(where we just run the QDense
constructor, and if it ends up with no blocks then we throw an error), as opposed to actually in the QDense
constructor itself.
from itensor.
Ok that's the right solution of course!
from itensor.
Related Issues (20)
- range1 not working like python HOT 2
- (no)prime not working appropriately with <keyword arguments> HOT 1
- Add stracktraces to error messages
- configure/cmake HOT 3
- Introduce `apply` and `contract` MPS/MPO functions
- extract dense ITensor storage HOT 4
- .position() of MPS does not preserve the link index of the MPS HOT 1
- Typo in sample/Makefile
- subscript out of range in itensor/util/autovector.h HOT 2
- Reading input from a .tns file HOT 2
- Two issues in installing ITensor c++ on Windows HOT 10
- fatal error: itensor/config.h: No such file or directory HOT 3
- Performing multiple HDF5 operations "captures" cout,cerr HOT 9
- compile error when using OpenBLAS in Ubuntu 22.04 HOT 1
- Losing QN information when reading from HDF5 HOT 1
- Bug: unexpected returning order of indexes HOT 3
- Unexpected behaviour: elt(T) doesn't raise out-of range error HOT 5
- Failure to compile with gcc-13: call of overloaded 'format(..)' is ambiguous HOT 2
- Fixing a bug in Unitttest SECTION("arnoldi (multiple eigenvectors)") HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from itensor.