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

Describe the specific ip-qos schemes, State how the different IP-QoS needs ...

State how the different IP-QoS needs for controling traffic, data and voice applications can be supported in your technology choice from Q7. Describe the specific IP-QoS schemes -

Assignment, i want to make the assignment from you

i want to make the assignment from you

Why routine security audits are essential, Why Routine security audits are ...

Why Routine security audits are essential It is essential that regular security audits are conducted to find out physically which computer is connected and permits access to

Explain classification of computer network by range, Question 1 Explain cl...

Question 1 Explain classification of computer Network by range Question 2 Explain three major problems of Transmission lines Question 3 What is the maximum data rate of

What are different ways of securing a computer network, What are different ...

What are different ways of securing a computer network? There are lots of ways to do this. Install reliable and updated anti-virus program on all computers. Make sure firewalls

Show the security policy as well integrated security, Q. Show the Security ...

Q. Show the Security Policy as well Integrated Security ? Security policy is on paper statement describing what assets are to be protected and why who is responsible and which

Hyper cube, Hyper Cube A Hypercube interconnection network is increamen...

Hyper Cube A Hypercube interconnection network is increament  of cube network. Hypercube interconnection network for n ≥ 3, can be distinct recursively as follow: For n = 3,

Explain how a cdma system works, (a) Explain how a CDMA system works? (b...

(a) Explain how a CDMA system works? (b) Explain howWelsh-Hadamard codes are generated. Explain why orthogonality between different spreading codes is important. (c) Consider

Basic working of spanning tree, Q. Basic working of Spanning Tree? Spa...

Q. Basic working of Spanning Tree? Spanning Tree - Redundant bridges may be installed to provide reliability - To prevent infinite looping of packets between bridges,

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