You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
2.9 KiB

  1. // This program is free software; you can redistribute it and/or
  2. // modify it under the terms of the GNU General Public License
  3. // as published by the Free Software Foundation; either version 2
  4. // of the License, or (at your option) any later version.
  5. //
  6. // This program is distributed in the hope that it will be useful,
  7. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. // GNU General Public License for more details.
  10. // You should have received a copy of the GNU General Public License
  11. // along with this program; if not, write to the Free Software
  12. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  13. //
  14. #ifndef ACTION_ROT
  15. #define ACTION_ROT
  16. #include "utilities.h"
  17. #include "STL_interface.hh"
  18. #include <string>
  19. #include "init/init_function.hh"
  20. #include "init/init_vector.hh"
  21. #include "init/init_matrix.hh"
  22. using namespace std;
  23. template<class Interface>
  24. class Action_rot {
  25. public :
  26. // Ctor
  27. BTL_DONT_INLINE Action_rot( int size ):_size(size)
  28. {
  29. MESSAGE("Action_rot Ctor");
  30. // STL matrix and vector initialization
  31. typename Interface::stl_matrix tmp;
  32. init_vector<pseudo_random>(A_stl,_size);
  33. init_vector<pseudo_random>(B_stl,_size);
  34. // generic matrix and vector initialization
  35. Interface::vector_from_stl(A_ref,A_stl);
  36. Interface::vector_from_stl(A,A_stl);
  37. Interface::vector_from_stl(B_ref,B_stl);
  38. Interface::vector_from_stl(B,B_stl);
  39. }
  40. // invalidate copy ctor
  41. Action_rot( const Action_rot & )
  42. {
  43. INFOS("illegal call to Action_rot Copy Ctor");
  44. exit(1);
  45. }
  46. // Dtor
  47. BTL_DONT_INLINE ~Action_rot( void ){
  48. MESSAGE("Action_rot Dtor");
  49. Interface::free_vector(A);
  50. Interface::free_vector(B);
  51. Interface::free_vector(A_ref);
  52. Interface::free_vector(B_ref);
  53. }
  54. // action name
  55. static inline std::string name( void )
  56. {
  57. return "rot_" + Interface::name();
  58. }
  59. double nb_op_base( void ){
  60. return 6.0*_size;
  61. }
  62. BTL_DONT_INLINE void initialize( void ){
  63. Interface::copy_vector(A_ref,A,_size);
  64. Interface::copy_vector(B_ref,B,_size);
  65. }
  66. BTL_DONT_INLINE void calculate( void ) {
  67. BTL_ASM_COMMENT("#begin rot");
  68. Interface::rot(A,B,0.5,0.6,_size);
  69. BTL_ASM_COMMENT("end rot");
  70. }
  71. BTL_DONT_INLINE void check_result( void ){
  72. // calculation check
  73. // Interface::vector_to_stl(X,resu_stl);
  74. // STL_interface<typename Interface::real_type>::rot(A_stl,B_stl,X_stl,_size);
  75. // typename Interface::real_type error=
  76. // STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
  77. // if (error>1.e-3){
  78. // INFOS("WRONG CALCULATION...residual=" << error);
  79. // exit(0);
  80. // }
  81. }
  82. private :
  83. typename Interface::stl_vector A_stl;
  84. typename Interface::stl_vector B_stl;
  85. typename Interface::gene_vector A_ref;
  86. typename Interface::gene_vector B_ref;
  87. typename Interface::gene_vector A;
  88. typename Interface::gene_vector B;
  89. int _size;
  90. };
  91. #endif