# NAG AD Libraryf06ya (dgemm)

## ▸▿ Contents

Settings help

AD Name Style:

AD Specification Language:

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine f06ya_AD_f ( ad_handle, transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc, ifail)
 Integer, Intent (In) :: m, n, k, lda, ldb, ldc Integer, Intent (Inout) :: ifail ADTYPE, Intent (In) :: alpha, a(lda,*), b(ldb,*), beta ADTYPE, Intent (Inout) :: c(ldc,*) Character (1), Intent (In) :: transa, transb 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 f06ya ( void *&ad_handle, const char *transa, const char *transb, const Integer &m, const Integer &n, const Integer &k, const ADTYPE &alpha, const ADTYPE a[], const Integer &lda, const ADTYPE b[], const Integer &ldb, const ADTYPE &beta, ADTYPE c[], const Integer &ldc, Integer &ifail)
}
}
The function is overloaded on ADTYPE which represents the type of active arguments. ADTYPE may be any of the following types:
double,
dco::ga1s<double>::type,
dco::gt1s<double>::type
Note: this function can be used with AD tools other than dco/c++. For details, please contact NAG.

## 3Description

f06ya is the AD Library version of the primal routine f06yaf (dgemm).
f06yaf (dgemm) performs one of the matrix-matrix operations
 $C←αAB+βC, C←αATB+βC, C←αABT+βC or C←αATBT+βC,$
where $A$, $B$ and $C$ are real matrices, and $\alpha$ and $\beta$ are real scalars; $C$ is always $m×n$. For further information see Section 3 in the documentation for f06yaf (dgemm).

## 5Arguments

In addition to the arguments present in the interface of the primal routine, f06ya 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: transa – character Input
3: transb – character Input
4: m – Integer Input
5: n – Integer Input
6: k – Integer Input
7: Input
8: a(lda, $*$) – ADTYPE array Input
9: lda – Integer Input
10: b(ldb, $*$) – ADTYPE array Input
11: ldb – Integer Input
12: Input
13: c(ldc, $*$) – ADTYPE array Input/Output
14: ldc – Integer Input
15: ifail – Integer Input/Output
On entry: must be set to $\mathrm{0}$, $-\mathrm{1}\text{ or }\mathrm{1}$. On exit: any errors are indicated as described in Section 6.

## 6Error Indicators and Warnings

There are no specific error codes from f06yaf (dgemm), however f06ya can return:
${\mathbf{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.
${\mathbf{ifail}}=-199$
The routine was called using a mode that has not yet been implemented.
${\mathbf{ifail}}=-443$
On entry: ad_handle is nullptr.
This check is only made if the overloaded C++ interface is used with arguments not of type double.
${\mathbf{ifail}}=-444$
A C++ exception was thrown.
The error message will show the details of the C++ exception text.
${\mathbf{ifail}}=-899$
Dynamic memory allocation failed for AD.
See Section 4.8.1 in the NAG AD Library Introduction for further information.

Not applicable.

## 8Parallelism and Performance

f06ya is not threaded in any implementation.

None.

## 10Example

The following examples are variants of the example for f06yaf (dgemm), modified to demonstrate calling the NAG AD Library.

### 10.1Adjoint modes

Language Source File Data Results
Fortran f06ya_a1w_fe.f90 f06ya_a1w_fe.d f06ya_a1w_fe.r
C++ f06ya_a1w_hcppe.cpp f06ya_a1w_hcppe.d f06ya_a1w_hcppe.r

### 10.2Tangent modes

Language Source File Data Results
Fortran f06ya_t1w_fe.f90 f06ya_t1w_fe.d f06ya_t1w_fe.r
C++ f06ya_t1w_hcppe.cpp f06ya_t1w_hcppe.d f06ya_t1w_hcppe.r

### 10.3Passive mode

Language Source File Data Results
Fortran f06ya_p0w_fe.f90 f06ya_p0w_fe.d f06ya_p0w_fe.r
C++ f06ya_p0w_hcppe.cpp f06ya_p0w_hcppe.d f06ya_p0w_hcppe.r
{"ft_lang_label":"__label__en","ft_lang_prob":0.81664664,"math_prob":0.82934564,"size":1052,"snap":"2021-21-2021-25","text_gpt3_token_len":229,"char_repetition_ratio":0.14694656,"word_repetition_ratio":0.0,"special_character_ratio":0.20437263,"punctuation_ratio":0.1,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9543642,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-06-23T22:12:46Z\",\"WARC-Record-ID\":\"<urn:uuid:3d44253b-05c2-407c-9e8f-2b5da5bfe495>\",\"Content-Length\":\"36522\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:78d76906-e74e-410b-b8b7-8cbb5eb34855>\",\"WARC-Concurrent-To\":\"<urn:uuid:dcad8b7f-9df0-4d7b-91b9-1238708cb7fc>\",\"WARC-IP-Address\":\"78.129.168.4\",\"WARC-Target-URI\":\"https://www.nag.com/numeric/nl/nagdoc_latest/adhtml/f06/f06ya_ad_f.html\",\"WARC-Payload-Digest\":\"sha1:3ZK7K3WY6EFPSDJPU6RYABPBT6346T7A\",\"WARC-Block-Digest\":\"sha1:N3C2RYQ7LY43LD6AY3IKP24P32NUWQOZ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-25/CC-MAIN-2021-25_segments_1623488540235.72_warc_CC-MAIN-20210623195636-20210623225636-00557.warc.gz\"}"}