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
What are the two broad class classifications under which Networks can be divided? All computer networks fit in one of the two dimensions namely: a)      Transmission Technol

i want an assignment with 2500 words on this topic with Harvard referencing on 22th of dec can i get it ?

Name the two commands that save the running-config to a TFTP server Ans)  Two commands are:- a) copy running tftp  b) write network

Error Detecting Code - Parity bit: The general idea for achieving error detection and correction is to add some redundancy (i.e., some extra data) to a message, which receiver

Q. Explain the Communication Channel Threats? Secrecy Threat - Secrecy is the avoidance of unauthorized information disclosure - Privacy is the guard of individua

Unguided Media: Wireless - A Wireless communication transporting electromagnetic waves without a physical conductor Wireless Propagation Methods - Ground - radio

Explain how the lan model be developed The LAN model can be developed incrementally. If LAN is just a long cable. it cannot be brought down by single failure (if servers are re

What is Multi-mode fiber Multi-mode fiber uses LEDs like the light-generating devices while single-mode fiber generally uses lasers. FDDI specifies the utilization of dual r

Simple Mail Transfer Protocoland Secure Sockets Layer SMTP: Simple Mail Transfer Protocol is a server-to-server protocol for delivering electronic mail. SSL: Secure Sockets

What are the various security measures A matter of prime concern to companies is the overheads in the form of huge investment on extra hardware and software. It is quite possi