• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSConfused... matrices and NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >NSConfused... matrices and NSData (From: James Maxwell <email@hidden>)

  • Prev by Date: Re: NSConfused... matrices and NSData
  • Next by Date: Re: NSConfused... matrices and NSData
  • Previous by thread: Re: NSConfused... matrices and NSData
  • Next by thread: should release or not? (basic memory management question)
  • Index(es):
    • Date
    • Thread