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

Function make_linC_from_linPy

cvxpy/cvxcore/python/cppbackend.py:160–186  ·  view source on GitHub ↗

Construct a C++ LinOp corresponding to LinPy. Children of linPy are retrieved from linPy_to_linC.

(linPy, linPy_to_linC)

Source from the content-addressed store, hash-verified

158
159
160def 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
189def set_slice_data(linC, linPy) -> None:

Callers 1

build_lin_op_treeFunction · 0.85

Calls 7

push_backMethod · 0.95
push_backMethod · 0.95
set_linOp_dataMethod · 0.95
set_data_ndimMethod · 0.95
get_typeFunction · 0.85
set_linC_dataFunction · 0.85
LinOpMethod · 0.80

Tested by

no test coverage detected