[geeks] Matrix code

Greg A. Woods woods at weird.com
Thu Apr 18 22:16:27 CDT 2002


[ On Thursday, April 18, 2002 at 22:12:56 (-0400), Joshua D Boyd wrote: ]
> Subject: Re: [geeks] Matrix code
>
> I'd have to translate it into C then though, so it seems hardly worth the
> effort.

There's been a whole lot of noise about C++ code in this thread and now
you're saying you're really trying to write C code to handle matrices?

Why didn't you say so in the first place!?!?!? ;-)

If you happen to now have that C book I think I remember recommending to
you before then you'll find in it what I believe to be a very lucid
explanation of the realtionship between array element references and
pointer dereferencing.

	C: A Reference Manual
	Harbison & Steele
	0-13-326224-3 (fourth edition)

on page 124:

	Second, array subscripting is defined in terms of pointer
	arithmetic.  That is the expression a[i] is defined to be the
	same as *((a)+(i)), where 'a' is converted to &a[0] under the
	usual unary conversions.  This definition of subscripting also
	means that a[i] is the same as i[a], and that any pointer may be
	subscripted just like an array.

on page 125:

	The language places no limit on the number of dimesions an
	array might have
     [[ .... ]]
	The expression t[1][2] is expanded to *(*((t)+1)+2)

I.e. Array subscripts _are_ pointer dereferences in C.  Traditional
array notation is really just in C to help out the FORTRAN guys....

-- 
								Greg A. Woods

+1 416 218-0098;  <gwoods at acm.org>;  <g.a.woods at ieee.org>;  <woods at robohack.ca>
Planix, Inc. <woods at planix.com>; VE3TCP; Secrets of the Weird <woods at weird.com>



More information about the geeks mailing list