ViennaCL - The Vienna Computing Library: viennacl/linalg/tred2.hpp Source File

ViennaCL - The Vienna Computing Library 1.6.2 Free open-source GPU-accelerated linear algebra and solver library. |

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tred2.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_TRED2_HPP_
2 #define VIENNACL_LINALG_TRED2_HPP_
3
4 /* =========================================================================
5 Copyright (c) 2010-2014, Institute for Microelectronics,
6 Institute for Analysis and Scientific Computing,
7 TU Wien.
8 Portions of this software are copyright by UChicago Argonne, LLC.
9
10 -----------------
11 ViennaCL - The Vienna Computing Library
12 -----------------
13
14 Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15
16 (A list of authors and contributors can be found in the PDF manual)
17
18 License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20
27 #include "viennacl/linalg/host_based/sse_kernels.hpp"
28 #include <boost/numeric/ublas/matrix.hpp>
29
30 namespace viennacl
31 {
32 namespace linalg
33 {
39 template<typename ScalarType>
40 void inplace_tred2(boost::numeric::ublas::matrix<ScalarType> const & A, vcl_size_t block_size = 1)
41 {
42
43 #ifdef VIENNACL_WITH_OPENMP
44 vcl_size_t num_threads=(vcl_size_t)omp_get_max_threads();
45 omp_set_num_threads(omp_get_max_threads());
46 #else
47 vcl_size_t num_threads=1;
48 #endif
49
50 vcl_size_t n=A.size1();
51 if (n!=A.size2())
52 std::cerr << "ViennaCL: Warning in inplace_tred2(): Matrix is not hermitian (or real symmetric)" << std::endl;
53 block_size=std::min(n,block_size);
54
55 //get pointers to the value arrays
56 ScalarType** rows=new ScalarType*[n];
57 for (vcl_size_t i=0;i<n;i++)
58 rows[i]=(ScalarType*)&A(i,0);
59
60 //call the optimized CPU code
61 inplace_tred2(rows,A.size1(),block_size,num_threads);
62
63 delete [] rows;
64 }
65
66 } //namespace linalg
67 } //namespace viennacl
68 #endif
sse_kernels.hpp
optimized linear algebra operations for the CPU
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:74
ScalarType
float ScalarType
Definition: fft_1d.cpp:42
viennacl::linalg::detail::min
T min(const T &lhs, const T &rhs)
Minimum.
Definition: util.hpp:45
viennacl::linalg::inplace_tred2
void inplace_tred2(boost::numeric::ublas::matrix< ScalarType > const &A, vcl_size_t block_size=1)
Inplace reduction of a hermitian (or real symmetric) to tridiagonal form using householder similarity...
Definition: tred2.hpp:40