{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Operacons example trivial barrier supports one use

Info icon This preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: tion: abs() and – are scalar operators, automatically promoted to A[LastRow] = operands work with array 1.0; do { [(i,j) in D] Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD: domain(2) = {0..n+1, 0..n+1}, D: subdomain(BigD) = {1..n, 1..n}, LastRow: subdomain(BigD) = D.exterior(1,0); C Temp : back ] real; var A,opy data [BigD& Repeat until done uses slicing and A[LastRow] = 1.0;whole array assignment standard do…while loop construct do { [(i,j) in D] Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD: domain(2) = {0..n+1, 0..n+1}, D: subdomain(BigD) = {1..n, 1..n}, LastRow: subdomain(BigD) = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; Write array to console do { [(i,j) in D] Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD: domain(2) = {0..n+1, 0..n+1}, D: subdomain(BigD) = {1..n, 1..n}, LastRow: subdomain(BigD) = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; do { [(i,j) in D] Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); forall a in A do writeln(“Here is an element of A: ”, a); •  How many tasks will be used? •  How are iteraCons mapped to the tasks? forall (a, i) in zip(A, 1..n) do a = i / 10.0; Forall- loops may be zippered, like for- loops •  Corresponding iteraCons must match up •  But how does this work? 72 —༉  Arrays can be indexed using variables of their domain’s index type (tuples) or lists of integers var i = 1, j = 2; var ij = (i,j); A[ij] = 1.0; A[i, j] = 2.0; —༉  Array indexing can use either par...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern