1 //
2 // Copyright (c) 2000-2002
3 // Joerg Walter, Mathias Koch
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // The authors gratefully acknowledge the support of
10 // GeNeSys mbH & Co. KG in producing this work.
11 //
12
13 #include "test2.hpp"
14
15 template<class M, std::size_t N>
test()16 void test_blas_3<M, N>::test () {
17 {
18 M m1 (N, N), m2 (N, N), m3 (N, N);
19
20 // _t_mm
21 initialize_matrix (m1);
22 initialize_matrix (m2);
23 ublas::blas_3::tmm (m1, value_type (1), m2, m1);
24 std::cout << "tmm (m1, 1, m2, m1) = " << m1 << std::endl;
25 initialize_matrix (m1);
26 initialize_matrix (m2);
27 ublas::blas_3::tmm (m1, value_type (1), m2, ublas::trans (m1));
28 std::cout << "tmm (m1, 1, m2, trans (m1)) = " << m1 << std::endl;
29 initialize_matrix (m1);
30 initialize_matrix (m2);
31 ublas::blas_3::tmm (m1, value_type (1), ublas::trans (m2), m1);
32 std::cout << "tmm (m1, 1, trans (m2), m1) = " << m1 << std::endl;
33 initialize_matrix (m1);
34 initialize_matrix (m2);
35 ublas::blas_3::tmm (m1, value_type (1), ublas::trans (m2), ublas::trans (m1));
36 std::cout << "tmm (m1, 1, trans (m2), trans (m1)) = " << m1 << std::endl;
37 #ifdef USE_STD_COMPLEX
38 initialize_matrix (m1);
39 initialize_matrix (m2);
40 ublas::blas_3::tmm (m1, value_type (1), m2, ublas::herm (m1));
41 std::cout << "tmm (m1, 1, m2, herm (m1)) = " << m1 << std::endl;
42 initialize_matrix (m1);
43 initialize_matrix (m2);
44 ublas::blas_3::tmm (m1, value_type (1), ublas::herm (m2), m1);
45 std::cout << "tmm (m1, 1, herm (m2), m1) = " << m1 << std::endl;
46 initialize_matrix (m1);
47 initialize_matrix (m2);
48 ublas::blas_3::tmm (m1, value_type (1), ublas::trans (m2), ublas::herm (m1));
49 std::cout << "tmm (m1, 1, trans (m2), herm (m1)) = " << m1 << std::endl;
50 initialize_matrix (m1);
51 initialize_matrix (m2);
52 ublas::blas_3::tmm (m1, value_type (1), ublas::herm (m2), ublas::trans (m1));
53 std::cout << "tmm (m1, 1, herm (m2), trans (m1)) = " << m1 << std::endl;
54 initialize_matrix (m1);
55 initialize_matrix (m2);
56 ublas::blas_3::tmm (m1, value_type (1), ublas::herm (m2), ublas::herm (m1));
57 std::cout << "tmm (m1, 1, herm (m2), herm (m1)) = " << m1 << std::endl;
58 #endif
59
60 // _t_sm
61 initialize_matrix (m1);
62 initialize_matrix (m2, ublas::lower_tag ());
63 initialize_matrix (m3);
64 ublas::blas_3::tsm (m1, value_type (1), m2, ublas::lower_tag ());
65 std::cout << "tsm (m1, 1, m2) = " << m1 << " " << ublas::prod (m2, m1) - value_type (1) * m3 << std::endl;
66 initialize_matrix (m1);
67 initialize_matrix (m2, ublas::upper_tag ());
68 ublas::blas_3::tsm (m1, value_type (1), ublas::trans (m2), ublas::lower_tag ());
69 std::cout << "tsm (m1, 1, trans (m2)) = " << m1 << " " << ublas::prod (ublas::trans (m2), m1) - value_type (1) * m3 << std::endl;
70 #ifdef USE_STD_COMPLEX
71 initialize_matrix (m1);
72 initialize_matrix (m2, ublas::upper_tag ());
73 ublas::blas_3::tsm (m1, value_type (1), ublas::herm (m2), ublas::lower_tag ());
74 std::cout << "tsm (m1, 1, herm (m2)) = " << m1 << " " << ublas::prod (ublas::herm (m2), m1) - value_type (1) * m3 << std::endl;
75 #endif
76 initialize_matrix (m1);
77 initialize_matrix (m2, ublas::upper_tag ());
78 ublas::blas_3::tsm (m1, value_type (1), m2, ublas::upper_tag ());
79 std::cout << "tsm (m1, 1, m2) = " << m1 << " " << ublas::prod (m2, m1) - value_type (1) * m3 << std::endl;
80 initialize_matrix (m1);
81 initialize_matrix (m2, ublas::lower_tag ());
82 ublas::blas_3::tsm (m1, value_type (1), ublas::trans (m2), ublas::upper_tag ());
83 std::cout << "tsm (m1, 1, trans (m2)) = " << m1 << " " << ublas::prod (ublas::trans (m2), m1) - value_type (1) * m3 << std::endl;
84 #ifdef USE_STD_COMPLEX
85 initialize_matrix (m1);
86 initialize_matrix (m2, ublas::lower_tag ());
87 ublas::blas_3::tsm (m1, value_type (1), ublas::herm (m2), ublas::upper_tag ());
88 std::cout << "tsm (m1, 1, herm (m2)) = " << m1 << " " << ublas::prod (ublas::herm (m2), m1) - value_type (1) * m3 << std::endl;
89 #endif
90
91 // _g_mm
92 // _s_mm
93 // _h_mm
94 initialize_matrix (m1);
95 initialize_matrix (m2);
96 initialize_matrix (m3);
97 ublas::blas_3::gmm (m1, value_type (1), value_type (1), m2, m3);
98 std::cout << "gmm (m1, 1, 1, m2, m3) = " << m1 << std::endl;
99 initialize_matrix (m1);
100 initialize_matrix (m2);
101 initialize_matrix (m3);
102 ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::trans (m2), m3);
103 std::cout << "gmm (m1, 1, 1, trans (m2), m3) = " << m1 << std::endl;
104 initialize_matrix (m1);
105 initialize_matrix (m2);
106 initialize_matrix (m3);
107 ublas::blas_3::gmm (m1, value_type (1), value_type (1), m2, ublas::trans (m3));
108 std::cout << "gmm (m1, 1, 1, m2, trans (m3)) = " << m1 << std::endl;
109 initialize_matrix (m1);
110 initialize_matrix (m2);
111 initialize_matrix (m3);
112 ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::trans (m2), ublas::trans (m3));
113 std::cout << "gmm (m1, 1, 1, trans (m2), trans (m3)) = " << m1 << std::endl;
114 #ifdef USE_STD_COMPLEX
115 initialize_matrix (m1);
116 initialize_matrix (m2);
117 initialize_matrix (m3);
118 ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::herm (m2), m3);
119 std::cout << "gmm (m1, 1, 1, herm (m2), m3) = " << m1 << std::endl;
120 initialize_matrix (m1);
121 initialize_matrix (m2);
122 initialize_matrix (m3);
123 ublas::blas_3::gmm (m1, value_type (1), value_type (1), m2, ublas::herm (m3));
124 std::cout << "gmm (m1, 1, 1, m2, herm (m3)) = " << m1 << std::endl;
125 initialize_matrix (m1);
126 initialize_matrix (m2);
127 initialize_matrix (m3);
128 ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::herm (m2), ublas::trans (m3));
129 std::cout << "gmm (m1, 1, 1, herm (m2), trans (m3)) = " << m1 << std::endl;
130 initialize_matrix (m1);
131 initialize_matrix (m2);
132 initialize_matrix (m3);
133 ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::trans (m2), ublas::herm (m3));
134 std::cout << "gmm (m1, 1, 1, trans (m2), herm (m3)) = " << m1 << std::endl;
135 initialize_matrix (m1);
136 initialize_matrix (m2);
137 initialize_matrix (m3);
138 ublas::blas_3::gmm (m1, value_type (1), value_type (1), ublas::herm (m2), ublas::herm (m3));
139 std::cout << "gmm (m1, 1, 1, herm (m2), herm (m3)) = " << m1 << std::endl;
140 #endif
141
142 // s_rk
143 initialize_matrix (m1);
144 initialize_matrix (m2);
145 ublas::blas_3::srk (m1, value_type (1), value_type (1), m2);
146 std::cout << "srk (m1, 1, 1, m2) = " << m1 << std::endl;
147 initialize_matrix (m1);
148 initialize_matrix (m2);
149 ublas::blas_3::srk (m1, value_type (1), value_type (1), ublas::trans (m2));
150 std::cout << "srk (m1, 1, 1, trans (m2)) = " << m1 << std::endl;
151
152 #ifdef USE_STD_COMPLEX
153 // h_rk
154 initialize_matrix (m1);
155 initialize_matrix (m2);
156 ublas::blas_3::hrk (m1, value_type (1), value_type (1), m2);
157 std::cout << "hrk (m1, 1, 1, m2) = " << m1 << std::endl;
158 initialize_matrix (m1);
159 initialize_matrix (m2);
160 ublas::blas_3::hrk (m1, value_type (1), value_type (1), ublas::herm (m2));
161 std::cout << "hrk (m1, 1, 1, herm (m2)) = " << m1 << std::endl;
162 #endif
163
164 // s_r2k
165 initialize_matrix (m1);
166 initialize_matrix (m2);
167 initialize_matrix (m3);
168 ublas::blas_3::sr2k (m1, value_type (1), value_type (1), m2, m3);
169 std::cout << "sr2k (m1, 1, 1, m2, m3) = " << m1 << std::endl;
170 initialize_matrix (m1);
171 initialize_matrix (m2);
172 initialize_matrix (m3);
173 ublas::blas_3::sr2k (m1, value_type (1), value_type (1), ublas::trans (m2), ublas::trans (m3));
174 std::cout << "sr2k (m1, 1, 1, trans (m2), trans (m3)) = " << m1 << std::endl;
175
176 #ifdef USE_STD_COMPLEX
177 // h_r2k
178 initialize_matrix (m1);
179 initialize_matrix (m2);
180 initialize_matrix (m3);
181 ublas::blas_3::hr2k (m1, value_type (1), value_type (1), m2, m3);
182 std::cout << "hr2k (m1, 1, 1, m2, m3) = " << m1 << std::endl;
183 initialize_matrix (m1);
184 initialize_matrix (m2);
185 initialize_matrix (m3);
186 ublas::blas_3::hr2k (m1, value_type (1), value_type (1), ublas::herm (m2), ublas::herm (m3));
187 std::cout << "hr2k (m1, 1, 1, herm (m2), herm (m3)) = " << m1 << std::endl;
188 #endif
189 }
190 }
191
192 #ifdef USE_FLOAT
193 template struct test_blas_3<ublas::matrix<float>, 3>;
194 #endif
195
196 #ifdef USE_DOUBLE
197 template struct test_blas_3<ublas::matrix<double>, 3>;
198 #endif
199
200 #ifdef USE_STD_COMPLEX
201 #ifdef USE_FLOAT
202 template struct test_blas_3<ublas::matrix<std::complex<float> >, 3>;
203 #endif
204
205 #ifdef USE_DOUBLE
206 template struct test_blas_3<ublas::matrix<std::complex<double> >, 3>;
207 #endif
208 #endif
209