Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 1.75 KB

Problems.md

File metadata and controls

55 lines (36 loc) · 1.75 KB

Example codes (serial)

dot_prod

Simple example that computes the dot product of two vectors.

pi

Example that approximates pi via numerical integration, $$\pi = 4\int_{0}^{1} \frac{1}{1+x^2} \mathrm dx$$ using the midpoint rule over n equal subintervals

global_min

Interactive demo that focuses on global minimization via calling the steepest-descent method repeatedly using different initial conditions.

Key learning topics:

  • Steepest descent minimization
  • Calling functions
  • Standard math library
  • Control structures

chemistry

Example that computes equilibrium chemical densities at multiple spatial locations, given a random background temperature field, using a simple damped fixed-point iteration as the nonlinear solver.

Key learning topics:

  • Calling functions from other files
  • Call by reference vs call by value

advection

This example sets up and evolves the 2D first order wave equations in time, using a regular staggered spatial discretization and an explicit "leapfrog" time discretization.

Key learning topics:

  • File input/output
  • Header files, macros
  • "Flattened" 2D -> 1D array data structures
  • Nontrivial loop structures
  • "() ? () : ()" conditional operators
  • Python postprocessing/visualization of simulation output data

memory_leak

This example demonstrates how we can use the Linux program "valgrind" to help identify the location of memory leaks in a program.

Key learning topics:

  • Memory leaks
  • Valgrind

matvec

This example performs a simple matrix-vector product, but where we access the matrix data in different orders, illustrating that knowledge of memory layout is crucial for efficient programs.

Key learning topic: matching loop structure to data layout