Skip to content

Commit

Permalink
update iterate_method_inplace to pass the coordinates of the current …
Browse files Browse the repository at this point in the history
…element. Also, some other fixes that I can't remember
  • Loading branch information
Whiteknight committed Nov 6, 2009
1 parent 3edbb8a commit 382a6a9
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/pmc/nummatrix2d.pmc
Expand Up @@ -134,8 +134,7 @@ pmclass NumMatrix2D dynpmc auto_attrs {
*/

VTABLE FLOATVAL get_number_keyed_int(INTVAL key) {
Parrot_NumMatrix2D_attributes * const attrs
= (Parrot_NumMatrix2D_attributes *) PARROT_NUMMATRIX2D(SELF);
Parrot_NumMatrix2D_attributes * const attrs = PARROT_NUMMATRIX2D(SELF);
const INTVAL total_size = attrs->x * attrs->y;
if (key >= total_size) {
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
Expand Down Expand Up @@ -237,10 +236,8 @@ pmclass NumMatrix2D dynpmc auto_attrs {
MULTI PMC *add(NumMatrix2D *value, PMC *dest) {
int i = 0;
INTVAL x_size, y_size;
Parrot_NumMatrix2D_attributes * const selfattr
= (Parrot_NumMatrix2D_attributes *) PARROT_NUMMATRIX2D(SELF);
Parrot_NumMatrix2D_attributes * const valattr
= (Parrot_NumMatrix2D_attributes *) PARROT_NUMMATRIX2D(value);
Parrot_NumMatrix2D_attributes * const selfattr = PARROT_NUMMATRIX2D(SELF);
Parrot_NumMatrix2D_attributes * const valattr = PARROT_NUMMATRIX2D(value);
Parrot_NumMatrix2D_attributes * destattr;

x_size = selfattr->x;
Expand All @@ -258,7 +255,7 @@ pmclass NumMatrix2D dynpmc auto_attrs {
}

dest = VTABLE_clone(INTERP, value);
destattr = (Parrot_NumMatrix2D_attributes *) PARROT_NUMMATRIX2D(dest);
destattr = PARROT_NUMMATRIX2D(dest);

cblas_daxpy(x_size*y_size, 1, selfattr->storage, 1, destattr->storage, 1);

Expand Down Expand Up @@ -404,7 +401,7 @@ pmclass NumMatrix2D dynpmc auto_attrs {
METHOD resize(INTVAL new_x, INTVAL new_y) {
resize_matrix(INTERP, SELF, new_x - 1, new_y - 1);
}

/*

=item fill()
Expand Down Expand Up @@ -440,7 +437,7 @@ sizes, growing the matrix if needed.
}
}
}

/*

=item transpose()
Expand Down Expand Up @@ -468,7 +465,7 @@ Transposes the matrix.
transposed = !transposed;
RETURN(INTVAL transposed);
}

/*

=item mem_transpose()
Expand Down Expand Up @@ -503,7 +500,7 @@ than the transpose() method.
attrs->y = new_y;
free(old_s);
}

/*

=item iterate_function_inplace()
Expand All @@ -525,11 +522,11 @@ value with the return value of the called function.
FLOATVAL * new_s = (FLOATVAL *)mem_sys_allocate_zeroed(newsize * sizeof (FLOATVAL));

INTVAL i, j;
for (i = 0; i < x_size; i++) {
for (j = 0; j < y_size; j++) {
for (i = 0; i < y_size; j++) {
for (j = 0; j < x_size; i++) {
FLOATVAL value = ITEM_XY_ROWMAJOR(old_s, x_size, y_size, i, j);
FLOATVAL result = 0.0;
Parrot_ext_call(INTERP, func, "PNPf->N", SELF, value, args, &result);
Parrot_ext_call(INTERP, func, "PNIIPf->N", SELF, value, i, j, args, &result);
ITEM_XY_ROWMAJOR(new_s, x_size, y_size, i, j) = result;
}
}
Expand Down

0 comments on commit 382a6a9

Please sign in to comment.