func dgelsHelper(m, n, nrhs int, a []float64, lda int, b []float64, ldb int, work []float64, lwork int) error { var ( trans_ = transChar(false) m_ = C.integer(m) n_ = C.integer(n) nrhs_ = C.integer(nrhs) a_ = ptrFloat64(a) lda_ = C.integer(lda) b_ = ptrFloat64(b) ldb_ = C.integer(ldb) work_ = ptrFloat64(work) lwork_ = C.integer(lwork) ) var info_ C.integer C.dgels_(&trans_, &m_, &n_, &nrhs_, a_, &lda_, b_, &ldb_, work_, &lwork_, &info_) info := int(info_) switch { case info < 0: return errInvalidArg(-info) case info > 0: return errNotFullRank(info) default: return nil } }
// void dgels_(char *trans, int *m, int *n, int *nrhs, double *A, int *lda, // double *B, int *ldb, double *work, int *lwork, int *info); func dgels(trans string, M, N, NRHS int, A []float64, lda int, B []float64, ldb int) int { var info int = 0 var lwork int = -1 var work float64 ctrans := C.CString(trans) defer C.free(unsafe.Pointer(ctrans)) // calculate work buffer size C.dgels_( ctrans, (*C.int)(unsafe.Pointer(&M)), (*C.int)(unsafe.Pointer(&N)), (*C.int)(unsafe.Pointer(&NRHS)), nil, (*C.int)(unsafe.Pointer(&lda)), nil, (*C.int)(unsafe.Pointer(&ldb)), (*C.double)(unsafe.Pointer(&work)), (*C.int)(unsafe.Pointer(&lwork)), (*C.int)(unsafe.Pointer(&info))) lwork = int(work) wbuf := make([]float64, lwork) C.dgels_( ctrans, (*C.int)(unsafe.Pointer(&M)), (*C.int)(unsafe.Pointer(&N)), (*C.int)(unsafe.Pointer(&NRHS)), (*C.double)(unsafe.Pointer(&A[0])), (*C.int)(unsafe.Pointer(&lda)), (*C.double)(unsafe.Pointer(&B[0])), (*C.int)(unsafe.Pointer(&ldb)), (*C.double)(unsafe.Pointer(&wbuf[0])), (*C.int)(unsafe.Pointer(&lwork)), (*C.int)(unsafe.Pointer(&info))) return info }