MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _matrix_exp_pade9

Function _matrix_exp_pade9

tensorflow/python/ops/linalg/linalg_impl.py:180–202  ·  view source on GitHub ↗

9th-order Pade approximant for matrix exponential.

(matrix)

Source from the content-addressed store, hash-verified

178
179
180def _matrix_exp_pade9(matrix):
181 """9th-order Pade approximant for matrix exponential."""
182 b = [
183 17643225600.0, 8821612800.0, 2075673600.0, 302702400.0, 30270240.0,
184 2162160.0, 110880.0, 3960.0, 90.0
185 ]
186 b = [constant_op.constant(x, matrix.dtype) for x in b]
187 ident = linalg_ops.eye(
188 array_ops.shape(matrix)[-2],
189 batch_shape=array_ops.shape(matrix)[:-2],
190 dtype=matrix.dtype)
191 matrix_2 = math_ops.matmul(matrix, matrix)
192 matrix_4 = math_ops.matmul(matrix_2, matrix_2)
193 matrix_6 = math_ops.matmul(matrix_4, matrix_2)
194 matrix_8 = math_ops.matmul(matrix_6, matrix_2)
195 tmp = (
196 matrix_8 + b[7] * matrix_6 + b[5] * matrix_4 + b[3] * matrix_2 +
197 b[1] * ident)
198 matrix_u = math_ops.matmul(matrix, tmp)
199 matrix_v = (
200 b[8] * matrix_8 + b[6] * matrix_6 + b[4] * matrix_4 + b[2] * matrix_2 +
201 b[0] * ident)
202 return matrix_u, matrix_v
203
204
205def _matrix_exp_pade13(matrix):

Callers 1

matrix_exponentialFunction · 0.85

Calls 3

constantMethod · 0.45
shapeMethod · 0.45
matmulMethod · 0.45

Tested by

no test coverage detected