Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix a bunch of tests that were failing after the recent changes. More…
… to fix still
- Loading branch information
1 parent
c4b1b92
commit 55ef25f
Showing
8 changed files
with
58 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,77 @@ | ||
disp("1..19"); | ||
plan(19); | ||
|
||
% Test indexing into vectors | ||
function vector_tester(a, b, c) | ||
if a == b | ||
printf("ok %d\n", c); | ||
else | ||
printf("not ok %d\n", c); | ||
end | ||
endfunction | ||
|
||
|
||
a = [1 2 3 4]; | ||
vector_tester(a(1), 1, 1); | ||
vector_tester(a(2), 2, 2); | ||
vector_tester(a(3), 3, 3); | ||
vector_tester(a(4), 4, 4); | ||
is(a(1), 1); | ||
is(a(2), 2); | ||
is(a(3), 3); | ||
is(a(4), 4); | ||
|
||
b = [1;2;3;4]; | ||
vector_tester(b(1), 1, 5); | ||
vector_tester(b(2), 2, 6); | ||
vector_tester(b(3), 3, 7); | ||
vector_tester(b(4), 4, 8); | ||
is(b(1), 1); | ||
is(b(2), 2); | ||
is(b(3), 3); | ||
is(b(4), 4); | ||
|
||
% Relational operator tests | ||
a = [1 2 3]; | ||
b = [1 2 3]; | ||
c = [4 5 6]; | ||
if a == b | ||
disp("ok 9"); | ||
else | ||
disp("not ok 9"); | ||
end | ||
is(a, b, "equal row vectors are equal); | ||
if a == c | ||
disp("not ok 10"); | ||
ok(0, "inequal vectors are apparently equal"); | ||
else | ||
disp("ok 10"); | ||
ok(1, "equal column vectors are equal"); | ||
end | ||
if a != b | ||
disp("not ok 11"); | ||
ok(0, "equal vectors are apparently inequal"); | ||
else | ||
disp("ok 11"); | ||
ok(1, "equal vectors are not inequal"); | ||
end | ||
if a != c | ||
disp("ok 12"); | ||
ok(1, "inequal vectors are inequal"); | ||
else | ||
disp("not ok 12"); | ||
ok(0, "inequal vectors aren't inequal"); | ||
end | ||
% Test the use of whitespace in specifying column vectors: | ||
foo = [1 | ||
2 | ||
3]; | ||
bar = [1;2;3]; | ||
if foo == bar | ||
disp("ok 13"); | ||
else | ||
disp("not ok 13"); | ||
end | ||
is(foo, bar, "matrix rows using different syntax); | ||
% Test that we can assign to a row vector cell | ||
y = [1 2 3]; | ||
y(3) = 4; | ||
if y == [1 2 4] | ||
disp("ok 14"); | ||
else | ||
disp("not ok 14"); | ||
endif | ||
is(y, [1 2 4]); | ||
% Test that we can assign to a column vector cell | ||
y = [1;2;3]; | ||
y(3) = 4; | ||
if y == [1;2;4] | ||
disp("ok 15"); | ||
else | ||
disp("not ok 15"); | ||
endif | ||
is(y, [1;2;4]); | ||
% Test that assigning to a row vector causes autoextending | ||
y = [1 2 3]; | ||
y(5) = 5; | ||
if y == [1 2 3 0 5] | ||
disp("ok 16"); | ||
else | ||
disp("not ok 16"); | ||
endif | ||
is(y, [1 2 3 0 5]); | ||
% Test that assigning to a column vector causes autoextending | ||
y = [1;2;3]; | ||
y(5) = 5; | ||
if y == [1;2;3;0;5] | ||
disp("ok 17"); | ||
else | ||
disp("not ok 17"); | ||
endif | ||
is(y, [1;2;3;0;5]); | ||
% Test that a 1x1 matrix autoextends like a row vector | ||
y = [1]; | ||
y(3) = 3; | ||
if y == [1 0 3] | ||
disp("ok 18"); | ||
else | ||
disp("not ok 18"); | ||
endif | ||
is(y, [1 0 3]); | ||
% Test that row vectors autovivify when we assign to an index of them | ||
_not_existing_vector(3) = 3; | ||
if _not_existing_vector == [0 0 3] | ||
disp("ok 19"); | ||
else | ||
disp("not ok 19"); | ||
endif | ||
is(_not_existing_vector, [0 0 3]); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
function isscalar(A) | ||
%% isscalar(A) | ||
%% returns 1 if A is 1 x 1 matrix | ||
if columns(A) == 1 and rows(A) == 1 | ||
return 1 | ||
if columns(A) == 1 | ||
if rows(A) == 1 | ||
return 1 | ||
end | ||
end | ||
return 0 | ||
endfunction |