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)
| 202 | |
| 203 | |
| 204 | def 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 | |
| 230 | def set_matrix_data(linC, linPy) -> None: |
no test coverage detected