Re: Extracting 2D array from SAFEARRAY [Was "Passing a 2D array in a property"]

From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 06/08/04


Date: Mon, 7 Jun 2004 22:28:40 -0700

The organization of multi-dimensional safe arrays has not been
designed by me... Complain to Microsoft. Or change your code
to loop over the second dimension first, so you maximize the
benefit of the CPU cache.

-- 
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Kevin J. Menard, Jr." <kmenard@wpi.edu> wrote in message
news:40C4D60F.7090409@wpi.edu...
> Alexander Nickolov wrote:
> > No, you can't address the array as two dimensional unfortunately.
> > You need to linearize the access: [x + n*y] for the pair [x][y].
> > Note this is the opposite of C arrays - the first index changes
> > the fastest.
>
> Just to make sure we're using the same nomenclature, since I normally
> access the data points as data[row][col], with row being the y
> coordinate and col being the x coordinate.  Are you saying I need to
> reverse the dimensions then?  Isn't this going to incur a lot of memory
> jumps?
>
> Thanks,
> Kevin


Relevant Pages

  • Re: AS2005: Nice implementation of Current Day/Month/Qtr/Yr - any suggestions
    ... currently I am looking into idea of having calculated dimension ... This is Justin from Microsoft. ... > Microsoft Online Partner Support ... > | every time they came back to same report, ...
    (microsoft.public.sqlserver.olap)
  • Re: gfortran & adjustable array: most values remain zero
    ... Indeed I expected that adjustable arrays would work in 2D the same ... adjustable arrays of more than one dimension should be generally avoided ... the actual and dummy arrays don't ...
    (comp.lang.fortran)
  • Re: Pros and cons of assumed-shape arrays
    ... dimension relations. ... In most subroutines with several arrays as ... arguments almost all of the arrays have similar shapes. ... is loop invariant and will be done once in the loop preamble ...
    (comp.lang.fortran)
  • Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
    ... Dimension xbys, rbys ... calculated integer numerical constant ... You can only dimension arrays passed as arguments with nPlns, ... You could always join the 21st century and follow Ron Shepard's suggestion, but you'll have to follow it carefully. ...
    (comp.lang.fortran)
  • Two dimensional arrays "C question"
    ... My question has to do with two dimensional arrays. ... int main ... So we see that the compiler can automatically calculate the first dimension. ...
    (microsoft.public.vc.language)