Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site watmath.UUCP Path: utzoo!watmath!kpmartin From: kpmartin@watmath.UUCP (Kevin Martin) Newsgroups: net.lang.c Subject: Non-zero lower bounds Message-ID: <8769@watmath.UUCP> Date: Sun, 26-Aug-84 15:03:11 EDT Article-I.D.: watmath.8769 Posted: Sun Aug 26 15:03:11 1984 Date-Received: Mon, 27-Aug-84 00:29:55 EDT References: <8131@umcp-cs.UUCP> Reply-To: kpmartin@watmath.UUCP (Kevin Martin) Organization: U of Waterloo, Ontario Lines: 17 With non-zero lower bounds, but no bounds checking, there is no need for subtracting each lower subscript bound from the corresponding subscript. Since the lower bounds and multipliers are constants, all the constant terms can be pulled out, to form one constant, e.g. for a zero-origin 10 by 20 by 30 array, z_offset(i, j, k) = 20 * (30 * i + j) + k For one-origin, general_offset(i, j, k) = 20 * (30 * (i-1) + (j-1)) + (k-1) = 20 * (30 * i - 30 + j - 1) + (k-1) = 20 * (30 * i + j - 31) + (k-1) = 20 * (30 * i + j) - 620 + k - 1 = 20 * (30 * i + j) + k - 621 = z_offset(i, j, k) - z_offset(1, 1, 1) Note that the second term is a compile-time constant. Kevin Martin, UofW Software Development Group