moygit / exact_cover_np Goto Github PK
View Code? Open in Web Editor NEWFinding exact covers in NumPy (and solving Sudoku!)
License: GNU General Public License v2.0
Finding exact covers in NumPy (and solving Sudoku!)
License: GNU General Public License v2.0
Hi,
Thanks for writing this. Here are some corner cases:
import exact_cover_np
import numpy as np
exact_cover_np.get_exact_cover(np.array([[1,0,0],[0,1,1]],dtype=np.int32))
#array([0, 0], dtype=int32)
exact_cover_np.get_exact_cover(np.array([[1,1,1]],dtype=np.int32))
#Segmentation fault (core dumped)
Currently the entire matrix is created in Python and then passed whole to the C code, which then translates it into a sparse matrix. So the example on the front page says S = ...
and then calls get_exact_cover(S)
. If this matrix is large, though, the caller might prefer to construct it piecemeal, say row by row, and pass each row to the C code to be sparsified individually.
What this means in code: currently get_exact_cover
(or, more precisely, dlx_get_exact_cover
) calls create_sparse_matrix
. A more flexible and memory-efficient approach, though less time-efficient, would be to have an API like init_create_sparse_matrix
, add_row_to_sparse_matrix
, and done_creating_sparse_matrix
.
Hi Moy,
Thanks for this code!
I've made a few updates to get it working with Python 3. (They break Python 2 compatibility but I figured that was ok since it's end-of-lifed. Making it work with both shouldn't be too much harder.) You can see what I've done at jwg4#1
I just wondered whether you would care to merge these in. If you're not bothered, I might submit to pypi under a slightly different name? Let me know what you think.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.