g02asc computes the nearest correlation matrix, in the Frobenius norm, while fixing elements and optionally with bounds on the eigenvalues, to a given square input matrix.
The function may be called by the names: g02asc or nag_correg_corrmat_fixed.
3Description
g02asc finds the nearest correlation matrix, , to a matrix, , in the Frobenius norm. It uses an alternating projections algorithm with Anderson acceleration. Elements in the input matrix can be fixed by supplying the value in the corresponding element of the matrix . However, note that the algorithm may fail to converge if the fixed elements do not form part of a valid correlation matrix. You can optionally specify a lower bound, , on the eigenvalues of the computed correlation matrix, forcing the matrix to be positive definite with .
4References
Anderson D G (1965) Iterative Procedures for Nonlinear Integral Equations J. Assoc. Comput. Mach.12 547–560
Higham N J and Strabić N (2016) Anderson acceleration of the alternating projections method for computing the nearest correlation matrix Numer. Algor.72 1021–1042
5Arguments
1: – doubleInput/Output
Note: the th element of the matrix is stored in .
On entry: , the initial matrix.
On exit: the symmetric matrix with the diagonal elements set to .
2: – IntegerInput
On entry: the stride separating matrix row elements in the array g.
Constraint:
.
3: – IntegerInput
On entry: the order of the matrix .
Constraint:
.
4: – doubleInput
On entry: the value of .
If , a value of is used.
Constraint:
.
5: – const IntegerInput
Note: the th element of the matrix is stored in .
On entry: the symmetric matrix . If an element of is then the corresponding element in is fixed in the output . Only the strictly lower triangular part of need be set.
6: – IntegerInput
On entry: the stride separating matrix row elements in the array h.
Constraint:
.
7: – doubleInput
On entry: the termination tolerance for the iteration.
On entry: specifies the maximum number of iterations.
If , a value of is used.
9: – IntegerInput
On entry: the number of previous iterates to use in the Anderson acceleration. If , Anderson acceleration is not used. See Section 7 for further details.
If , a value of is used.
Constraint:
.
10: – doubleOutput
Note: the th element of the matrix is stored in .
On exit: contains the matrix .
11: – IntegerInput
On entry: the stride separating matrix row elements in the array x.
Constraint:
.
12: – Integer *Output
On exit: the number of iterations taken.
13: – double *Output
On exit: the value of after the final iteration.
14: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
NE_ALG_FAIL
Failure during Anderson acceleration. Consider setting and recomputing.
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_BAD_PARAM
On entry, argument had an illegal value.
NE_CONVERGENCE
Function failed to converge in iterations. A solution may not exist, however, try increasing maxit.
NE_INT
On entry, .
Constraint: .
NE_INT_2
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
The fixed element , lies outside the interval , for and .
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: .
7Accuracy
Alternating projections is an iterative process where at each iteration the new iterate, , can be improved by using Anderson acceleration to reduce the overall number of iterations. The alternating projections algorithm terminates at the th iteration when
where is the result of the first of two projections computed at each step.
Without Anderson acceleration this algorithm is guaranteed to converge. There is no theoretical guarantee of convergence of Anderson acceleration and, therefore, when it is used, no guarantee of convergence of g02asc. However, in practice it can be seen to significantly reduce the number of alternating projection iterations. Anderson acceleration is not used when m is set to zero. See c05mdc and Higham and Strabić (2016) and Anderson (1965) for further information.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g02asc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g02asc 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.
9Further Comments
Arrays are internally allocated by g02asc. The total size of these arrays does not exceed real elements. All allocated memory is freed before return of g02asc.
10Example
This example finds the nearest correlation matrix, , to the input, , whilst fixing two diagonal blocks as given by . The minimum eigenvalue of is stipulated to be .
and
Only the strictly lower half of is supplied in the example.