Schema
Owner
postgres
Descriptions
There is no description for function st_mean4ma
Options
Option | Value |
---|---|
Returns |
double precision |
Language |
|
Parameters |
matrix double precision [] nodatamode text variadic args text [] |
Definition
CREATE OR REPLACE FUNCTION public.st_mean4ma (
matrix double precision [],
nodatamode text,
variadic args text []
)
RETURNS double precision AS
$span$
DECLARE
_matrix float[][];
sum float;
count float;
BEGIN
_matrix := matrix;
sum := 0;
count := 0;
FOR x in array_lower(matrix, 1)..array_upper(matrix, 1) LOOP
FOR y in array_lower(matrix, 2)..array_upper(matrix, 2) LOOP
IF _matrix[x][y] IS NULL THEN
IF nodatamode = 'ignore' THEN
_matrix[x][y] := 0;
ELSE
_matrix[x][y] := nodatamode::float;
count := count + 1;
END IF;
ELSE
count := count + 1;
END IF;
sum := sum + _matrix[x][y];
END LOOP;
END LOOP;
IF count = 0 THEN
RETURN NULL;
END IF;
RETURN sum / count;
END;
$span$
LANGUAGE 'plpgsql'
IMMUTABLE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;
This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 13/03/2014 13:23 |