| 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 V, int N> |
|---|
| 20 | void test_blas_1<V, N>::test () { |
|---|
| 21 | { |
|---|
| 22 | value_type t; |
|---|
| 23 | real_type n; |
|---|
| 24 | V v1 (N), v2 (N); |
|---|
| 25 | |
|---|
| 26 | // _asum |
|---|
| 27 | initialize_vector (v1); |
|---|
| 28 | n = ublas::blas_1::asum (v1); |
|---|
| 29 | std::cout << "asum (v1) = " << n << std::endl; |
|---|
| 30 | |
|---|
| 31 | // _amax |
|---|
| 32 | initialize_vector (v1); |
|---|
| 33 | n = ublas::blas_1::amax (v1); |
|---|
| 34 | std::cout << "amax (v1) = " << n << std::endl; |
|---|
| 35 | |
|---|
| 36 | // _nrm2 |
|---|
| 37 | initialize_vector (v1); |
|---|
| 38 | n = ublas::blas_1::nrm2 (v1); |
|---|
| 39 | std::cout << "nrm2 (v1) = " << n << std::endl; |
|---|
| 40 | |
|---|
| 41 | // _dot |
|---|
| 42 | // _dotu |
|---|
| 43 | // _dotc |
|---|
| 44 | initialize_vector (v1); |
|---|
| 45 | initialize_vector (v2); |
|---|
| 46 | t = ublas::blas_1::dot (v1, v2); |
|---|
| 47 | std::cout << "dot (v1, v2) = " << t << std::endl; |
|---|
| 48 | t = ublas::blas_1::dot (ublas::conj (v1), v2); |
|---|
| 49 | std::cout << "dot (conj (v1), v2) = " << t << std::endl; |
|---|
| 50 | |
|---|
| 51 | // _copy |
|---|
| 52 | initialize_vector (v2); |
|---|
| 53 | ublas::blas_1::copy (v1, v2); |
|---|
| 54 | std::cout << "copy (v1, v2) = " << v1 << std::endl; |
|---|
| 55 | |
|---|
| 56 | // _swap |
|---|
| 57 | initialize_vector (v1); |
|---|
| 58 | initialize_vector (v2); |
|---|
| 59 | ublas::blas_1::swap (v1, v2); |
|---|
| 60 | std::cout << "swap (v1, v2) = " << v1 << " " << v2 << std::endl; |
|---|
| 61 | |
|---|
| 62 | // _scal |
|---|
| 63 | // csscal |
|---|
| 64 | // zdscal |
|---|
| 65 | initialize_vector (v1); |
|---|
| 66 | ublas::blas_1::scal (v1, value_type (1)); |
|---|
| 67 | std::cout << "scal (v1, 1) = " << v1 << std::endl; |
|---|
| 68 | |
|---|
| 69 | // _axpy |
|---|
| 70 | initialize_vector (v1); |
|---|
| 71 | initialize_vector (v2); |
|---|
| 72 | ublas::blas_1::axpy (v1, value_type (1), v2); |
|---|
| 73 | std::cout << "axpy (v1, 1, v2) = " << v1 << std::endl; |
|---|
| 74 | |
|---|
| 75 | // _rot |
|---|
| 76 | initialize_vector (v1); |
|---|
| 77 | initialize_vector (v2); |
|---|
| 78 | ublas::blas_1::rot (value_type (1), v1, value_type (1), v2); |
|---|
| 79 | std::cout << "rot (1, v1, 1, v2) = " << v1 << " " << v2 << std::endl; |
|---|
| 80 | } |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | #ifdef USE_FLOAT |
|---|
| 84 | template struct test_blas_1<ublas::vector<float>, 3>; |
|---|
| 85 | #endif |
|---|
| 86 | |
|---|
| 87 | #ifdef USE_DOUBLE |
|---|
| 88 | template struct test_blas_1<ublas::vector<double>, 3>; |
|---|
| 89 | #endif |
|---|
| 90 | |
|---|
| 91 | #ifdef USE_STD_COMPLEX |
|---|
| 92 | #ifdef USE_FLOAT |
|---|
| 93 | template struct test_blas_1<ublas::vector<std::complex<float> >, 3>; |
|---|
| 94 | #endif |
|---|
| 95 | |
|---|
| 96 | #ifdef USE_DOUBLE |
|---|
| 97 | template struct test_blas_1<ublas::vector<std::complex<double> >, 3>; |
|---|
| 98 | #endif |
|---|
| 99 | #endif |
|---|