From d04ea8cbeafa613c3e7b4538c13afa871fb87662 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Wed, 25 Jan 2012 17:07:50 -0500 Subject: [PATCH] * Completing jskip formula for LD that is analogous to the jskip formula for UD matrix format. --- math/symmetrix-array-index.PY | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/math/symmetrix-array-index.PY b/math/symmetrix-array-index.PY index 23f43dc..f659dd8 100644 --- a/math/symmetrix-array-index.PY +++ b/math/symmetrix-array-index.PY @@ -40,6 +40,28 @@ Note: {m} SUM a = 1 + 2 + ... + m = m(m+1)/2 {a=1} +""" + +""" +Update 20120124: the jskip formula can be written in similar fashion to +the 'UD' array format, as shown below. + +The endpoint of the array index is N(N+1)/2 . +The (negative) offset of the j index from the rightmost column is +dj = (N + 1 - j). +Note: dj is 1 on the rightmost column. + +So, the jskip is given by: + +N(N+1)/2 - (N+1-j)(N+2-j) / 2 = + = [ N**2 + N - ( N**2 + 3N - 2jN + 2 - 3j + j**2 ) ] / 2 + = ( -2N + 2jN - 2 + 3j - j**2 ) / 2 + = (j-1)N + (j-2)(j-1)/2 + >>> the same formula as before. + + + + """ import numpy @@ -175,7 +197,7 @@ def Hack2_LD_enc_dec(N): #print "%3d %3d | %6d | %3d %3d" % (i,j, ij, ii,jj) print "%3d %3d | %6d %6d | %3d %3d // %8.4f" % ( i,j, - ij, LDsize-ij, + ij, (LDsize-ij) * 2, ii,jj, jj2)