1 / 12

Outline

Outline. Announcements Add/drop by Monday HWI on the web Principal Components Analysis (PCA) Linking to libraries. PCA. Many scientific problems are complicated High-dimensional (lots of interesting parameters) Observations from mulitple instruments/locations

mabli
Download Presentation

Outline

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Outline Announcements Add/drop by Monday HWI on the web Principal Components Analysis (PCA) Linking to libraries

  2. PCA Many scientific problems are complicated High-dimensional (lots of interesting parameters) Observations from mulitple instruments/locations PCA is a method for reducing the dimensionality of a system by exploiting covariance among variables PCA identifies linear combinations (vectors) that represent “interesting” features common to the data sets

  3. Example: Temperature in NW Atlantic PCA

  4. PCA

  5. Matrix of data: PCA n m Cov=1/(m-1)*CT*C Cov is n-by-n

  6. PCA • Let • v1, v2, …, vN be the eigenvectors of Cov • 1, 2, …, N be the corresponding eigenvalues • Assume 1>2> …> N • Then, • C* v1 is a new time-series representing 1/(1+ 2+ …+ N ) percent of the total variance • If you’re lucky, v1 & v2 will represent a lot of the variance and can be used instead of the entire system

  7. PCA

  8. Load m-by-n data matrix C Compute Cov=1/(m-1)*CT*C BLAS Level 3 routine SSYRK computes a*A*AT+b*v a*AT*A+b*v Compute eigenvalues and eigenvectors of Cov LAPACK routine SSYEV computes eigenvectors and eigenvalues for symmetric matrices PCA Summary

  9. We could download code for BLAS and LAPACK and compile with our code Slow (BLAS and LAPACK are big) Ideally, we would compile BLAS & LAPACK once to object code (.o) and link Saves compile time, easier to maintain Accessing Libraries

  10. UNIX Libraries Pre-built libraries (commercial or otherwise) are stored as “archives” on UNIX machines lib<NAME>.a libblas.a -- BLAS routines liblapack.a--LAPACK routines System libraries are in directories like /lib and /usr/lib archives are actually collections of object code (.o) How do we access routines in libraries?

  11. Compiling & Linking prog.c prog prog.o printf.o for (j=0;j<5){ sin(x[j]); } #($**@)@__!( {ø∆˜ß√ˆœπ˚ Œ¨Ω√≈˜¡£¢∞ #($**@)@__!( Œ¨Ω√≈˜¡£¢∞ #($**@)@__!( Œ¨Ω√≈˜¡£¢∞ #($**@)@__!( Œ¨Ω√≈˜¡£¢∞ sin.o cc prog.c -oprog Transnslation Link

  12. 1) Compile the code you have (use -c) 2) Link your code together and link to the libraries you need g77 <YOUR OBJECTS> {-L<LIBPATH>} -lname -L sets directory where linker will look for libraries System libraries (/usr/lib, etc.) automatically included, so -L not necessary -lname links to libname.a system libraries (or LIBPATH) Building with libraries

More Related