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

Which osi reference layer is concerned with logical address, There are two ...

There are two logical addressing :- a) Datalink is physical (hardware) addressing. b) Network is logical (software) addressing.

State the network environment of intranets and internet, State the Network ...

State the Network environment of Intranets and Internet Intranets as well as the Internet are based purely on networks, the company intending to install Intranet must consider

What is an interrupt request, Question: a) Briefly describe the purpos...

Question: a) Briefly describe the purpose of Windows Powershell? b) Name three ways software can be installed on Linux? c) What is an interrupt request? d) As the

Introduction to operations research, explain the three classification of op...

explain the three classification of operation research

What is stop-and-wait automatic repeat request, What is Stop-and-Wait Autom...

What is Stop-and-Wait Automatic Repeat Request? Error correction in Stop-and-Wait ARQ is implemented by keeping a copy of the sent frame and retransmitting of the frame when th

Show the drawbacks of go-back-N, Q. Show the Drawbacks of Go-back-N? D...

Q. Show the Drawbacks of Go-back-N? Drawbacks of Go-back- N - Inefficient - Every out of order received packets are discarded (receiver side is simplified) - This

Application layer , Normal 0 false false false EN-IN ...

Normal 0 false false false EN-IN X-NONE X-NONE Application Layer   The application  layer

Networking security, difference between spambox and inbox in gmail

difference between spambox and inbox in gmail

Determine 10base-fl- fiber link ethernet, 10Base-FL: Fiber Link Ethernet ...

10Base-FL: Fiber Link Ethernet Utilizes star topology to connect stations to a hub External transceiver entitle as a fiber-optic MAU connects processing device to fib

Ipv6 packet format - network layer and routing , IPv6 packet Format Th...

IPv6 packet Format The format  of an IPv6 header is shown  in figure. Although IPv6 addresses are four  times  the size  of IPv4 address  the basic  IPv6 header is only twice

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