MCPcopy Create free account
hub / github.com/davisking/dlib / bind_other

Function bind_other

tools/python/src/other.cpp:136–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134// ----------------------------------------------------------------------------------------
135
136void bind_other(py::module &m)
137{
138 m.def("max_cost_assignment", _max_cost_assignment, py::arg("cost"),
139"requires \n\
140 - cost.nr() == cost.nc() \n\
141 (i.e. the input must be a square matrix) \n\
142ensures \n\
143 - Finds and returns the solution to the following optimization problem: \n\
144 \n\
145 Maximize: f(A) == assignment_cost(cost, A) \n\
146 Subject to the following constraints: \n\
147 - The elements of A are unique. That is, there aren't any \n\
148 elements of A which are equal. \n\
149 - len(A) == cost.nr() \n\
150 \n\
151 - Note that this function converts the input cost matrix into a 64bit fixed \n\
152 point representation. Therefore, you should make sure that the values in \n\
153 your cost matrix can be accurately represented by 64bit fixed point values. \n\
154 If this is not the case then the solution my become inaccurate due to \n\
155 rounding error. In general, this function will work properly when the ratio \n\
156 of the largest to the smallest value in cost is no more than about 1e16. "
157 );
158
159 m.def("assignment_cost", _assignment_cost, py::arg("cost"),py::arg("assignment"),
160"requires \n\
161 - cost.nr() == cost.nc() \n\
162 (i.e. the input must be a square matrix) \n\
163 - for all valid i: \n\
164 - 0 <= assignment[i] < cost.nr() \n\
165ensures \n\
166 - Interprets cost as a cost assignment matrix. That is, cost[i][j] \n\
167 represents the cost of assigning i to j. \n\
168 - Interprets assignment as a particular set of assignments. That is, \n\
169 i is assigned to assignment[i]. \n\
170 - returns the cost of the given assignment. That is, returns \n\
171 a number which is: \n\
172 sum over i: cost[i][assignment[i]] "
173 );
174
175 m.def("make_sparse_vector", _make_sparse_vector ,
176"This function modifies its argument so that it is a properly sorted sparse vector. \n\
177This means that the elements of the sparse vector will be ordered so that pairs \n\
178with smaller indices come first. Additionally, there won't be any pairs with \n\
179identical indices. If such pairs were present in the input sparse vector then \n\
180their values will be added together and only one pair with their index will be \n\
181present in the output. "
182 );
183 m.def("make_sparse_vector", _make_sparse_vector2 ,
184 "This function modifies a sparse_vectors object so that all elements it contains are properly sorted sparse vectors.");
185
186 m.def("load_libsvm_formatted_data",_load_libsvm_formatted_data, py::arg("file_name"),
187"ensures \n\
188 - Attempts to read a file of the given name that should contain libsvm \n\
189 formatted data. The data is returned as a tuple where the first tuple \n\
190 element is an array of sparse vectors and the second element is an array of \n\
191 labels. "
192 );
193

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 3

pickleFunction · 0.85
argClass · 0.50

Tested by

no test coverage detected