The forall statement, Computer Networking

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]

Posted Date: 3/2/2013 8:11:54 AM | Location : United States







Related Discussions:- The forall statement, Assignment Help, Ask Question on The forall statement, Get Answer, Expert's Help, The forall statement Discussions

Write discussion on The forall statement
Your posts are moderated
Related Questions
Control Frame: solicit_successor Periodically ask for any station to link by sending solicit_successor Token with sender's addr and successor's addr wait 2 (as in

Explain the term- congestion The average queue size over the last cycle and the current cycle is calculated. This value is the threshold. By averaging over two cycles instead o

State the list of protocols supported by the Intranet The following is the list of protocols supported by the Intranet: ARP: Address resolution Protocol is used to resol

Identify the 3 major functions at layer 3 of the OSI model Ans) Layer three explains the path, forwards the packet and executes software / logical addressing.

Question 1 What is bandwidth?                         >>What is the bandwidth of                            a) Telephone signal                            b) Commercial radio broa

Full-Duplex Ethernet 10Base5 as well as 10Base2 are half-duplex Full-duplex raises capacity of each domain No require for CSMA/CD

Explain the uses of Firewall in computer For Intranet developers, restricting access of unauthorised users to the Web site has been the greatest challenge. In addition to preve

Source quench is the process where the destination router, or end internetworking device will "quench" the date from the "source", or the source router. This usually occurs when th

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

How to protect computer Hardware by threats The first component in the computer system vulnerable to attacks or threats, and most important to be protected, is the hardware.