def attach_pogs_common_ccalls(lib, single_precision=False): if not 'vector_p' in lib.__dict__: attach_dense_linsys_ctypes(lib, single_precision) if not 'function_vector_p' in lib.__dict__: attach_prox_ctypes(lib, single_precision) if not 'pogs_variables_p' in lib.__dict__: attach_pogs_common_ctypes(lib, single_precision) ok_float = lib.ok_float ok_float_p = lib.ok_float_p vector_p = lib.vector_p function_vector_p = lib.function_vector_p pogs_output_p = lib.pogs_output_p pogs_info_p = lib.pogs_info_p pogs_settings_p = lib.pogs_settings_p adapt_params_p = lib.adapt_params_p block_vector_p = lib.block_vector_p pogs_residuals_p = lib.pogs_residuals_p pogs_tolerances = lib.pogs_tolerances pogs_tolerances_p = lib.pogs_tolerances_p pogs_objectives_p = lib.pogs_objectives_p pogs_variables_p = lib.pogs_variables_p lib.set_default_settings.argtypes = [pogs_settings_p] lib.set_default_settings.restype = c_uint # Private API if lib.full_api_accessible: ## argtypes lib.initialize_conditions.argtypes = [pogs_objectives_p, pogs_residuals_p, pogs_tolerances_p, pogs_settings_p, c_size_t, c_size_t] lib.set_prev.argtypes = [pogs_variables_p] lib.prox.argtypes = [c_void_p, function_vector_p, function_vector_p, pogs_variables_p, ok_float] lib.update_dual.argtypes = [c_void_p, pogs_variables_p, ok_float] lib.adaptrho.argtypes = [pogs_variables_p, pogs_settings_p, ok_float_p, adapt_params_p, pogs_residuals_p, pogs_tolerances_p, c_uint] lib.copy_output.argtypes = [pogs_output_p, pogs_variables_p, vector_p, vector_p, ok_float, c_uint] ## results lib.initialize_conditions.restype = c_uint lib.set_prev.restype = c_uint lib.prox.restype = c_uint lib.update_dual.restype = c_uint lib.adaptrho.restype = c_uint lib.copy_output.restype = c_uint else: lib.initialize_conditions = AttributeError() lib.set_prev = AttributeError() lib.prox = AttributeError() lib.update_dual = AttributeError() lib.adaptrho = AttributeError() lib.copy_output = AttributeError()
def attach_pogs_abstract_ctypes(lib, single_precision=False): if not 'vector_p' in lib.__dict__: attach_dense_linsys_ctypes(lib, single_precision) if not 'function_vector_p' in lib.__dict__: attach_prox_ctypes(lib, single_precision) if not 'operator_p' in lib.__dict__: attach_operator_ctypes(lib, single_precision) if not 'projector_p' in lib.__dict__: attach_projector_ctypes(lib, single_precision) if not 'pogs_settings_p' in lib.__dict__: attach_pogs_common_ctypes(lib, single_precision) ok_float = lib.ok_float vector_p = lib.vector_p function_vector_p = lib.function_vector_p operator_p = lib.operator_p projector_p = lib.projector_p pogs_settings_p = lib.pogs_settings_p pogs_variables_p = lib.pogs_variables_p # lib properties lib.private_api_accessible.restype = c_int lib.full_api_accessible = lib.private_api_accessible() class PogsWork(Structure): _fields_ = [('A', operator_p), ('P', projector_p), ('d', vector_p), ('e', vector_p), ('operator_scale', CFUNCTYPE(c_uint, operator_p, ok_float)), ('operator_equilibrate', CFUNCTYPE(c_uint, c_void_p, operator_p, vector_p, vector_p, ok_float)), ('normA', ok_float), ('skinny', c_int), ('normalized', c_int), ('equilibrated', c_int)] lib.pogs_work = PogsWork lib.pogs_work_p = POINTER(lib.pogs_work) class PogsSolver(Structure): _fields_ = [('W', lib.pogs_work_p), ('z', pogs_variables_p), ('f', function_vector_p), ('g', function_vector_p), ('rho', ok_float), ('settings', pogs_settings_p), ('linalg_handle', c_void_p), ('init_time', ok_float)] lib.pogs_solver = PogsSolver lib.pogs_solver_p = POINTER(lib.pogs_solver)
def attach_pogs_ctypes(lib, single_precision=False): if not 'matrix_p' in lib.__dict__: attach_dense_linsys_ctypes(lib, single_precision) if not 'function_vector_p' in lib.__dict__: attach_prox_ctypes(lib, single_precision) if not 'pogs_settings_p' in lib.__dict__: print("HERE") attach_pogs_common_ctypes(lib, single_precision) ok_float = lib.ok_float vector_p = lib.vector_p matrix_p = lib.matrix_p function_vector_p = lib.function_vector_p pogs_settings_p = lib.pogs_settings_p pogs_variables_p = lib.pogs_variables_p # lib properties full_api_accessible = lib.full_api_accessible lib.is_direct.restype = c_int lib.direct = lib.is_direct() class PogsMatrix(Structure): _fields_ = [('A', matrix_p), ('P', c_void_p), ('d', vector_p), ('e', vector_p), ('normA', ok_float), ('skinny', c_int), ('normalized', c_int), ('equilibrated', c_int)] lib.pogs_matrix = PogsMatrix lib.pogs_matrix_p = POINTER(lib.pogs_matrix) pogs_matrix_p = lib.pogs_matrix_p class PogsSolver(Structure): _fields_ = [('M', pogs_matrix_p), ('z', pogs_variables_p), ('f', function_vector_p), ('g', function_vector_p), ('rho', ok_float), ('settings', pogs_settings_p), ('linalg_handle', c_void_p), ('init_time', ok_float)] lib.pogs_solver = PogsSolver lib.pogs_solver_p = POINTER(lib.pogs_solver)
def attach_pogs_ccalls(lib, single_precision=False): if not 'vector_p' in lib.__dict__: attach_dense_linsys_ctypes(lib, single_precision) if not 'function_vector_p' in lib.__dict__: attach_prox_ctypes(lib, single_precision) if not 'pogs_solver_p' in lib.__dict__: attach_pogs_ctypes(lib, single_precision) ok_float = lib.ok_float ok_float_p = lib.ok_float_p vector_p = lib.vector_p function_vector_p = lib.function_vector_p pogs_output_p = lib.pogs_output_p pogs_info_p = lib.pogs_info_p pogs_settings_p = lib.pogs_settings_p adapt_params_p = lib.adapt_params_p block_vector_p = lib.block_vector_p pogs_residuals_p = lib.pogs_residuals_p pogs_tolerances = lib.pogs_tolerances pogs_tolerances_p = lib.pogs_tolerances_p pogs_objectives_p = lib.pogs_objectives_p pogs_matrix_p = lib.pogs_matrix_p pogs_variables_p = lib.pogs_variables_p pogs_solver_p = lib.pogs_solver_p ## arguments lib.pogs_init.argtypes = [ok_float_p, c_size_t, c_size_t, c_uint] lib.pogs_solve.argtypes = [c_void_p, function_vector_p, function_vector_p, pogs_settings_p, pogs_info_p, pogs_output_p] lib.pogs_finish.argtypes = [c_void_p, c_int] lib.pogs.argtypes = [ok_float_p, function_vector_p, function_vector_p, pogs_settings_p, pogs_info_p, pogs_output_p, c_uint, c_int] lib.pogs_load_solver.argtypes = [ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float, c_size_t, c_size_t, c_uint] lib.pogs_extract_solver.argtypes = [c_void_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, ok_float_p, c_uint] ## return types lib.pogs_init.restype = pogs_solver_p lib.pogs_solve.restype = c_uint lib.pogs_finish.restype = c_uint lib.pogs.restype = c_uint lib.pogs_load_solver.restype = pogs_solver_p lib.pogs_extract_solver.restype = c_uint # Private API if lib.full_api_accessible: ## argtypes lib.update_problem.argtypes = [pogs_solver_p, function_vector_p, function_vector_p] lib.initialize_variables.argtypes = [pogs_solver_p] lib.pogs_solver_loop.argtypes = [pogs_solver_p, pogs_info_p] lib.project_primal.argtypes = [c_void_p, c_void_p, pogs_variables_p, ok_float] lib.check_convergence.argtypes = [c_void_p, pogs_solver_p, pogs_objectives_p, pogs_residuals_p, pogs_tolerances_p] ## results lib.update_problem.restype = c_uint lib.initialize_variables.restype = c_uint lib.pogs_solver_loop.restype = c_uint lib.project_primal.restype = c_uint lib.check_convergence.restype = c_int proj_argtypes = [c_void_p, c_void_p, vector_p, vector_p, vector_p, vector_p] proj_restype = c_uint if lib.direct: lib.direct_projector_project.argtypes = proj_argtypes lib.direct_projector_project.restype = proj_restype else: lib.indirect_projector_project.argtypes = proj_argtypes lib.indirect_projector_project.restype = proj_restype else: lib.update_problem = AttributeError() lib.initialize_variables = AttributeError() lib.pogs_solver_loop = AttributeError() lib.project_primal = AttributeError() lib.check_convergence = AttributeError() lib.direct_projector_project = AttributeError() lib.indirect_projector_project = AttributeError()