Пример #1
0
int lwpr_write_binary(const LWPR_Model *model, const char *filename) {
   int ok;
   FILE *fp;

   fp = fopen(filename, "wb");
   if (fp==NULL) return 0;
   ok = lwpr_write_binary_fp(model,fp);
   fclose(fp);
   return ok;
}
Пример #2
0
static PyObject *PyLWPR_write_binary(PyLWPR *self, PyObject *args) {
   char *filename;
   FILE *fp;
   LWPR_Model *model = &(self->model);
   int ok;

   if (!PyArg_ParseTuple(args, "s", &filename))  return NULL;
   fp = fopen(filename, "wb");
   if (fp==NULL) {
      PyErr_SetString(PyExc_IOError, "File cannot be opened for writing.");
      return NULL;
   }
   ok=lwpr_write_binary_fp(model, fp);
   fclose(fp);
   
   if (!ok) {
      PyErr_SetString(PyExc_IOError, "Errors occured during writing.");
      return NULL;
   }
   
   Py_INCREF(Py_None);
   return Py_None;
}
Пример #3
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) {
   LWPR_Model model;
   char filename[MAX_PATH];
   FILE *fp;   
   int ok;
   
   if (nrhs<2 || !mxIsChar(prhs[1])) mexErrMsgTxt("Second argument must be a filename (string).\n");
   
   create_model_from_matlab(&model, prhs[0]);
   mxGetString(prhs[1],filename,MAX_PATH);
   
   fp = fopen(filename, "wb");
   if (fp==NULL) {
      mexErrMsgTxt("Could not open the file. Please check filename and access permissions.\n");
   }
  
   ok = lwpr_write_binary_fp(&model, fp);
   fclose(fp);
   
   plhs[0] = mxCreateDoubleScalar(ok);
   
   lwpr_free_model(&model);
}