Cytnx icon indicating copy to clipboard operation
Cytnx copied to clipboard

get_block(blockindex) should drop an error if blockindex != 0 for non-symmetric tensors

Open manuschneider opened this issue 2 years ago • 3 comments

Blocks can be access with get_block(blockindex). This works for symmetric as well as for non-symmetric UniTensors. For the latter, the blockindex is not needed. But it can still be specified and is currently simply ignored. If a blockindex != 0 is given, the user seems to assume a block form, which is wrong.

I would suggest that there is a check: for a UniTensor which is not in block form, blockindex has to be either 0 or omitted. Otherwise there should be an error.

Python Example:

Create an UniTensor from Tensor

T = cytnx.UniTensor(cytnx.ones([3,3])) print(T.get_block(2))

Should produce something like: [ERROR] Trying to access a block with blockindex != 0 on a UniTensor without block form!

manuschneider avatar Jun 26 '23 10:06 manuschneider

This will add overhead to get_block though... Maybe just state clearly in user-guide?

kaihsin avatar Jul 04 '23 11:07 kaihsin

How about implementing the relevant functions get_block(_) in SparseUniTensor and BlockUniTensor only, instead of providing it for all UniTensor? This seems to be a cleaner structure to me, since not all UniTensors have blocks, so functionality concerning blocks should only be provided in the relevant subclasses.

manuschneider avatar Aug 07 '23 07:08 manuschneider

Let's just let it popping error on DenseUT then.

kaihsin avatar Aug 07 '23 12:08 kaihsin