Re: NSConfused... matrices and NSData
Re: NSConfused... matrices and NSData
- Subject: Re: NSConfused... matrices and NSData
- From: Michael Ash <email@hidden>
- Date: Sun, 29 Mar 2009 12:58:53 -0400
On Sun, Mar 29, 2009 at 12:43 PM, James Maxwell
<email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden