33 #ifndef __VMML__TUCKER4_TENSOR__HPP__
34 #define __VMML__TUCKER4_TENSOR__HPP__
36 #include <vmmlib/t4_hooi.hpp>
41 template<
size_t R1,
size_t R2,
size_t R3,
size_t R4,
size_t I1,
size_t I2,
size_t I3,
size_t I4,
typename T =
float>
44 typedef double T_internal;
58 size_t nnz_core()
const;
59 size_t size_core()
const;
60 void reconstruct(
t4_type& data_);
62 template<
typename T_init>
63 tensor_stats decompose(
const t4_type& data_, T_init init,
const size_t max_iterations = 10,
const float tolerance = 10);
65 template<
typename T_init>
66 tensor_stats tucker_als(
const t4_type& data_, T_init init,
const size_t max_iterations = 10,
const float tolerance = 1e-04);
80 #define VMML_TEMPLATE_STRING template< size_t R1, size_t R2, size_t R3, size_t R4, size_t I1, size_t I2, size_t I3, size_t I4, typename T >
81 #define VMML_TEMPLATE_CLASSNAME tucker4_tensor< R1, R2, R3, R4, I1, I2, I3, I4, T >
84 VMML_TEMPLATE_CLASSNAME::tucker4_tensor() {
98 VMML_TEMPLATE_CLASSNAME::nnz_core()
const {
104 VMML_TEMPLATE_CLASSNAME::size_core()
const {
109 VMML_TEMPLATE_CLASSNAME::~tucker4_tensor() {
118 VMML_TEMPLATE_CLASSNAME::reconstruct(t4_type& data_) {
120 t4_ttm::full_tensor4_matrix_multiplication(_core, *_u1, *_u2, *_u3, *_u4, data_);
124 template<
typename T_init>
126 VMML_TEMPLATE_CLASSNAME::decompose(
const t4_type& data_, T_init init,
const size_t max_iterations,
const float tolerance) {
127 return tucker_als(data_, init, max_iterations, tolerance);
131 template<
typename T_init>
133 VMML_TEMPLATE_CLASSNAME::tucker_als(
const t4_type& data_, T_init init,
const size_t max_iterations,
const float tolerance) {
136 typedef t4_hooi< R1, R2, R3, R4, I1, I2, I3, I4, T_internal > hooi_type;
137 result += hooi_type::als(data_, *_u1, *_u2, *_u3, *_u4, _core, init, 0, max_iterations, tolerance);
142 #undef VMML_TEMPLATE_STRING
143 #undef VMML_TEMPLATE_CLASSNAME