/* mex ndsumC.c flops.obj */ /* Written by Tom Minka * (c) Microsoft Corporation. All rights reserved. */ #include "mex.h" #include "flops.h" void ndsum(double *dest, double *src, unsigned ndim, unsigned *size, unsigned total, unsigned *mask) { /* dest is the destination array. * src is the source array. * ndim is the number of dimensions in the source array (the length of size). * size[i] is the size of dimension i in the source array. * mask[i] indicates that dimension i is to be summed out. */ unsigned *masked_size,*cum_masked_size,*advance,*rewind; int *subs = mxCalloc(ndim,sizeof(int)); int i,j; masked_size = mxCalloc(ndim,sizeof(int)); for(i=0;i