예제 #1
0
def test_eig_raises():
    np.random.seed(10)
    num_charges = 1
    D = 20
    R = 3
    charges = [
        BaseCharge(np.random.randint(-5, 6, (num_charges, D), dtype=np.int16),
                   charge_types=[U1Charge] * num_charges) for n in range(R)
    ]
    flows = [False] * R
    inds = [Index(charges[n], flows[n]) for n in range(R)]
    A = BlockSparseTensor.random(inds)
    with pytest.raises(NotImplementedError):
        eig(A)
예제 #2
0
def test_eig_prod(dtype, Ds, num_charges):
  np.random.seed(10)
  R = len(Ds)
  charges = [
      BaseCharge(
          np.random.randint(-5, 6, (num_charges, Ds[n]), dtype=np.int16),
          charge_types=[U1Charge] * num_charges) for n in range(R)
  ]
  flows = [False] * R
  inds = [Index(charges[n], flows[n]) for n in range(R)]

  A = BlockSparseTensor.random(
      inds + [i.copy().flip_flow() for i in inds], dtype=dtype)
  dims = np.prod(Ds)
  A = A.reshape([dims, dims])
  E, V = eig(A)
  A_ = V @ diag(E) @ inv(V)
  np.testing.assert_allclose(A.data, A_.data)