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

Layer of security, Other than performance  issues, there could be security ...

Other than performance  issues, there could be security reasons for using something like xinetd.  Make simple design in which a new version of xinetd gives a layer of security.

What is intranet security, What is Intranet security Every company star...

What is Intranet security Every company starts its operations with a genuine and honest thinking. As time passes, based on the needs of its employees as well as customers, a nu

Nfs best performance, what parameters should i have for the best nfs v4 per...

what parameters should i have for the best nfs v4 performance?

Metropolitan area network ( man)- fundamentals of networks , Normal 0 ...

Normal 0 false false false EN-IN X-NONE X-NONE Metropolitan area Network ( MAN) Metropoli

What is exterior gateway protocol, What is EGP (Exterior Gateway Protocol)?...

What is EGP (Exterior Gateway Protocol)? It is the protocol the routers in neighboring autonomous systems use to recognize the set of networks that can be reached within or by

Topology-tcp and udp sources, To relieve some programming burden, project 5...

To relieve some programming burden, project 5 is a group project that two students can form a group to do and submit one report. In your submitted report, please specify who is you

Wireless Networks, Is a complete OSI/TCPIP network architecture available i...

Is a complete OSI/TCPIP network architecture available in MATLAB?

What is difference between igp and eigrp, IGP= Interior gateway routing pro...

IGP= Interior gateway routing protocol and EIGRP= Enhanced Interior Gateway routing protocol IGP = use in one Autonomous and EIGRP = use with many autonomous

Show the distribution of name space, Q. Show the Distribution of Name Space...

Q. Show the Distribution of Name Space? Distribution of Name Space --Information for domain name space must be stored on multiple servers (DNS servers) to be efficient

Dns message - application layer, DNS Message There are  the only  two ...

DNS Message There are  the only  two kinds  of DNS message DNS query and reply messages. Further mote both query  and reply message have  the same  format  as shown in figure.

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