ViennaCL - The Vienna Computing Library  1.6.1
Free open-source GPU-accelerated linear algebra and solver library.
bisect_large.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_DETAIL_BISECT_BISECT_LARGE_HPP_
2 #define VIENNACL_LINALG_DETAIL_BISECT_BISECT_LARGE_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 
21 
31 // includes, system
32 #include <iostream>
33 #include <iomanip>
34 #include <stdlib.h>
35 #include <stdio.h>
36 
37 // includes, project
41 
42 namespace viennacl
43 {
44 namespace linalg
45 {
46 namespace detail
47 {
48 
58 template<typename NumericT>
59 void
61  const unsigned int mat_size,
62  const NumericT lg, const NumericT ug, const NumericT precision)
63 {
64  // First kernel call: decide on which intervals bisect_Large_OneIntervals/
65  // bisect_Large_MultIntervals is executed
66  viennacl::linalg::detail::bisectLarge(input, result, mat_size, lg, ug, precision);
67 
68  // compute eigenvalues for intervals that contained only one eigenvalue
69  // after the first processing step
70  viennacl::linalg::detail::bisectLarge_OneIntervals(input, result, mat_size, precision);
71 
72  // process intervals that contained more than one eigenvalue after
73  // the first processing step
74  viennacl::linalg::detail::bisectLarge_MultIntervals(input, result, mat_size, precision);
75 
76 }
77 
84 template<typename NumericT>
85 bool
87  const unsigned int mat_size)
88 {
89  bool bCompareResult = true;
90 
91  // copy data from intervals that contained more than one eigenvalue after
92  // the first processing step
93  std::vector<NumericT> lambda_mult(mat_size);
94  viennacl::copy(result.g_lambda_mult, lambda_mult);
95 
96  std::vector<unsigned int> pos_mult(mat_size);
97  viennacl::copy(result.g_pos_mult, pos_mult);
98 
99  std::vector<unsigned int> blocks_mult_sum(mat_size);
100  viennacl::copy(result.g_blocks_mult_sum, blocks_mult_sum);
101 
102  unsigned int num_one_intervals = result.g_num_one;
103  unsigned int sum_blocks_mult = mat_size - num_one_intervals;
104 
105 
106  // copy data for intervals that contained one eigenvalue after the first
107  // processing step
108  std::vector<NumericT> left_one(mat_size);
109  std::vector<NumericT> right_one(mat_size);
110  std::vector<unsigned int> pos_one(mat_size);
111 
112  viennacl::copy(result.g_left_one, left_one);
113  viennacl::copy(result.g_right_one, right_one);
114  viennacl::copy(result.g_pos_one, pos_one);
115 
116 
117  // singleton intervals generated in the second step
118  for (unsigned int i = 0; i < sum_blocks_mult; ++i)
119  {
120  if (pos_mult[i] != 0)
121  result.std_eigenvalues[pos_mult[i] - 1] = lambda_mult[i];
122 
123  else
124  {
125  // printf("pos_mult[%u] = %u\n", i, pos_mult[i]);
126  bCompareResult = false;
127  }
128  }
129 
130  // singleton intervals generated in the first step
131  unsigned int index = 0;
132 
133  for (unsigned int i = 0; i < num_one_intervals; ++i, ++index)
134  {
135  result.std_eigenvalues[pos_one[i] - 1] = left_one[i];
136  }
137 
138  return bCompareResult;
139 }
140 } // namespace detail
141 } // namespace linalg
142 } // namespace viennacl
143 #endif //VIENNACL_LINALG_DETAIL_BISECT_LARGE_HPP_
void bisectLarge_MultIntervals(const InputData< NumericT > &input, ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT precision)
void bisectLarge(const InputData< NumericT > &input, ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT lg, const NumericT ug, const NumericT precision)
Helper structures to simplify variable handling.
viennacl::vector< NumericT > g_left_one
Definition: structs.hpp:143
Kernel calls for the bisection algorithm.
Global configuration parameters.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
In this class the input matrix is stored.
Definition: structs.hpp:53
Definition: blas3.hpp:36
viennacl::vector< NumericT > g_lambda_mult
Definition: structs.hpp:177
bool processResultDataLargeMatrix(ResultDataLarge< NumericT > &result, const unsigned int mat_size)
viennacl::vector< unsigned int > g_pos_one
Definition: structs.hpp:151
std::vector< NumericT > std_eigenvalues
eigenvalues
Definition: structs.hpp:132
void computeEigenvaluesLargeMatrix(InputData< NumericT > &input, ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT lg, const NumericT ug, const NumericT precision)
void bisectLarge_OneIntervals(const InputData< NumericT > &input, ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT precision)
viennacl::vector< NumericT > g_right_one
Definition: structs.hpp:147
viennacl::vector< unsigned int > g_pos_mult
Definition: structs.hpp:181
void copy(std::vector< NumericT > &cpu_vec, circulant_matrix< NumericT, AlignmentV > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
In this class the data of the result for large matrices is stored.
Definition: structs.hpp:129
viennacl::vector< unsigned int > g_blocks_mult_sum
Definition: structs.hpp:173
viennacl::scalar< unsigned int > g_num_one
number of intervals containing one eigenvalue after the first step
Definition: structs.hpp:135