Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

Commit 7dca945

Browse files
committed
fix bug in mink and mink_test
1 parent 0d835cc commit 7dca945

3 files changed

Lines changed: 24 additions & 8 deletions

File tree

mink.hhs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function mink(input, k, dim)
3535
{
3636
result.push(raw_in[i]);
3737
}
38-
return result;
38+
return (new Mat(result));
3939
}
4040
// for 2 dims, the direction determined by dim parameter
4141
else if(dims === 2)

mink_test.hhs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,30 @@ function mink_test()
99

1010
let A = [[3, 2, 1, 4, 7], [2, 7, 0, 5, 2], [1, 9, 4, 3, 0], [2, 3, 4, 5, 6]];
1111
// A-num-num means the 3 parameters of mink
12-
const A_3_1 = [[1, 2, 0, 3, 0], [2, 3, 1, 4, 2], [2, 7, 4, 5, 6]];
13-
const A_3_2 = [[1, 2, 3], [0, 2, 2], [0, 1, 3], [2, 3, 4]];
14-
const A_4_1 = [[1, 2, 0, 3, 0], [2, 3, 1, 4, 2], [2, 7, 4, 5, 6], [3, 9, 4, 5, 7]];
15-
const A_4_2 = [[1, 2, 3, 4], [0, 2, 2, 5],[0, 1, 3, 4], [2, 3, 4, 5]];
12+
const A_3_1 = [[1, 2, 0, 3, 0],
13+
[2, 3, 1, 4, 2],
14+
[2, 7, 4, 5, 6]];
15+
const A_3_2 = [[1, 2, 3],
16+
[0, 2, 2],
17+
[0, 1, 3],
18+
[2, 3, 4]];
19+
const A_4_1 = [[1, 2, 0, 3, 0],
20+
[2, 3, 1, 4, 2],
21+
[2, 7, 4, 5, 6],
22+
[3, 9, 4, 5, 7]];
23+
const A_4_2 = [[1, 2, 3, 4],
24+
[0, 2, 2, 5],
25+
[0, 1, 3, 4],
26+
[2, 3, 4, 5]];
1627

1728
function test(input, k, dim, result)
1829
{
19-
if(!(mink(input, k, dim).join("") === result.join("")))
30+
let output = mink(input, k, dim);
31+
if(output instanceof Mat)
32+
{
33+
output = output.clone().val;
34+
}
35+
if(!(output.join("") === result.join("")))
2036
{
2137
throw new Error('Unit test failed for mink.')
2238
}

transpose.hhs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function transpose(input) {
2424

2525
//checks: 0 dims, not square, ndim not === 2?
2626
if (raw_in.length === 0 || raw_in[0].length === 0 || (ndim(raw_in) > 2)) {
27-
throw new Error('Exception occured in transpose - parameter must be non-empty and two dimensional matrix or list');
27+
throw new Error('Exception occured in transpose - parameter must be non-empty and 1d list or 2d matrix');
2828
}
2929

3030
//loop through twice as it's a 2d array
@@ -55,5 +55,5 @@ function transpose(input) {
5555
result.push(temp);
5656
}
5757
}
58-
return result;
58+
return (new Mat(result));
5959
}

0 commit comments

Comments
 (0)