| 1 | #include <math.h> |
| 2 | #include <grass/imagery.h> |
| 3 | #include "mat.h" |
| 4 | #include "local_proto.h" |
| 5 | |
| 6 | #define ZERO 1.0e-8 |
| 7 | |
| 8 | /* |
| 9 | * isnull: returns 1 if matrix is null, else 0. |
| 10 | */ |
| 11 | int isnull(MATRIX *a) |
| 12 | { |
| 13 | register int i, j, rows, cols; |
| 14 | |
| 15 | if (a->nrows == 0) |
| 16 | return error("isnull: argument not defined.\n"); |
| 17 | |
| 18 | rows = a->nrows; |
| 19 | cols = a->ncols; |
| 20 | |
| 21 | for (i = 0; i < rows; i++) |
| 22 | for (j = 0; j < cols; j++) |
| 23 | if ((fabs(a->x[i][j]) - ZERO) > ZERO) |
| 24 | return 0; |
| 25 | |
| 26 | return 1; |
| 27 | } |