forked from gtolias/hqe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaggregate_binary.c
More file actions
executable file
·35 lines (26 loc) · 862 Bytes
/
Copy pathaggregate_binary.c
File metadata and controls
executable file
·35 lines (26 loc) · 862 Bytes
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
#include "aggregate.h"
#include "mex.h"
#include <string.h>
void mexFunction (int nlhs, mxArray *plhs[],
int nrhs, const mxArray*prhs[])
{
int i;
if (nlhs != 1 || nrhs != 3 )
mexErrMsgTxt ("Usage: agr_bs = aggregate_binary (bs, keys, max_key)");
int m = mxGetM (prhs[0]);
int n = mxGetN (prhs[0]);
uint8 * bs = (uint8 *) mxGetPr (prhs[0]);
int * keys = (int *) mxGetPr (prhs[1]);
int nt = (int) mxGetScalar (prhs[2]);
/* keys should start from 0*/
for (i = 0; i < n ; i++)
if (keys[i] > nt)
mexErrMsgTxt ("key larger than maximum key value provided");
else
keys[i]--;
float * mvec_ = aggregate_binary(bs, keys, m, n, nt);
plhs[0] = mxCreateNumericMatrix (8 * m, nt, mxSINGLE_CLASS, mxREAL);
float * mvec = (float *) mxGetPr (plhs[0]);
memcpy (mvec, mvec_, sizeof(float) * 8 * m * nt);
free(mvec_);
}