MCPcopy Create free account
hub / github.com/cvxpy/cvxpy / build_lin_op_tree

Function build_lin_op_tree

cvxpy/cvxcore/python/cppbackend.py:204–227  ·  view source on GitHub ↗

Construct C++ LinOp tree from Python LinOp tree. Constructed C++ linOps are stored in the linPy_to_linC dict, which maps Python linOps to their corresponding C++ linOps. Parameters ---------- linPy_to_linC: a dict for memoizing construction and storing the C++ L

(root_linPy, linPy_to_linC)

Source from the content-addressed store, hash-verified

202
203
204def build_lin_op_tree(root_linPy, linPy_to_linC) -> None:
205 """Construct C++ LinOp tree from Python LinOp tree.
206
207 Constructed C++ linOps are stored in the linPy_to_linC dict,
208 which maps Python linOps to their corresponding C++ linOps.
209
210 Parameters
211 ----------
212 linPy_to_linC: a dict for memoizing construction and storing
213 the C++ LinOps
214 """
215 bfs_stack = [root_linPy]
216 post_order_stack = []
217 while bfs_stack:
218 linPy = bfs_stack.pop()
219 if linPy not in linPy_to_linC:
220 post_order_stack.append(linPy)
221 for arg in linPy.args:
222 bfs_stack.append(arg)
223 if isinstance(linPy.data, lo.LinOp):
224 bfs_stack.append(linPy.data)
225 while post_order_stack:
226 linPy = post_order_stack.pop()
227 make_linC_from_linPy(linPy, linPy_to_linC)
228
229
230def set_matrix_data(linC, linPy) -> None:

Callers 1

build_matrixFunction · 0.85

Calls 3

make_linC_from_linPyFunction · 0.85
popMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected