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

Function cholesky_solve

tensorflow/python/ops/linalg_ops.py:85–124  ·  view source on GitHub ↗

Solves systems of linear eqns `A X = RHS`, given Cholesky factorizations. ```python # Solve 10 separate 2x2 linear systems: A = ... # shape 10 x 2 x 2 RHS = ... # shape 10 x 2 x 1 chol = tf.linalg.cholesky(A) # shape 10 x 2 x 2 X = tf.linalg.cholesky_solve(chol, RHS) # shape 10 x 2 x

(chol, rhs, name=None)

Source from the content-addressed store, hash-verified

83 'linalg.cholesky_solve', v1=['linalg.cholesky_solve', 'cholesky_solve'])
84@deprecation.deprecated_endpoints('cholesky_solve')
85def cholesky_solve(chol, rhs, name=None):
86 """Solves systems of linear eqns `A X = RHS`, given Cholesky factorizations.
87
88 ```python
89 # Solve 10 separate 2x2 linear systems:
90 A = ... # shape 10 x 2 x 2
91 RHS = ... # shape 10 x 2 x 1
92 chol = tf.linalg.cholesky(A) # shape 10 x 2 x 2
93 X = tf.linalg.cholesky_solve(chol, RHS) # shape 10 x 2 x 1
94 # tf.matmul(A, X) ~ RHS
95 X[3, :, 0] # Solution to the linear system A[3, :, :] x = RHS[3, :, 0]
96
97 # Solve five linear systems (K = 5) for every member of the length 10 batch.
98 A = ... # shape 10 x 2 x 2
99 RHS = ... # shape 10 x 2 x 5
100 ...
101 X[3, :, 2] # Solution to the linear system A[3, :, :] x = RHS[3, :, 2]
102 ```
103
104 Args:
105 chol: A `Tensor`. Must be `float32` or `float64`, shape is `[..., M, M]`.
106 Cholesky factorization of `A`, e.g. `chol = tf.linalg.cholesky(A)`.
107 For that reason, only the lower triangular parts (including the diagonal)
108 of the last two dimensions of `chol` are used. The strictly upper part is
109 assumed to be zero and not accessed.
110 rhs: A `Tensor`, same type as `chol`, shape is `[..., M, K]`.
111 name: A name to give this `Op`. Defaults to `cholesky_solve`.
112
113 Returns:
114 Solution to `A x = rhs`, shape `[..., M, K]`.
115 """
116 # To solve C C^* x = rhs, we
117 # 1. Solve C y = rhs for y, thus y = C^* x
118 # 2. Solve C^* x = y for x
119 with ops.name_scope(name, 'cholesky_solve', [chol, rhs]):
120 y = gen_linalg_ops.matrix_triangular_solve(
121 chol, rhs, adjoint=False, lower=True)
122 x = gen_linalg_ops.matrix_triangular_solve(
123 chol, y, adjoint=True, lower=True)
124 return x
125
126
127@tf_export('eye', 'linalg.eye')

Callers 2

_overdeterminedFunction · 0.85
_underdeterminedFunction · 0.85

Calls 1

name_scopeMethod · 0.45

Tested by

no test coverage detected