The forall statement, Computer Networking

Assignment Help:

The FORALL Statement

The FORALL statement allows for more common assignments to sections of an array. A FORALL statement has the general form.

              FORALL ( triplet, ..., triplet,  mask )

                     statement

  where triplet has the general form

                 subscript = lower: upper : step-size

and states a set of indices. step-size is optional. Statement is an pointer or arithmetic assignment and the assignment statement is evaluated for those index values shown by the list of triplets that are not rejected by the optional mask.

Example 7 The following statements set each element of matrix X to the sum of its indices.

 Parallel Programming

 FORALL (i=1:m, j=1:n)     X(i,j) = i+j

and the following statement sets the upper right triangle of  matrix Y to zero .

FORALL (i=1:n, j=1:n, i

Multi-statement FORALL construct:

Multi-statement FORALL is shorthand for the series of single statement FORALLs. The

syntax for FORALL is

FORALL (index-spec-list [,mask]) Body

END FORALL

Nesting of FORALL is allowed.

Example 8

Let a= [2,4,6,8,10], b=[1,3,5,7,9], c=[0,0,0,0,0]

Consider the following program segment

FORALL (i = 2:4) a(i) = a(i-1)+a(i+1) c(i) = b(i) *a(i+1). END FORALL

The computation will be a[2] =a[1]+a[3] =2+6=8 a[3] =a[2]+a[4] =4+8=12 a[4] =a[3]+a[5] = 6+10=16

c[2] = b[2] *a[3] = 3*12=36 c[3] = b[3] *a[4] = 5*16=80

c[4] = b[4] *a[5] =7*10=70

Thus output is

a= [2,8,12,16,10], b=[1,3,5,7,9], c=[0,36,80,70,0]


Related Discussions:- The forall statement

Different types of subnet classfull networks are present, How many dissimil...

How many dissimilar types of subnet classful networks are present?

What is project 802, What is Project 802? It is a project begins by IEE...

What is Project 802? It is a project begins by IEEE to set standards that enable intercommunication among equipment from a variety of manufacturers. It is a way for specifying

Packet switching, Suppose there are exactly five packet switches (Figure 4)...

Suppose there are exactly five packet switches (Figure 4) between a sending host and a receiving host connected by a virtual circuit line (shown as dotted line in figure 4). The tr

What is fiber distributed data interface, FDDI -(Fiber Distributed Data Int...

FDDI -(Fiber Distributed Data Interface) FDDI Basics: FDDI (Fiber Distributed Data Interface) came about because system managers became concerned with network reliability i

Virtual lans, One of the design requirements is to isolate other network tr...

One of the design requirements is to isolate other network traffic and broadcast from finance department to improve security. In order for this to possible we will implement VLAN o

Name the standard isdn term for a native isdn modem, The marketing term 'IS...

The marketing term 'ISDN modem' was formed to help sell the ISDN idea to America. There is no such thing as an analog modulator demodulator for digital ISDN. The Terminal Adapter (

What is smtp, What is SMTP? SMTP is short for Simple Mail Transfer Proto...

What is SMTP? SMTP is short for Simple Mail Transfer Protocol. This protocol deals with all internal mail, and gives the essential mail delivery services on the TCP/IP protocol

Cost involved in inter-processor communication, Cost Involved in Inter-Proc...

Cost Involved in Inter-Processor Communication As the data is assigned to many processors in a parallel computer while implementing a parallel algorithm, the processors might

State 802.11 DSSS , 802.11 DSSS a) Direct sequence spread spectrum in a...

802.11 DSSS a) Direct sequence spread spectrum in a 2.4 GHz band b) Each bit is replaced by a sequence of bits called a chip code, implemented at the physical layer c) Se

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd