hwk4_2011 - MSC321 Homework 4 Due Feb 28 1 Readings 1. What...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: MSC321 Homework 4 Due Feb 28 1 Readings 1. What is the difference between an array and an array element? 2. How may arrays be declared? 3. What are the definitions of the rank, extent, size and shape of an array? 4. Determine the above quantities for the following arrays: integer :: a(3,2), b(-1:5), c(5,-3:6,2) 5. Given that the left most indeces in a 3D array change fastest, what would be the memory offset of element ( i,j,k ) in an array declared as integer, parameter :: M=4,N=5,K=6 integer :: A(M,N,K) 2 Passing arrays to procedures What gets printed in each call to the subroutine PrintVector (please explain) program aaa implicit none integer, parameter :: m=6,n=3 integer :: i,j,ij, ia(m,n) ij = 0 do j = 1,n do i = 1,m ij = ij+1 ia(i,j) = ij enddo enddo call PrintVector(ia,m) call PrintVector(ia(1,2),n) call PrintVector(ia(1,3),m) call PrintVector(ia,m*n) stop end program aaa subroutine PrintVector(jvec,n) implicit none integer, intent(in) :: n integer, intent(in) :: jvec(n) do i = 1,n print *,jvec(i) enddo return end subroutine PrintVector 1 3 Vector Norms The 1,2, p and ∞-norm of a vector u with N components ( u 1 ,u 2 ,...,u N ) are defined as: k u k 1 = N X i =1 | u i | k u k 2 = N X i =1 | u i | 2 ! 1 2 k u k p = N X i =1 | u i | p ! 1 p k u k ∞ = max 1 ≤ i ≤ N | u i | Write module vecnorms that includes four functions to compute these norms. Each function should receive in its argument list the vector u , its dimension N , and when required p , and must return the requisite p-norm. Test your code on simple short vectors to verify that the functions work properly, and then find the 1,2,5, and ∞...
View Full Document

Page1 / 5

hwk4_2011 - MSC321 Homework 4 Due Feb 28 1 Readings 1. What...

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

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