1
- import AbstractMatrix from './abstractMatrix' ;
2
-
3
1
import { Matrix , WrapperMatrix2D , NNMF } from './index' ;
4
2
5
3
function linearCombination ( X , epsilon ) {
@@ -31,10 +29,11 @@ function linearCombination(X, epsilon) {
31
29
* @param {object } [options={}]
32
30
* @param {number } [options.NNMF_maxIterations=100000]
33
31
* @param {number } [options.NNMF_version=2]
32
+ * @param {number } [options.delta=1000]
34
33
* @return {Matrix }
35
34
*/
36
35
export function positiveLinearCombination ( base , vector , options = { } ) {
37
- const { NNMFmaxIterations = 100000 , NNMFversion = 2 } = options ;
36
+ const { NNMFmaxIterations = 100000 , NNMFversion = 2 , delta = 1000 } = options ;
38
37
39
38
base = WrapperMatrix2D . checkMatrix ( base ) ;
40
39
vector = WrapperMatrix2D . checkMatrix ( vector ) ;
@@ -61,7 +60,19 @@ export function positiveLinearCombination(base, vector, options = {}) {
61
60
for ( let j = 0 ; j < n ; j ++ ) {
62
61
A . set ( m - 1 , j , vector . get ( 0 , j ) ) ;
63
62
}
63
+
64
64
let nA = new NNMF ( A , 1 , { maxIterations : NNMFmaxIterations , version : NNMFversion } ) ;
65
+
66
+ console . table ( nA . X ) ;
67
+
68
+ for ( let i = 0 ; i < m ; i ++ ) {
69
+ if ( ( nA . X . get ( m - 1 , 0 ) / delta ) > nA . X . get ( i , 0 ) ) {
70
+ nA . X . set ( i , 0 , 0 ) ;
71
+ }
72
+ }
73
+
74
+ console . table ( nA . X ) ;
75
+
65
76
solutions = linearCombination ( nA . X , nA . X . min ( ) - Number . EPSILON ) ;
66
77
return ( solutions ) ;
67
78
}
0 commit comments