ViennaCL - The Vienna Computing Library
1.5.1
|
00001 #ifndef VIENNACL_LINALG_TRED2_HPP_ 00002 #define VIENNACL_LINALG_TRED2_HPP_ 00003 00004 /* ========================================================================= 00005 Copyright (c) 2010-2014, Institute for Microelectronics, 00006 Institute for Analysis and Scientific Computing, 00007 TU Wien. 00008 Portions of this software are copyright by UChicago Argonne, LLC. 00009 00010 ----------------- 00011 ViennaCL - The Vienna Computing Library 00012 ----------------- 00013 00014 Project Head: Karl Rupp rupp@iue.tuwien.ac.at 00015 00016 (A list of authors and contributors can be found in the PDF manual) 00017 00018 License: MIT (X11), see file LICENSE in the base directory 00019 ============================================================================= */ 00020 00027 #include "viennacl/linalg/host_based/sse_kernels.hpp" 00028 #include <boost/numeric/ublas/matrix.hpp> 00029 00030 namespace viennacl 00031 { 00032 namespace linalg 00033 { 00039 template<typename ScalarType> 00040 void inplace_tred2(boost::numeric::ublas::matrix<ScalarType> const & A, vcl_size_t block_size = 1) 00041 { 00042 00043 #ifdef VIENNACL_WITH_OPENMP 00044 vcl_size_t num_threads=(vcl_size_t)omp_get_max_threads(); 00045 omp_set_num_threads(omp_get_max_threads()); 00046 #else 00047 vcl_size_t num_threads=1; 00048 #endif 00049 00050 vcl_size_t n=A.size1(); 00051 if(n!=A.size2()) 00052 std::cerr << "ViennaCL: Warning in inplace_tred2(): Matrix is not hermitian (or real symmetric)" << std::endl; 00053 block_size=std::min(n,block_size); 00054 00055 //get pointers to the value arrays 00056 ScalarType** rows=new ScalarType*[n]; 00057 for(vcl_size_t i=0;i<n;i++) 00058 rows[i]=(ScalarType*)&A(i,0); 00059 00060 //call the optimized CPU code 00061 inplace_tred2(rows,A.size1(),block_size,num_threads); 00062 00063 delete [] rows; 00064 } 00065 00066 } //namespace linalg 00067 } //namespace viennacl 00068 #endif