3rd-order Pade approximant for matrix exponential.
(matrix)
| 130 | # This section is ported nearly verbatim from Eigen's implementation: |
| 131 | # https://eigen.tuxfamily.org/dox/unsupported/MatrixExponential_8h_source.html |
| 132 | def _matrix_exp_pade3(matrix): |
| 133 | """3rd-order Pade approximant for matrix exponential.""" |
| 134 | b = [120.0, 60.0, 12.0] |
| 135 | b = [constant_op.constant(x, matrix.dtype) for x in b] |
| 136 | ident = linalg_ops.eye( |
| 137 | array_ops.shape(matrix)[-2], |
| 138 | batch_shape=array_ops.shape(matrix)[:-2], |
| 139 | dtype=matrix.dtype) |
| 140 | matrix_2 = math_ops.matmul(matrix, matrix) |
| 141 | tmp = matrix_2 + b[1] * ident |
| 142 | matrix_u = math_ops.matmul(matrix, tmp) |
| 143 | matrix_v = b[2] * matrix_2 + b[0] * ident |
| 144 | return matrix_u, matrix_v |
| 145 | |
| 146 | |
| 147 | def _matrix_exp_pade5(matrix): |
no test coverage detected