test21.cpp 2.5 KB

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