xref: /csrg-svn/old/lib2648/setmat.c (revision 11493)
1*11493Sralph /*	setmat.c	4.1	83/03/09	*/
2*11493Sralph /*
3*11493Sralph  * setmat: set the value in m[r, c] to nval.
4*11493Sralph  */
5*11493Sralph 
6*11493Sralph #include "bit.h"
7*11493Sralph 
8*11493Sralph setmat(m, rows, cols, r, c, nval)
9*11493Sralph bitmat m;
10*11493Sralph int rows, cols, r, c, nval;
11*11493Sralph {
12*11493Sralph 	register int offset, thisbit;
13*11493Sralph 
14*11493Sralph 	if (r<0 || c<0 || r>=rows || c>=cols) {
15*11493Sralph #ifdef TRACE
16*11493Sralph 		if (trace)
17*11493Sralph 			fprintf(trace, "setmat range error: (%d, %d) <- %d in a (%d, %d) matrix %x\n", r, c, nval, rows, cols, m);
18*11493Sralph #endif
19*11493Sralph 
20*11493Sralph 		return;
21*11493Sralph 	}
22*11493Sralph 	offset = r*((cols+7)>>3) + (c>>3);
23*11493Sralph 	thisbit = 0x80 >> (c&7);
24*11493Sralph 	if (nval)
25*11493Sralph 		m[offset] |= thisbit;
26*11493Sralph 	else
27*11493Sralph 		m[offset] &= ~thisbit;
28*11493Sralph }
29