예제 #1
0
파일: model.go 프로젝트: sridif/gosvm
// Get a slice with class labels
func (model *Model) labels() []int {
	nClasses := C.svm_get_nr_class_wrap(model.model)
	cLabels := C.labels_new(nClasses)
	defer C.free(unsafe.Pointer(cLabels))
	C.svm_get_labels_wrap(model.model, cLabels)

	labels := make([]int, int(nClasses))

	for idx, _ := range labels {
		labels[idx] = int(C.get_int_idx(cLabels, C.int(idx)))
	}

	return labels
}
예제 #2
0
파일: malloc.go 프로젝트: shirayu/golinear
func newLabels(n C.int) *C.int {
	labels := tryNew(func() unsafe.Pointer {
		return unsafe.Pointer(C.labels_new(n))
	})
	return (*C.int)(labels)
}