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

Structure of internet servers address, In a client's software , the structu...

In a client's software , the structure of an Internet server's address keyed is as follows: Where: http refer for the communication protocol to be used www refer for th

Describe about the server and browser software, Describe about the Server a...

Describe about the Server and browser software Most of the server and browser software developed by various vendors carry out encryption using either a 40-bit or a 128-bit sec

Program annotation packages, A fairly renowned approach in this area is Ope...

A fairly renowned approach in this area is OpenMP, a recently developed industry standard for shared memory programming on architectures with uniform memory access characteristics.

Show the process of mail delivery, Q. Show the process of Mail Delivery? ...

Q. Show the process of Mail Delivery? Mail Delivery -Consists of three stages -First stage - email goes from user agent to local server, where it is stored until it ma

What is bens network, Q. What is Bens Network? It's a non-blocking netw...

Q. What is Bens Network? It's a non-blocking network. It's a special type of Clos network where first and last stage consists of  2×2 switches (for n input  and m output networ

Programming based on data parallelism, Programming Based on Data Parallelis...

Programming Based on Data Parallelism In a data parallel programming model, the focus is on data distribution. Every processor works with a portion of data. We shall discuss on

Set up to use pvm run and complie, PVM uses two environment variables when ...

PVM uses two environment variables when starting and running. Every PVM user needs to set these two variables to use PVM. The initial variable is PVM_ROOT, which is set to the loca

Multicast extension to ospf, MOSPF MOSPF is multicast extension to OSP...

MOSPF MOSPF is multicast extension to OSPF. This protocol is extension of OSPF which is a unicast routing protocol which make MOSPF a combination of unicast and multicast prot

What is money laundering and how is money laundered, Question: a) (i)...

Question: a) (i) Describe the entire process of credit card processing, identifying the different steps and parties involved. (ii) What are the roles of the acquiring ban

Ethernet framing is used for tcp/ip, Which type of Ethernet framing is used...

Which type of Ethernet framing is used for TCP/IP and AppleTalk Ans)Ethernet SNAP

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