Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/numeric/ublas/test/test2/test22.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 5.5 KB
Line 
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
19template<class V, class M, int N>
20void test_blas_2<V, M, N>::test () {
21    {
22        V v1 (N), v2 (N);
23        M m (N, N);
24
25        // _t_mv
26        initialize_vector (v1);
27        initialize_matrix (m);
28        ublas::blas_2::tmv (v1, m);
29        std::cout << "tmv (v1, m) = " << v1 << std::endl;
30        initialize_vector (v1);
31        initialize_matrix (m);
32        ublas::blas_2::tmv (v1, ublas::trans (m));
33        std::cout << "tmv (v1, trans (m)) = " << v1 << std::endl;
34#ifdef USE_STD_COMPLEX
35        initialize_vector (v1);
36        initialize_matrix (m);
37        ublas::blas_2::tmv (v1, ublas::herm (m));
38        std::cout << "tmv (v1, herm (m)) = " << v1 << std::endl;
39#endif
40
41        // _t_sv
42        initialize_vector (v1);
43        initialize_vector (v2);
44        initialize_matrix (m, ublas::lower_tag ());
45        ublas::blas_2::tsv (v1, m, ublas::lower_tag ());
46        std::cout << "tsv (v1, m) = " << v1 << " " << ublas::prod (m, v1) - v2 << std::endl;
47        initialize_vector (v1);
48        initialize_vector (v2);
49        initialize_matrix (m, ublas::upper_tag ());
50        ublas::blas_2::tsv (v1, ublas::trans (m), ublas::lower_tag ());
51        std::cout << "tsv (v1, trans (m)) = " << v1 << " " << ublas::prod (ublas::trans (m), v1) - v2 << std::endl;
52#ifdef USE_STD_COMPLEX
53        initialize_vector (v1);
54        initialize_vector (v2);
55        initialize_matrix (m, ublas::upper_tag ());
56        ublas::blas_2::tsv (v1, ublas::herm (m), ublas::lower_tag ());
57        std::cout << "tsv (v1, herm (m)) = " << v1 << " " << ublas::prod (ublas::herm (m), v1) - v2 << std::endl;
58#endif
59        initialize_vector (v1);
60        initialize_vector (v2);
61        initialize_matrix (m, ublas::upper_tag ());
62        ublas::blas_2::tsv (v1, m, ublas::upper_tag ());
63        std::cout << "tsv (v1, m) = " << v1 << " " << ublas::prod (m, v1) - v2 << std::endl;
64        initialize_vector (v1);
65        initialize_vector (v2);
66        initialize_matrix (m, ublas::lower_tag ());
67        ublas::blas_2::tsv (v1, ublas::trans (m), ublas::upper_tag ());
68        std::cout << "tsv (v1, trans (m)) = " << v1 << " " << ublas::prod (ublas::trans (m), v1) - v2 << std::endl;
69#ifdef USE_STD_COMPLEX
70        initialize_vector (v1);
71        initialize_vector (v2);
72        initialize_matrix (m, ublas::lower_tag ());
73        ublas::blas_2::tsv (v1, ublas::herm (m), ublas::upper_tag ());
74        std::cout << "tsv (v1, herm (m)) = " << v1 << " " << ublas::prod (ublas::herm (m), v1) - v2 << std::endl;
75#endif
76
77        // _g_mv
78        // _s_mv
79        // _h_mv
80        initialize_vector (v1);
81        initialize_vector (v2);
82        initialize_matrix (m);
83        ublas::blas_2::gmv (v1, value_type (1), value_type (1), m, v2);
84        std::cout << "gmv (v1, 1, 1, m, v2) = " << v1 << std::endl;
85        ublas::blas_2::gmv (v1, value_type (1), value_type (1), ublas::trans (m), v2);
86        std::cout << "gmv (v1, 1, 1, trans (m), v2) = " << v1 << std::endl;
87#ifdef USE_STD_COMPLEX
88        ublas::blas_2::gmv (v1, value_type (1), value_type (1), ublas::herm (m), v2);
89        std::cout << "gmv (v1, 1, 1, herm (m), v2) = " << v1 << std::endl;
90#endif
91
92        // _g_r
93        // _g_ru
94        // _g_rc
95        initialize_vector (v1);
96        initialize_vector (v2);
97        initialize_matrix (m);
98        ublas::blas_2::gr (m, value_type (1), v1, v2);
99        std::cout << "gr (m, 1, v1, v2) = " << m << std::endl;
100        ublas::blas_2::gr (m, value_type (1), v1, ublas::conj (v2));
101        std::cout << "gr (m, 1, v1, conj (v2)) = " << m << std::endl;
102
103        // _s_r
104        initialize_vector (v1);
105        initialize_matrix (m);
106        ublas::blas_2::sr (m, value_type (1), v1);
107        std::cout << "sr (m, 1, v1) = " << m << std::endl;
108
109#ifdef USE_STD_COMPLEX
110        // _h_r
111        initialize_vector (v1);
112        initialize_matrix (m);
113        ublas::blas_2::hr (m, value_type (1), v1);
114        std::cout << "hr (m, 1, v1) = " << m << std::endl;
115#endif
116
117        // _s_r2
118        initialize_vector (v1);
119        initialize_vector (v2);
120        initialize_matrix (m);
121        ublas::blas_2::sr2 (m, value_type (1), v1, v2);
122        std::cout << "sr2 (m, 1, v1, v2) = " << m << std::endl;
123
124#ifdef USE_STD_COMPLEX
125        // _h_r2
126        initialize_vector (v1);
127        initialize_vector (v2);
128        initialize_matrix (m);
129        ublas::blas_2::hr2 (m, value_type (1), v1, v2);
130        std::cout << "hr2 (m, 1, v1, v2) = " << m << std::endl;
131#endif
132    }
133}
134
135#ifdef USE_FLOAT
136template struct test_blas_2<ublas::vector<float>, ublas::matrix<float>, 3>;
137#endif
138
139#ifdef USE_DOUBLE
140template struct test_blas_2<ublas::vector<double>, ublas::matrix<double>, 3>;
141#endif
142
143#ifdef USE_STD_COMPLEX
144#ifdef USE_FLOAT
145template struct test_blas_2<ublas::vector<std::complex<float> >, ublas::matrix<std::complex<float> >, 3>;
146#endif
147
148#ifdef USE_DOUBLE
149template struct test_blas_2<ublas::vector<std::complex<double> >, ublas::matrix<std::complex<double> >, 3>;
150#endif
151#endif
Note: See TracBrowser for help on using the repository browser.