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

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nmf.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_NMF_HPP
2 #define VIENNACL_LINALG_NMF_HPP
3
4 /* =========================================================================
5 Copyright (c) 2010-2016, 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 manual)
17
18 License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20
27 #include "viennacl/vector.hpp"
28 #include "viennacl/matrix.hpp"
29 #include "viennacl/linalg/prod.hpp"
30 #include "viennacl/linalg/norm_2.hpp"
31 #include "viennacl/linalg/norm_frobenius.hpp"
32
33 #include "viennacl/linalg/host_based/nmf_operations.hpp"
34
35 #ifdef VIENNACL_WITH_OPENCL
36 #include "viennacl/linalg/opencl/kernels/nmf.hpp"
37 #include "viennacl/linalg/opencl/nmf_operations.hpp"
38 #endif
39
40 #ifdef VIENNACL_WITH_CUDA
41 #include "viennacl/linalg/cuda/nmf_operations.hpp"
42 #endif
43
44 namespace viennacl
45 {
46 namespace linalg
47 {
48
56 template<typename ScalarType>
57 void nmf(viennacl::matrix_base<ScalarType> const & V, viennacl::matrix_base<ScalarType> & W,
58 viennacl::matrix_base<ScalarType> & H, viennacl::linalg::nmf_config const & conf)
59 {
60 assert(V.size1() == W.size1() && V.size2() == H.size2() && bool("Dimensions of W and H don't allow for V = W * H"));
61 assert(W.size2() == H.size1() && bool("Dimensions of W and H don't match, prod(W, H) impossible"));
62
63 switch (viennacl::traits::handle(V).get_active_handle_id())
64 {
65 case viennacl::MAIN_MEMORY:
66 viennacl::linalg::host_based::nmf(V, W, H, conf);
67 break;
68 #ifdef VIENNACL_WITH_OPENCL
69 case viennacl::OPENCL_MEMORY:
70 viennacl::linalg::opencl::nmf(V,W,H,conf);
71 break;
72 #endif
73
74 #ifdef VIENNACL_WITH_CUDA
75 case viennacl::CUDA_MEMORY:
76 viennacl::linalg::cuda::nmf(V,W,H,conf);
77 break;
78 #endif
79
80 case viennacl::MEMORY_NOT_INITIALIZED:
81 throw memory_exception("not initialised!");
82 default:
83 throw memory_exception("not implemented");
84
85 }
86
87 }
88 }
89 }
90
91 #endif
nmf_operations.hpp
viennacl::linalg::cuda::nmf
void nmf(viennacl::matrix_base< NumericT > const &V, viennacl::matrix_base< NumericT > &W, viennacl::matrix_base< NumericT > &H, viennacl::linalg::nmf_config const &conf)
The nonnegative matrix factorization (approximation) algorithm as suggested by Lee and Seung...
Definition: nmf_operations.hpp:59
norm_2.hpp
Generic interface for the l^2-norm. See viennacl/linalg/vector_operations.hpp for implementations...
viennacl::memory_exception
Exception class in case of memory errors.
Definition: forwards.h:572
viennacl::linalg::opencl::nmf
void nmf(viennacl::matrix_base< NumericT > const &V, viennacl::matrix_base< NumericT > &W, viennacl::matrix_base< NumericT > &H, viennacl::linalg::nmf_config const &conf)
The nonnegative matrix factorization (approximation) algorithm as suggested by Lee and Seung...
Definition: nmf_operations.hpp:45
prod.hpp
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
nmf_operations.hpp
matrix.hpp
Implementation of the dense matrix class.
viennacl::OPENCL_MEMORY
Definition: forwards.h:349
viennacl::matrix_base
Definition: matrix_def.hpp:103
viennacl::linalg::nmf_config
Configuration class for the nonnegative-matrix-factorization algorithm. Specify tolerances, maximum iteration counts, etc., here.
Definition: nmf_operations.hpp:39
nmf_operations.hpp
viennacl::linalg::host_based::nmf
void nmf(viennacl::matrix_base< NumericT > const &V, viennacl::matrix_base< NumericT > &W, viennacl::matrix_base< NumericT > &H, viennacl::linalg::nmf_config const &conf)
The nonnegative matrix factorization (approximation) algorithm as suggested by Lee and Seung...
Definition: nmf_operations.hpp:156
viennacl::MEMORY_NOT_INITIALIZED
Definition: forwards.h:347
viennacl::CUDA_MEMORY
Definition: forwards.h:350
norm_frobenius.hpp
Generic interface for the Frobenius norm.
viennacl::matrix_base::size2
size_type size2() const
Returns the number of columns.
Definition: matrix_def.hpp:226
viennacl::matrix_base::size1
size_type size1() const
Returns the number of rows.
Definition: matrix_def.hpp:224
viennacl::MAIN_MEMORY
Definition: forwards.h:348
vector.hpp
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
viennacl::linalg::nmf
void nmf(viennacl::matrix_base< ScalarType > const &V, viennacl::matrix_base< ScalarType > &W, viennacl::matrix_base< ScalarType > &H, viennacl::linalg::nmf_config const &conf)
The nonnegative matrix factorization (approximation) algorithm as suggested by Lee and Seung...
Definition: nmf.hpp:57
nmf.hpp
OpenCL kernel file for nonnegative matrix factorization.
viennacl::traits::handle
viennacl::backend::mem_handle & handle(T &obj)
Returns the generic memory handle of an object. Non-const version.
Definition: handle.hpp:41
viennacl::backend::mem_handle::get_active_handle_id
memory_types get_active_handle_id() const
Returns an ID for the currently active memory buffer. Other memory buffers might contain old or no da...
Definition: mem_handle.hpp:118