NAG CL Interface
c06sac (fast_gauss)
1
Purpose
c06sac calculates the multidimensional fast Gauss transform.
2
Specification
void |
c06sac (Integer d,
const double srcs[],
Integer n,
const double trgs[],
Integer m,
const double q[],
Integer *p1,
Integer *p2,
Integer *k,
const double hin[],
Integer lhin,
double tol,
double v[],
double term[],
NagError *fail) |
|
The function may be called by the names: c06sac or nag_sum_fast_gauss.
3
Description
c06sac calculates the
-dimensional fast Gauss transform (FGT),
, that approximates the discrete Gauss transform (DGT),
, evaluated at a set of target points
, for
. The DGT is defined as:
where
, for
, are the Gaussian source points,
, for
, are the source weights and
, for
, are the source standard deviations (alternatively source scales or source bandwidths).
This function implements the improved FGT algorithm presented in
Raykar and Duraiswami (2005). The algorithm clusters the sources into
distinct clusters and then computes two Taylor series approximations per cluster with
and
terms respectively. You must provide
,
and
when calling the function. See
Section 7 below for a further discussion on accuracy when choosing their values.
The input array
of this function is designed to allow maximum flexibility in the supply of the standard deviation arguments by reusing, in a cyclic manner, elements of the array when it is less than
elements long. For example, if all Gaussian sources have the same standard deviation then it is only necessary to set
to
and to provide the value of the standard deviation in
; the function will then automatically expand
to be of length
. For further details please see
Section 2.6 in the
G01 Chapter Introduction.
4
References
Greengard L and Strain J (1991) The Fast Gauss Transform SIAM J. Sci. Statist. Comput. 12(1) 79–94
Raykar V C and Duraiswami R (2005) Improved Fast Gauss Transform With Variable Source Scales University of Maryland Technical Report CS-TR-4727/UMIACS-TR-2005-34
5
Arguments
-
1:
– Integer
Input
-
On entry: , the number of dimensions.
Constraint:
.
-
2:
– const double
Input
-
Note: the th element of the matrix is stored in .
On entry: , the locations of the Gaussian sources.
-
3:
– Integer
Input
-
On entry: , the number of Gaussian sources.
Constraint:
.
-
4:
– const double
Input
-
Note: the th element of the matrix is stored in .
On entry: , the locations of the target points at which the FGT will be evaluated.
-
5:
– Integer
Input
-
On entry: , the number of target points.
Constraint:
.
-
6:
– const double
Input
-
On entry: , the weights of the Gaussian sources.
-
7:
– Integer *
Input/Output
-
On entry: , the number of terms of the first Taylor series to be evaluated.
On exit:
p1 is unchanged.
Constraint:
.
-
8:
– Integer *
Input/Output
-
On entry: , the number of terms of the second Taylor series to be evaluated.
On exit:
p2 is unchanged.
Constraint:
.
-
9:
– Integer *
Input/Output
-
On entry: , the number of clusters into which the source points will be aggregated.
Constraint:
.
-
10:
– const double
Input
-
On entry:
, the standard deviations of the Gaussian sources. If
, the array will be expanded automatically by repeating
hin until it is of length
n. See
Section 2.6 in the
G01 Chapter Introduction for further information.
Constraint:
, for .
-
11:
– Integer
Input
-
On entry: the length of the array
hin.
Constraint:
.
-
12:
– double
Input
-
On entry: , the desired accuracy of the FGT approximation of the DGT. Determines the radius of the source clusters: the contribution of a source point to the FGT approximation at a target point is disregarded if the source is outside the corresponding cluster radius.
Constraint:
.
-
13:
– double
Output
-
On exit: , the value of the FGT evaluated at .
-
14:
– double
Output
-
On exit: contains the absolute value of the final Taylor series term that is largest, relative to the size of the sum of the corresponding series, across all clusters that contribute to the FGT at target point .
-
15:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
- NE_ARRAY_SIZE
-
On entry, .
Constraint: .
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_INT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INT_2
-
On entry, and .
Constraint: .
- NE_INTERNAL_ERROR
-
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
See
Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library CL Interface for further information.
- NE_REAL
-
On entry, .
Constraint: .
- NE_REAL_ARRAY_INPUT
-
On entry, .
Constraint: , for .
- NW_TOO_FEW_TERMS
-
On exit,
,
and
.
p1,
p2 or
k may have been too small to calculate
to the required accuracy
tol.
7
Accuracy
The function does not currently implement the procedure described in
Raykar and Duraiswami (2005) for automatically determining values for
p1,
p2 and
k. Nonzero values must therefore be provided for these parameters when calling the function.
For a given set of source and target points and a specified tolerance, there is an interaction between the number of clusters,
k, and the number of Taylor series terms,
p1 and
p2: if the sources are clustered together in fewer clusters (small
k) then more terms will be needed in each cluster's Taylor series (large
p1 and
p2) to capture the effect of the source points further from the cluster centres. Increasing the number of clusters reduces their individual radii and requires fewer terms in their Taylor series, but increases the number of Taylor series that must be evaluated overall.
If the source and target points are uniformly distributed in a unit hypercube,
Raykar and Duraiswami (2005) advise users to select
. If the points are not uniformly distributed then more clusters than this will be needed to calculate the FGT to within the specified
tol without requiring prohibitively large values for
p1 and
p2.
There is less guidance available for selecting good values for
p1 and
p2. As the number of Taylor series terms is a major factor on the computation time taken by this function, you are advised to initially try a small number, e.g.
or so, and then tune
p1 and
p2 up or down based on the values returned. Note that
p1 and
p2 are not required to have identical values.
To aid the selection of values for
p1,
p2 and
k, the function returns in
the absolute value of the final Taylor series term that is largest, relative to the size of the sum of the corresponding series, across all clusters that contribute to the FGT at target point
. If this value is larger than the requested
tol, the function will additionally return a nonzero
fail value and you are advised to re-run the function with larger
p1,
p2 or
k.
8
Parallelism and Performance
c06sac is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
c06sac makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
The time complexity of the algorithm implemented by this function is , versus the time complexity of evaluating the DGT directly.
10
Example
In this example values for , , , , and are read in, calculated and the results displayed.
10.1
Program Text
10.2
Program Data
10.3
Program Results