| 1 | #include "mat.h" |
| 2 | #include "local_proto.h" |
| 3 | |
| 4 | /* |
| 5 | * m_copy: matrix equivalency (return a = b). |
| 6 | */ |
| 7 | int m_copy(MATRIX *a, MATRIX *b) |
| 8 | { |
| 9 | register int r, c; |
| 10 | register double *ap, *bp; |
| 11 | |
| 12 | if (b->nrows == 0) |
| 13 | return error("=: arg2 not defined\n"); |
| 14 | |
| 15 | r = b->nrows; |
| 16 | a->nrows = b->nrows; |
| 17 | a->ncols = b->ncols; |
| 18 | while (r--) { |
| 19 | c = b->ncols; |
| 20 | ap = &(a->x[r][0]); |
| 21 | bp = &(b->x[r][0]); |
| 22 | while (c--) |
| 23 | *ap++ = *bp++; |
| 24 | } |
| 25 | |
| 26 | return 1; |
| 27 | } |