~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to imagery/i.ortho.photo/libes/m_add.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdio.h>
2
 
#include "mat.h"
3
 
#include "matrixdefs.h"
4
 
#include "local_proto.h"
5
 
 
6
 
/*
7
 
 * m_add: matrix addition (returns c = a + b)
8
 
 */
9
 
 
10
 
int m_add(MATRIX * a, MATRIX * b, MATRIX * c)
11
 
{
12
 
    register int nr, nc;
13
 
    char message[256];
14
 
    register double *ap, *bp, *mp;
15
 
    static MATRIX m;
16
 
 
17
 
    if (a->nrows == 0)
18
 
        return error("+: arg1 not defined\n");
19
 
    else if (b->nrows == 0)
20
 
        return error("+: arg2 not defined\n");
21
 
 
22
 
    /* check for conformity */
23
 
    if ((a->nrows != b->nrows) || (a->ncols != b->ncols)) {
24
 
        sprintf(message, "+: matrices not conformable, %d x %d + %d x %d\n",
25
 
                a->nrows, a->ncols, b->nrows, b->ncols);
26
 
        return error(message);
27
 
    }
28
 
 
29
 
    nr = a->nrows;
30
 
    while (nr--) {
31
 
        nc = a->ncols;
32
 
        ap = &(a->x[nr][0]);
33
 
        bp = &(b->x[nr][0]);
34
 
        mp = &(m.x[nr][0]);
35
 
        while (nc--)
36
 
            *mp++ = *ap++ + *bp++;
37
 
    }
38
 
    m.nrows = a->nrows;
39
 
    m.ncols = a->ncols;
40
 
    m_copy(c, &m);
41
 
    return 1;
42
 
}