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

Length- transport layer, Length This is a 16 bit  field  that  defines...

Length This is a 16 bit  field  that  defines  the total  length  of the user  datagram, header  plus data. This 16 bit  can define  a total  length  of a 0 to 65, 535 bytes.

Task of changing the ip address, 1. Bob has been given the task of changing...

1. Bob has been given the task of changing the IP address and enabling telnet access on a CISCO 2950 enterprise switch. The current IP address is 10.10.10.2/8 the new IP address

Implication of increasing and decreasing subnet bits, What is the suggestio...

What is the suggestion of increasing and decreasing subnet Bits?

Explain short term and medium-term scheduling, What are short, long and med...

What are short, long and medium-term scheduling? Long term scheduler verifies which programs are admitted to the system for processing. It controls the degree of multiprogrammi

Routers - network layer and routing , Routers The network  layer (also ...

Routers The network  layer (also  called layer3) manages device  addressing  tracks the location  of devices on the network  and determines  the best  way to  move data. Which

What is a hypertext link, A hypertext link is a special tag that links sing...

A hypertext link is a special tag that links single page to another page or resource. If you click the link, the browser goes to the link's destination.

Define about the term - hackers, Define about the term - hackers Every ...

Define about the term - hackers Every time technology updates itself, new techniques evolve. At the same time thieves or intruders (in the information technology line, they are

Determine the concept of placing antenna on hieght, Determine the concept o...

Determine the concept of placing antenna on hieght First, starting deployment simply placed cells in regions where there was high density of vehicle or human population. Once t

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