Mercurial > repos > vipints > deseq_hts
diff deseq-hts_1.0/mex/mex_input.cpp @ 0:94a108763d9e draft
deseq-hts version 1.0 wraps the DESeq 1.6.0
author | vipints |
---|---|
date | Wed, 09 May 2012 20:43:47 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deseq-hts_1.0/mex/mex_input.cpp Wed May 09 20:43:47 2012 -0400 @@ -0,0 +1,60 @@ +/* +* 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]; +}