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

Function _matrix_exp_pade13

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

13th-order Pade approximant for matrix exponential.

(matrix)

Source from the content-addressed store, hash-verified

203
204
205def _matrix_exp_pade13(matrix):
206 """13th-order Pade approximant for matrix exponential."""
207 b = [
208 64764752532480000.0, 32382376266240000.0, 7771770303897600.0,
209 1187353796428800.0, 129060195264000.0, 10559470521600.0, 670442572800.0,
210 33522128640.0, 1323241920.0, 40840800.0, 960960.0, 16380.0, 182.0
211 ]
212 b = [constant_op.constant(x, matrix.dtype) for x in b]
213 ident = linalg_ops.eye(
214 array_ops.shape(matrix)[-2],
215 batch_shape=array_ops.shape(matrix)[:-2],
216 dtype=matrix.dtype)
217 matrix_2 = math_ops.matmul(matrix, matrix)
218 matrix_4 = math_ops.matmul(matrix_2, matrix_2)
219 matrix_6 = math_ops.matmul(matrix_4, matrix_2)
220 tmp_u = (
221 math_ops.matmul(matrix_6, matrix_6 + b[11] * matrix_4 + b[9] * matrix_2) +
222 b[7] * matrix_6 + b[5] * matrix_4 + b[3] * matrix_2 + b[1] * ident)
223 matrix_u = math_ops.matmul(matrix, tmp_u)
224 tmp_v = b[12] * matrix_6 + b[10] * matrix_4 + b[8] * matrix_2
225 matrix_v = (
226 math_ops.matmul(matrix_6, tmp_v) + b[6] * matrix_6 + b[4] * matrix_4 +
227 b[2] * matrix_2 + b[0] * ident)
228 return matrix_u, matrix_v
229
230
231@tf_export('linalg.expm')

Callers 1

matrix_exponentialFunction · 0.85

Calls 3

constantMethod · 0.45
shapeMethod · 0.45
matmulMethod · 0.45

Tested by

no test coverage detected