test21.cpp 2.6 KB

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