Outline
description
Transcript of Outline
![Page 1: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/1.jpg)
OutlineOutline
• Announcements– Add/drop by Monday– HWI on the web
• Principal Components Analysis (PCA)• Linking to libraries
![Page 2: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/2.jpg)
PCAPCA
• 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
![Page 3: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/3.jpg)
PCAPCA
• Example: Temperature in NW Atlantic
![Page 4: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/4.jpg)
PCAPCA
![Page 5: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/5.jpg)
PCAPCA
Rgn 1 Rgn 2 … Rgn 8
C =
Cov=1/(m-1)*CT*C
Cov is n-by-n
• Matrix of data: n
m
![Page 6: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/6.jpg)
PCAPCA
• 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
![Page 7: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/7.jpg)
PCAPCA
![Page 8: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/8.jpg)
PCA SummaryPCA Summary
• 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
![Page 9: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/9.jpg)
Accessing LibrariesAccessing Libraries
• 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
![Page 10: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/10.jpg)
UNIX LibrariesUNIX 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?
![Page 11: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/11.jpg)
Compiling & LinkingCompiling & Linkingprog.c
for (j=0;j<5){ sin(x[j]);}
prog#($**@)@__!({ø∆˜ß√ˆœπ˚Œ¨Ω√≈˜¡£¢∞
cc prog.c -oprog
Transnslation
prog.o#($**@)@__!(Œ¨Ω√≈˜¡£¢∞
Linkprintf.o
#($**@)@__!(Œ¨Ω√≈˜¡£¢∞
#($**@)@__!(Œ¨Ω√≈˜¡£¢∞
sin.o
![Page 12: Outline](https://reader035.fdocuments.net/reader035/viewer/2022070418/56815858550346895dc5b391/html5/thumbnails/12.jpg)
• 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 librariesBuilding with libraries