grid_concat

tenpy.linalg.np_conserved.grid_concat(grid, axes, copy=True)[source]

Given an np.array of npc.Arrays, performs a multi-dimensional concatenation along ‘axes’.

Similar to numpy.block(), but only for uniform blocking.

Stacks the qind of the array, without sorting/blocking.

Parameters:
  • grid (array_like of Array) – The grid of arrays.

  • axes (list of int) – The axes along which to concatenate the arrays, same len as the dimension of the grid. Concatenate arrays of the i`th axis of the grid along the axis ``axes[i]`

  • copy (bool) – Whether the _data blocks are copied.

Examples

Assume we have prepared rank 2 Arrays A, B, C, D sharing the legs of equal sizes and looking like this:

>>> print(A.to_ndarray())
[[0 1]]
>>> print(B.to_ndarray())
[[10 11 12 13]]
>>> print(C.to_ndarray())
[[20 21]
 [22 23]
 [24 25]]
>>> print(D.to_ndarray())
[[30 31 32 33]
 [34 35 36 37]
 [38 39 40 41]]

Then the following grid will result in a (1+3, 2+4) shaped array:

>>> g = npc.grid_concat([[A, B],
...                      [C, D]], axes=[0, 1])
>>> g.shape
(4, 6)
>>> print(g.to_ndarray())
[[ 0  1 10 11 12 13]
 [20 21 30 31 32 33]
 [22 23 34 35 36 37]
 [24 25 38 39 40 41]]

If A, B, C, D were rank 4 arrays, with the first and last leg as before, and sharing common legs 1 and 2 of dimensions 1, 2, then you would get a rank-4 array:

>>> g = grid_concat([[A, B], [C, D]], axes=[0, 3])
>>> g.shape
(4, 1, 2, 6)

See also

Array.sort_legcharge

can be used to block by charges.