WEEK7 - Week7 ClicktoeditMastersubtitlestyle Arrays 3/14/11...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style  3/14/11  Dr. Lale T. Ergene Week 7 Arrays
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
 3/14/11  Dr. Lale T. Ergene 22 Introduction In scientific and engineering computing, it is very common to need to manipulate ordered sets of values, such as  vectors  and  matrices . F language provides extensive facilities for grouping a set of items of the same type into an array which can be operated on • either as an  object  in its own right • or by  reference  to each of its individual elements.
Background image of page 2
 3/14/11  Dr. Lale T. Ergene 33 In all the programs we have written so far, a variable name  refers to  a single location in the  computer’s memory. It is possible to refer a complete set of data obtained for example from repeating statements, etc. One way to do this would be to define a group called array ”  with locations in the memory so that its all elements are identified by the same name but with an The Array Concept
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
 3/14/11  Dr. Lale T. Ergene 44 The Array Concept o A set with n(=6) elements, is named  A o In mathematical terms, A is a vector o And we refer to its elements as  A1 , A2 , A3 , … o In F language they are referred as A(1), A(2), A(3),….
Background image of page 4
 3/14/11  Dr. Lale T. Ergene 55 The array concept o In F, we call such an ordered set of related  variables an  array o Individual items within an array are called  array elements o A(1), A(2), A(3), …, A(n)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
 3/14/11  Dr. Lale T. Ergene 66 Some forms of writing an array element x(10)   10th element of array x y(i+4) z(3*i+ max (i, j, k)) expression inside parenthesis must be integer x( int (y(i)*z(j)+x(k))) x(1)=x(2)+x(4)+1 print *,x(5)
Background image of page 6
 3/14/11  Dr. Lale T. Ergene 77 The array concept 1 2 3 4 5 6 A
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
 3/14/11  Dr. Lale T. Ergene 88 The array concept A 1 2 3 4 1 2 3 4 5 A22 A32
Background image of page 8
 3/14/11  Dr. Lale T. Ergene 99 Array declarations Declaration of arrays: type , dimension(subscript bounds) :: list_of_array_names type , dimension(n:m) :: variable_name_list Examples: real , dimension(0:4) :: gravity, pressure integer , dimension(1:100) :: scores logical , dimension(-1, 3) :: table
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
 3/14/11  Dr. Lale T. Ergene 1010 Array declarations o Up to 7 dimensions o Number of permissible subscripts: rank o Number of elements in a particular dimension: extent o Total number of elements of an array: size o Shape  of an array is determined by its  rank  and 
Background image of page 10
 3/14/11  Dr. Lale T. Ergene 1111 Examples for Shape Arrays The array “z” has 50 elements real, dimension ( 0 : 49 ) : : z a,b,c has 50 elements real, dimension ( 11 : 60 ) : : a, b, c The array “x” has 20 elements real, dimension ( -20 : -1 ) : : x The array “y” has 20 elements real, dimension ( -9 : 10 ) : : y Both negative and zero subscripts are allowed
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
 3/14/11  Dr. Lale T. Ergene 1212
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 36

WEEK7 - Week7 ClicktoeditMastersubtitlestyle Arrays 3/14/11...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online