-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmex_expdist.cpp
59 lines (53 loc) · 1.98 KB
/
mex_expdist.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*%%=====================================================================
%% Entry function for evaluating bhatt cost
%% Author: Hamidreza Heydarian
%%=====================================================================*/
#include <stdio.h>
#include "mex.h"
double expdist(const double* A, const double* B, int m, int n, int dim, const double* scale_A, const double* scale_B);
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
/* Declare variables */
int m, n, dim;
double *A, *B, *result, *scale_A, *scale_B;
/* Check for proper number of input and output arguments */
if (nrhs != 4) {
mexErrMsgTxt("Seven input arguments required.");
}
if (nlhs > 2){
mexErrMsgTxt("Too many output arguments.");
}
/* Check data type of input argument */
if (!(mxIsDouble(prhs[0]))) {
mexErrMsgTxt("Input array must be of type double.");
}
if (!(mxIsDouble(prhs[1]))) {
mexErrMsgTxt("Input array must be of type double.");
}
if (!(mxIsDouble(prhs[2]))) {
mexErrMsgTxt("Input array must be of type double.");
}
if (!(mxIsDouble(prhs[3]))) {
mexErrMsgTxt("Input array must be of type double.");
}
/* Get the number of elements in the input argument */
/* elements=mxGetNumberOfElements(prhs[0]); */
/* Get the data */
A = (double *)mxGetPr(prhs[0]);
B = (double *)mxGetPr(prhs[1]);
scale_A = (double *)mxGetPr(prhs[2]);
scale_B = (double *)mxGetPr(prhs[3]);
/* Get the dimensions of the matrix input A&B. */
m = mxGetM(prhs[0]);
n = mxGetM(prhs[1]);
dim = mxGetN(prhs[0]);
if (mxGetN(prhs[1])!=dim)
{
mexErrMsgTxt("The two input point sets should have same dimension.");
}
/* Allocate the space for the return argument */
plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
result = mxGetPr(plhs[0]);
*result = expdist(A, B, m, n, dim, scale_A, scale_B);
}