Optimum multiplication algorithms using multiples of the multiplicand

Optimum multiplication algorithms using multiples of the multiplicand

OPTIMUM MULTIPLICATION ALGORITHMS USING MULTIPLES OF THE MULTIPLICAND* V. M. MIKHELEV (MOSCOW) (Received The speed rithms of multiplication us...

525KB Sizes 0 Downloads 15 Views

OPTIMUM MULTIPLICATION ALGORITHMS USING MULTIPLES OF THE MULTIPLICAND* V. M.

MIKHELEV

(MOSCOW) (Received

The

speed

rithms

of

multiplication

using

special

both

features

where

the

the of

relative

independent

of

the

different.

This

However,

quired.

Consequently.

of

cases

summations the

From a mathematical to

greatest

time

ments for

the

tion

of

the

does

code

the

of

the

the

is

of

factor

or the

view,

higher

realization

of

formation

which

of

than is

of

com-

can be a

is

re-

either

of

(subtractions),

or

by

algorithms is

the number of

an appropriate

de-

by re-

displacements,

construction

in

some-

may or may not

can be reduced

reducing

class

by one number,

number of

the

code,

one

and displacements

one operation the

algo-

and certain

a binary

range

summator.

for

summations

of

generally

non-binary,

determining

the

factor

Mat.

which

4,

of with

No.

5,

is

a control

this

problem

transforms

form of

transfer

a minimum as compared

l’ych.

the

multiplication,

an algorithm

Zh.

of

the

multiplication

the methods

involve

of

l

to

“optimum”

device

of

the

displace-

logical

scheme

mechanism.

Since which

point

since

basically

within

code

of

a minimum number of

interest

the

characteristic

(subtractions)

pend on the actual code value of ducing the number of summations, both at the same time.

leading

of

minimum time

in all

number of

by various

concept base. The “optimum” algorithm according to the technical possibilities

requiring

certain

is

operations

transmission

algorithms

1963)

possibilities

code.

number of

the

October

can be increased

technical

the code with any other what conditional since, puters,

26

the

recording,

the

multiplicand

any other

956-963. 243

code is factor

1964.

code

in which into

algorithm

for

reduced the the

using

the mechanism to into

the

formula-

another

number of summator, the

symbols would be

same symbols

244

V.W.

dMikhelev

for recording the factor. Naturally, the symbols used should conform to the technical possibilities of the type of machine used. All the algorithms studied below assume in particular, the presence of a certain number of discriminators or other devices in the machine for storing or obtaining the multiples of the multiplicand which can be transmitted with a plus or minus sign to the summator. In this case it is advisable + - + to use e.g. the following as symbols: 0, 1. 1. 3. 3 or similar symbols denoting the transfer to the summator of the multiplicand or trebled multiplicand with a plus or minus sign. Using these symbols, the binary cods of factor 0111101101 can be written, e.g. in one of the following forms:

fn the first case to multipiy. seven additions have to be made; in the second, three and one subtraction and in the third, one addition and two subtractions. It can be seen from the example given that even with the according to the algorithm, can be represented same symbols the factor, in different forms by different numbers of operations. As a very simple

example we will

consider

two algorithms which trans+ form a binary code to a code with symbols 0. 1 and i. The first algorithm indicates that the multiplicand is transmitted to the summator only if the value of the factor order is changed to a binary entry (transition This algorithm can be exfrom zero to unity and from unity to zero). pressed in the form of the logical functions Si = (Ui# Qi_1),

sign si = Ui,

where Si denotes the transfer of the factor to the summator on multiplying by the i-th order of the factor and sign Si is the sign of the operation. With sign Si = 0 addition and with sign Si = 1, subtraction is carried out. The meaning of the algorithm is to replace a group of units by two unities with plus and minus signs. It is easy to see that the + number of operations (additions 1 and subtractions 1) in the transformed code will be an average of (a + 1)/2, where n is the length of the factor code. Another algorithm which also uses symbols 0, l and 1 for recording a transformed code, can be expressed in the form of the logical functions si = (ai + Ui_i)Si_i’

sign si = ai+i.

Optimum multiplication

This the

algorithm optimum

was proposed

algorithm

age number of

i. e.

for

operations

a high

These method

value

factor.

orders,

denote

US

than

of

by S; the

the if,

multiplication

operation

by the

i-order

the

the with of

of

the

the

the

the

factor

is

previous

using to

factor i-th

the

general

multiples

the

of

summator

order

factor,

aver-

algorithm.

by an i-th

operation

is

case

to understand

algorithms

transmission

as a result

be seen,

In this

for

possible

class

as will

by an n-order

when multiplying

only

and,

24.5

symbols.

less

make it

a wider

Obviously, out

analogous

1% times

examples

multiplicand

can be carried out,

n.

of

Let

a j-multiple the

of

formulation

[II

by Lehman in using

q when multiplying

two simplest

of

a multiplicand. of

for

algorithms

of

of

order the

factor

in previous

has not

been

carried

i.e.

_

.vi =

where

pi

is

the

-.s.1_lsi_’

function

orders by which with tion can be effected, plicand

for

of

with the

1

-. s’lo. i-k-1

.

resolving

_.

;j,,

’ ’ ’

i-_k__l

the

operation,

s’lii

i-/(-l’

k

is

the

selected multiples of the multiplicand, irrespective of the value of orders of

and k + 1 is

code,

can be effected multiples

-Al Yi_&&

.

_

the

a certain

number of code

of

orders

by which

the multiplicand,

number of

multiplicathe multi-

multiplication using

certain

multiplicand.

The operation which has to be carried out in the i-th order of the factor in order to multiply by the i-th and subsequent orders, depends on the nearest orders of the factor and is carried out only in case of resolving

the

operation .s!,= $j (. . ., ai+l’ aj, ui_l, . . .) <.

The sign the

of

the

operation

is

also

determined

by the

nearest

orders

of

factor sign

Thus a set information

of

logical

on the

Si =

functions operations

q(. . ., cZi+l,(li,Ui_1,. . .).

is

obtained,

in previous

the orders

factor being

orders the

and the

initial

in-

formation. Logical functions y and 9 can be selected by widely different methods. Obtaining the optimum algorithm depends on the method of selection. We will now consider the subclass of algorithms of factor coding which is

246

V.M.

distinguished present, i. e.

by the

,w is

class

of

the

number of

algorithm

changing

sign”

from

condition

the

considering groups

in Ivj a factor

of

of

various

multiples

of

be termed

factor

coding

that

the

of

logical

multiplying

admissibility

units

the

will

implying

the

of

express

that

the

type

oi

f

“i-l

is

$ @i* ai_l)and~,;V~p;V~~V...VV~=”

4) = where

fact

Mikhelev

zeros

are

logical

si = (ai # ai_l)

sf_ 1

4 = $i(. . ., ai+l,

.

functions

made.

Taking

equation .

‘i-k -&

i_k_1

are

for

selected

clearly

number of

Si = (ai #

system . * .

This

“operation

Thus operations

subtraction.

not

*

with

by a maximum possible

of

following

the multiplicand.

for

the

we can

ai_l)<,

this

orders

inside

class:

?&_, . . . q’k_l. . . ij&_,,

. . .)si,

ai, ai_l,

sign si = 9 (. . ., ai+l, ai, ai_i, . . .). We will

now prove

in relation

to the

of

the

average

of

the

multiplicand.

The set are

ak+l

jc <

is

is

example

factor ation

of j<

the

are

optimum

if

of

. . . .OllOlO..

effected “with

multiples

If the selection

leads set of of the

one hand,

number of changing

three

1,

2,

of

the

algrithms

5,

of

. . For a set in the

form

from unity

multiples

jz, . . . , jl

where ak -

an operation

is

1 <

changing

dense.

changing the also follows

to unity.

At the

the sign” +-+ . ..lOlOlO...

operations

or

for

multiples

when changing

on the other, unity

number of

sign” from

multiples of 1 and 5 this + + . ..010050... and the second oper-

can be carried

to

assumptions reduction

of

multiplication and,

of

. . . , Zk - 1, jl,

“with

is dense, it is operation by the

orders

the

multiplicand,

multiplicand

multiples required

from zero

certain

character

“with an operation for multiples is not dense,

operation to

type

set

by changing the

with

the

odd.

of

the

explain,

on increasing

multiples

can be represented is

algorithm

the

operations

The fact that the algorithm not optimum, if the set of

the

of

multiples,

The subclass

f.

sign”

which

factor

of

set

I and all

-

Theorem

the

multiples

a dense

theorems

of

number of

of

termed

the set

the

from unity

possible following out

same time the

the

same set

to organize the method so that

on

by the

maximum possible

is

out

operation to

for

zero.

carried

by

multiplication

Optimum

We note that the

order

always

by

by

the

(k

dense

+ 1)

k orders.

set

of

algorithms

makes

multiples

with

almost

any

We use

the

following

247

it possible

combination

of

selection

to

factor of

multiply

orders

and

multiplicand

multiples: 1)

if

ai+k+I

= 0.

2)

if

ai+k+l

= ai+k+2

then

then

= . . .

aa . . . ap is

the

absence

carried

ples

of

out

out

the

With

real.

can

with

be

sign.

in

Since

the

optimum

“with

We will number

operations

multiples

be termed Theorem

using of

2.

used. the

For

a complete

operations n/(3 the

multiplicand.

For

a given

termined

Let of

us

+ log2

w) for

class

by the

denote

a j-order

of

orders

of

logical

by Pj factor.

of

entry

of

of

is

Is

always begins

from

1 to

to

k + 1 by

Place

the

place

0

the as

k,

following

by changing for

multi-

carried

unity

i.e.

selected

of

operation

replacing

to

j

versa.

4i+k+l,

procedure

set

the

multiplication

by cbsnging

a subclass

of

by

the

sign.

algorithms

sign”. of

the

dependence

algorithm

set

of

on the

the

type

multiples

*with

of

an operation

of

the

n values,

II is

existence

the

3.

5,

average of

multiplicand.

for

changing the

the

the

operation

in

1

sign’ number

multfplier

number

of

2k -

average

n-ordered the

multi-

. . . .

the

by one

where

the

1,

of

number

multiplicand,

multiplication

algorithms

value

vice

takes

belongs the

multiples

large

f

same the

addition

of

is

the

since

following

and takes

nature

set

case also

an optimum

for

binary

operations

(2).

the

case

The dense

necessary

is

of

algorithms set

of

order this

complete

= 0,

(or

Set,

case

the

of

When ei+k

in

the

(1)

The

the

this

involves

changing

for

factor

respective

case

constructed for

now elucidate

of

plicand will

algorithm

an operation

ei+k+k+l

following

of

the

i + k + 1-st number

the

In

In

the

case

in

1 + 1.

operation

of

the

of

OCCUrS Only

a maximum possible the

the 1,

i + k +

k.

dense,

complement

seen,

the

In

= 0;

and Sign Si = 1,

multiple

each

0 to

the

number

easily

is

sign. from

obtaining

operation

= 1 and

code

k + 1 by

selection

Si

multiple).

a suitable

multiplicand

by changing

order

of

the

replacing

this

when changing since

‘Li+k+I

a binary

of In

=

j = 2itktz+1 - ai+k+l .. . ai

where

Is

j = Oi+k.. . Oi and sign

of

multiples

operation

is

de-

function

the For

probability Pj

based

of

the

on the

logical

function

the of

j-tb order the

248

a difference

we have

operation,

Pj = $ (’ The particular teristic

solution takes

2&-

zk-i f

us consider

Let

of

equation

equation

-Pj_l

-

this

the

Pj-2

-

equation

root

to in addition X0 = 1. We have

iik (2; Consequently, Since terms of j

it

value l,‘(k

It of

+ 2);

,*+I _ Z- i

I”+

the

charac-

1

= 0.

i = r-j *

the

initial

:zjq,z -

!I=

iand

or

I z( < 1, since

solution

the

Pj = l/(k

of

independent

is

Thus,

Pj_*)-

of

the

of

theorem

I;{”

contains

I 23I # 1.

homogeneous

length

of

proved.

another

(2 /;I-i)[
equation

Ci is a constant, for Thus, the probability

the is

equation,

the

code

Since

comprises

k

higher Pj for

value a high

the of

and is

equal

k = 1 + logEm,

to then

+ log,m). is

the

j

2).

q En/(3

general

roots

the type ci(xi)j, where can be as low as desired.

of f

the

lZ/ < 1,

the

of

-

equation

1,

1) =

is

or

22”+” _ :k _ which,

*

form

. * * +z+i=O,

the

* ’

easy

to

see

that

multiplicand,

the

with

a dense

number of

but

set

incomplete

operations

of

in the

q lies

multiples range

&
consider

with of

symbols

examples

multiplier

zero

of

the coding + + 0, 1. 1, 3, orders.

to unity;

the

algorithms

algorithm 3. Table

The first

second,

vice

belonging using

to

a given

a threefold

1 shows

all

the

column

corresponds

versa,

from unity

possible to to

zero.

-

I

i

i+l

I

-

i+2

i-l

j

if-l

j

i

/

we i.e.

combinations

transition

TABLE 1

ii_?

class,

multiplicand,

i-l

-

0

0

1

0

;

0

u

0

1

0

1

1

i)

$

I)

1

0

1

1

0

1

0

i

1

0

0

I

i

1

1

0

T

I

I

u

I

from

Ootinrun mu~t~plicaiio~

249

afrrorithms

Operations in the first and second row of the first column cause DO Uncertainty. Subtraction in the third and fourth, apparently, lead to a minimum number of operations irrespective of the code value in i + 3 and subsequent orders. It should be noted that since subtraction is effected in thse orders. in the i t 3 order unity should be added. Multiplication is thus. in fact, carried out by at least three orders. In case of unity has to be effected in the (i + 3) or in the fi + 2) order, correction next order, where the operation has to be carried out, i.e. where the sign is changed. This has been taken into account when determining the operation in the second column. It is carried trebled ation is pressed

easy to see that the operation with a simple multiplicand is out in the case of equality of (i + I) and (i + 2). and with a multiplicand, in the case of inequality. The sign of the operdetermined by the (i f 2) order. Thus, the algorithm can be exin the form _ $4= (di # oi_i) s*_iSi.+ ‘t = (‘i+i # ‘$*s) si, $ = (ai+i = a*+s)si, sign si = u{+~.

This algorithm

is optimum since

the set

The average number of operations factor for this algorithm is

q2++-

1 2 o/y)

(l/Tjn

of multiples

in mUltipliC8tiOn

. s’n

[

(n

- if arc tg VT-

is dense. by one a-th order

arc tg 5v-

. 3

This formula does not take into account the operation in the (II + 1) order, if the previous operation was subtraction. This, however, is not necessary since the known methods of multiPlication by a negative number mean precisely that multiplication by an order following the sign, is not effected. The result of the formula is similar to the proof of theorem 2. In this case. however, the determination of the roots of the characteristic equation can be completed. Here

It is easy to see that q & n/4 directly also from the general

for high values of n which follows theory since this algorithm belong

to the

V.M. Mikhelev

250

subclass of algorithms “with an operation set of multiples Is complete. As an example of the algorithm multiples, an algorithm sidered (see Table 2).

using

with symbols

0,

for

changing

the sign”

and the

a dense but incomplete set of t t - + 1. 1. 5. 3, 3 and 5 may be con-

TABLE 2

i+3

I

i+2

i+l

i-f

i+3

i+.Z

i+r

i-i

I

0

0

0

0

0

0

0

1

0

1

1

0

0

1

1

1

1

0

0

0

1

0

0

1

i

i

1

0

1

1

1

1

In all the rows of the first column in Table 2, in addition to the fourth and fifth, the operation selected mahes it possible to multiply by orders of up to i + 3. In the fourth and fifth rows multiplication is carried out by orders of up to i + 2 inclusive. However, in this case, there is a change of sign in i + 3. In addition, all the rows, in which It is remembered that unity is added to the order following the last, by contain unity in this last order. which multiplication has been effected, This has been taken into account when determining the operation in the second column. It is easy to see that operation with a simple multivlicand (I or 1) is orders and with ity. The treble the equality of plicsnd, in the in the form

effected with the equality of the (i f 1) and (i + 2) treble or quintuvle multiplicand, ia the case of inequalmultivlicand is transferred to the summator in case of the (i + 2) and (i + 3) orders and the quintuple multicase of inequality. Thus, the algorithm can be expressed _ _ Si = (ai # a*_i) si-l ‘i-e’:-,* s; = (uitL=

54.2 1 ‘i,

sf =

‘I$+3 #

tai+$ =

ai+l)

“i,

Optimum

multiplication

sf=(ai+3=ai+l# sign si = (ai+ 1 = ai+ J ai+

For this ations

algorithm,

which is also

251

algorithns

ai +2) %,

V (ai+1# ai+2)‘i+ 3.

optimum, the average number of oper-

is

All the observations in this case also.

concerning

g for

the previous

algorithm

are valid

It follows from theorem 2 that the average number of orders, by which multiplication can be effected in one operation (n/q), is proportional to the logarithm of the number of multiples of the multiplicand (3 + log2 m). Thus, the number of orders has increased much more slowly than the number of multiples, which reflects increased equipment in the multiusing a trebled plying mechanism. From this point of view, multiplication multiplicand, is the most effective. However, in sequential machines a sufficiently large number of multiples can easily be obtained with only one additional summator which makes it possible to use more complicated algorithms.

REFERMCES 1.

Lehman, Y.,

IRE Trans.

Electronic

Comput.,

Sept.,

EC-6, 204-205.

1957.