Skip to content

Commit

Permalink
redo initialize_from_array to be cleaner and more sane
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Nov 3, 2009
1 parent bf202a1 commit b7010f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/pmc/nummatrix2d.pmc
Expand Up @@ -551,17 +551,13 @@ in order.
METHOD initialize_from_array(INTVAL x_size, INTVAL y_size, PMC *values) {
Parrot_NumMatrix2D_attributes * const attrs = PARROT_NUMMATRIX2D(SELF);
FLOATVAL * s;
INTVAL self_x = attrs->x;
INTVAL self_y = attrs->y;
INTVAL i, j, num = 0;
if (self_x * self_y > VTABLE_elements(INTERP, values))
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
"NumMatrix2D: not enough elements available for initialization.");
INTVAL self_x, self_y, i, j, num = 0;

resize_matrix(INTERP, SELF, x_size - 1, y_size - 1);
self_x = attrs->x;
self_y = attrs->y;
s = attrs->storage;

for (i = 0; i < y_size; i++) {
for (j = 0; j < x_size; j++) {
FLOATVAL value = VTABLE_get_number_keyed_int(INTERP, values, num);
Expand Down
2 changes: 0 additions & 2 deletions t/10-nummatrix.t
Expand Up @@ -431,8 +431,6 @@ sub method_transpose() {
$P0[0;2] = 3.0
$P0[0;1] = 2.0
$P0[0;0] = 1.0
say "P0: "
say $P0

$P1 = new 'NumMatrix2D'
$P1[2;1] = 6.0
Expand Down

0 comments on commit b7010f2

Please sign in to comment.