Negabinary encoding for optical complex matrix operation

Negabinary encoding for optical complex matrix operation

15 December 1994 OPTICS COMMUNICATIONS ELSEVIER Optics Communications 113 (1994) 15-19 Negabinary encoding for optical complex matrix operation Guo...

337KB Sizes 2 Downloads 50 Views

15 December 1994

OPTICS COMMUNICATIONS ELSEVIER

Optics Communications 113 (1994) 15-19

Negabinary encoding for optical complex matrix operation Guoqiang Li, Liren Liu Shanghai Institute of Optics and Fine Mechanics, Academia Sinica, P.O. Box 800-211, Shanghai 201800, China

Received 30 May 1994

Abstract

Based on negabinary number representation, complex matrix-vector multiplication is performed using an optical multichannel shadow-casting incoherent correlator. The architecture resolves the difficulties presented in the systems using other number encodings. In multiplication, bipolar data are processed without signs and extensional digits, and the mixed negabinary product can be summed directly. Through negative 2's complement operation, subtraction is converted to addition. By the decomposition of complex numbers, the complex matrix-vector operation is executed in parallel. The experiment is demonstrated, too.

1. Introduction

Numerical calculation is a basic task for digital optical computing. As a special-purpose optical computer, the matrix operation processor has aroused more interest in recent years. A great effort has been devoted to the investigation of number representation and the corresponding algorithms, Among the algorithms, the technologies of outer-product and digital multiplication via analog convolution (DMAC) are pursued [ 1 ]. It is necessary to provide adequately parallel optical systems, where multichannel operations are performed with high speed and throughput. The number representation is one of the most important factors in computation, since every encoding method has its own specific working style in algorithm, resulting in different speeds and the requirement on the bit number, data manipulation, and postprocessing, etc. At present, it is more convenient for optical devices to deal with the data encoded in binary case, and these encoding methods mainly indude the positive radix number system (binary) [ 1,2 ], radix-complement system (2's complement)

[ 3,4 ] and the sign-magnitude representation [ 5 ]. The binary expression can only process positive numbers. To deal with bipolar data, time- and space-multiplexing were employed. Time multiplexing [ 6 ] decreases the speed by a factor of 2, while space multiplexing [7] uses two times of space-bandwidth product (SBWP). For sign-magnitude expression, the multichannel vector inner products (VIP) can not be added parallelly by optics, but by sequential electronic processing with sign comparison. The bipolar matrix and vector data encoded in 2's complement can be accommodated in parallel. However, the algorithm itself has difficulties in actual applications. For instance, the bit number required to represent the product should be known in advance and the operand is encoded with the same number of bits. This is a severe restriction on the practice and is a waste of SBWP. Furthermore, the convolutional result is unable to be summed directly. An improvement made by Taylor and Casasent [ 8 ] saves extensional bits, but needs much sign postdetection and irregular correction. To overcome the various difficulties, we must seek other number systems which will make the optical matrix operation more efficient.

0030-4018/94/$07.00 © 1994 ElsevierScience B.V. All rights reserved SSD! 0030-4018 (94) 00485-4

16

G. Li, L. Liu / Optics Communications 113 (1994) 15-19

In this paper, a negabinary number system [9] (NBS) with the fixed base ( - 2) is exploited. In contrast to the former number systems, NBS can encode any bipolar data without a sign digit. By negative 2's complement operation, subtraction can be turned to addition. Moreover, its multiplication can be applied to multichannel VIP operations. The algorithm overcomes the above mentioned problems thoroughly. During the multiplication procedure, the whole signless word is carried into operation without particular treatment. The convolutional string is in the mixed negabinary system (MNS), and the weighted sum makes up the final product in decimal. No number storage and combination is needed and there is no waste of SBWP. In the real world, complex matrix operation is of more generality [ 10-14 ], but high accuracy optical complex operation has not been investigated deeply [ 15 ]. As a proof of principle, the NBS algorithm is incorporated into an optical multichannel shadowcasting incoherent correlator [16] to outperform complex matrix-vector multiplication. By decomposing the complex data into real and imaginary parts, the output vector is obtained in full parallelism. Due to the advantages offered by the NBS encoding, the architecture is superior to the referred schemes. It requires the least postprocessing.

2. Definitions The NBS is a member of positional digital number systems. In the system, the algebraic value of a string encoded by a N-digit {aN_ 1, a s - 2 .... , al, ao} is given by N--I

a=

~ a,~(-2) i, ate{0,1}.

(1)

i=0

The representation is unique, i.e., there is a one-toone correspondence between a and at (i=0, 1, ..., N - 1 ). It is seen that the weight of each bit changes alternatively. For even i, a~ is positively weighted, and for odd i, a, is negatively weighted. This property eliminates the need of a specific sign bit for bipolar data and is an advantage over other systems such as the signless binary and 2's complement encodings. Algorithms for conversion of numbers from decimal

to NBS and vice versa have been investigated in electronics [ 17 ]. The largest positive integer P is determined by the string whose even index digits are equal to 1 and odd index digits 0, i.e., ... 010101, and the string is called being full. The smallest negative integer N is represented by the string... 101010, which is called being empty. The 2s representable data is in the range from N to P, and is asymmetric [ 18 ]. The asymmetry is defined by the difference N--I

R=P-IN[=P+N=

~

(-2)'

i=0

=-(2N--1)/3,

when Nis even,

= (2N+1)/3,

when Nis odd.

(2)

3. Application in matrix operation Before considering the algorithm of the complex matrix-vector operation, we first briefly discuss the operations at the word level. 3. I Basic operations

Assume the two numbers a and b are both encoded by N NBS digits. For addition, as usually done, the parallel summation of a and b leads to the result u represented in MNS, in which each digit ui may be multiple-valued: ui=ai+bi,

(i=0,1,...,N-1).

Subtraction of b from a can be transformed to addition by a - b = a + ( - b). The additive inverse of b may be formed by adding the additive inverse of R to the complement of b: N--1

-b=b+(-R),

/~= }~ / ~ ( - 2 ) t.

(3)

i=0

From Eq. (2), we see that for even N, - R equals (2 N - 1 )/3, which can be translated into the N-bit NBS string 0101 ... 0101. For odd N, - R is equivalent to - (2N+ 1)/3, which corresponds to the (N+ 1 )-bit NBS string 1101 ... 0101. In the latter case, we can rewrite the operands in even N format by adding a zero in front of the most significant bit (MSB), and use the unified formation:

G. Li, L. Liu / Optics Communications 113 (1994115-19 -a=(G_,,G_2

.....

b,,bo) + ( 0 , 1 , 0 , 1 .... , 0 , 1 ) .

Cil (4)

The complement operation is carry-free, and the bitwise addition also makes - b expressed in MNS. If bg=0, t h e n / ~ = 1 (i=2k, k < N / 2 ) , in consequence this will generate a 2 in - hi. Multiplication is performed by convolving the two NBS digit sequences:

2N--2

2

m=O

rn ( ~

(-2/

17 N-- 1

2

~k/~=1 n=O

+ank2(--b~-n) ] ) ,

Ci2

2N--2 m=0

(--2) m

/k~=M N--I

~ [a~k, bkm2-n

1 rim0

n m--rl ] I . +a~k~bk,

2N--2

p=ab=

[aTk, bj,~-~

~ p ~ ( - 2 ) i,

(7)

(5)

i=0

The operations involved are very suitable for optical implementation.

where N--1

Pi= ~ akbi-k,

( i = 0 , 1 .... , 2 N - - 2 ) .

k=0

4. Optical implementation

The operation results in a MNS digital string, which can be simply summed into decimal. This is an advantage in comparison with the 2's complement algorithm. Furthermore, this version requires no extensional bits for the two operands, and all the convolutional digits contribute to the final result. Therefore, there is no waste of SBWP.

3.2 Complex matrix-vector operation For an M × M matrix A multiplied by an N × 1 vector b the product c=Ab is written as g

c,= ~ a,kbk,

( i = 1 , 2 .... , M ) .

(6)

k= 1

Presume a,~ = aik, + iaik2, bk = bk, + ibk= ( i, k= 1, 2,..., M/, then the matrix A can be represented by two real submatrixes A~ and ,4 2 (with a,k, and a~2 being their elements respectively), and b by two real subvectors bl and b2 (with bk, and b~= being their elements respectively), i.e., A=A~ +iA2, b=bl +ib2. Therefore, C=Cl +ic2, in which Cl =A1 bl -A2b2,

c2 =Al b2 +A2b] .

To carry out the subtraction in cl, in preprocessing, one needs to form the additive inverse of either A2 or b2. Since b2 has fewer elements, cl =Albt + A 2 ( - b 2 ) is preferred. By extending the DMAC of two real numbers to multichannel operation for complex matrix-vector multiplication, we obtain

To achieve the above operations, an incoherent optical correlator based on multichannel shadowcasting is utilized (Fig. 1 ). In the setup, Mask 2 and Mask 3 are used to encode the matrix A and vector b separately. For illustration, Fig. lb shows the data arrangement in the two masks when M = 2 and N = 4. In Mask 2, the upper part is for A~, whose elements are distributed in column order and each row marks one element. The digit order is indicated by MSB and LSB (the least significant bit). So it is for the lower A2 part. In Mask 3, there are four parts: upper left and lower right for bl, upper right for b2, and lower left for -b2. The distance between the neighbor rows should be M times of that in Mask 2. Note that the digit order of the two masks is different. To avoid the crosstalk among the channels, the separation L between the left and the right parts in Mask 3 should be at least ( N - 1 ) digit intervals. Since the value of the even digits of the elements in the vector - b 2 might be 2, the intensity of those locations (indicated by squares) should be two times that of other positions. This can be simply realized by polarization optics. Another choice is to use spatial encoding. The coded Mask 1 has the same pattern as that of the positions of the correlation points on the scatterer, i.e., there are M rows of transparent little bulbs. In each row, the two groups of ( 2 N - 1 )-long bulbs are isolated ( L - N + 1 ) intervals. All of the light rays diverging from a bulb in Mask I are collimated by the first lens, pass through the transparencies of the fol-

18

G. Li, L. Liu / Optics Communications 113 (1994) 15-19 Diffuse

Coded

Source

Mask 1

!.. I"

Lens 1 M a s k 2

fl

J

Mask3

D

l..

Lens2

J

Scatterer

f2

I~

j "I

(a) Mask 2 LSE

Mask 3

MSB

~ = I l o o 0 o

AI 2 1 o o O o 1 2 0 0 0 0

MSB k=l bl 2

LSB

0

0

0

0

0

0

0

0

0

D

0

D

0

[] 0

O o

o

LSB o

0

0

0

MSB

k=ll I)2

2

0

2 2 0 0 0 0 ~ = i I 0 0 0 o

A2 2 1 o o o o 1 2 0 0 0 0

~ I 0 0 0 0

I

-b2 2

I

[]

2 o o o o

2 2 0 0 0 0

,L(>N-I).,

(b)

r

"I

Fig. 1. (a) Optical multichannel shadow-casting correlator for complex matrix-vector multiplication. (b) Data arrangement in Mask 2 and Mask 3.

lowing two masks at a certain angle, and are converged to a point in the back focal plane of the second lens. The intensity is given by

-10+i5 4+i3

3 + i "~ 1-i7/' b=(Yl;14)"

Hence,

l ( rnd2 , nd2)= ~ ~ T, ( m 'd, - rnd~ D / f j , n' d, m'

A=\

n I

- ndl D/f~ ) × T2 ( m'd~, n'dt ) ,

(8)

where T~ and 7"2 are the transmittances of Mask 2 and Mask 3 respectively, d~ and d2 are the pixel intervals of the masks and the scatterer separately. This yields a multiple-valued digit for the ci (i= 1, 2, ..., M), and all the operations contained in Eq. (7) are carried out in full parallelism. A CCD photodetector array receives the MNS products, and the postprocessing electronics sums them into decimal. If required, they can be further converted into NBS.

5. Experiment

In the experiment, the following matrix and vector with 4-bit elements are presumed for demonstration:

A

A2

b,(:) The NBS input patterns and the MNS output pattern are sketched in Fig. 2. The corresponding decimal product is (67-i41~ c= k-57-i/" In our optical architecture, the diameter of each pixel is 1 mm, and the interval between the adjacent pixels is 1.5 ram. The focal length of the two lens are f~ = 210 mm, f2 = 240 mm respectively. The coded Mask 1 is uniformly illuminated by an extended diffuse light source. Fig. 3 is the photograph taken in the

G. LL L. Liu / Optics Communications 113 (1994) 15-19

Input A

~pm b 1001

0011

1100

llOfl

1201

1001

0112

1100

Output c [0:3466231214411[ 1254523 02354|1

Fig. 2. Input and output numerical simulations.

19

can be directly s u m m e d in decimal. All the M N S digits contribute to the result, so it does not waste SBWP. The pre- a n d post-processing is simple. The optical setup is very flexible. By the d e c o m p o s i t i o n o f a complex n u m b e r into real and imaginary parts, complex matrix-vector multiplication is accomplished in parallel. It should be noted that the negabinary representation can encode a fractional n u m b e r without the indication o f the decimal point, i f the lower index is a negative integer rather than zero.

Acknowledgments

Fig. 3. Experiment photograph. correlation plane. It is seen that the experimental result is consistent with the previous data simulations. A PC c o m p u t e r performs the simple postprocessing.

6. Discussions and conclusions In the negabinary algorithm, the N-bit encoding (even N) can represent 2 u n u m b e r s in the range o f [ - 2 ( 2 / v - 1 ) / 3 , (2 N - 1 ) / 3 ] . But in the 2's complement multiplication, one needs to use about 2 N bits to encode the 2 N N-bit n u m b e r s ranging from - 2 n - 1 to 2 N - l - 1. Therefore, by the negabinary representation, the SBWP is saved by a factor o f about 50%. In the above complex m a t r i x - v e c t o r multiplication architecture, the a d d i t i v e inverse o f the vector - b2 can also be f o r m e d optically. The involved complement operation can be achieved by polarization optics, and the terms (0, 1, 0, 1.... , 0, 1)'s can be a m e n d e d using a d d i t i o n a l channels. In summary, based on an optical multichannel shadow-casting incoherent correlator, we have realized complex m a t r i x - v e c t o r operation using negabinary encoding. The architecture has o v e r c o m e the problems encountered in the n u m b e r systems such as binary, sign-magnitude, 2's c o m p l e m e n t , etc. In the negabinary multiplication, b i p o l a r d a t a are performed without signs and extensional digits, and there does not exist any storage or c o m b i n a t i o n o f the int e r m e d i a t e results, since the weighted M N S p r o d u c t

This research is supported by N a t i o n a l Natural Science F o u n d a t i o n o f China.

References [ 1] For example, D. Psaltis, D. Casasent, D. Neff and M. Carlotto, Proc. SPIE 232 (1980) 151; R. Athale, W. Collins and P. Stilwell,Appl. Optics 22 ( 1983 ) 368; G. Guilfoyle, Opt. Eng. 23 (1984) 23; D. Psaltis and R. Athale, Appl. Optics 25 (1986) 3071; E. Baranoski and D. Casasent, Appl. Optics 28 (1989) 5351. [2] A. Goutzoulis, Optics Comm. 51 (1984) 137. [3] R. Bocker, S. Clayton and K. Bromley, Appl. Optics 22 (1983) 2019. [4] A. Goutzoulis, Appl. Optics 23 (1984) 4095. [ 5 ] D. Casasent and B. Taylor, Appl. Optics 24 ( 1985 ) 1476. [6] W. Collins, R. Athale and P. Stilwell,Proc. SPIE 352 (1983) 59. [7] D. Casasent and J. Jackson, Appl. Optics 25 (1986) 2258. [ 8 ] B. Taylor and D. Casasent, Appl. Optics 25 ( 1986 ) 956. [9] M. Regt, Comput. Design 6 (1967) 53. [10]J.W. Goodman, A. Dias and L. Woody, Optics Lett. 2 (1978) 1. [ 11 ] E. Mosca, R. Griffin, F. Pursel and J. Lee, Appl. Optics 28 (1989) 3843. [12] E. Pockapsky and D. Casasent, Appl. Optics 29 (1990) 2532.

[ 13 ] H. Huang, L. Liu, Y. Yin and L. Zhao, Optics Comm. 68 (1988) 408. [ 14] L. Zhang and L. Liu, Optics Comm. 74 (1990) 295. [ 15] G. Li and L. Liu, Optics Comm. 105 (1994) 101. [ 16] M. Monahan, K. Bromley and R. Bocker, Proc. IEEE 65 (1977) 121. [ 17] S. Zohar, IEEE Trans. on Comput. C-19 (1970) 222. [ 18 ] I. Koren and Y. Maliniak, IEEE Trans. on Comput. C-30 (1981) 312.