date and time created 83/08/11 20:49:40 by sam
[unix-history] / usr / src / old / lib2648 / setmat.c
CommitLineData
d755da8b
RC
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
8setmat(m, rows, cols, r, c, nval)
9bitmat m;
10int 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}