1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "test2.hpp"
template<class V, class M, std::size_t N>
void test_blas_2<V, M, N>::test () {
{
V v1 (N), v2 (N);
M m (N, N);
// _t_mv
initialize_vector (v1);
initialize_matrix (m);
ublas::blas_2::tmv (v1, m);
std::cout << "tmv (v1, m) = " << v1 << std::endl;
initialize_vector (v1);
initialize_matrix (m);
ublas::blas_2::tmv (v1, ublas::trans (m));
std::cout << "tmv (v1, trans (m)) = " << v1 << std::endl;
#ifdef USE_STD_COMPLEX
initialize_vector (v1);
initialize_matrix (m);
ublas::blas_2::tmv (v1, ublas::herm (m));
std::cout << "tmv (v1, herm (m)) = " << v1 << std::endl;
#endif
// _t_sv
initialize_vector (v1);
initialize_vector (v2);
initialize_matrix (m, ublas::lower_tag ());
ublas::blas_2::tsv (v1, m, ublas::lower_tag ());
std::cout << "tsv (v1, m) = " << v1 << " " << ublas::prod (m, v1) - v2 << std::endl;
initialize_vector (v1);
initialize_vector (v2);
initialize_matrix (m, ublas::upper_tag ());
ublas::blas_2::tsv (v1, ublas::trans (m), ublas::lower_tag ());
std::cout << "tsv (v1, trans (m)) = " << v1 << " " << ublas::prod (ublas::trans (m), v1) - v2 << std::endl;
#ifdef USE_STD_COMPLEX
initialize_vector (v1);
initialize_vector (v2);
initialize_matrix (m, ublas::upper_tag ());
ublas::blas_2::tsv (v1, ublas::herm (m), ublas::lower_tag ());
std::cout << "tsv (v1, herm (m)) = " << v1 << " " << ublas::prod (ublas::herm (m), v1) - v2 << std::endl;
#endif
initialize_vector (v1);
initialize_vector (v2);
initialize_matrix (m, ublas::upper_tag ());
ublas::blas_2::tsv (v1, m, ublas::upper_tag ());
std::cout << "tsv (v1, m) = " << v1 << " " << ublas::prod (m, v1) - v2 << std::endl;
initialize_vector (v1);
initialize_vector (v2);
initialize_matrix (m, ublas::lower_tag ());
ublas::blas_2::tsv (v1, ublas::trans (m), ublas::upper_tag ());
std::cout << "tsv (v1, trans (m)) = " << v1 << " " << ublas::prod (ublas::trans (m), v1) - v2 << std::endl;
#ifdef USE_STD_COMPLEX
initialize_vector (v1);
initialize_vector (v2);
initialize_matrix (m, ublas::lower_tag ());
ublas::blas_2::tsv (v1, ublas::herm (m), ublas::upper_tag ());
std::cout << "tsv (v1, herm (m)) = " << v1 << " " << ublas::prod (ublas::herm (m), v1) - v2 << std::endl;
#endif
// _g_mv
// _s_mv
// _h_mv
initialize_vector (v1);
initialize_vector (v2);
initialize_matrix (m);
ublas::blas_2::gmv (v1, value_type (1), value_type (1), m, v2);
std::cout << "gmv (v1, 1, 1, m, v2) = " << v1 << std::endl;
ublas::blas_2::gmv (v1, value_type (1), value_type (1), ublas::trans (m), v2);
std::cout << "gmv (v1, 1, 1, trans (m), v2) = " << v1 << std::endl;
#ifdef USE_STD_COMPLEX
ublas::blas_2::gmv (v1, value_type (1), value_type (1), ublas::herm (m), v2);
std::cout << "gmv (v1, 1, 1, herm (m), v2) = " << v1 << std::endl;
#endif
// _g_r
// _g_ru
// _g_rc
initialize_vector (v1);
initialize_vector (v2);
initialize_matrix (m);
ublas::blas_2::gr (m, value_type (1), v1, v2);
std::cout << "gr (m, 1, v1, v2) = " << m << std::endl;
ublas::blas_2::gr (m, value_type (1), v1, ublas::conj (v2));
std::cout << "gr (m, 1, v1, conj (v2)) = " << m << std::endl;
// _s_r
initialize_vector (v1);
initialize_matrix (m);
ublas::blas_2::sr (m, value_type (1), v1);
std::cout << "sr (m, 1, v1) = " << m << std::endl;
#ifdef USE_STD_COMPLEX
// _h_r
initialize_vector (v1);
initialize_matrix (m);
ublas::blas_2::hr (m, value_type (1), v1);
std::cout << "hr (m, 1, v1) = " << m << std::endl;
#endif
// _s_r2
initialize_vector (v1);
initialize_vector (v2);
initialize_matrix (m);
ublas::blas_2::sr2 (m, value_type (1), v1, v2);
std::cout << "sr2 (m, 1, v1, v2) = " << m << std::endl;
#ifdef USE_STD_COMPLEX
// _h_r2
initialize_vector (v1);
initialize_vector (v2);
initialize_matrix (m);
ublas::blas_2::hr2 (m, value_type (1), v1, v2);
std::cout << "hr2 (m, 1, v1, v2) = " << m << std::endl;
#endif
}
}
#ifdef USE_FLOAT
template struct test_blas_2<ublas::vector<float>, ublas::matrix<float>, 3>;
#endif
#ifdef USE_DOUBLE
template struct test_blas_2<ublas::vector<double>, ublas::matrix<double>, 3>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct test_blas_2<ublas::vector<std::complex<float> >, ublas::matrix<std::complex<float> >, 3>;
#endif
#ifdef USE_DOUBLE
template struct test_blas_2<ublas::vector<std::complex<double> >, ublas::matrix<std::complex<double> >, 3>;
#endif
#endif
|