1- import AbstractMatrix from './abstractMatrix' ;
2-
31import { Matrix , WrapperMatrix2D , NNMF } from './index' ;
42
53function linearCombination ( X , epsilon ) {
@@ -31,10 +29,11 @@ function linearCombination(X, epsilon) {
3129 * @param {object } [options={}]
3230 * @param {number } [options.NNMF_maxIterations=100000]
3331 * @param {number } [options.NNMF_version=2]
32+ * @param {number } [options.delta=1000]
3433 * @return {Matrix }
3534 */
3635export function positiveLinearCombination ( base , vector , options = { } ) {
37- const { NNMFmaxIterations = 100000 , NNMFversion = 2 } = options ;
36+ const { NNMFmaxIterations = 100000 , NNMFversion = 2 , delta = 1000 } = options ;
3837
3938 base = WrapperMatrix2D . checkMatrix ( base ) ;
4039 vector = WrapperMatrix2D . checkMatrix ( vector ) ;
@@ -61,7 +60,19 @@ export function positiveLinearCombination(base, vector, options = {}) {
6160 for ( let j = 0 ; j < n ; j ++ ) {
6261 A . set ( m - 1 , j , vector . get ( 0 , j ) ) ;
6362 }
63+
6464 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+
6576 solutions = linearCombination ( nA . X , nA . X . min ( ) - Number . EPSILON ) ;
6677 return ( solutions ) ;
6778 }
0 commit comments