comparison deseq-hts_2.0/mex/mex_input.cpp @ 10:2fe512c7bfdf draft

DESeq2 version 1.0.19 added to the repo
author vipints <vipin@cbio.mskcc.org>
date Tue, 08 Oct 2013 08:15:34 -0400
parents
children
comparison
equal deleted inserted replaced
9:e27b4f7811c2 10:2fe512c7bfdf
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 3 of the License, or
5 * (at your option) any later version.
6 *
7 * Written (W) 2010-2011 Jonas Behr, Regina Bohnert, Gunnar Raetsch
8 * Copyright (C) 2010-2011 Max Planck Society
9 */
10
11
12 #include <stdio.h>
13 #include <mex.h>
14 #include "mex_input.h"
15
16 char *get_string(const mxArray *prhs) {
17 char *buf;
18 int buflen;
19 if (!prhs)
20 mexErrMsgTxt("get_string called with NULL pointer arg");
21 if (!mxIsChar(prhs))
22 mexErrMsgTxt("input is not a string");
23 if (mxGetM(prhs) != 1)
24 mexErrMsgTxt("input is not a row vector");
25 buflen = mxGetN(prhs) + 1;
26 buf = (char*) malloc(buflen);
27 /* copy the string from prhs into buf and add terminating NULL char */
28 if (mxGetString(prhs, buf, buflen))
29 mexErrMsgTxt("not enough space");
30 return buf;
31 }
32
33 bool get_bool(const mxArray *prhs)
34 {
35 const int M = mxGetM(prhs);
36 const int N = mxGetN(prhs);
37 double *f = (double*) mxGetPr(prhs);
38
39 if (!prhs)
40 mexErrMsgTxt("Arg is NULL pointer");
41 if (M != 1 || N != 1)
42 mexErrMsgTxt("Arg is not a scalar");
43 if (f[0] != 0)
44 return true;
45 return false;
46 }
47
48 int get_int(const mxArray *prhs)
49 {
50 const int M = mxGetM(prhs);
51 const int N = mxGetN(prhs);
52 double *f = (double*) mxGetPr(prhs);
53
54 if (!prhs)
55 mexErrMsgTxt("Arg is NULL pointer");
56 if (M != 1 || N != 1)
57 mexErrMsgTxt("Arg is not a scalar");
58
59 return (int) f[0];
60 }