Cokriging Weights

`template <`

class MatrixLibrary,

class Location,

class InputIterator,

class CovarianceSet,

class KrigingConstraints,

class Vector

>

int

cokriging_weights(

Vector& weights, double kriging_variance,

const Location& center,

InputIterator first_neigh, InputIterator last_neigh,

CovarianceSet& covar,

KrigingConstraints& Kconstraints

)

`template <`

class MatrixLibrary,

class Location,

class InputIterator,

class CovarianceSet,

class KrigingConstraints,

class Vector

>

int

cokriging_weights(

Vector& weights,

const Location& center,

InputIterator first_neigh, InputIterator last_neigh,

CovarianceSet& covar,

KrigingConstraints& Kconstraints

)

The `cokriging_weights` algorithm solves a cokriging system :

where
*f*_{i}{},{},...,{},
*i* = 1,..., *p* are p constraints expressed by the `Kconstraint`. The solution to this system is a set of weights:

(,...,,,...,,,...,), where the weights are the Lagrange weights used to account for the constraints
*f*_{1},..., *f*_{p}.

The `cokriging_weights` function stores the kriging weights into `Vector` `weights` in the following order:

(,...,,,...,,,...,).

Only the weights
,..., are useful to compute the kriging estimate. The weights
,..., are used to compute the kriging variance.
`Vector` `weights` does not need to be of the correct size *n* + *p* when passed to the function.

Two versions of the algorithm exist. Version 1 computes the kriging variance and stores it into `kriging_variance`, while Version 2 does not compute the kriging variance (there are cases where the kriging variance is useless, e.g. in indicator kriging).
Both version of the algorithm allow to change the linear algebra library (which defines matrices, matrix inversion routines, ...) used by `cokriging_weights` (see 2.4).
The default linear algebra library is the *TNT*library (slightly modified), a public domain library by Roldan Pozo, Mathematical and Computational Sciences Division,National Institute of Standards and Technology.

The value returned by `kriging_weights` indicates if any problem were encountered:

- returns 0 if the function executed successfully
- returns 1 if the kriging system could not be solved
- returns 2 if the neighborhood of conditioning data was empty

`Vector`is a container on which an iterator is defined. It must have three member functions whose prototypes are:`iterator Vector::begin()`which returns an iterator to the first element of the`Vector``size_type Vector::size()`which returns the size of the`Vector`.`void Vector::resize(size_type n)`which changes the size of the`Vector`to n

`Location`is a model of Location.`InputIterator`is a model of Input Iterator (see STL requirements). It iterates on a range of Neighborhood.`CovarianceSet`is a model of Covariance Set. In expression`covar(i,j,u1,u2)`, required by Covariance Set,`u1`and`u2`must be of type`Location`.`KrigingConstraints`is a model of Kriging Constraint.`MatrixLibrary`specifies the linear algebra library to use. The requirements on`matrix_lib`are fully defined in 2.4. By default, it is the*TNT*library (slightly modified), a public domain library by Roldan Pozo, Mathematical and Computational Sciences Division,National Institute of Standards and Technology.

`
typedef std::vector<geo_value2d> neighborhood;
int main()
{
location2d u1(2,3);
location2d u2(4,-7);
geo_value2d Z1(u1,0.21);
geo_value2d Z2(u2,0.09);
Neighborhood neighbors1, neighbors2;
neighbors1.push_back(Z1);
neighbors1.push_back(Z2);
location2d u3(1,2);
geo_value2d S1(u3,42.1);
neighbors2.push_back(S1);
neighborhood* neigh_array[2]={&neighbors1, &neighbors2};
location2d u(0,0);
std::vector<double> weights;
double kvariance;
kriging_weights(weights, kvariance,
u, neigh_array, 2,
LMC_covariance, OK_constraint);
}
`