Construct a C++ LinOp corresponding to LinPy. Children of linPy are retrieved from linPy_to_linC.
(linPy, linPy_to_linC)
| 158 | |
| 159 | |
| 160 | def make_linC_from_linPy(linPy, linPy_to_linC) -> None: |
| 161 | """Construct a C++ LinOp corresponding to LinPy. |
| 162 | |
| 163 | Children of linPy are retrieved from linPy_to_linC. |
| 164 | """ |
| 165 | |
| 166 | if linPy in linPy_to_linC: |
| 167 | return |
| 168 | typ = get_type(linPy) |
| 169 | shape = cvxcore.IntVector() |
| 170 | lin_args_vec = cvxcore.ConstLinOpVector() |
| 171 | for dim in linPy.shape: |
| 172 | shape.push_back(int(dim)) |
| 173 | for argPy in linPy.args: |
| 174 | lin_args_vec.push_back(linPy_to_linC[argPy]) |
| 175 | linC = cvxcore.LinOp(typ, shape, lin_args_vec) |
| 176 | linPy_to_linC[linPy] = linC |
| 177 | # Note: added special case for sum_entries, since it has a data field |
| 178 | # that doesn't need to get converted to actual data. |
| 179 | # same thing for transpose, where the data field can potentially be the axes. |
| 180 | if linPy.data is not None and linPy.type not in ["sum_entries", "transpose"]: |
| 181 | if isinstance(linPy.data, lo.LinOp): |
| 182 | linC_data = linPy_to_linC[linPy.data] |
| 183 | linC.set_linOp_data(linC_data) |
| 184 | linC.set_data_ndim(len(linPy.data.shape)) |
| 185 | else: |
| 186 | set_linC_data(linC, linPy) |
| 187 | |
| 188 | |
| 189 | def set_slice_data(linC, linPy) -> None: |
no test coverage detected