示例#1
0
 def test_custom_tolerance_broadcasts(self):
     q = linalg.qr(random_ops.random_uniform([3, 3], dtype=self.dtype))[0]
     e = constant_op.constant([0.1, 0.2, 0.3], dtype=self.dtype)
     a = linalg.solve(q, linalg.transpose(a=e * q), adjoint=True)
     self.assertAllEqual([3, 2, 1, 0],
                         self.evaluate(
                             linalg.matrix_rank(a,
                                                tol=[[0.09], [0.19], [0.29],
                                                     [0.31]])))
示例#2
0
 def test_nonsquare(self):
     x_ = np.array(
         [
             [
                 [2, 3, -2, 2],  # = row2+row3
                 [-1, 1, -2, 4],
                 [3, 2, 0, -2]
             ],
             [
                 [0, 2, 0, 6],  # = 2*row2
                 [0, 1, 0, 3],
                 [0, 3, 0, 9]
             ]
         ],  # = 3*row2
         self.dtype)
     x = array_ops.placeholder_with_default(
         x_, shape=x_.shape if self.use_static_shape else None)
     self.assertAllEqual([2, 1], self.evaluate(linalg.matrix_rank(x)))
示例#3
0
# In[234]:

a1 | b1

# In[237]:

linalg.inv(e)

# In[253]:

linalg.pinv(e)

# In[238]:

linalg.matrix_rank(e)

# In[249]:

a = array([[1, 5], [2, 2]])
b = array([[3], [5]])
linalg.solve(a, b)

# In[257]:

U, S, Vh = linalg.svd(a)
V = Vh.T
print(U, S, Vh, V)

# In[272]:
示例#4
0
文件: mm_math.py 项目: queid7/hma
def matrix_rank(mat):
    return linalg.matrix_rank(mat)