51 int main(
int argc,
char **argv)
53 const unsigned int n = 5;
54 std::vector<double>
a(n*n), b(n),
c(n);
55 std::vector<FadType>
A(n*n),
B(n),
C(n);
56 for (
unsigned int i=0; i<n; i++) {
57 for (
unsigned int j=0; j<n; j++)
62 for (
unsigned int j=0; j<n; j++)
69 blas.
GEMV(
Teuchos::NO_TRANS, n, n, 1.0, &
a[0], n, &b[0], 1, 0.0, &c[0], 1);
75 sacado_fad_blas.
GEMV(
Teuchos::NO_TRANS, n, n, 1.0, &
A[0], n, &
B[0], 1, 0.0, &C[0], 1);
80 std::cout.setf(std::ios::scientific);
81 std::cout.precision(p);
83 std::cout <<
"BLAS GEMV calculation:" << std::endl;
84 std::cout <<
"a = " << std::endl;
85 for (
unsigned int i=0; i<n; i++) {
86 for (
unsigned int j=0; j<n; j++)
87 std::cout <<
" " << std::setw(w) <<
a[i+j*n];
88 std::cout << std::endl;
90 std::cout <<
"b = " << std::endl;
91 for (
unsigned int i=0; i<n; i++) {
92 std::cout <<
" " << std::setw(w) << b[i];
94 std::cout << std::endl;
95 std::cout <<
"c = " << std::endl;
96 for (
unsigned int i=0; i<n; i++) {
97 std::cout <<
" " << std::setw(w) << c[i];
99 std::cout << std::endl << std::endl;
101 std::cout <<
"FAD BLAS GEMV calculation:" << std::endl;
102 std::cout <<
"A.val() (should = a) = " << std::endl;
103 for (
unsigned int i=0; i<n; i++) {
104 for (
unsigned int j=0; j<n; j++)
105 std::cout <<
" " << std::setw(w) <<
A[i+j*n].val();
106 std::cout << std::endl;
108 std::cout <<
"B.val() (should = b) = " << std::endl;
109 for (
unsigned int i=0; i<n; i++) {
110 std::cout <<
" " << std::setw(w) <<
B[i].val();
112 std::cout << std::endl;
113 std::cout <<
"C.val() (should = c) = " << std::endl;
114 for (
unsigned int i=0; i<n; i++) {
115 std::cout <<
" " << std::setw(w) << C[i].val();
117 std::cout << std::endl;
118 std::cout <<
"C.dx() ( = dc/db, should = a) = " << std::endl;
119 for (
unsigned int i=0; i<n; i++) {
120 for (
unsigned int j=0; j<n; j++)
121 std::cout <<
" " << std::setw(w) << C[i].dx(j);
122 std::cout << std::endl;
125 double tol = 1.0e-14;
127 for (
unsigned int i=0; i<n; i++) {
130 for (
unsigned int j=0; j<n; j++) {
136 std::cout <<
"\nExample passed!" << std::endl;
140 std::cout <<
"\nSomething is wrong, example failed!" << std::endl;
void GEMV(ETransp trans, const OrdinalType &m, const OrdinalType &n, const alpha_type alpha, const A_type *A, const OrdinalType &lda, const x_type *x, const OrdinalType &incx, const beta_type beta, ScalarType *y, const OrdinalType &incy) const
Sacado::Fad::DFad< double > FadType
expr expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c *expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 c
void GEMV(ETransp trans, const int &m, const int &n, const double &alpha, const double *A, const int &lda, const double *x, const int &incx, const double &beta, double *y, const int &incy) const