コード例 #1
0
 def rq(
     self,
     tensor: Tensor,
     pivot_axis: int = -1,
     non_negative_diagonal: bool = False
 ) -> Tuple[Tensor, Tensor]:
   return decompositions.rq(jnp, tensor, pivot_axis, non_negative_diagonal)
コード例 #2
0
 def rq(
     self,
     tensor: Tensor,
     pivot_axis: int = -1,
     non_negative_diagonal: bool = False
 ) -> Tuple[Tensor, Tensor]:
   #pylint: disable=too-many-function-args
   return decompositions.rq(np, tensor, pivot_axis, non_negative_diagonal)
コード例 #3
0
def test_rq(dtype, R, R1, num_charges):
    np.random.seed(10)
    D = 30
    charges = [
        BaseCharge(np.random.randint(-5, 6, (D, num_charges)),
                   charge_types=[U1Charge] * num_charges) for n in range(R)
    ]

    flows = [True] * R
    A = BlockSparseTensor.random(
        [Index(charges[n], flows[n]) for n in range(R)], dtype=dtype)

    r, q = decompositions.rq(bs, A, R1)
    res = bs.tensordot(r, q, 1)
    r_dense, q_dense = np_decompositions.rq(np, A.todense(), R1, False)
    res2 = np.tensordot(r_dense, q_dense, 1)
    np.testing.assert_almost_equal(res.todense(), res2)
コード例 #4
0
 def test_rq(self):
     random_matrix = np.random.rand(10, 10)
     for non_negative_diagonal in [True, False]:
         r, q = decompositions.rq(np, random_matrix, 1,
                                  non_negative_diagonal)
         self.assertAllClose(r.dot(q), random_matrix)
コード例 #5
0
 def test_expected_shapes_rq(self):
     val = np.zeros((2, 3, 4, 5))
     r, q = decompositions.rq(np, val, 2, False)
     self.assertEqual(r.shape, (2, 3, 6))
     self.assertEqual(q.shape, (6, 4, 5))