All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bisect_large.hpp
Go to the documentation of this file.
#ifndef VIENNACL_LINALG_DETAIL_BISECT_BISECT_LARGE_HPP_
#define VIENNACL_LINALG_DETAIL_BISECT_BISECT_LARGE_HPP_
/* =========================================================================
Copyright (c) 2010-2016, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.
-----------------
ViennaCL - The Vienna Computing Library
-----------------
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
(A list of authors and contributors can be found in the manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
// includes, system
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
// includes, project
#include "viennacl/linalg/detail/bisect/config.hpp"
#include "viennacl/linalg/detail/bisect/structs.hpp"
#include "viennacl/linalg/detail/bisect/bisect_kernel_calls.hpp"
namespace viennacl
{
namespace linalg
{
namespace detail
{
template<typename NumericT>
void
computeEigenvaluesLargeMatrix(InputData<NumericT> &input, ResultDataLarge<NumericT> &result,
const unsigned int mat_size,
const NumericT lg, const NumericT ug, const NumericT precision)
{
// First kernel call: decide on which intervals bisect_Large_OneIntervals/
// bisect_Large_MultIntervals is executed
viennacl::linalg::detail::bisectLarge(input, result, mat_size, lg, ug, precision);
// compute eigenvalues for intervals that contained only one eigenvalue
// after the first processing step
viennacl::linalg::detail::bisectLarge_OneIntervals(input, result, mat_size, precision);
// process intervals that contained more than one eigenvalue after
// the first processing step
viennacl::linalg::detail::bisectLarge_MultIntervals(input, result, mat_size, precision);
}
template<typename NumericT>
bool
processResultDataLargeMatrix(ResultDataLarge<NumericT> &result,
const unsigned int mat_size)
{
bool bCompareResult = true;
// copy data from intervals that contained more than one eigenvalue after
// the first processing step
std::vector<NumericT> lambda_mult(mat_size);
viennacl::copy(result.g_lambda_mult, lambda_mult);
std::vector<unsigned int> pos_mult(mat_size);
viennacl::copy(result.g_pos_mult, pos_mult);
std::vector<unsigned int> blocks_mult_sum(mat_size);
viennacl::copy(result.g_blocks_mult_sum, blocks_mult_sum);
unsigned int num_one_intervals = result.g_num_one;
unsigned int sum_blocks_mult = mat_size - num_one_intervals;
// copy data for intervals that contained one eigenvalue after the first
// processing step
std::vector<NumericT> left_one(mat_size);
std::vector<NumericT> right_one(mat_size);
std::vector<unsigned int> pos_one(mat_size);
viennacl::copy(result.g_left_one, left_one);
viennacl::copy(result.g_right_one, right_one);
viennacl::copy(result.g_pos_one, pos_one);
// singleton intervals generated in the second step
for (unsigned int i = 0; i < sum_blocks_mult; ++i)
{
if (pos_mult[i] != 0)
result.std_eigenvalues[pos_mult[i] - 1] = lambda_mult[i];
else
{
throw memory_exception("Invalid array index! Are there more than 256 equal eigenvalues?");
}
}
// singleton intervals generated in the first step
unsigned int index = 0;
for (unsigned int i = 0; i < num_one_intervals; ++i, ++index)
{
result.std_eigenvalues[pos_one[i] - 1] = left_one[i];
}
return bCompareResult;
}
} // namespace detail
} // namespace linalg
} // namespace viennacl
#endif //VIENNACL_LINALG_DETAIL_BISECT_LARGE_HPP_
viennacl::linalg::detail::bisectLarge_MultIntervals
void bisectLarge_MultIntervals(const InputData< NumericT > &input, ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT precision)
Definition: bisect_kernel_calls.hpp:160
viennacl::linalg::detail::bisectLarge
void bisectLarge(const InputData< NumericT > &input, ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT lg, const NumericT ug, const NumericT precision)
Definition: bisect_kernel_calls.hpp:93
structs.hpp
Helper structures to simplify variable handling.
viennacl::memory_exception
Exception class in case of memory errors.
Definition: forwards.h:572
viennacl::linalg::detail::ResultDataLarge::g_left_one
viennacl::vector< NumericT > g_left_one
left interval limits of intervals containing one eigenvalue after the first iteration step ...
Definition: structs.hpp:137
bisect_kernel_calls.hpp
Kernel calls for the bisection algorithm.
config.hpp
Global configuration parameters.
NumericT
float NumericT
Definition: bisect.cpp:40
viennacl::linalg::detail::InputData
In this class the input matrix is stored.
Definition: structs.hpp:53
viennacl::linalg::detail::ResultDataLarge::g_lambda_mult
viennacl::vector< NumericT > g_lambda_mult
eigenvalues that have been generated in the second step from intervals that still contained multiple ...
Definition: structs.hpp:162
viennacl::linalg::detail::processResultDataLargeMatrix
bool processResultDataLargeMatrix(ResultDataLarge< NumericT > &result, const unsigned int mat_size)
Definition: bisect_large.hpp:88
viennacl::linalg::detail::ResultDataLarge::g_pos_one
viennacl::vector< unsigned int > g_pos_one
interval indices (position in sorted listed of eigenvalues) of intervals containing one eigenvalue af...
Definition: structs.hpp:143
viennacl::linalg::detail::ResultDataLarge::std_eigenvalues
std::vector< NumericT > std_eigenvalues
eigenvalues
Definition: structs.hpp:128
viennacl::linalg::detail::computeEigenvaluesLargeMatrix
void computeEigenvaluesLargeMatrix(InputData< NumericT > &input, ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT lg, const NumericT ug, const NumericT precision)
Definition: bisect_large.hpp:60
viennacl::linalg::detail::bisectLarge_OneIntervals
void bisectLarge_OneIntervals(const InputData< NumericT > &input, ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT precision)
Definition: bisect_kernel_calls.hpp:128
viennacl::linalg::detail::ResultDataLarge::g_right_one
viennacl::vector< NumericT > g_right_one
right interval limits of intervals containing one eigenvalue after the first iteration step ...
Definition: structs.hpp:140
viennacl::linalg::detail::ResultDataLarge::g_pos_mult
viennacl::vector< unsigned int > g_pos_mult
eigenvalue index of intervals that have been generated in the second processing step ...
Definition: structs.hpp:165
viennacl::copy
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) ...
Definition: circulant_matrix.hpp:150
viennacl::linalg::detail::ResultDataLarge
In this class the data of the result for large matrices is stored.
Definition: structs.hpp:125
viennacl::linalg::detail::ResultDataLarge::g_blocks_mult_sum
viennacl::vector< unsigned int > g_blocks_mult_sum
accumulated number of intervals in g_left_mult etc. of blocks of intervals containing more than one e...
Definition: structs.hpp:159
viennacl::linalg::detail::ResultDataLarge::g_num_one
viennacl::scalar< unsigned int > g_num_one
number of intervals containing one eigenvalue after the first step
Definition: structs.hpp:131