コード例 #1
0
ファイル: codes.go プロジェクト: jsgilmore/goerasure
// NewCaucheGoodCode returns a type of bitmatrix code with both the
// bitmatrix and schedule initialised.
func NewCauchyGoodCode(k, m, w, packetSize int, bufferSize int64) Coder {
	code := &cauchyGoodCode{bitmatrixCode{code{k, m, w, packetSize, bufferSize}, nil, nil}}
	matrix := C.cauchy_good_general_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
}
コード例 #2
0
ファイル: encoder.go プロジェクト: postfix/ecgo
// NewCauchyEncoder creates new CauchyEncoder, initialized with parameters from p
func NewCauchyEncoder(p encoder_params) *CauchyEncoder {
	k := C.int(p.b)
	m := C.int(p.r)
	w := C.int(p.word_size)
	matrix := C.cauchy_good_general_coding_matrix(k, m, w)
	bitmatrix := C.jerasure_matrix_to_bitmatrix(k, m, w, matrix)

	return &CauchyEncoder{
		p:           &p,
		k:           k,
		m:           m,
		w:           w,
		packet_size: C.int(p.packet_size),
		bitmatrix:   bitmatrix,
	}
}