summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-19 23:09:30 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 02:40:39 -0400
commitf618466c25d43f3bae9e40920273bf77de1e1149 (patch)
tree460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c')
-rwxr-xr-xSD-VBS/benchmarks/mser/src/matlab/old/mexutils.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c b/SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c
new file mode 100755
index 0000000..0fc664b
--- /dev/null
+++ b/SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c
@@ -0,0 +1,111 @@
1/* file: mexutils.c
2** author: Andrea Vedaldi
3** description: Utility functions to write MEX files.
4**/
5
6#include"mex.h"
7
8#undef M_PI
9#define M_PI 3.14159265358979
10
11/** @brief Is scalar?
12 **
13 ** @return @c true if the array @a A is a scalar.
14 **/
15int
16uIsScalar(const mxArray* A)
17{
18 return
19 !mxIsComplex(A) &&
20 mxGetNumberOfDimensions(A) == 2 &&
21 mxGetM(A) == 1 &&
22 mxGetN(A) == 1 ;
23}
24
25/** @brief Is real scalar?
26 **
27 ** @return @c true if the array @a A is a real scalar.
28 **/
29int
30uIsRealScalar(const mxArray* A)
31{
32 return
33 mxIsDouble(A) &&
34 !mxIsComplex(A) &&
35 mxGetNumberOfDimensions(A) == 2 &&
36 mxGetM(A) == 1 &&
37 mxGetN(A) == 1 ;
38}
39
40/** @brief Is real matrix?
41 **
42 ** The function checks wether the argument @a A is a real matrix. In
43 ** addition, if @a M >= 0, it checks wether the number of rows is
44 ** equal to @a M and, if @a N >= 0, if the number of columns is equal
45 ** to @a N.
46 **
47 ** @param M number of rows.
48 ** @param N number of columns.
49 ** @return @c true if the array is a real matrix with the specified format.
50 **/
51int
52uIsRealMatrix(const mxArray* A, int M, int N)
53{
54 return
55 mxIsDouble(A) &&
56 !mxIsComplex(A) &&
57 mxGetNumberOfDimensions(A) == 2 &&
58 ((M>=0)?(mxGetM(A) == M):1) &&
59 ((N>=0)?(mxGetN(A) == N):1) ;
60}
61
62/** @brief Is real vector?
63 **
64 ** The function checks wether the argument @a V is a real vector. By
65 ** definiton, a matrix is a vector if one of its dimension is one.
66 ** In addition, if @a D >= 0, it checks wether the dimension of the
67 ** vecotr is equal to @a D.
68 **
69 ** @param D lenght of the vector.
70 ** @return @c true if the array is a real vector of the specified dimension.
71 **/
72int
73uIsRealVector(const mxArray* V, int D)
74{
75 int M = mxGetM(V) ;
76 int N = mxGetN(V) ;
77 int is_vector = (N == 1) || (M == 1) ;
78
79 return
80 mxIsDouble(V) &&
81 !mxIsComplex(V) &&
82 mxGetNumberOfDimensions(V) == 2 &&
83 is_vector &&
84 ( D < 0 || N == D || M == D) ;
85}
86
87
88/** @brief Is a string?
89 **
90 ** The function checks wether the array @a S is a string. If
91 ** @a L is non-negative, it also check wether the strign has
92 ** length @a L.
93 **
94 ** @return @a c true if S is a string of the specified length.
95 **/
96int
97uIsString(const mxArray* S, int L)
98{
99 int M = mxGetM(S) ;
100 int N = mxGetN(S) ;
101
102 return
103 mxIsChar(S) &&
104 M == 1 &&
105 (L < 0 || N == L) ;
106}
107
108/**
109 **
110 **/
111