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

Broadcast domain and collision domain, Explain Difference between broadcast...

Explain Difference between broadcast domain and collision domain? Ans) Broadcast Domain Send the packet to all the Present Network IT might be send by the person It mig

What is packet filter, What is packet filter? Packet filter is a standa...

What is packet filter? Packet filter is a standard router up to with some extra functionality. The extra functionality permits every incoming or outgoing packet to be inspected

Configure the physical topology- ccna, Configure the Physical Topology ...

Configure the Physical Topology Step 1: Cable the network. Refer to the figure and table below for the essential cables. Step 2: Physically connect lab devices. C

What is the last step in data encapsulation, The Five steps to data encapsu...

The Five steps to data encapsulation (IN ORDER): 1) User information is changed into data. 2) Data is changed into segments. 3) Segments are changed into datagram and pack

Command that shows traffic statistics on serial 0/1, Recognize the command ...

Recognize the command that shows traffic statistics on serial0/1? Ans) show interface serial 0/1

Sockets, When programming a server or a client, we have to deal with port n...

When programming a server or a client, we have to deal with port numbers and IP addresses, but we usually do this through an abstraction called a socket. Sockets are the standard A

Node selection principle, QUESTION (a) Briefly describe the steps invol...

QUESTION (a) Briefly describe the steps involved in Network Simplex Method. (b) In Radix Heap Algorithm, the technique of buckets is employed. However this idea is an extens

Networking, Discuss the interdependence of networking hardware and software...

Discuss the interdependence of networking hardware and software. Is it possible to have one without the other?

Bit stuffing, bit stuffing program in python

bit stuffing program in python

virtual private network - virtual private network vpns, Virtual private ne...

Virtual private network The virtual  private  networks takes the  user data  encrypts them and sends them  to their  destination over  the internet. the sender  and the receiv

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