29 int main(
int argc,
char **argv)
31 const unsigned int n = 5;
32 std::vector<double>
a(n*n), b(n),
c(n);
33 std::vector<FadType>
A(n*n),
B(n),
C(n);
34 for (
unsigned int i=0;
i<n;
i++) {
35 for (
unsigned int j=0; j<n; j++)
40 for (
unsigned int j=0; j<n; j++)
47 blas.
GEMV(
Teuchos::NO_TRANS, n, n, 1.0, &
a[0], n, &b[0], 1, 0.0, &c[0], 1);
53 sacado_fad_blas.
GEMV(
Teuchos::NO_TRANS, n, n, 1.0, &
A[0], n, &
B[0], 1, 0.0, &C[0], 1);
58 std::cout.setf(std::ios::scientific);
59 std::cout.precision(p);
61 std::cout <<
"BLAS GEMV calculation:" << std::endl;
62 std::cout <<
"a = " << std::endl;
63 for (
unsigned int i=0;
i<n;
i++) {
64 for (
unsigned int j=0; j<n; j++)
65 std::cout <<
" " << std::setw(w) <<
a[
i+j*n];
66 std::cout << std::endl;
68 std::cout <<
"b = " << std::endl;
69 for (
unsigned int i=0;
i<n;
i++) {
70 std::cout <<
" " << std::setw(w) << b[
i];
72 std::cout << std::endl;
73 std::cout <<
"c = " << std::endl;
74 for (
unsigned int i=0;
i<n;
i++) {
75 std::cout <<
" " << std::setw(w) << c[
i];
77 std::cout << std::endl << std::endl;
79 std::cout <<
"FAD BLAS GEMV calculation:" << std::endl;
80 std::cout <<
"A.val() (should = a) = " << std::endl;
81 for (
unsigned int i=0;
i<n;
i++) {
82 for (
unsigned int j=0; j<n; j++)
83 std::cout <<
" " << std::setw(w) <<
A[
i+j*n].val();
84 std::cout << std::endl;
86 std::cout <<
"B.val() (should = b) = " << std::endl;
87 for (
unsigned int i=0;
i<n;
i++) {
88 std::cout <<
" " << std::setw(w) <<
B[
i].val();
90 std::cout << std::endl;
91 std::cout <<
"C.val() (should = c) = " << std::endl;
92 for (
unsigned int i=0;
i<n;
i++) {
93 std::cout <<
" " << std::setw(w) << C[
i].val();
95 std::cout << std::endl;
96 std::cout <<
"C.dx() ( = dc/db, should = a) = " << std::endl;
97 for (
unsigned int i=0;
i<n;
i++) {
98 for (
unsigned int j=0; j<n; j++)
99 std::cout <<
" " << std::setw(w) << C[
i].dx(j);
100 std::cout << std::endl;
103 double tol = 1.0e-14;
105 for (
unsigned int i=0;
i<n;
i++) {
108 for (
unsigned int j=0; j<n; j++) {
114 std::cout <<
"\nExample passed!" << std::endl;
118 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