Problem 1051. Exact binary matrix factorization
Given a binary-valued (only ones and zeroes) MxN matrix C, and K (where K<M and K<N) find a binary-valued MxK matrix A and a binary-valued KxN matrix B such that A*B equals C. e.g. for K = 2, and
C =
1 1 1 0 0 0 0 0 0 1 0 1
then one possible solution is
A =
0 1 0 0 1 0
B =
0 1 0 1 1 1 1 0
For this problem, assume that at least one solution exists.
Note that you cannot do matrix multiplication with two logical matrices in MATLAB.
Solution Stats
Problem Comments
-
3 Comments
you should probably add an assert statement that checks the size of the output matrices
I second @bmtran. lu wins!
thanks, I added the extra asserts as you suggest. the other solutions submitted so far look interesting, thanks for them!
Solution Comments
Show commentsProblem Recent Solvers13
Suggested Problems
-
Find state names that start with the letter N
1143 Solvers
-
Construct a string from letters and counts
139 Solvers
-
Find a subset that divides the vector into equal halves
379 Solvers
-
Replace all zeros and NaNs in a matrix with the string 'error'
97 Solvers
-
Split a string into chunks of specified length
1444 Solvers
More from this Author5
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!