Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / multiprecision / test / ublas_interop / test21.cpp
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 #if defined(__GNUC__) && (__GNUC__ >= 9)
14 #pragma GCC diagnostic ignored "-Wdeprecated-copy"
15 #endif
16
17 #include "test2.hpp"
18
19 template <class V, int N>
20 void test_blas_1<V, N>::test()
21 {
22    {
23       value_type t;
24       real_type  n;
25       V          v1(N), v2(N);
26
27       // _asum
28       initialize_vector(v1);
29       n = ublas::blas_1::asum(v1);
30       std::cout << "asum (v1) = " << n << std::endl;
31
32       // _amax
33       initialize_vector(v1);
34       n = ublas::blas_1::amax(v1);
35       std::cout << "amax (v1) = " << n << std::endl;
36
37       // _nrm2
38       initialize_vector(v1);
39       n = ublas::blas_1::nrm2(v1);
40       std::cout << "nrm2 (v1) = " << n << std::endl;
41
42       // _dot
43       // _dotu
44       // _dotc
45       initialize_vector(v1);
46       initialize_vector(v2);
47       t = ublas::blas_1::dot(v1, v2);
48       std::cout << "dot (v1, v2) = " << t << std::endl;
49       t = ublas::blas_1::dot(ublas::conj(v1), v2);
50       std::cout << "dot (conj (v1), v2) = " << t << std::endl;
51
52       // _copy
53       initialize_vector(v2);
54       ublas::blas_1::copy(v1, v2);
55       std::cout << "copy (v1, v2) = " << v1 << std::endl;
56
57       // _swap
58       initialize_vector(v1);
59       initialize_vector(v2);
60       ublas::blas_1::swap(v1, v2);
61       std::cout << "swap (v1, v2) = " << v1 << " " << v2 << std::endl;
62
63       // _scal
64       // csscal
65       // zdscal
66       initialize_vector(v1);
67       ublas::blas_1::scal(v1, value_type(1));
68       std::cout << "scal (v1, 1) = " << v1 << std::endl;
69
70       // _axpy
71       initialize_vector(v1);
72       initialize_vector(v2);
73       ublas::blas_1::axpy(v1, value_type(1), v2);
74       std::cout << "axpy (v1, 1, v2) = " << v1 << std::endl;
75
76       // _rot
77       initialize_vector(v1);
78       initialize_vector(v2);
79       ublas::blas_1::rot(value_type(1), v1, value_type(1), v2);
80       std::cout << "rot (1, v1, 1, v2) = " << v1 << " " << v2 << std::endl;
81    }
82 }
83
84 #ifdef USE_FLOAT
85 template struct test_blas_1<ublas::vector<mp_test_type>, 3>;
86 #endif
87
88 #ifdef USE_DOUBLE
89 template struct test_blas_1<ublas::vector<double>, 3>;
90 #endif
91
92 #ifdef USE_STD_COMPLEX
93 #ifdef USE_FLOAT
94 template struct test_blas_1<ublas::vector<std::complex<mp_test_type> >, 3>;
95 #endif
96
97 #ifdef USE_DOUBLE
98 template struct test_blas_1<ublas::vector<std::complex<double> >, 3>;
99 #endif
100 #endif