~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to lib/stats/c_max.c

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <grass/gis.h>
2
2
 
3
 
void c_max(DCELL * result, DCELL * values, int n)
 
3
void c_max(DCELL * result, DCELL * values, int n, const void *closure)
4
4
{
5
5
    DCELL max;
6
6
    int i;
20
20
    else
21
21
        *result = max;
22
22
}
 
23
 
 
24
void w_max(DCELL * result, DCELL(*values)[2], int n, const void *closure)
 
25
{
 
26
    DCELL max;
 
27
    int i;
 
28
 
 
29
    G_set_d_null_value(&max, 1);
 
30
 
 
31
    for (i = 0; i < n; i++) {
 
32
        if (G_is_d_null_value(&values[i][0]))
 
33
            continue;
 
34
 
 
35
        if (G_is_d_null_value(&max) || max < values[i][0])
 
36
            max = values[i][0];
 
37
    }
 
38
 
 
39
    if (G_is_d_null_value(&max))
 
40
        G_set_d_null_value(result, 1);
 
41
    else
 
42
        *result = max;
 
43
}