Files
sics/arrayutil.c
Ferdi Franceschini 10d29d597c Cleaned up ANSTO code to merge with sinqdev.sics
This is our new RELEASE-4_0 branch which was taken from ansto/93d9a7c
Conflicts:
	.gitignore
	SICSmain.c
	asynnet.c
	confvirtualmot.c
	counter.c
	devexec.c
	drive.c
	event.h
	exebuf.c
	exeman.c
	histmem.c
	interface.h
	motor.c
	motorlist.c
	motorsec.c
	multicounter.c
	napi.c
	napi.h
	napi4.c
	network.c
	nwatch.c
	nxscript.c
	nxxml.c
	nxxml.h
	ofac.c
	reflist.c
	scan.c
	sicshipadaba.c
	sicsobj.c
	site_ansto/docs/Copyright.txt
	site_ansto/instrument/lyrebird/config/tasmad/sicscommon/nxsupport.tcl
	site_ansto/instrument/lyrebird/config/tasmad/taspub_sics/tasscript.tcl
	statusfile.c
	tasdrive.c
	tasub.c
	tasub.h
	tasublib.c
	tasublib.h
2015-04-23 20:49:26 +10:00

54 lines
879 B
C

/*
* arrayutil.c
*
* copyright: see file COPYRIGHT
*
* some utilities for dealing with arrays
*
* Created on: Mar 16, 2011
* Author: koennecke
*/
long sumWindow(int *data, int xstart, int xend, int xlength,
int ystart, int yend, int ylength)
{
int i,j;
long result = 0;
int *row;
if(xstart < 0 || xstart > xlength){
return -2;
}
if(xend < 0 || xend > xlength){
return -2;
}
if(xend < xstart){
return -2;
}
if(ystart < 0 || ystart > ylength){
return -2;
}
if(yend < 0 || yend > ylength){
return -2;
}
if(yend < ystart){
return -2;
}
/* for(j = ystart; j < yend; j++){ */
/* row = data + j*xlength; */
/* for(i = xstart; i < xend; i++){ */
/* result += row[i]; */
/* } */
/* } */
for(i = xstart; i < xend; i++){
row = data + i*ylength;
for(j = ystart; j < yend; j++){
result += row[j];
}
}
return result;
}