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