Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fe5948
commit 95a1beb
Showing
2 changed files
with
25 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
plan(6); | ||
x = cell(2); | ||
is(parrot_typeof(x), "PMCMatrix2D", "cell is PMCMatrix2D"); | ||
is(iscell(x), 1, "cell is cell"); | ||
is(columns(x), 2, "cell(n) is square, columns"); | ||
is(rows(x), 2, "cell(n) is square, rows"); | ||
|
||
y = cell(3, 4); | ||
is(columns(y), 3, "cell(n, m) is rectangle, columns"); | ||
is(rows(y), 4, "cell(n, m) is rectangle, rows"); |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function c = cell(y, x) | ||
% Creates a new cell array. | ||
% If one argument is provided, cell will be NxN square | ||
% If two arguments are provided, cell will be NxM | ||
if nargin == 1 | ||
x = y; | ||
end | ||
c = pir([".sub cell_helper" | ||
" .param int y" | ||
" .param int x" | ||
" $P0 = new ['PMCMatrix2D']" | ||
" $P0.'resize'(y, x)" | ||
" .return($P0)" | ||
".end"], y, x); | ||
endfunction |