Mercurial > repos > public > sbplib
changeset 478:d91f27460741 feature/sublassable_cellarray
Implement size, length and transpose
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 02 Aug 2017 10:51:44 +0200 |
parents | 97c505c87f56 |
children | c5705458beb1 |
files | Cell.m CellTest.m |
diffstat | 2 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Cell.m Wed Aug 02 10:31:48 2017 +0200 +++ b/Cell.m Wed Aug 02 10:51:44 2017 +0200 @@ -27,6 +27,24 @@ % % display(A.data) % end + function s = size(A) + s = size(A.data); + end + + function l = length(A) + l = length(A.data); + end + + function B = transpose(A) + b = A.data.'; + B = callConstructor(A, b); + end + + function B = ctranspose(A) + b = A.data'; + B = callConstructor(A, b); + end + function disp(A) disp(A.data) end
--- a/CellTest.m Wed Aug 02 10:31:48 2017 +0200 +++ b/CellTest.m Wed Aug 02 10:51:44 2017 +0200 @@ -37,8 +37,13 @@ end function testTranspose(testCase) - testCase.verifyEqual(Cell({1, 2})', Cell({1; 2})); - testCase.verifyEqual(Cell({1; 2})', Cell({1, 2})); + testCase.verifyEqual(Cell({1i, 2}).', Cell({1i; 2})); + testCase.verifyEqual(Cell({1i; 2}).', Cell({1i, 2})); +end + +function testCtranspose(testCase) + testCase.verifyEqual(Cell({1i, 2})', Cell({1i; 2})); + testCase.verifyEqual(Cell({1i; 2})', Cell({1i, 2})); end function testRoundIndexWithProperty(testCase)