1 #ifndef VIENNACL_LINALG_HOST_BASED_DIRECT_SOLVE_HPP
2 #define VIENNACL_LINALG_HOST_BASED_DIRECT_SOLVE_HPP
42 template<
typename MatrixT1,
typename MatrixT2>
45 typedef typename MatrixT2::value_type value_type;
51 for (
vcl_size_t j = current_row + 1; j < A_size; ++j)
53 value_type A_element = A(current_row, j);
55 B(current_row, k) -= A_element * B(j, k);
60 value_type A_diag = A(current_row, current_row);
62 B(current_row, k) /= A_diag;
67 template<
typename MatrixT1,
typename MatrixT2>
73 template<
typename MatrixT1,
typename MatrixT2>
82 template<
typename MatrixT1,
typename MatrixT2>
85 typedef typename MatrixT2::value_type value_type;
91 value_type A_element = A(i, j);
93 B(i, k) -= A_element * B(j, k);
98 value_type A_diag = A(i, i);
105 template<
typename MatrixT1,
typename MatrixT2>
111 template<
typename MatrixT1,
typename MatrixT2>
131 template<
typename NumericT,
typename SolverTagT>
136 typedef NumericT value_type;
138 value_type
const * data_A = detail::extract_raw_pointer<value_type>(A);
139 value_type * data_B = detail::extract_raw_pointer<value_type>(B);
160 if (!trans_A && !trans_B)
191 else if (!trans_A && trans_B)
222 else if (trans_A && !trans_B)
253 else if (trans_A && trans_B)
291 template<
typename NumericT,
typename SolverTagT>
296 typedef NumericT value_type;
298 value_type
const * data_A = detail::extract_raw_pointer<value_type>(A);
299 value_type * data_B =
const_cast<value_type *
>(detail::extract_raw_pointer<value_type>(proxy_B.lhs()));
318 if (A.
row_major() && proxy_B.lhs().row_major())
325 else if (A.
row_major() && !proxy_B.lhs().row_major())
332 else if (!A.
row_major() && proxy_B.lhs().row_major())
354 template<
typename NumericT,
typename SolverTagT>
359 typedef NumericT value_type;
361 value_type
const * data_A = detail::extract_raw_pointer<value_type>(proxy_A.lhs());
362 value_type * data_B =
const_cast<value_type *
>(detail::extract_raw_pointer<value_type>(B));
380 if (proxy_A.lhs().row_major() && B.
row_major())
387 else if (proxy_A.lhs().row_major() && !B.
row_major())
394 else if (!proxy_A.lhs().row_major() && B.
row_major())
415 template<
typename NumericT,
typename SolverTagT>
420 typedef NumericT value_type;
422 value_type
const * data_A = detail::extract_raw_pointer<value_type>(proxy_A.lhs());
423 value_type * data_B =
const_cast<value_type *
>(detail::extract_raw_pointer<value_type>(proxy_B.lhs()));
441 if (proxy_A.lhs().row_major() && proxy_B.lhs().row_major())
448 else if (proxy_A.lhs().row_major() && !proxy_B.lhs().row_major())
455 else if (!proxy_A.lhs().row_major() && proxy_B.lhs().row_major())
480 template<
typename MatrixT,
typename VectorT>
483 typedef typename VectorT::value_type value_type;
489 for (
vcl_size_t j = current_row + 1; j < A_size; ++j)
491 value_type A_element = A(current_row, j);
492 b(current_row) -= A_element * b(j);
496 b(current_row) /= A(current_row, current_row);
500 template<
typename MatrixT,
typename VectorT>
506 template<
typename MatrixT,
typename VectorT>
515 template<
typename MatrixT,
typename VectorT>
518 typedef typename VectorT::value_type value_type;
524 value_type A_element = A(i, j);
525 b(i) -= A_element * b(j);
533 template<
typename MatrixT,
typename VectorT>
539 template<
typename MatrixT,
typename VectorT>
547 template<
typename NumericT,
typename SolverTagT>
552 typedef NumericT value_type;
554 value_type
const * data_A = detail::extract_raw_pointer<value_type>(mat);
555 value_type * data_v = detail::extract_raw_pointer<value_type>(vec);
Helper class for accessing a strided subvector of a larger vector.
result_of::size_type< matrix_base< NumericT > >::type stride1(matrix_base< NumericT > const &s)
Implementation of the dense matrix class.
vcl_size_t internal_size1(matrix_base< NumericT > const &mat)
Helper routine for obtaining the internal number of entries per row of a ViennaCL matrix...
void lower_inplace_solve_vector(MatrixT &A, VectorT &b, vcl_size_t A_size, bool unit_diagonal)
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
A tag class representing a lower triangular matrix.
vcl_size_t internal_size2(matrix_base< NumericT > const &mat)
Helper routine for obtaining the internal number of entries per column of a ViennaCL matrix...
void inplace_solve(const matrix_base< NumericT > &A, bool trans_A, matrix_base< NumericT > &B, bool trans_B, SolverTagT)
Direct inplace solver for triangular systems with multiple right hand sides, i.e. A \ B (MATLAB notat...
Expression template class for representing a tree of expressions which ultimately result in a matrix...
result_of::size_type< viennacl::vector_base< T > >::type stride(viennacl::vector_base< T > const &s)
result_of::size_type< T >::type start1(T const &obj)
void upper_inplace_solve_vector(MatrixT &A, VectorT &b, vcl_size_t A_size, bool unit_diagonal)
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
void lower_inplace_solve_matrix(MatrixT1 &A, MatrixT2 &B, vcl_size_t A_size, vcl_size_t B_size, bool unit_diagonal)
result_of::size_type< T >::type start2(T const &obj)
Helper array for accessing a strided submatrix embedded in a larger matrix.
A tag class representing an upper triangular matrix.
result_of::size_type< T >::type start(T const &obj)
Common routines for single-threaded or OpenMP-enabled execution on CPU.
result_of::size_type< matrix_base< NumericT > >::type stride2(matrix_base< NumericT > const &s)
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
void upper_inplace_solve_matrix(MatrixT1 &A, MatrixT2 &B, vcl_size_t A_size, vcl_size_t B_size, bool unit_diagonal)
void inplace_solve_vector(MatrixT &A, VectorT &b, vcl_size_t A_size, viennacl::linalg::unit_upper_tag)
A tag class representing a lower triangular matrix with unit diagonal.
A tag class representing transposed matrices.
void inplace_solve_matrix(MatrixT1 &A, MatrixT2 &B, vcl_size_t A_size, vcl_size_t B_size, viennacl::linalg::unit_upper_tag)
A tag class representing an upper triangular matrix with unit diagonal.