NAG AD Library
e04fc_a1w_f (lsq_uncon_mod_func_comp_a1w)

Note: a1w denotes that first order adjoints are computed in working precision; this has the corresponding argument type nagad_a1w_w_rtype. Also available is the t1w (first order tangent linear) mode, the interface of which is implied by replacing a1w by t1w throughout this document. Additionally, the p0w (passive interface, as alternative to the FL interface) mode is available and can be inferred by replacing of active types by the corresponding passive types. The method of codifying AD implementations in the routine name and corresponding argument types is described in the NAG AD Library Introduction.
Settings help

AD Name Style:


AD Specification Language:

1 Purpose

e04fc_a1w_f is the adjoint version of the primal routine e04fcf.

2 Specification

Fortran Interface
Subroutine e04fc_a1w_f ( ad_handle, m, n, lsqfun, lsqmon, iprint, maxcal, eta, xtol, stepmx, x, fsumsq, fvec, fjac, ldfjac, s, v, ldv, niter, nf, iw, liw, w, lw, iuser, ruser, ifail)
Integer, Intent (In) :: m, n, iprint, maxcal, ldfjac, ldv, liw, lw
Integer, Intent (Inout) :: iw(liw), iuser(*), ifail
Integer, Intent (Out) :: niter, nf
Type (nagad_a1w_w_rtype), Intent (In) :: eta, xtol, stepmx
Type (nagad_a1w_w_rtype), Intent (Inout) :: x(n), fjac(ldfjac,n), v(ldv,n), w(lw), ruser(*)
Type (nagad_a1w_w_rtype), Intent (Out) :: fsumsq, fvec(m), s(n)
Type (c_ptr), Intent (Inout) :: ad_handle
External :: lsqfun, lsqmon
C++ Header Interface
#include <nagad.h>
void e04fc_a1w_f_ ( void *&ad_handle, const Integer &m, const Integer &n,
void (NAG_CALL lsqfun)(void *&ad_handle, Integer &iflag, const Integer &m, const Integer &n, const nagad_a1w_w_rtype xc[], nagad_a1w_w_rtype fvec[], Integer iuser[], nagad_a1w_w_rtype ruser[]),
void (NAG_CALL lsqmon)(void *&ad_handle, const Integer &m, const Integer &n, const nagad_a1w_w_rtype xc[], const nagad_a1w_w_rtype fvec[], const nagad_a1w_w_rtype fjac[], const Integer &ldfjac, const nagad_a1w_w_rtype s[], const Integer &igrade, const Integer &niter, const Integer &nf, Integer iuser[], nagad_a1w_w_rtype ruser[]),
const Integer &iprint, const Integer &maxcal, const nagad_a1w_w_rtype &eta, const nagad_a1w_w_rtype &xtol, const nagad_a1w_w_rtype &stepmx, nagad_a1w_w_rtype x[], nagad_a1w_w_rtype &fsumsq, nagad_a1w_w_rtype fvec[], nagad_a1w_w_rtype fjac[], const Integer &ldfjac, nagad_a1w_w_rtype s[], nagad_a1w_w_rtype v[], const Integer &ldv, Integer &niter, Integer &nf, Integer iw[], const Integer &liw, nagad_a1w_w_rtype w[], const Integer &lw, Integer iuser[], nagad_a1w_w_rtype ruser[], Integer &ifail)
The routine may be called by the names e04fc_a1w_f or nagf_opt_lsq_uncon_mod_func_comp_a1w. The corresponding t1w and p0w variants of this routine are also available.

3 Description

e04fc_a1w_f is the adjoint version of the primal routine e04fcf.
e04fcf is a comprehensive algorithm for finding an unconstrained minimum of a sum of squares of m nonlinear functions in n variables (mn). No derivatives are required.
The routine is intended for functions which have continuous first and second derivatives (although it will usually work even if the derivatives have occasional discontinuities). For further information see Section 3 in the documentation for e04fcf.

4 References

Gill P E and Murray W (1978) Algorithms for the solution of the nonlinear least squares problem SIAM J. Numer. Anal. 15 977–992

5 Arguments

