Skip to content

Commit

Permalink
start reworking indexing to be more sane, row-major
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Dec 7, 2009
1 parent d285f87 commit 4063a56
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 32 deletions.
9 changes: 4 additions & 5 deletions src/builtins/columns.pir
Expand Up @@ -5,12 +5,11 @@
.param int nargin
.param pmc matrix

$P0 = matrix
$S0 = typeof $P0
if $S0 == 'NumMatrix2D' goto _its_an_array
$I0 = does matrix, "matrix"
if $I0 == 1 goto _its_a_matrix
.return(1)
_its_an_array:
$P1 = getattribute $P0, "X"
_its_a_matrix:
$P1 = getattribute matrix, "cols"
$I0 = $P1
.return($I0)
.end
8 changes: 4 additions & 4 deletions src/builtins/rows.pir
Expand Up @@ -5,12 +5,12 @@
.param int nargin
.param pmc matrix

$S0 = typeof matrix
if $S0 == 'NumMatrix2D' goto _its_an_array
$I0 = does matrix, "matrix"
if $I0 == 1 goto _its_a_matrix
.return(1)

_its_an_array:
$P0 = getattribute matrix, "Y"
_its_a_matrix:
$P0 = getattribute matrix, "rows"
$I0 = $P0
.return($I0)
.end
Expand Down
44 changes: 22 additions & 22 deletions src/internals/aggregates.pir
Expand Up @@ -161,50 +161,50 @@
.sub '!_build_numerical_matrix'
.param pmc rows
.local pmc matrix
.local int x
.local int y
.local int row
.local int col
.local int width
.local int height
matrix = new ['NumMatrix2D']
y = 0
row = 0
height = rows
$P0 = rows[0]
width = $P0
outer_loop_top:
x = 0
$P0 = rows[y]
col = 0
$P0 = rows[row]
inner_loop_top:
$N0 = $P0[x]
matrix[x;y] = $N0
inc x
if x < width goto inner_loop_top
inc y
if y < height goto outer_loop_top
$N0 = $P0[col]
matrix[row;col] = $N0
inc col
if col < width goto inner_loop_top
inc row
if row < height goto outer_loop_top
.return(matrix)
.end

.sub '!_build_complex_matrix'
.param pmc rows
.local pmc matrix
.local int x
.local int y
.local int col
.local int row
.local int width
.local int height
matrix = new ['ComplexMatrix2D']
y = 0
row = 0
height = rows
$P0 = rows[0]
width = $P0
outer_loop_top:
x = 0
$P0 = rows[y]
col = 0
$P0 = rows[row]
inner_loop_top:
$P1 = $P0[x]
matrix[x;y] = $P1
inc x
if x < width goto inner_loop_top
inc y
if y < height goto outer_loop_top
$P1 = $P0[col]
matrix[row;col] = $P1
inc col
if col < width goto inner_loop_top
inc row
if row < height goto outer_loop_top
.return(matrix)
.end

Expand Down
2 changes: 1 addition & 1 deletion toolbox/is.m
Expand Up @@ -3,7 +3,7 @@ function is(a, b, comment)
%% tests that the two values a and b are equal. Calls ok() to handle
%% the test output logic, so has all the same capabilities as that
%% function.
if nargin == 2
if nargin == 3
ok(a == b, comment);
else
ok(a == b);
Expand Down

0 comments on commit 4063a56

Please sign in to comment.