annotate _FullBNT/KPMtools/rectintLoopC.c @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
rev   line source
matthiasm@8 1
matthiasm@8 2 #include "mex.h"
matthiasm@8 3 #include <stdio.h>
matthiasm@8 4
matthiasm@8 5 #define MAX(x,y) ((x)>(y) ? (x) : (y))
matthiasm@8 6 #define MIN(x,y) ((x)<(y) ? (x) : (y))
matthiasm@8 7
matthiasm@8 8 void mexFunction(
matthiasm@8 9 int nlhs, mxArray *plhs[],
matthiasm@8 10 int nrhs, const mxArray *prhs[]
matthiasm@8 11 )
matthiasm@8 12 {
matthiasm@8 13 int j,k,m,n,nzmax,*irs,*jcs, *irs2, *jcs2;
matthiasm@8 14 double *overlap, *overlap2, tmp, areaA, areaB;
matthiasm@8 15 double *leftA, *rightA, *topA, *bottomA;
matthiasm@8 16 double *leftB, *rightB, *topB, *bottomB;
matthiasm@8 17 double *verbose;
matthiasm@8 18
matthiasm@8 19 m = MAX(mxGetM(prhs[0]), mxGetN(prhs[0]));
matthiasm@8 20 n = MAX(mxGetM(prhs[4]), mxGetN(prhs[4]));
matthiasm@8 21 /* printf("A=%d, B=%d\n", m, n); */
matthiasm@8 22
matthiasm@8 23 leftA = mxGetPr(prhs[0]);
matthiasm@8 24 rightA = mxGetPr(prhs[1]);
matthiasm@8 25 topA = mxGetPr(prhs[2]);
matthiasm@8 26 bottomA = mxGetPr(prhs[3]);
matthiasm@8 27
matthiasm@8 28 leftB = mxGetPr(prhs[4]);
matthiasm@8 29 rightB = mxGetPr(prhs[5]);
matthiasm@8 30 topB = mxGetPr(prhs[6]);
matthiasm@8 31 bottomB = mxGetPr(prhs[7]);
matthiasm@8 32
matthiasm@8 33 verbose = mxGetPr(prhs[8]);
matthiasm@8 34
matthiasm@8 35 plhs[0] = mxCreateDoubleMatrix(m,n, mxREAL);
matthiasm@8 36 overlap = mxGetPr(plhs[0]);
matthiasm@8 37
matthiasm@8 38 plhs[1] = mxCreateDoubleMatrix(m,n, mxREAL);
matthiasm@8 39 overlap2 = mxGetPr(plhs[1]);
matthiasm@8 40
matthiasm@8 41 k = 0;
matthiasm@8 42 for (j = 0; (j < n); j++) {
matthiasm@8 43 int i;
matthiasm@8 44 for (i = 0; (i < m); i++) {
matthiasm@8 45 tmp = (MAX(0, MIN(rightA[i], rightB[j]) - MAX(leftA[i], leftB[j]) )) *
matthiasm@8 46 (MAX(0, MIN(topA[i], topB[j]) - MAX(bottomA[i], bottomB[j]) ));
matthiasm@8 47
matthiasm@8 48 if (tmp > 0) {
matthiasm@8 49 overlap[k] = tmp;
matthiasm@8 50
matthiasm@8 51 areaA = (rightA[i]-leftA[i])*(topA[i]-bottomA[i]);
matthiasm@8 52 areaB = (rightB[j]-leftB[j])*(topB[j]-bottomB[j]);
matthiasm@8 53 overlap2[k] = tmp/MIN(areaA, areaB);
matthiasm@8 54
matthiasm@8 55 if (*verbose) {
matthiasm@8 56 printf("j=%d,i=%d,overlap=%5.3f, norm=%5.3f\n", j,i, overlap[k], overlap2[k]);
matthiasm@8 57 }
matthiasm@8 58 }
matthiasm@8 59
matthiasm@8 60 k++;
matthiasm@8 61 }
matthiasm@8 62 }
matthiasm@8 63 }
matthiasm@8 64
matthiasm@8 65
matthiasm@8 66
matthiasm@8 67
matthiasm@8 68
matthiasm@8 69
matthiasm@8 70
matthiasm@8 71