1 #ifndef VIENNACL_LINALG_OPENCL_NMF_OPERATIONS_HPP_
2 #define VIENNACL_LINALG_OPENCL_NMF_OPERATIONS_HPP_
44 template<
typename NumericT>
52 const std::string NMF_MUL_DIV_KERNEL =
"el_wise_mul_div";
77 bool stagnation_flag =
false;
108 diff_init = diff_val;
111 std::cout << diff_val / diff_init << std::endl;
114 if (diff_val / diff_init < conf.
tolerance())
124 stagnation_flag =
true;
127 stagnation_flag =
false;
130 last_diff = diff_val;
void trans(const matrix_expression< const matrix_base< NumericT, SizeT, DistanceT >, const matrix_base< NumericT, SizeT, DistanceT >, op_trans > &proxy, matrix_base< NumericT > &temp_trans)
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...
Represents an OpenCL kernel within ViennaCL.
vcl_size_t check_after_steps() const
Number of steps after which the convergence of NMF should be checked (again)
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Configuration class for the nonnegative-matrix-factorization algorithm. Specify tolerances, maximum iteration counts, etc., here.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
viennacl::ocl::kernel & get_kernel(std::string const &program_name, std::string const &kernel_name)
Convenience function for retrieving the kernel of a program directly from the context.
vcl_size_t max_iterations() const
Returns the maximum number of iterations for the NMF algorithm.
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
double tolerance() const
Returns the relative tolerance for convergence.
Main kernel class for generating OpenCL kernels for nonnegative matrix factorization of a dense matri...
size_type size2() const
Returns the number of columns.
size_type size1() const
Returns the number of rows.
double stagnation_tolerance() const
Relative tolerance for the stagnation check.
void enqueue(KernelType &k, viennacl::ocl::command_queue const &queue)
Enqueues a kernel in the provided queue.
scalar_expression< const matrix_base< NumericT >, const matrix_base< NumericT >, op_norm_frobenius > norm_frobenius(const matrix_base< NumericT > &A)
OpenCL kernel file for nonnegative matrix factorization.
static void init(viennacl::ocl::context &ctx)
size_type internal_size2() const
Returns the internal number of columns. Usually required for launching OpenCL kernels only...
size_type internal_size1() const
Returns the internal number of rows. Usually required for launching OpenCL kernels only...
bool print_relative_error() const
Returns the flag specifying whether the relative tolerance should be printed in each iteration...