Mercurial > repos > vipints > deseq_hts
view deseq-hts_1.0/mex/mex_input.cpp @ 8:2b3bb3348076 draft
Deleted selected files
author | vipints |
---|---|
date | Wed, 27 Jun 2012 15:38:39 -0400 |
parents | 94a108763d9e |
children |
line wrap: on
line source
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Written (W) 2010-2011 Jonas Behr, Regina Bohnert, Gunnar Raetsch * Copyright (C) 2010-2011 Max Planck Society */ #include <stdio.h> #include <mex.h> #include "mex_input.h" char *get_string(const mxArray *prhs) { char *buf; int buflen; if (!prhs) mexErrMsgTxt("get_string called with NULL pointer arg"); if (!mxIsChar(prhs)) mexErrMsgTxt("input is not a string"); if (mxGetM(prhs) != 1) mexErrMsgTxt("input is not a row vector"); buflen = mxGetN(prhs) + 1; buf = (char*) malloc(buflen); /* copy the string from prhs into buf and add terminating NULL char */ if (mxGetString(prhs, buf, buflen)) mexErrMsgTxt("not enough space"); return buf; } bool get_bool(const mxArray *prhs) { const int M = mxGetM(prhs); const int N = mxGetN(prhs); double *f = (double*) mxGetPr(prhs); if (!prhs) mexErrMsgTxt("Arg is NULL pointer"); if (M != 1 || N != 1) mexErrMsgTxt("Arg is not a scalar"); if (f[0] != 0) return true; return false; } int get_int(const mxArray *prhs) { const int M = mxGetM(prhs); const int N = mxGetN(prhs); double *f = (double*) mxGetPr(prhs); if (!prhs) mexErrMsgTxt("Arg is NULL pointer"); if (M != 1 || N != 1) mexErrMsgTxt("Arg is not a scalar"); return (int) f[0]; }