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

What are intrusion detection systems, Question : a) Give three example...

Question : a) Give three examples of vulnerable services which are among the overwhelming majority of successful attacks. b) Name the five outside sources which can be the

What are the various security measures, What are the various security meas...

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

Application of internet control message protocol, The application for this ...

The application for this assignment is somewhat arti?cial. Normally, an application would not interact directly with IP. Instead, it would create a UDP or TCP socket and interact w

computer computinons, Difference between synchronous tdm and statistical t...

Difference between synchronous tdm and statistical tdm

Explain about wireless ethernet, Wireless Ethernet (802.11) a) Operates...

Wireless Ethernet (802.11) a) Operates on physical plus data link layers b) BSS (Basic service set) stationary or mobile wireless stations and a central base station known a

Sorting using combinational circuit, Now, let us suppose a famous sequence ...

Now, let us suppose a famous sequence called as bitonic sequence and sort out the elements using a combinational circuit consisting of a set of comparators. The property of bitonic

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

What are the advantages of adaptive routing, What are the Advantages of ada...

What are the Advantages of adaptive routing  (1) An adaptive routing method can improve performance, as realised by the network user. (2) An adaptive routing method can aid

IPV6, is DVMRP multicast prtocol supports IPV6?

is DVMRP multicast prtocol supports IPV6?

State about the future of the intranet, Future of the intranet At ...

Future of the intranet At present, the world of information technology is guided bythe C 3 paradigm that stands for Command, Control and Communication, which is normally

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