Skip to content

Commit f83557f

Browse files
committed
Now function remove some values in nA.X if not usefull
1 parent ab9302b commit f83557f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/positiveLinearCombination.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import AbstractMatrix from './abstractMatrix';
2-
31
import { Matrix, WrapperMatrix2D, NNMF } from './index';
42

53
function 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
*/
3635
export 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

Comments
 (0)