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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
//
// 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 M, std::size_t N>
void test_blas_3<M, N>::test () {
{
M m1 (N, N), m2 (N, N), m3 (N, N);
// _t_mm
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::tmm (m1, value_type (1), m2, m1);
std::cout << "tmm (m1, 1, m2, m1) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::tmm (m1, value_type (1), m2, ublas::trans (m1));
std::cout << "tmm (m1, 1, m2, trans (m1)) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::tmm (m1, value_type (1), ublas::trans (m2), m1);
std::cout << "tmm (m1, 1, trans (m2), m1) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::tmm (m1, value_type (1), ublas::trans (m2), ublas::trans (m1));
std::cout << "tmm (m1, 1, trans (m2), trans (m1)) = " << m1 << std::endl;
#ifdef USE_STD_COMPLEX
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::tmm (m1, value_type (1), m2, ublas::herm (m1));
std::cout << "tmm (m1, 1, m2, herm (m1)) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::tmm (m1, value_type (1), ublas::herm (m2), m1);
std::cout << "tmm (m1, 1, herm (m2), m1) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::tmm (m1, value_type (1), ublas::trans (m2), ublas::herm (m1));
std::cout << "tmm (m1, 1, trans (m2), herm (m1)) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::tmm (m1, value_type (1), ublas::herm (m2), ublas::trans (m1));
std::cout << "tmm (m1, 1, herm (m2), trans (m1)) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::tmm (m1, value_type (1), ublas::herm (m2), ublas::herm (m1));
std::cout << "tmm (m1, 1, herm (m2), herm (m1)) = " << m1 << std::endl;
#endif
// _t_sm
initialize_matrix (m1);
initialize_matrix (m2, ublas::lower_tag ());
initialize_matrix (m3);
ublas::blas_3::tsm (m1, value_type (1), m2, ublas::lower_tag ());
std::cout << "tsm (m1, 1, m2) = " << m1 << " " << ublas::prod (m2, m1) - value_type (1) * m3 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2, ublas::upper_tag ());
ublas::blas_3::tsm (m1, value_type (1), ublas::trans (m2), ublas::lower_tag ());
std::cout << "tsm (m1, 1, trans (m2)) = " << m1 << " " << ublas::prod (ublas::trans (m2), m1) - value_type (1) * m3 << std::endl;
#ifdef USE_STD_COMPLEX
initialize_matrix (m1);
initialize_matrix (m2, ublas::upper_tag ());
ublas::blas_3::tsm (m1, value_type (1), ublas::herm (m2), ublas::lower_tag ());
std::cout << "tsm (m1, 1, herm (m2)) = " << m1 << " " << ublas::prod (ublas::herm (m2), m1) - value_type (1) * m3 << std::endl;
#endif
initialize_matrix (m1);
initialize_matrix (m2, ublas::upper_tag ());
ublas::blas_3::tsm (m1, value_type (1), m2, ublas::upper_tag ());
std::cout << "tsm (m1, 1, m2) = " << m1 << " " << ublas::prod (m2, m1) - value_type (1) * m3 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2, ublas::lower_tag ());
ublas::blas_3::tsm (m1, value_type (1), ublas::trans (m2), ublas::upper_tag ());
std::cout << "tsm (m1, 1, trans (m2)) = " << m1 << " " << ublas::prod (ublas::trans (m2), m1) - value_type (1) * m3 << std::endl;
#ifdef USE_STD_COMPLEX
initialize_matrix (m1);
initialize_matrix (m2, ublas::lower_tag ());
ublas::blas_3::tsm (m1, value_type (1), ublas::herm (m2), ublas::upper_tag ());
std::cout << "tsm (m1, 1, herm (m2)) = " << m1 << " " << ublas::prod (ublas::herm (m2), m1) - value_type (1) * m3 << std::endl;
#endif
// _g_mm
// _s_mm
// _h_mm
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::gmm (m1, value_type (1), value_type (1), m2, m3);
std::cout << "gmm (m1, 1, 1, m2, m3) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::trans (m2), m3);
std::cout << "gmm (m1, 1, 1, trans (m2), m3) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::gmm (m1, value_type (1), value_type (1), m2, ublas::trans (m3));
std::cout << "gmm (m1, 1, 1, m2, trans (m3)) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::trans (m2), ublas::trans (m3));
std::cout << "gmm (m1, 1, 1, trans (m2), trans (m3)) = " << m1 << std::endl;
#ifdef USE_STD_COMPLEX
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::herm (m2), m3);
std::cout << "gmm (m1, 1, 1, herm (m2), m3) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::gmm (m1, value_type (1), value_type (1), m2, ublas::herm (m3));
std::cout << "gmm (m1, 1, 1, m2, herm (m3)) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::herm (m2), ublas::trans (m3));
std::cout << "gmm (m1, 1, 1, herm (m2), trans (m3)) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::trans (m2), ublas::herm (m3));
std::cout << "gmm (m1, 1, 1, trans (m2), herm (m3)) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::herm (m2), ublas::herm (m3));
std::cout << "gmm (m1, 1, 1, herm (m2), herm (m3)) = " << m1 << std::endl;
#endif
// s_rk
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::srk (m1, value_type (1), value_type (1), m2);
std::cout << "srk (m1, 1, 1, m2) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::srk (m1, value_type (1), value_type (1), ublas::trans (m2));
std::cout << "srk (m1, 1, 1, trans (m2)) = " << m1 << std::endl;
#ifdef USE_STD_COMPLEX
// h_rk
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::hrk (m1, value_type (1), value_type (1), m2);
std::cout << "hrk (m1, 1, 1, m2) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
ublas::blas_3::hrk (m1, value_type (1), value_type (1), ublas::herm (m2));
std::cout << "hrk (m1, 1, 1, herm (m2)) = " << m1 << std::endl;
#endif
// s_r2k
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::sr2k (m1, value_type (1), value_type (1), m2, m3);
std::cout << "sr2k (m1, 1, 1, m2, m3) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::sr2k (m1, value_type (1), value_type (1), ublas::trans (m2), ublas::trans (m3));
std::cout << "sr2k (m1, 1, 1, trans (m2), trans (m3)) = " << m1 << std::endl;
#ifdef USE_STD_COMPLEX
// h_r2k
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::hr2k (m1, value_type (1), value_type (1), m2, m3);
std::cout << "hr2k (m1, 1, 1, m2, m3) = " << m1 << std::endl;
initialize_matrix (m1);
initialize_matrix (m2);
initialize_matrix (m3);
ublas::blas_3::hr2k (m1, value_type (1), value_type (1), ublas::herm (m2), ublas::herm (m3));
std::cout << "hr2k (m1, 1, 1, herm (m2), herm (m3)) = " << m1 << std::endl;
#endif
}
}
#ifdef USE_FLOAT
template struct test_blas_3<ublas::matrix<float>, 3>;
#endif
#ifdef USE_DOUBLE
template struct test_blas_3<ublas::matrix<double>, 3>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct test_blas_3<ublas::matrix<std::complex<float> >, 3>;
#endif
#ifdef USE_DOUBLE
template struct test_blas_3<ublas::matrix<std::complex<double> >, 3>;
#endif
#endif
|