Skip to content

Commit

Permalink
fix zeros.pir. zeros.t tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Nov 15, 2009
1 parent 29fb803 commit 8f9b525
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/builtins/zeros.pir
Expand Up @@ -10,12 +10,10 @@ Create an n x m matrix of zeros.
.param int nargin
.param int rows
.param int cols
$I0 = rows + 1
$I1 = cols + 1

# NumMatrix2D zero-fills by default
$P0 = new ['NumMatrix2D']
$P0.'resize'($I0, $I1)
$P0.'resize'(cols, rows)
.return($P0)
.end

Expand Down
7 changes: 4 additions & 3 deletions t/200-zeros.t
@@ -1,11 +1,12 @@
plan(3);

x = zeros(1, 1);
is(x(1, 1), 0, "zeros() returns at least 1 zero");

y = [0];
ok(isequal(x,y), "zeros(1,1) works");

x = zeros(3, 3);
ok(x(1, 1) + x(2, 2) + x(3, 3) == 0, "zeros() returns at least 3 zeros");
y = [0 0 0;0 0 0;0 0 0];
ok(isequal(x,y), "zeros(3,3) works");

x = zeros(4, 7);
y = [ 0 0 0 0 0 0 0; 0 0 0 0 0 0 0; 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 ];
Expand Down

0 comments on commit 8f9b525

Please sign in to comment.