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