NAG AD Library
f08kp (zgesvd)

Settings help

AD Name Style:

AD Specification Language:

1 Purpose

f08kp is the AD Library version of the primal routine f08kpf (zgesvd). Based (in the C++ interface) on overload resolution, f08kp can be used for primal, tangent and adjoint evaluation. It supports tangents and adjoints of first order.

2 Specification

Fortran Interface
Subroutine f08kp_AD_f ( ad_handle, jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, rwork, ifail)
Integer, Intent (In) :: m, n, lda, ldu, ldvt, lwork
Integer, Intent (Inout) :: ifail
ADTYPE, Intent (Inout) :: s(*), rwork(*)
ADCTYPE, Intent (Inout) :: a(lda,*), u(ldu,*), vt(ldvt,*)
ADCTYPE, Intent (Out) :: work(max(1,lwork))
Character (1), Intent (In) :: jobu, jobvt
Type (c_ptr), Intent (Inout) :: ad_handle
Corresponding to the overloaded C++ function, the Fortran interface provides five routines with names reflecting the type used for active real arguments. The actual subroutine and type names are formed by replacing AD and ADTYPE in the above as follows:
when ADTYPE is Real(kind=nag_wp) then AD is p0w
when ADTYPE is Type(nagad_a1w_w_rtype) then AD is a1w
when ADTYPE is Type(nagad_t1w_w_rtype) then AD is t1w
C++ Header Interface
#include <dco.hpp>
#include <nagad.h>
namespace nag {
namespace ad {
void f08kp ( void *&ad_handle, const char *jobu, const char *jobvt, const Integer &m, const Integer &n, ADCTYPE a[], const Integer &lda, ADTYPE s[], ADCTYPE u[], const Integer &ldu, ADCTYPE vt[], const Integer &ldvt, ADCTYPE work[], const Integer &lwork, ADTYPE rwork[], Integer &ifail)
The function is overloaded on ADTYPE which represents the type of active arguments. ADTYPE may be any of the following types:
Note: this function can be used with AD tools other than dco/c++. For details, please contact NAG.

3 Description

f08kp is the AD Library version of the primal routine f08kpf (zgesvd).
f08kpf (zgesvd) computes the singular value decomposition (SVD) of a complex m×n matrix A, optionally computing the left and/or right singular vectors. For further information see Section 3 in the documentation for f08kpf (zgesvd).

4 References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

5 Arguments

In addition to the arguments present in the interface of the primal routine, f08kp includes some arguments specific to AD.
A brief summary of the AD specific arguments is given below. For the remainder, links are provided to the corresponding argument from the primal routine. A tooltip popup for all arguments can be found by hovering over the argument name in Section 2 and in this section.
1: ad_handle – Pointer to AD Data Input/Output
On entry: a handle to the AD configuration data object, as created by x10aa.
2: jobu – character Input
3: jobvt – character Input
4: m – Integer Input
5: n – Integer Input
6: a(lda, *) – ADCTYPE array Input/Output
7: lda – Integer Input
8: s(*) – ADTYPE array Output
9: u(ldu, *) – ADCTYPE array Output
10: ldu – Integer Input
11: vt(ldvt, *) – ADCTYPE array Output
12: ldvt – Integer Input
13: work(max(1,lwork)) – ADCTYPE array Workspace
14: lwork – Integer Input
15: rwork(*) – ADTYPE array Workspace
16: ifail – Integer Input/Output
On entry: must be set to 0, -1  or  1.
On exit: any errors are indicated as described in Section 6.

6 Error Indicators and Warnings

f08kp uses the standard NAG ifail mechanism. Any errors indicated via info values returned by f08kpf may be indicated with the same value returned by ifail. In addition, this routine may return:
An unexpected AD error has been triggered by this routine. Please contact NAG.
See Section 4.8.2 in the NAG AD Library Introduction for further information.
The routine was called using a mode that has not yet been implemented.
On entry: ad_handle is nullptr.
This check is only made if the overloaded C++ interface is used with arguments not of type double.
A C++ exception was thrown.
The error message will show the details of the C++ exception text.
Dynamic memory allocation failed for AD.
See Section 4.8.1 in the NAG AD Library Introduction for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

f08kp is not threaded in any implementation.

9 Further Comments


10 Example

The following examples are variants of the example for f08kpf (zgesvd), modified to demonstrate calling the NAG AD Library.
Description of the primal example.
This example finds the singular values and left and right singular vectors of the 6×4 matrix
A = ( 0.96-0.81i -0.03+0.96i -0.91+2.06i -0.05+0.41i -0.98+1.98i -1.20+0.19i -0.66+0.42i -0.81+0.56i 0.62-0.46i 1.01+0.02i 0.63-0.17i -1.11+0.60i -0.37+0.38i 0.19-0.54i -0.98-0.36i 0.22-0.20i 0.83+0.51i 0.20+0.01i -0.17-0.46i 1.47+1.59i 1.08-0.28i 0.20-0.12i -0.07+1.23i 0.26+0.26i ) ,  
together with approximate error bounds for the computed singular values and vectors.
The example program for f08kr illustrates finding a singular value decomposition for the case mn.

10.1 Adjoint modes

Language Source File Data Results
Fortran f08kp_a1w_fe.f90 f08kp_a1w_fe.d f08kp_a1w_fe.r
C++ f08kp_a1w_hcppe.cpp f08kp_a1w_hcppe.d f08kp_a1w_hcppe.r

10.2 Tangent modes

Language Source File Data Results
Fortran f08kp_t1w_fe.f90 f08kp_t1w_fe.d f08kp_t1w_fe.r
C++ f08kp_t1w_hcppe.cpp f08kp_t1w_hcppe.d f08kp_t1w_hcppe.r

10.3 Passive mode

Language Source File Data Results
Fortran f08kp_p0w_fe.f90 f08kp_p0w_fe.d f08kp_p0w_fe.r
C++ f08kp_p0w_hcppe.cpp f08kp_p0w_hcppe.d f08kp_p0w_hcppe.r