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