Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site wateng.UUCP Path: utzoo!watmath!wateng!ksbszabo From: ksbszabo@wateng.UUCP (Kevin Szabo) Newsgroups: net.lang.c Subject: Re: help converting multi-dim arrays Message-ID: <2250@wateng.UUCP> Date: Sat, 6-Apr-85 04:05:53 EST Article-I.D.: wateng.2250 Posted: Sat Apr 6 04:05:53 1985 Date-Received: Sat, 6-Apr-85 05:57:30 EST References: <569@utcs.UUCP> Reply-To: ksbszabo@wateng.UUCP (Kevin Szabo) Organization: VLSI Group, U of Waterloo Lines: 25 Summary: In article <569@utcs.UUCP> you write: >But, we still want to access the >matrices as: > ...data[row][col] ... >Any ideas? >Dave Harrison, Dept. of Physics, Univ. of Toronto: ..utzoo!utcs!physics If you only have one matrix that you want to access, how about: static double *data; #define DATA(row,col) (*(data + row*numcols + col)) Or if you only have a few, how about a couple of macro's? You can even adopt the matrix format where the matrix is an array of pointers. It's all hidden in the macro. The nice thing about this is that you could easily implement a sparse matrix by redefining DATA to be a function or inline code. #define DATA(row,col) (*Find_address_of_sparse_array_element(row,col)) Kevin -- Kevin Szabo watmath!wateng!ksbszabo (U of Waterloo VLSI Group, Waterloo Ont.)