// int *cauchy_original_coding_matrix(int k, int m, int w); // int *jerasure_matrix_to_bitmatrix(k, m, w, matrix); func GenerateCRSBitMatrix(k, m, w int) []int { gom := make([]int, 0) matrix := C.cauchy_original_coding_matrix(C.int(k), C.int(m), C.int(w)) if matrix == nil { log.Fatal("erasure: cannot make matrix") } bitmatrix := C.jerasure_matrix_to_bitmatrix(C.int(k), C.int(m), C.int(w), matrix) if bitmatrix == nil { log.Fatal("erasure: cannot make matrix") } length := int(k * m * w * w) hdr := reflect.SliceHeader{ Data: uintptr(unsafe.Pointer(bitmatrix)), Len: length, Cap: length, } matrixSlice := *(*[]C.int)(unsafe.Pointer(&hdr)) for _, e := range matrixSlice { gom = append(gom, int(e)) } return gom }
// NewCaucheOrigCode returns a type of bitmatrix code with both the // bitmatrix and schedule initialised. func NewCauchyOrigCode(k, m, w, packetSize int, bufferSize int64) Coder { code := &cauchyOrigCode{bitmatrixCode{code{k, m, w, packetSize, bufferSize}, nil, nil}} matrix := C.cauchy_original_coding_matrix(C.int(k), C.int(m), C.int(w)) code.bitmatrix = C.jerasure_matrix_to_bitmatrix(C.int(k), C.int(m), C.int(w), matrix) code.schedule = C.jerasure_smart_bitmatrix_to_schedule(C.int(k), C.int(m), C.int(w), code.bitmatrix) code.ValidateCode() return code }