remove code redundancy in encode.cu
remove code redundancy in decode.cu and encode.cu
format code style in matrix.cu