In addition to the arguments present in the interface of the primal routine, e04fc_a1w_f 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 – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object, as created by x10aa_a1w_f.
2: m – Integer Input
3: n – Integer Input
4: lsqfun – Subroutine External Procedure
The specification of lsqfun is:
Fortran Interface
Subroutine lsqfun ( ad_handle, iflag, m, n, xc, fvec, iuser, ruser)
Integer, Intent (In) :: m, n
Integer, Intent (Inout) :: iflag, iuser(*)
Type (nagad_a1w_w_rtype), Intent (In) :: xc(n)
Type (nagad_a1w_w_rtype), Intent (Inout) :: ruser(*)
Type (nagad_a1w_w_rtype), Intent (Out) :: fvec(m)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void lsqfun ( void *&ad_handle, Integer &iflag, const Integer &m, const Integer &n, const nagad_a1w_w_rtype xc[], nagad_a1w_w_rtype fvec[], Integer iuser[], nagad_a1w_w_rtype ruser[])
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: iflag – Integer Input/Output
3: m – Integer Input
4: n – Integer Input
5: xcType (nagad_a1w_w_rtype) array Input
6: fvecType (nagad_a1w_w_rtype) array Output
7: iuser(*) – Integer array User Workspace
8: ruser(*)Type (nagad_a1w_w_rtype) array User Workspace
5: lsqmon – Subroutine External Procedure
The specification of lsqmon is:
Fortran Interface
Subroutine lsqmon ( ad_handle, m, n, xc, fvec, fjac, ldfjac, s, igrade, niter, nf, iuser, ruser)
Integer, Intent (In) :: m, n, ldfjac, igrade, niter, nf
Integer, Intent (Inout) :: iuser(*)
Type (nagad_a1w_w_rtype), Intent (In) :: xc(n), fvec(m), fjac(ldfjac,n), s(n)
Type (nagad_a1w_w_rtype), Intent (Inout) :: ruser(*)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Header Interface
#include <nagad.h>
void lsqmon ( void *&ad_handle, const Integer &m, const Integer &n, const nagad_a1w_w_rtype xc[], const nagad_a1w_w_rtype fvec[], const nagad_a1w_w_rtype fjac[], const Integer &ldfjac, const nagad_a1w_w_rtype s[], const Integer &igrade, const Integer &niter, const Integer &nf, Integer iuser[], nagad_a1w_w_rtype ruser[])
1: ad_handle – Type (c_ptr) Input/Output
On entry: a handle to the AD configuration data object.
2: m – Integer Input
3: n – Integer Input
4: xcType (nagad_a1w_w_rtype) array Input
5: fvecType (nagad_a1w_w_rtype) array Input
6: fjacType (nagad_a1w_w_rtype) array Input
7: ldfjac – Integer Input
8: sType (nagad_a1w_w_rtype) array Input
9: igrade – Integer Input
10: niter – Integer Input
11: nf – Integer Input
12: iuser(*) – Integer array User Workspace
13: ruser(*)Type (nagad_a1w_w_rtype) array User Workspace
6: iprint – Integer Input
7: maxcal – Integer Input
8: etaType (nagad_a1w_w_rtype) Input
9: xtolType (nagad_a1w_w_rtype) Input
10: stepmxType (nagad_a1w_w_rtype) Input
11: x(n) – Type (nagad_a1w_w_rtype) array Input/Output
12: fsumsqType (nagad_a1w_w_rtype) Output
13: fvec(m) – Type (nagad_a1w_w_rtype) array Output
14: fjac(ldfjac, n) – Type (nagad_a1w_w_rtype) array Output
15: ldfjac – Integer Input
16: s(n) – Type (nagad_a1w_w_rtype) array Output
17: v(ldv, n) – Type (nagad_a1w_w_rtype) array Output
18: ldv – Integer Input
19: niter – Integer Output
20: nf – Integer Output
21: iw(liw) – Integer array Input/Output
Workspace.
22: liw – Integer Input
23: w(lw) – Type (nagad_a1w_w_rtype) array Input/Output
Workspace.
24: lw – Integer Input
25: iuser(*) – Integer array User Workspace
User workspace.
26: ruser(*) – Type (nagad_a1w_w_rtype) array User Workspace
User workspace.
27: ifail – Integer Input/Output

6 Error Indicators and Warnings

e04fc_a1w_f preserves all error codes from e04fcf and in addition can return:
ifail=-89
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.
ifail=-899
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

e04fc_a1w_f is not threaded in any implementation.

9 Further Comments

None.

10 Example

The following examples are variants of the example for e04fcf, modified to demonstrate calling the NAG AD Library.

10.1 Adjoint mode (a1w)

LanguageSource FileDataResults
Fortrane04fc_a1w_fe.f90e04fc_a1w_fe.de04fc_a1w_fe.r
C++e04fc_a1w_hcppe.cppe04fc_a1w_hcppe.de04fc_a1w_hcppe.r

10.2 Tangent mode (t1w)

LanguageSource FileDataResults
Fortrane04fc_t1w_fe.f90e04fc_t1w_fe.de04fc_t1w_fe.r
C++e04fc_t1w_hcppe.cppe04fc_t1w_hcppe.de04fc_t1w_hcppe.r

10.3 Passive mode (p0w)

LanguageSource FileDataResults
Fortrane04fc_p0w_fe.f90e04fc_p0w_fe.de04fc_p0w_fe.r
C++e04fc_p0w_hcppe.cppe04fc_p0w_hcppe.de04fc_p0w_hcppe.r