A. N. Skodras, ‘On the Computation of the Discrete Pascal Transform’
Technical Report HOU-CS-TR-2005-06-EN
On the Computation of the Discrete Pascal Transform
Α. N. Skodras
Hellenic Open University: Technical Report HOU-CS-TR-2005-06-EN
1
A. N. Skodras, ‘On the Computation of the Discrete Pascal Transform’
On the Computation of the Discrete Pascal Transform Athanassios N. Skodras Computer Science School of Science and Technology Hellenic Open University GR-26222 Patras - Greece Email:
[email protected]
Abstract – The recently proposed discrete Pascal transform possesses a computational complexity for an N-point vector of the order of N2 for both the multiplications and additions. In the present work an efficient structure is proposed, which eliminates the multiplications and halves the number of additions.
Indexing terms: Discrete Pascal Transform, fast transforms, binomial polynomials, complexity
1
Introduction
The discrete Pascal transform (DPT) was recently introduced by Aburdene and Goodman [1]. It belongs to the family of the discrete polynomial transforms, and it is based on a variation of the Pascal matrix [2]. Such transforms find numerous applications in signal and image processing, as well as in communication and control systems [3, 4]. As with all discrete transforms the main concern is their increased computational complexity, which by their definition as matrix multiplications is of the order of N2 for vectors of length N. In the present work a reduced computational complexity scheme is proposed for the DPT. This scheme owns a complexity of ½ N(N-1) additions and no multiplications. Such a reduced complexity will facilitate the use of the DPT in more applications. The report is structured as follows: In section 2 an overview of the Pascal’s triangle is given. The DPT is introduced in section 3 and its complexity is analyzed in section 4. Finally, a computationally efficient realization of the DPT is given in section 5.
Hellenic Open University: Technical Report HOU-CS-TR-2005-06-EN
2
A. N. Skodras, ‘On the Computation of the Discrete Pascal Transform’
2
Pascal’s Triangle: An Overview
Pascal’s triangle* is a geometric arrangement of the binomial coefficients in a triangle [5,6]. The first eight rows of Pascal’s triangle are shown in Fig. 1. 1 1
1
1 1
3
1 1 1 1
5
6 10
15 21
1 3
4
6 7
2
4 10
20 35
1 1 5 15
35
1 6
21
1 7
1
1 1 1 1 1 1 1 1
1 2 3 4 5 6 7
1 3 6 10 15 21
1 4 10 20 35
(a)
1 5 15 35
1 6 21
1 7
1
(b)
Fig. 1. The first eight rows of Pascal’s triangle in two different variations Each number of the triangle is equal to the binomial coefficient aij, where
⎛i⎞ i! a ≡ ⎜⎜ ⎟⎟ ≡ ij ⎝ j ⎠ j ! (i − j )!
(1)
⎛i⎞
⎛i⎞
with i, j non-negative integers, i ≥ j and ⎜⎜ ⎟⎟ = ⎜⎜ ⎟⎟ = 1 . ⎝0⎠ ⎝i ⎠ Pascal’s triangle can be constructed in a simple manner by observing that each element in a row is obtained by adding the two entries diagonally above. For example, in the fifth row element 4 is equal to 1 plus 3, i.e. the summation of the two elements diagonally above it. This is because the following formula holds:
⎛ i ⎞ ⎛ i-1 ⎞ ⎛ i-1⎞ ⎜⎜ ⎟⎟ = ⎜⎜ ⎟⎟ + ⎜⎜ ⎟⎟ ⎝ j ⎠ ⎝ j-1⎠ ⎝ j ⎠
(2)
Pascal’s triangle has numerous uses in binomial expansions. The simplest and the most well known example is
(x
+ y ) = 1 ⋅ x 2 + 2 xy + 1 ⋅ y 2 2
(3)
where we see that the coefficients 1, 2, 1 are actually the binomial coefficients of the third row of the triangle. In general we have
Historical note from [5]:The first reference to this triangle occurs in Indian mathematician Pingala's book on Sanskrit poetics that may be as early as 450 BC as Meru-prastaara, the "staircase of Mount Meru". The commentators of this book were also aware that the shallow diagonals of the triangle sum to the Fibonacci numbers. It was also known to Chinese mathematicians. It is said that the triangle was called "Yang Hui's triangle" by the Chinese. Later, the Persian mathematician Karaji and the Persian astronomer-poet Omar Khayyám; thus the triangle is referred to as the "Khayyam triangle" in Iran. Several theorems related to the triangle were known, including the binomial theorem. In fact we can be fairly sure that Khayyam used a method of finding nth roots based on the binomial expansion, and therefore on the binomial coefficients. Finally, in Italy, it is referred to as "Tartaglia's triangle", named after the Italian algebraist Niccolo Fontana Tartaglia who lived a century before Pascal; Tartaglia is credited with the general formula for solving cubic polynomials. In modern times, Pascal's triangle takes its name from the Traité du triangle arithmétique (1655) by Blaise Pascal. In that work, Pascal collected several results then known about the triangle, and employed them to solve problems in probability theory. The "arithmetical" triangle was later called after Pascal by Pierre Raymond de Montmort (1708) and Abraham de Moivre (1730). *
Hellenic Open University: Technical Report HOU-CS-TR-2005-06-EN
3
A. N. Skodras, ‘On the Computation of the Discrete Pascal Transform’
( x + y )n
= a 0 x n + a1 x n −1 y + ... + a n-1 xy n-1 + a n y n
(4)
where the coefficients
⎛ n⎞ ai = ⎜⎜ ⎟⎟ ⎝i⎠
(5)
are the entries on row n+1 of Pascal’s triangle. There exists a lot of properties about Pascal’s triangle. We will refer to only a few of them, those that are immediately apparent and will be easy to be compared with the Pascal transform that is described in the next section: • • • •
The diagonals along the left and right edges contain only 1s (Fig. 1a). The diagonals next to the edges contain the natural numbers in order. Moving inwards, the next pair of diagonals contain the triangle number in order. The sum of the elements of the ith row is equal to 2i, i.e. i
⎛i⎞
∑ ⎜⎜ j ⎟⎟ = 2 . j =0
3
i
⎝ ⎠
(6)
The Discrete Pascal Transform
The discrete Pascal transform (DPT) X of the 1D data vector x is defined as X=Px
(7)
where x, X are Nx1 vectors and P is the NxN Pascal transform matrix the elements of which are equal to
⎧( − 1 ) j a ij for i ≥ j pij = ⎨ ⎩ 0 otherwise
(8)
with i=0, 1, 2,…, N-1. From (8) we easily deduce that the elements of the Pascal transform matrix are obtained directly from the Pascal’s triangle entries (see Fig. 1b) by alternating the signs of the columns. The Pascal’s transform matrices for N=2, N=4, and N=8 are given below. (For clarity reasons we have denoted the zero elements by a dot).
⎡1 ⋅ ⎤ P2 = ⎢ ⎥ ⎣1 − 1⎦
(9)
⋅ ⋅ ⎤ ⎡1 ⋅ ⎢1 − 1 ⋅ ⋅ ⎥ ⎥ P4 = ⎢ ⎢1 − 2 1 ⋅ ⎥ ⎢ ⎥ ⎣1 − 3 3 − 1⎦
(10)
Hellenic Open University: Technical Report HOU-CS-TR-2005-06-EN
4
A. N. Skodras, ‘On the Computation of the Discrete Pascal Transform’
⎡1 ⎢1 ⎢ ⎢1 ⎢ 1 P8 = ⎢ ⎢1 ⎢ ⎢1 ⎢1 ⎢ ⎢⎣1
⋅ ⋅ ⋅ ⋅ ⋅ −1 ⋅ ⋅ ⋅ ⋅ −2 1 ⋅ ⋅ ⋅ − 3 3 −1 ⋅ ⋅ −4 6 −4 1 ⋅ − 5 10 − 10 5 − 1 − 6 15 − 20 15 − 6 − 7 21 − 35 35 − 21
⋅ ⋅ ⎤ ⋅ ⋅ ⎥⎥ ⋅ ⋅ ⎥ ⎥ ⋅ ⋅ ⎥ ⋅ ⋅ ⎥ ⎥ ⋅ ⋅ ⎥ 1 ⋅ ⎥ ⎥ 7 − 1⎥⎦
(11)
The basic properties of the P matrices are the following: • • • •
The elements of the first column are equal to 1. All matrices are lower triangular. The sum of the elements of each row (except the first one) is equal to zero. All matrices are equal to their inverses.
The DPT of eq. (7) is expressed in matrix form. It can also be expressed as summation: N −1
X k = ∑ p kn x n, n=0, 1, …, N-1
(12)
n =0
where k=0, 1, …, N-1. Since the elements of the Pascal transform matrix that are above the diagonal are equal to zero, i.e. pkn =0 for k>n, the upper limit of the summation of eq. (12) becomes equal to k instead of N-1. Thus the forward DPT can be rewritten as follows: k
X k = ∑ p kn x n , n=0, 1, …, N-1
(13)
k n⎛k ⎞ X k = ∑ (− 1) ⎜⎜ ⎟⎟ x n n =0 ⎝n⎠
(14)
n =0
or
It was mentioned above that the Pascal transform matrix is equal to its inverse, P-1 = P
(15)
Thus, the inverse DPT is written in matrix form as x=PX
(16)
and as a summation n
x n = ∑ p nk X k ,
k = 0,1,..., N − 1
(17)
k =0
or
Hellenic Open University: Technical Report HOU-CS-TR-2005-06-EN
5
A. N. Skodras, ‘On the Computation of the Discrete Pascal Transform’ k ⎛n⎞ x n = ∑ (− 1) ⎜⎜ ⎟⎟ X k , k =0 ⎝k ⎠ n
k = 0,1,..., N − 1
(18)
Equations (14) and (18) constitute the forward and inverse DPT respectively. The basis functions of the DPT are calculated via the polynomials P ( x, j ), where j j ⎛ x⎞ j x ( x − 1)( x − 2 )...( x − j + 1) for j ≥ x ≥ 0 P( x, j ) = p x j = (− 1) a x j = (− 1) ⎜⎜ ⎟⎟ = (− 1) j! ⎝ j⎠
(19) The first eight polynomials are the following:
P ( x ,0 ) = 1 P( x,1) = − x 1 1 P( x,2) = x( x − 1) = − ( x − 1) P( x,1) 2 2 1 1 P( x,3) = − x( x − 1)( x − 2) = − ( x − 2) P( x,2) 6 3 1 1 P ( x, 4 ) = x(x − 1)( x − 2)( x − 3) = − ( x − 3) P( x,3) 24 4 1 1 P( x,5) = − x( x − 1)( x − 2 )( x − 3)(x − 4) = − ( x − 4 ) P( x,4) 120 5 1 1 P( x,6) = x( x − 1)( x − 2)( x − 3)( x − 4 )( x − 5) = − ( x − 5) P( x,5) 720 6 1 1 P( x,7 ) = − x( x − 1)( x − 2)(x − 3)( x − 4)( x − 5)( x − 6) = − ( x − 6) P(x,6) 5040 7 In general, each polynomial P ( x, j + 1) can be recursively computed by means of the formula
P( x, j + 1) = −
1 ( x − j ) P ( x, j ) j +1
(20)
These polynomials when evaluated at the discrete points x = 0,1,..., N − 1 produce the columns of the Pascal transform matrix PN, which actually constitute the basis vectors of the transform.
4
Computational Complexity
The computation of the DPT of an N-point vector based on matrix definition of eq. (7) results in N2 multiplications and N(N-1) additions, i.e. MN=N2
(21)
AN=N(N-1)
(22)
and
If we take into account that the upper triangle entries of the transform matrix are zero and the diagonal entries are equal to 1 or -1, i.e. no multiplications are needed, then the operations counts become:
Hellenic Open University: Technical Report HOU-CS-TR-2005-06-EN
6
A. N. Skodras, ‘On the Computation of the Discrete Pascal Transform’
MN
N2 − N 1 = = N ( N − 1) 2 2
AN = 1 + 2 + 3 + ... + ( N − 1) =
(23)
1 N ( N − 1) 2
(24)
This is also the case when eq. (14) is used for the computation of the DPT. Going one step further and taking into account that the entries of the first column of the matrix are all equal to 1, i.e. no multiplications are needed, MN reduces to
MN = 5
1 1 N ( N − 1) − ( N − 1) = N ( N − 3) + 1 2 2
(25)
A Computationally Efficient Approach
The computational complexity of the DPT could be highly reduced if the computations were performed in a recursive manner, namely if the transform coefficients X0, X1,…, Xk-1 were used for the computation of Xk.
Calculation of a 2-point DPT (N=2)
[
Let x = x 0 x1
]T be
[
the data and X = X 0 X 1
]T be
the DPT coefficients. The transform
coefficients X are calculated through eq. (7) using the transform matrix (9), as
⎧ X 0 = x0 ⎡ X 0 ⎤ ⎡1 0 ⎤ ⎡ x0 ⎤ ⇒⎨ =⎢ ⎢ ⎥ ⎥ ⎥ ⎣ X 1 ⎦ ⎣1 − 1⎦ ⎣ x1 ⎦ ⎩ X 1 = x 0 − x1
X=Px ⇒ ⎢
(26)
The calculation of (26) can be depicted in a flow graph form by the well known butterfly of Fig. 2. In fact, only the lower part of the known butterfly is used, where we have only a subtraction of the two inputs. The complexity of the calculation is equal to: M2=0, A2=1.
x0
X0=x0
x1
X1=x0-x1
Fig. 2. The 2-point DPT butterfly
Calculation of a 3-point DPT (N=3)
[
In a case that we have three data points (N=3) x = x 0 x1 x 2
]T , then the calculation of the
DPT becomes: X=Px
⎡ X 0 ⎤ ⎡1 0 0 ⎤ ⎡ x 0 ⎤ ⇒ ⎢⎢ X 1 ⎥⎥ = ⎢⎢1 − 1 0 ⎥⎥ ⎢⎢ x1 ⎥⎥ ⇒ ⎢⎣ X 2 ⎥⎦ ⎢⎣1 − 2 1 ⎥⎦ ⎢⎣ x 2 ⎥⎦
X 0 = x0 ⎧ ⎪ X 1 = x 0 − x1 ⎨ ⎪ X = x − 2 x + x = (x − x ) − (x − x ) = X − (x − x ) 0 1 2 0 1 1 2 1 1 2 ⎩ 2 (27)
Hellenic Open University: Technical Report HOU-CS-TR-2005-06-EN
7
A. N. Skodras, ‘On the Computation of the Discrete Pascal Transform’ The flow graph for the calculation of (27) is shown in Fig. 3. The whole computation is completed in N-1=2 stages and needs no multiplications (M3=0) and 2+1=3 subtractions (A3=3). Stage 1
2
x0
X0
x1
X1
x2
X2
Fig. 3. The 3-point DPT flow graph
Calculation of a 4-point DPT (N=4) For the calculation of the 4-point DPT we have: X=Px
X 0 = x0 ⎧ ⎪ ⎡ X 0 ⎤ ⎡1 0 0 0 ⎤ ⎡ x 0 ⎤ X 1 = x 0 − x1 ⎢ X ⎥ ⎢1 - 1 0 0 ⎥ ⎢ x ⎥ ⎪ X 2 = ( x 0 − x1 ) − ( x 1 − x 2 ) ⎥ ⎢ 1 ⎥ = ⎪⎨ ⇒ ⎢ 1⎥=⎢ ⎢ X 2 ⎥ ⎢1 - 2 1 0 ⎥ ⎢ x 2 ⎥ ⎪ X 3 = x 0 − 3 x1 + 3 x 2 − x 3 = ( x 0 − x1 ) − 2(x1 − x 2 ) + (x 2 − x 3 ) ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎣ X 3 ⎦ ⎣1 - 3 3 − 1⎦ ⎣ x 3 ⎦ ⎪= [( x 0 − x1 ) − (x1 − x 2 )] − (x1 − x 2 ) + (x 2 − x 3 ) ⎪ ⎩= X 2 − [( x1 − x 2 ) − ( x 2 − x 3 )] (28) The flow graph for the calculation of the 4-point DPT according to (28) is depicted in Fig.4. The calculation is completed in three stages (N-1= 3) and only six subtractions (3+2+1=6) are required, or M4=0 and A4=6. Stage 1
2
3
x0
X0
x1
X1
x2
X2
x3
X3 Fig. 4. The 4-point DPT flow graph
Calculation of an N-point DPT Based on the above, the flow graph for the calculation of an N-point DPT will be as in Fig. 5. There exist N-1 stages. There exist N-1 butterflies at stage 1, N-2 butterflies at stage 2 and in general N-m butterflies at stage m. For each butterfly only one subtraction is needed. No multiplications are needed for the whole computation. The number of subtractions is equal to 1 at stage N-1, 2 at stage N-2,..., N-1 at stage 1. This sums up to
Hellenic Open University: Technical Report HOU-CS-TR-2005-06-EN
8
A. N. Skodras, ‘On the Computation of the Discrete Pascal Transform’
N −1
1 + 2 + 3 + ... + N − 1 = ∑ m = N m =1
N −1 . 2
Thus the total computational complexity for the N-point DPT will be MN=0
(29)
and
AN =
1 N (N − 1) 2
(30)
Stage 1
2
3
4
5
N-2
N-1
x0
X0
x1
X1
x2
X2
x3
X3
x4
X4
xN-2
XN-2
xN-1
XN-1 Fig. 5. The N-point DPT flow graph
The computational complexity for each of the methods presented in this report is shown in Table I. It is clear that the proposed one based on a butterfly structure possesses the lowest complexity and actually constitutes a fast Pascal transform (FPT).
MN AN
6
Table I. Computational complexity for the 1D DPT Direct matrix Lower triangular Lower triangular multiplication matrix with 1’s in the first (eq. 21, 22) (eq. 23, 24) column (eq. 25) 2 N ½ N(N-1) ½ N(N-1)-(N-1) N(N-1) ½ N(N-1) ½ N(N-1)
Proposed FPT (butterfly based) (eq. 29, 30) 0 ½ N(N-1)
Conclusions
The DPT is a new promising tool for many signal and image processing applications. The triangular structure of the discrete Pascal transform matrix produces a useful localization property, something that makes it attractive in bump and edge detection applications [1]. As with every discrete transform, the computation burden is always high and of the order of N2 for both multiplications and additions in the 1D case. In the present work a new approach has been proposed, which eliminates the multiplications and halves the number of additions. The calculation of every new transform coefficient is achieved by pairing the additions at each stage and combining the previous results.
Hellenic Open University: Technical Report HOU-CS-TR-2005-06-EN
9
A. N. Skodras, ‘On the Computation of the Discrete Pascal Transform’
Acknowledgements This work was funded by the European Social Fund, Operational Programme for Educational and Vocational Training II (EPEAEK II), programme ‘Pythagoras’ (contract no. 89188).
References [1]
M.F. Aburdene and T.J. Goodman: “The Discrete Pascal Transform”, IEEE Signal Processing Letters, Vol. 12, No. 7, pp. 493-495, July 2005.
[2]
M.F. Aburdene, R.J. Kozick, R.S. Magargle, J.D. Maloney-Hahn and C.M. Coviello: “Discrete Polynomial Transform Representation Using Binary Matrices and Flow Diagrams”, Proc. IEEE ICASSP 2001.
[3]
G. Mandyam and N. Ahmed: “The Discrete Laguerre Transform: Derivation and Applications”, IEEE Trans on Signal Processing, Vol. 44, No. 12, pp. 2925-2931, Dec. 1996.
[4]
S.A.M. Gilani and A.N. Skodras: “Watermarking of Images in the DLT Domain”, Technical Report TR2000-03-02, Computer Technology Institute, Patras, Greece, March 2000.
[5]
Pascal’s
Triangle
–
Wikipedia:
[on-line]
http://en.wikipedia.org/wiki/
Pascal's_triangle [6]
Pascal’s Triangle – PascalsTriangle.html
Mathworld:
[on-line]
Hellenic Open University: Technical Report HOU-CS-TR-2005-06-EN
http://mathworld.wolfram.com/
10