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

Define character stuffing, Define Character Stuffing? In byte stuffing ...

Define Character Stuffing? In byte stuffing (or character stuffing), a particular byte is added to the data section of the frame when there is a character with the same pattern

What is a private ip address, What is a private IP address? Private IP ...

What is a private IP address? Private IP addresses are allocated for use on intranets. These addresses are used for internal networks and are not routable on external public ne

Write down code snippets for the following in jade, Question 1 Using a ...

Question 1 Using a flowchart and appropriate annotations, describe the execution path of an Agent in JADE 2 Write down code snippets for the following in JADE a Agent A n

Tools for digital sound, Tools for Digital Sound Sound is the oscillat...

Tools for Digital Sound Sound is the oscillation of pressure that propagates in the form of a wave. Sound waves are transmitted through some medium (solid, liquid, or gas); th

Multiple activity charts, A multiple activity chart records the related ...

A multiple activity chart records the related sequence of activities of more than one subject, men and / or machine on a common time scale showing the relationship between

Minimum possible response time , Consider the similar conditions as the las...

Consider the similar conditions as the last problem, except for the following: what's the minimum possible response time for the 1 Gbps and a 1 Mbps line?  What does the diffrentia

What are general middleware, It consists of the communication stacks, distr...

It consists of the communication stacks, distributed directories, authentication services, network time, RPC, Queuing services along with the network OS extensions like the distrib

sorting circuit along with odd-even merging circuit, As we previously know...

As we previously know, the merge sort algorithm needs two circuits, i.e. one for merging and second for sorting the sequences. Thus, the sorting circuit has been derived from the a

Define rs232 interface, Q. Define RS232 Interface? - Indicates the inte...

Q. Define RS232 Interface? - Indicates the interface between DTE and DCE: V.28 mechanical as well as electrical characteristics V.24: functional as well as procedur

Explain the term standard error, Question: a) What is a Linux shell? ...

Question: a) What is a Linux shell? b) Prepare the commands for the following tasks: i) Change the working directory ii) Show the working directory iii) Execute a pro

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