diff options
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/range2.c')
-rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/range2.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/range2.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/range2.c new file mode 100755 index 0000000..b84f4e1 --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/range2.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | [MIN, MAX] = range2(MTX) | ||
3 | >>> See range2.m for documentation <<< | ||
4 | EPS, 3/97. | ||
5 | */ | ||
6 | |||
7 | #define V4_COMPAT | ||
8 | #include <matrix.h> /* Matlab matrices */ | ||
9 | #include <mex.h> | ||
10 | |||
11 | #include <stddef.h> /* NULL */ | ||
12 | |||
13 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
14 | |||
15 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
16 | mxArray *plhs[], /* Matrices on lhs */ | ||
17 | int nrhs, /* Num args on rhs */ | ||
18 | const mxArray *prhs[] /* Matrices on rhs */ | ||
19 | ) | ||
20 | { | ||
21 | register double temp, mn, mx; | ||
22 | register double *mtx; | ||
23 | register int i, size; | ||
24 | mxArray *arg; | ||
25 | |||
26 | if (nrhs != 1) mexErrMsgTxt("requires 1 argument."); | ||
27 | |||
28 | /* ARG 1: MATRIX */ | ||
29 | arg = prhs[0]; | ||
30 | if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix."); | ||
31 | mtx = mxGetPr(arg); | ||
32 | size = (int) mxGetM(arg) * mxGetN(arg); | ||
33 | |||
34 | /* FIND min, max values of MTX */ | ||
35 | mn = *mtx; mx = *mtx; | ||
36 | for (i=1; i<size; i++) | ||
37 | { | ||
38 | temp = mtx[i]; | ||
39 | if (temp < mn) | ||
40 | mn = temp; | ||
41 | else if (temp > mx) | ||
42 | mx = temp; | ||
43 | } | ||
44 | |||
45 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL); | ||
46 | if (plhs[0] == NULL) mexErrMsgTxt("Error allocating result matrix"); | ||
47 | plhs[1] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL); | ||
48 | if (plhs[1] == NULL) mexErrMsgTxt("Error allocating result matrix"); | ||
49 | mtx = mxGetPr(plhs[0]); | ||
50 | mtx[0] = mn; | ||
51 | mtx = mxGetPr(plhs[1]); | ||
52 | mtx[0] = mx; | ||
53 | |||
54 | return; | ||
55 | } | ||
56 | |||