-
Notifications
You must be signed in to change notification settings - Fork 0
/
bnd.cpp
29 lines (23 loc) · 792 Bytes
/
bnd.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
/**
* Author: Kelvin Abrokwa (kelvinabrokwa@gmail.com)
*
* Bottle Neck Distance Wrapper for Matlab mex
* Takes 2 string arguments in Matlab
*/
#include "mex.h"
#include "CBottleneckDistance.hpp"
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[]) {
// validate Matlab input
if (nrhs != 2)
mexErrMsgIdAndTxt("MyToolbox:bn:nrhs", "Need 2 arguments");
// read arguments
char *file1 = mxArrayToString(prhs[0]);
char *file2 = mxArrayToString(prhs[1]);
double maxGen = 1;
CBottleneckDistance d;
// compute the distance between two persistance diagrams
double distance = d.Distance( file1, file2, maxGen);
// return the distance to the Matlab caller
plhs[0] = mxCreateDoubleScalar(distance);
}