On Sun, Mar 29, 2009 at 12:43 PM, James Maxwell
<jbmaxw...@rubato-music.com> wrote:
> Sorry for the long post, but I'm trying to wrap my head around NSData,
> NSMutableData and matrices.
> So I made an example to test my (mis)conception of how this all should work.

There are two ways to store two-dimensional data in a one-dimensional
array. The standard way is row-major order, in which the rows of the
data are contiguous. To compute the index for this method, you use
index=row*columnCount+column.

The other way is column-major order, which is just the opposite. The
columns are contiguous. Here you compute the index as
index=column*rowCount+row.

You're computing the index as row*rowCount+column, which doesn't work.
As a consequence, you're repeating indexes in your 1D array, which
leads to funny results. Log your computed indexes as well as the
values you find, and I believe the problem will be apparent.

Mike
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to