@@ -11,6 +11,7 @@ under the European Union’s Horizon 2020 research and innovation programme
1111#pragma once
1212
1313#include " ../util/AlgorithmUtils.hpp"
14+ #include " ../util/EigenRandom.hpp"
1415#include " ../util/FluidEigenMappings.hpp"
1516#include " ../../data/FluidIndex.hpp"
1617#include " ../../data/TensorTypes.hpp"
@@ -28,7 +29,7 @@ class NNDSVD
2829
2930 index process (RealMatrixView X, RealMatrixView W, RealMatrixView H,
3031 index minRank = 0 , index maxRank = 200 , double amount = 0.8 ,
31- index method = 0 ) // 0 - NMF-SVD, 1 NNDSVDar, 2 NNDSVDa 3 NNDSVD
32+ index method = 0 , index seed = - 1 ) // 0 - NMF-SVD, 1 NNDSVDar, 2 NNDSVDa 3 NNDSVD
3233 {
3334 using namespace _impl ;
3435 using namespace Eigen ;
@@ -101,14 +102,16 @@ class NNDSVD
101102 WT.col (j) = u; // avoid scaling for NMF with normalized W
102103 HT.row (j) = lbd * v;
103104 }
104- WT = WT. array (). max (epsilon);
105- HT = HT. array (). max (epsilon );
105+
106+ double mean = XT. mean ( );
106107 if (method == 1 )
107108 {
108109 auto Wrand =
109- MatrixXd::Random (WT.rows (), WT.cols ()).array ().abs () / 100.0 ;
110+ EigenRandom<MatrixXd>(WT.rows (), WT.cols (), RandomSeed{seed},
111+ Range{epsilon, mean * 0.001 });
110112 auto Hrand =
111- MatrixXd::Random (HT.rows (), HT.cols ()).array ().abs () / 100.0 ;
113+ EigenRandom<MatrixXd>(HT.rows (), HT.cols (), RandomSeed{seed},
114+ Range{epsilon, mean * 0.001 });
112115 WT = (WT.array () < epsilon).select (Wrand, WT);
113116 HT = (HT.array () < epsilon).select (Hrand, HT);
114117 }
0 commit comments