Newsgroups: sci.math From: hoey@AIC.NRL.Navy.Mil (Dan Hoey) Date: Fri, 24 Sep 1993 21:05:39 GMT Subject: Re: Q: Row,col of element in upper T matrix? j...@cac.psu.edu (JAMES J VINCENT) asks: > Can anyone suggest a straightforward way to determine the row and > column number of a given element of a matrix while only counting > elements of the upper triangle, including the diagonal? For instance > in a 6x6 matrix if I want the 8th element it would be row 2, column 3 > by counting across rows, and only counting the upper triangle members. In an NxN matrix, if the I'th element is Row R, Column C, then I = (R-1)(2N-R+2)/2 + (C-R+1) The inverse is given as R = N - floor((sqrt((2N+1)^2 - 8I + 4) - 1)/2) C = I - (2N-R)(R-1)/2 Be sure to credit your sources. Dan Hoey Hoey@AIC.NRL.Navy.Mil