1, Add weight matrix to the algorithm.
2, Stop printing iterations.
Boolean matrix to matrix
Mofidied W input
Updating z should be very careful