SlideShare a Scribd company logo
1 of 63
Linear Algebra and MATLAB Tutorial
Jia-Bin Huang
University of Illinois, Urbana-Champaign
www.jiabinhuang.com
jbhuang1@Illinois.edu
Today’s class
• Introduction to MATLAB
• Linear algebra refresher
• Writing fast MATLAB code
Working with MATLAB
Learning by doing
• Let’s work through an example!
• Download the example script here
• Topics
• Basic types in Matlab
• Operations on vectors and matrices
• Control statements & vectorization
• Saving/loading your work
• Creating scripts or functions using m-files
• Plotting
• Working with images
Questions?
Linear algebra refresher
• Linear algebra is the math tool du jour
• Compact notation
• Convenient set operations
• Used in all modern texts
• Interfaces well with MATLAB, numpy, R, etc.
• We will use a lot of it!!
Slides credits: Paris Smaragdis and Karianne Bergen
Filtering, linear transformation
-> extracting frequency sub-bands
Vector dot products
-> measure patch similarities
Hybrid Image Image Quilting Gradient Domain Fusion
Solving linear systems
-> solve for pixel values
Image-based Lighting
Solving linear systems -> solve for radiance map
Video Stitching and Processing
Solving linear systems -> solve for geometric transform
Scalars, Vectors, Matrices, Tensors
How will we see these?
• Vector: an ordered collection of scalars (e.g., sounds)
• Matrix: a two-dimensional collection of scalars (e.g., images)
• Tensor: 3D signals (e.g., videos)
Element-wise operations
• Addition/subtraction
• 𝒂 ± 𝒃 = 𝒄 ⇒ 𝑎𝑖 + 𝑏𝑖 = 𝑐𝑖
• Multiplication (Hadamard product)
• 𝒂 𝒃 = 𝒄 ⇒ 𝑎𝑖 𝑏𝑖 = 𝑐𝑖
• No named operator for element-wise division
• Just use Hadamard with inverted elements
c = a + b;
c = a – b;
c = a.*b;
c = a./b;
Which division?
Left Right
Array division C = ldivide(A, B);
C = A.B;
C = rdivide(A, B);
C = A./B;
Matrix division C = mldivide(A, B);
C = A/B;
C = mldivide(A, B);
C = AB;
EX: Array division
A = [1 2; 3, 4];
B = [1,1; 1, 1];
C1 = A.B;
C2 = A./B;
C1 =
1.0000 0.5000
0.3333 0.2500
C2 =
1 2
3 4
EX: Matrix division
X = AB;
-> the (least-square) solution to AX = B
X = A/B;
-> the (least-square) solution to XB = A
B/A = (A'B')'
Transpose
• Change rows to columns (and vice versa)
• Hermitian (conjugate transpose)
• Notated as 𝑋H
• Y = X’; % Hermitian transpose
• Y = X.’; % Transpose (without conjugation)
Visualizing transposition
• Mostly pointless for 1D signals
• Swap dimensions for 2D signals
Reshaping operators
• The vec operator
• Unrolls elements column-wise
• Useful for getting rid of matrices/tensors
• B = A(:);
• The reshape operator
• B = reshape(A, sz);
• prod(sz) must be the same as
numel(A)
EX: Reshape
A = 1:12;
B = reshape(A,[3,4]);
B =
1 4 7 10
2 5 8 11
3 6 9 12
Trace and diag
• Matrix trace
• Sum of diagonal elements
• The diag operator EX: trace
A = [1, 2; 3, 4];
t = trace(A);
Q: What’s t?
EX: diag
x = diag(A);
D = diag(x);
Q: What’s x and D?
Vector norm (how “big" a vector is)
• Taxicab norm or Manhattan norm
• | 𝑣 | 1 = ∑|𝑣𝑖|
• Euclidean norm
• | 𝑣 | 2 = ∑𝑣𝑖
2
1
2 = 𝑣⊤ 𝑣
• Infinity norm
• | 𝑣 | ∞ = max
𝑖
|𝑣𝑖|
• P-norm
• | 𝑣 | 𝑝 = ∑𝑣𝑖
𝑝
1
𝑝
Unit circle
(the set of all vectors of norm 1)
Which norm to use?
• Say residual 𝑣 = (measured value) – (model estimate)
• | 𝑣 | 1: if you want to your measurement and estimate to match
exactly for as many samples as possible
• | 𝑣 | 2: use this if large errors are bad, but small errors are ok.
• | 𝑣 | ∞: use this if no error should exceed a prescribed value .
Vector-vector products
• Inner product 𝐱⊤ 𝒚
• Shorthand for multiply and accumulate
𝐱⊤ 𝒚 =
𝒊
𝑥𝑖 𝑦𝑖 = 𝐱 𝐲 cos 𝜃
• Outer product: 𝐱𝒚⊤
Matrix-vector product
• Generalizing the dot product
• Linear combination of the columns of A
Matrix-matrix product C = AB
Definition: as inner products
𝐶𝑖𝑗 = 𝑎𝑖
⊤
𝑏𝑗
As sum of outer productsAs a set of matrix-vector products
• matrix 𝐴 and columns of B
• rows of 𝐴 and matrix B
Matrix products
• Output rows == left matrix rows
• Output columns == right matrix columns
Matrix multiplication properties
• Associative:
𝐴𝐵 𝐶 = 𝐴(𝐵𝐶)
• Distributive:
𝐴 𝐵 + 𝐶 = 𝐴𝐵 + 𝐴𝐶
• NOT communitive:
𝐴𝐵 ≠ 𝐵𝐴
Linear independence
• Linear dependence: a set of vectors v1, v2, ⋯ , 𝑣𝑟 is linear dependent
if there exists a set of scalars 𝛼1, 𝛼2, ⋯ , 𝛼 𝑟 ∈ ℝ with at least one 𝛼𝑖 ≠
0 such that
𝛼1 𝑣1 + 𝛼2 𝑣2 + ⋯ + 𝛼 𝑟 𝑣𝑟 = 0
i.e., one of the vectors in the set can be written as a linear combination of one
or more other vectors in the set.
• Linear independence: a set of vectors v1, v2, ⋯ , 𝑣𝑟 is linear
independent if it is NOT linearly dependent.
𝛼1 𝑣1 + 𝛼2 𝑣2 + ⋯ + 𝛼 𝑟 𝑣𝑟 = 0 ⟺ 𝛼𝑖 = ⋯ = 𝛼 𝑟 = 0
Basis and dimension
• Basis: a basis for a subspace 𝑆 is a linear independent set of vectors
that span 𝑆
•
1
0
,
0
1
and
1
−1
,
1
1
are both bases that span ℝ2
• Not unique
• Dimension dim(𝑆): the number of linearly independent vectors in the
basis for 𝑆
Range and nullspace of a matrix 𝐴 ∈ ℝ 𝑚×𝑛
• The range (column space, image) of a matrix 𝐴 ∈ ℝ 𝑚×𝑛
• Denoted by ℛ(𝐴)
• The set of all linear combination of the columns of 𝐴
ℛ 𝐴 = 𝐴𝑥 𝑥 ∈ ℝ 𝑛
}, ℛ(𝐴) ⊆ ℝ 𝑚
• The nullspace (kernel) of a matrix 𝐴 ∈ ℝ 𝑚×𝑛
• Denoted by 𝒩(𝐴)
• The set of vectors z such that 𝐴𝑧 = 0
𝒩 𝐴 = { 𝑧 ∈ ℝ 𝑛|𝐴𝑧 = 0}, 𝒩 𝐴 ⊆ ℝ 𝑚
Rank of 𝐴 ∈ ℝ 𝑚×𝑛
• Column rank of 𝐴: dimension of ℛ(𝐴)
• Row rank of 𝐴: dimension of ℛ 𝐴⊤
• Column rank == row rank
• Matrix 𝐴 ∈ ℝ 𝑚×𝑛 is full rank if 𝑟𝑎𝑛𝑘 𝐴 = min {𝑚, 𝑛 }
System of linear equations
• Ex: Find values 𝑥1, 𝑥2, 𝑥3 ∈ ℝ that satisfy
• 3𝑥1 + 2𝑥2 − 𝑥3 − 1 = 0
• 2𝑥1 − 2𝑥2 + 𝑥3 + 2 = 0
• −𝑥1 −
1
2
𝑥2 − 𝑥3 = 0
Solution:
• Step 1: write the system of linear equations as a matrix equation
𝐴 =
3 2 −1
2 −2 1
−1 −
1
2
−1
, 𝑥 =
𝑥1
𝑥2
𝑥3
, 𝑏 =
1
−2
0
.
• Step 2: Solve for 𝐴𝑥 = 𝑏
Mini-quiz 1
• What’s the 𝐴, 𝑥, and 𝑏 for the following linear equations?
• 2𝑥2 − 7 = 0
• 2𝑥1 − 3𝑥3 + 2 = 0
• 4𝑥2 + 2𝑥3 = 0
• 𝑥1 + 3𝑥3 = 0
𝐴 =
0 1 0
2 0 −3
0
1
4
0
2
3
, 𝑥 =
𝑥1
𝑥2
𝑥3
, 𝑏 =
7
−2
0
0
.
Mini-quiz 2
• What’s the 𝐴, 𝑥, and 𝑏 for the following linear equation?
• 𝑋 =
𝑥1 𝑥3
𝑥2 𝑥4
•
1
2
⊤
𝑋
−2
1
− 3 = 0
•
1
0
⊤
𝑋
1
1
+ 1 = 0
𝐴 =
−2 − 4 1 2
1 0 1 0
, 𝑥 =
𝑥1
𝑥2
𝑥3
𝑥4
, 𝑏 =
3
−1
Solving system of linear equations
• Given 𝐴 ∈ ℝ 𝑚×𝑛 and b ∈ ℝ 𝑚, find x ∈ ℝ 𝑛 such that 𝐴𝑥 = 𝑏
• Special case: a square matrix 𝐴 ∈ ℝ 𝑛×𝑛
• The solution: 𝐴−1 𝑏
• The matrix inverse A−1exists and is unique if and only if
• 𝐴 is a squared matrix of full rank
• “Undoes” a matrix multiplication
• 𝐴−1 𝐴 = 𝐼
• 𝐴−1 𝐴𝑌 = 𝑌
• Y𝐴𝐴−1 = 𝑌
Least square problems
• What if 𝑏 ∉ ℛ(𝐴)?
• No solution 𝑥 exists such that 𝐴𝑥 = 𝑏
• Least Squares problem:
• Define residual 𝑟 = 𝐴𝑥 − 𝑏
• Find vector 𝑥 ∈ ℝ 𝑛 that minimizes
||𝑟||2
2
=||𝐴𝑥 − 𝑏||2
2
Least square problems
• Decompose b ∈ ℝm into components b = b1 + b2 with
• 𝑏1 ∈ ℛ(𝐴) and
• 𝑏2 ∈ 𝒩 A⊤ = ℛ A
⊥
.
• Since 𝑏2 is in ℛ A
⊥
, the orthogonal complement of ℛ A , the
residual norm
||𝑟||2
2
= ||𝐴𝑥 − 𝑏1 − 𝑏2||2
2
= ||𝐴𝑥 − 𝑏1||2
2
+ ||𝑏2||2
2
which is minimized when 𝐴𝑥 = 𝑏1 and 𝑟 = 𝑏2 ∈ 𝒩 A⊤
Normal equations
• The least squares solution 𝑥 occurs when 𝑟 = 𝑏2 ∈ 𝒩 A⊤ , or
equivalently
𝐴⊤ 𝑟 = 𝐴⊤ 𝑏 − 𝐴𝑥 = 0
• Normal equations: 𝐴⊤ 𝐴𝑥 = 𝐴⊤ 𝑏
• If 𝐴 has full column rank, then 𝐴⊤ 𝐴 is invertible.
• Thus (𝐴⊤ 𝐴)𝑥 = (𝐴⊤ 𝑏) has a unique solution
𝑥 = (𝐴⊤ 𝐴)−1 𝐴⊤ 𝑏
• x = Ab;
• x = inv(A’*A)*A’*b; % same as backslash operator
Questions?
Writing Fast MATLAB Code
Using the Profiler
• Helps uncover performance problems
• Timing functions:
• tic, toc
• The following timings were measured on
- CPU i5 1.7 GHz
- 4 GB RAM
• http://www.mathworks.com/help/matlab/ref/profile.html
Pre-allocation Memory
3.3071 s
>> n = 1000;
2.1804 s2.5148 s
Reducing Memory Operations
>> x = 4;
>> x(2) = 7;
>> x(3) = 12;
>> x = zeros(3,1);
>> x = 4;
>> x(2) = 7;
>> x(3) = 12;
Vectorization
2.1804 s 0.0157 s
139x faster!
Using Vectorization
• Appearance
• more like the mathematical expressions, easier to understand.
• Less Error Prone
• Vectorized code is often shorter.
• Fewer opportunities to introduce programming errors.
• Performance:
• Often runs much faster than the corresponding code containing loops.
See http://www.mathworks.com/help/matlab/matlab_prog/vectorization.html
Binary Singleton Expansion Function
• Make each column in A zero mean
>> n1 = 5000;
>> n2 = 10000;
>> A = randn(n1, n2);
• See http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-
performance/
0.2994 s 0.2251 s
Why bsxfun is faster than repmat?
- bsxfun handles replication of the array
implicitly, thus avoid memory allocation
- Bsxfun supports multi-thread
Loop, Vector and Boolean Indexing
• Make odd entries in vector v zero
• n = 1e6;
• See http://www.mathworks.com/help/matlab/learn_matlab/array-indexing.html
• See Fast manipulation of multi-dimensional arrays in Matlab by Kevin Murphy
0.3772 s 0.0081 s 0.0130 s
Solving Linear Equation System
0.1620 s 0.0467 s
Dense and Sparse Matrices
• Dense: 16.1332 s
• Sparse: 0.0040 s
More than 4000x faster!
Useful functions:
sparse(),
spdiags(),
speye(), kron().0.6424 s 0.1157 s
Repeated solution of an equation system with
the same matrix
3.0897 s 0.0739 s 41x faster!
Iterative Methods for Larger Problems
• Iterative solvers in MATLAB:
• bicg, bicgstab, cgs, gmres, lsqr, minres, pcg, symmlq, qmr
• [x,flag,relres,iter,resvec] = method(A,b,tol,maxit,M1,M2,x0)
• source: Writing Fast Matlab Code by Pascal Getreuer
Solving Ax = b when A is a Special Matrix
• Circulant matrices
• Matrices corresponding to cyclic convolution
Ax = conv(h, x) are diagonalized in the Fourier domain
>> x = ifft( fft(b)./fft(h) );
• Triangular and banded
• Efficiently solved by sparse LU factorization
>> [L,U] = lu(sparse(A));
>> x = U(Lb);
• Poisson problems
• See http://www.cs.berkeley.edu/~demmel/cs267/lecture25/lecture25.html
In-place Computation
>> x=randn(1000,1000,50);
0.1938 s 0.0560 s
3.5x faster!
Inlining Simple Functions
1.1942 s 0.3065 s
functions are worth inlining:
- conv, cross, fft2, fliplr, flipud, ifft, ifft2, ifftn, ind2sub, ismember, linspace, logspace, mean,
median, meshgrid, poly, polyval, repmat, roots, rot90, setdiff, setxor, sortrows, std, sub2ind,
union, unique, var
y = medfilt1(x,5); 0.2082 s
Using the Right Type of Data
“Do not use a cannon to kill a mosquito.”
double image: 0.5295 s
uint8 image: 0.1676 s
Confucius
Matlab Organize its Arrays as Column-Major
• Assign A to zero row-by-row or column-by-column
>> n = 1e4;
>> A = randn(n, n);
0.1041 s2.1740 s 21x faster!
Column-Major Memory Storage
>> x = magic(3)
x =
8 1 6
3 5 7
4 9 2
% Access one column
>> y = x(:, 1);
% Access one row
>> y = x(1, :);
Copy-on-Write (COW)
>> n = 500;
>> A = randn(n,n,n);
0.4794 s 0.0940 s
Clip values
>> n = 2000;
>> lowerBound = 0;
>> upperBound = 1;
>> A = randn(n,n);
0.0121 s0.1285 s 10x faster!
Moving Average Filter
• Compute an N-sample moving average of x
>> n = 1e7;
>> N = 1000;
>> x = randn(n,1);
3.2285 s 0.3847 s
Find the min/max of a matrix or N-d array
>> n = 500;
>> A = randn(n,n,n);
0.5465 s
0.1938 s
Acceleration using MEX (Matlab Executable)
• Call your C, C++, or Fortran codes from the MATLAB
• Speed up specific subroutines
• See http://www.mathworks.com/help/matlab/matlab_external/introducing-mex-
files.html
MATLAB Coder
• MATLAB Coder™ generates standalone C and C++ code from
MATLAB® code
• See video examples in http://www.mathworks.com/products/matlab-
coder/videos.html
• See http://www.mathworks.com/products/matlab-coder/
DoubleClass
• http://documents.epfl.ch/users/l/le/leuteneg/www/MATLABToolbox/
DoubleClass.html
parfor for parallel processing
• Requirements
• Task independent
• Order independent
See http://www.mathworks.com/products/parallel-computing/
Parallel Processing in Matlab
• MatlabMPI
• multicore
• pMatlab: Parallel Matlab Toolbox
• Parallel Computing Toolbox (Mathworks)
• Distributed Computing Server (Mathworks)
• MATLAB plug-in for CUDA (CUDA is a library that used an nVidia board)
• Source: http://www-h.eng.cam.ac.uk/help/tpl/programs/Matlab/faster_scripts.html
Resources for your final projects
• Awesome computer vision by Jia-Bin Huang
• A curated list of computer vision resources
• VLFeat
• features extraction and matching, segmentation, clustering
• Piotr's Computer Vision Matlab Toolbox
• Filters, channels, detectors, image/video manipulation
• OpenCV (MexOpenCV by Kota Yamaguchi)
• General purpose computer vision library
Resources
• Linear Algebra
• Linear Algebra Review and Reference
• Linear algebra refresher course
• Quick Review of Matrix and Real Linear Algebra
• MATLAB Tutorial
• Resource collection
• MATLAB F&Q
• Writing Fast MATLAB code
• Techniques for Improving Performance by Mathwork
• Writing Fast Matlab Code by Pascal Getreuer
• Guidelines for writing clean and fast code in MATLAB by Nico Schlömer

More Related Content

What's hot

Matlab on basic mathematics
Matlab on basic mathematicsMatlab on basic mathematics
Matlab on basic mathematicsmonauweralam1
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to MatlabTariq kanher
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersMurshida ck
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introductionideas2ignite
 
Eigen value and eigen vector
Eigen value and eigen vectorEigen value and eigen vector
Eigen value and eigen vectorRutvij Patel
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMohd Esa
 
systems of linear equations & matrices
systems of linear equations & matricessystems of linear equations & matrices
systems of linear equations & matricesStudent
 
Wavelets AND counterlets
Wavelets  AND  counterletsWavelets  AND  counterlets
Wavelets AND counterletsAvichal Sharma
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLABBhavesh Shah
 
Eigen values and eigen vectors engineering
Eigen values and eigen vectors engineeringEigen values and eigen vectors engineering
Eigen values and eigen vectors engineeringshubham211
 
Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problemsMake Mannan
 
Linear transformation.ppt
Linear transformation.pptLinear transformation.ppt
Linear transformation.pptRaj Parekh
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrencesWaqas Akram
 
Eigenvectors & Eigenvalues: The Road to Diagonalisation
Eigenvectors & Eigenvalues: The Road to DiagonalisationEigenvectors & Eigenvalues: The Road to Diagonalisation
Eigenvectors & Eigenvalues: The Road to DiagonalisationChristopher Gratton
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabSantosh V
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabTarun Gehlot
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab sessionDr. Krishna Mohbey
 

What's hot (20)

Matlab on basic mathematics
Matlab on basic mathematicsMatlab on basic mathematics
Matlab on basic mathematics
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to Matlab
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
 
Eigen value and eigen vector
Eigen value and eigen vectorEigen value and eigen vector
Eigen value and eigen vector
 
MATLAB - Arrays and Matrices
MATLAB - Arrays and MatricesMATLAB - Arrays and Matrices
MATLAB - Arrays and Matrices
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
systems of linear equations & matrices
systems of linear equations & matricessystems of linear equations & matrices
systems of linear equations & matrices
 
Wavelets AND counterlets
Wavelets  AND  counterletsWavelets  AND  counterlets
Wavelets AND counterlets
 
METHOD OF JACOBI
METHOD OF JACOBIMETHOD OF JACOBI
METHOD OF JACOBI
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Eigen values and eigen vectors engineering
Eigen values and eigen vectors engineeringEigen values and eigen vectors engineering
Eigen values and eigen vectors engineering
 
Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problems
 
Linear transformation.ppt
Linear transformation.pptLinear transformation.ppt
Linear transformation.ppt
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Use Of DFT In Power Spectral Estimation
Use Of DFT In Power Spectral EstimationUse Of DFT In Power Spectral Estimation
Use Of DFT In Power Spectral Estimation
 
Eigenvectors & Eigenvalues: The Road to Diagonalisation
Eigenvectors & Eigenvalues: The Road to DiagonalisationEigenvectors & Eigenvalues: The Road to Diagonalisation
Eigenvectors & Eigenvalues: The Road to Diagonalisation
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab session
 

Viewers also liked

Image Completion using Planar Structure Guidance (SIGGRAPH 2014)
Image Completion using Planar Structure Guidance (SIGGRAPH 2014)Image Completion using Planar Structure Guidance (SIGGRAPH 2014)
Image Completion using Planar Structure Guidance (SIGGRAPH 2014)Jia-Bin Huang
 
Writing Fast MATLAB Code
Writing Fast MATLAB CodeWriting Fast MATLAB Code
Writing Fast MATLAB CodeJia-Bin Huang
 
Toward Accurate and Robust Cross-Ratio based Gaze Trackers Through Learning F...
Toward Accurate and Robust Cross-Ratio based Gaze Trackers Through Learning F...Toward Accurate and Robust Cross-Ratio based Gaze Trackers Through Learning F...
Toward Accurate and Robust Cross-Ratio based Gaze Trackers Through Learning F...Jia-Bin Huang
 
Transformation Guided Image Completion ICCP 2013
Transformation Guided Image Completion ICCP 2013Transformation Guided Image Completion ICCP 2013
Transformation Guided Image Completion ICCP 2013Jia-Bin Huang
 
Saliency Detection via Divergence Analysis: A Unified Perspective ICPR 2012
Saliency Detection via Divergence Analysis: A Unified Perspective ICPR 2012Saliency Detection via Divergence Analysis: A Unified Perspective ICPR 2012
Saliency Detection via Divergence Analysis: A Unified Perspective ICPR 2012Jia-Bin Huang
 
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)Jia-Bin Huang
 
How to Read Academic Papers
How to Read Academic PapersHow to Read Academic Papers
How to Read Academic PapersJia-Bin Huang
 
Estimating Human Pose from Occluded Images (ACCV 2009)
Estimating Human Pose from Occluded Images (ACCV 2009)Estimating Human Pose from Occluded Images (ACCV 2009)
Estimating Human Pose from Occluded Images (ACCV 2009)Jia-Bin Huang
 
Lecture 21 - Image Categorization - Computer Vision Spring2015
Lecture 21 - Image Categorization -  Computer Vision Spring2015Lecture 21 - Image Categorization -  Computer Vision Spring2015
Lecture 21 - Image Categorization - Computer Vision Spring2015Jia-Bin Huang
 
Applying for Graduate School in S.T.E.M.
Applying for Graduate School in S.T.E.M.Applying for Graduate School in S.T.E.M.
Applying for Graduate School in S.T.E.M.Jia-Bin Huang
 
What Makes a Creative Photograph?
What Makes a Creative Photograph?What Makes a Creative Photograph?
What Makes a Creative Photograph?Jia-Bin Huang
 
Research 101 - Paper Writing with LaTeX
Research 101 - Paper Writing with LaTeXResearch 101 - Paper Writing with LaTeX
Research 101 - Paper Writing with LaTeXJia-Bin Huang
 
Lecture 29 Convolutional Neural Networks - Computer Vision Spring2015
Lecture 29 Convolutional Neural Networks -  Computer Vision Spring2015Lecture 29 Convolutional Neural Networks -  Computer Vision Spring2015
Lecture 29 Convolutional Neural Networks - Computer Vision Spring2015Jia-Bin Huang
 
Three Reasons to Join FVE at uiuc
Three Reasons to Join FVE at uiucThree Reasons to Join FVE at uiuc
Three Reasons to Join FVE at uiucJia-Bin Huang
 
Jia-Bin Huang's Curriculum Vitae
Jia-Bin Huang's Curriculum VitaeJia-Bin Huang's Curriculum Vitae
Jia-Bin Huang's Curriculum VitaeJia-Bin Huang
 
A Physical Approach to Moving Cast Shadow Detection (ICASSP 2009)
A Physical Approach to Moving Cast Shadow Detection (ICASSP 2009)A Physical Approach to Moving Cast Shadow Detection (ICASSP 2009)
A Physical Approach to Moving Cast Shadow Detection (ICASSP 2009)Jia-Bin Huang
 
UIUC CS 498 - Computational Photography - Final project presentation
UIUC CS 498 - Computational Photography - Final project presentation UIUC CS 498 - Computational Photography - Final project presentation
UIUC CS 498 - Computational Photography - Final project presentation Jia-Bin Huang
 
美國研究所申請流程 (A Guide for Applying Graduate Schools in USA)
美國研究所申請流程 (A Guide for Applying Graduate Schools in USA)美國研究所申請流程 (A Guide for Applying Graduate Schools in USA)
美國研究所申請流程 (A Guide for Applying Graduate Schools in USA)Jia-Bin Huang
 
Single Image Super-Resolution from Transformed Self-Exemplars (CVPR 2015)
Single Image Super-Resolution from Transformed Self-Exemplars (CVPR 2015)Single Image Super-Resolution from Transformed Self-Exemplars (CVPR 2015)
Single Image Super-Resolution from Transformed Self-Exemplars (CVPR 2015)Jia-Bin Huang
 
Computer Vision Crash Course
Computer Vision Crash CourseComputer Vision Crash Course
Computer Vision Crash CourseJia-Bin Huang
 

Viewers also liked (20)

Image Completion using Planar Structure Guidance (SIGGRAPH 2014)
Image Completion using Planar Structure Guidance (SIGGRAPH 2014)Image Completion using Planar Structure Guidance (SIGGRAPH 2014)
Image Completion using Planar Structure Guidance (SIGGRAPH 2014)
 
Writing Fast MATLAB Code
Writing Fast MATLAB CodeWriting Fast MATLAB Code
Writing Fast MATLAB Code
 
Toward Accurate and Robust Cross-Ratio based Gaze Trackers Through Learning F...
Toward Accurate and Robust Cross-Ratio based Gaze Trackers Through Learning F...Toward Accurate and Robust Cross-Ratio based Gaze Trackers Through Learning F...
Toward Accurate and Robust Cross-Ratio based Gaze Trackers Through Learning F...
 
Transformation Guided Image Completion ICCP 2013
Transformation Guided Image Completion ICCP 2013Transformation Guided Image Completion ICCP 2013
Transformation Guided Image Completion ICCP 2013
 
Saliency Detection via Divergence Analysis: A Unified Perspective ICPR 2012
Saliency Detection via Divergence Analysis: A Unified Perspective ICPR 2012Saliency Detection via Divergence Analysis: A Unified Perspective ICPR 2012
Saliency Detection via Divergence Analysis: A Unified Perspective ICPR 2012
 
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)
 
How to Read Academic Papers
How to Read Academic PapersHow to Read Academic Papers
How to Read Academic Papers
 
Estimating Human Pose from Occluded Images (ACCV 2009)
Estimating Human Pose from Occluded Images (ACCV 2009)Estimating Human Pose from Occluded Images (ACCV 2009)
Estimating Human Pose from Occluded Images (ACCV 2009)
 
Lecture 21 - Image Categorization - Computer Vision Spring2015
Lecture 21 - Image Categorization -  Computer Vision Spring2015Lecture 21 - Image Categorization -  Computer Vision Spring2015
Lecture 21 - Image Categorization - Computer Vision Spring2015
 
Applying for Graduate School in S.T.E.M.
Applying for Graduate School in S.T.E.M.Applying for Graduate School in S.T.E.M.
Applying for Graduate School in S.T.E.M.
 
What Makes a Creative Photograph?
What Makes a Creative Photograph?What Makes a Creative Photograph?
What Makes a Creative Photograph?
 
Research 101 - Paper Writing with LaTeX
Research 101 - Paper Writing with LaTeXResearch 101 - Paper Writing with LaTeX
Research 101 - Paper Writing with LaTeX
 
Lecture 29 Convolutional Neural Networks - Computer Vision Spring2015
Lecture 29 Convolutional Neural Networks -  Computer Vision Spring2015Lecture 29 Convolutional Neural Networks -  Computer Vision Spring2015
Lecture 29 Convolutional Neural Networks - Computer Vision Spring2015
 
Three Reasons to Join FVE at uiuc
Three Reasons to Join FVE at uiucThree Reasons to Join FVE at uiuc
Three Reasons to Join FVE at uiuc
 
Jia-Bin Huang's Curriculum Vitae
Jia-Bin Huang's Curriculum VitaeJia-Bin Huang's Curriculum Vitae
Jia-Bin Huang's Curriculum Vitae
 
A Physical Approach to Moving Cast Shadow Detection (ICASSP 2009)
A Physical Approach to Moving Cast Shadow Detection (ICASSP 2009)A Physical Approach to Moving Cast Shadow Detection (ICASSP 2009)
A Physical Approach to Moving Cast Shadow Detection (ICASSP 2009)
 
UIUC CS 498 - Computational Photography - Final project presentation
UIUC CS 498 - Computational Photography - Final project presentation UIUC CS 498 - Computational Photography - Final project presentation
UIUC CS 498 - Computational Photography - Final project presentation
 
美國研究所申請流程 (A Guide for Applying Graduate Schools in USA)
美國研究所申請流程 (A Guide for Applying Graduate Schools in USA)美國研究所申請流程 (A Guide for Applying Graduate Schools in USA)
美國研究所申請流程 (A Guide for Applying Graduate Schools in USA)
 
Single Image Super-Resolution from Transformed Self-Exemplars (CVPR 2015)
Single Image Super-Resolution from Transformed Self-Exemplars (CVPR 2015)Single Image Super-Resolution from Transformed Self-Exemplars (CVPR 2015)
Single Image Super-Resolution from Transformed Self-Exemplars (CVPR 2015)
 
Computer Vision Crash Course
Computer Vision Crash CourseComputer Vision Crash Course
Computer Vision Crash Course
 

Similar to Linear Algebra and Matlab tutorial

Lines and planes in space
Lines and planes in spaceLines and planes in space
Lines and planes in spaceFaizan Shabbir
 
matrix algebra
matrix algebramatrix algebra
matrix algebrakganu
 
Support Vector Machines is the the the the the the the the the
Support Vector Machines is the the the the the the the the theSupport Vector Machines is the the the the the the the the the
Support Vector Machines is the the the the the the the the thesanjaibalajeessn
 
Optimum Engineering Design - Day 2b. Classical Optimization methods
Optimum Engineering Design - Day 2b. Classical Optimization methodsOptimum Engineering Design - Day 2b. Classical Optimization methods
Optimum Engineering Design - Day 2b. Classical Optimization methodsSantiagoGarridoBulln
 
machine learning.pptx
machine learning.pptxmachine learning.pptx
machine learning.pptxAbdusSadik
 
Paper study: Learning to solve circuit sat
Paper study: Learning to solve circuit satPaper study: Learning to solve circuit sat
Paper study: Learning to solve circuit satChenYiHuang5
 
Matlab tutorial and Linear Algebra Review.ppt
Matlab tutorial and Linear Algebra Review.pptMatlab tutorial and Linear Algebra Review.ppt
Matlab tutorial and Linear Algebra Review.pptIndra Hermawan
 
08-Regression.pptx
08-Regression.pptx08-Regression.pptx
08-Regression.pptxShree Shree
 
LINEAR ALGEBRA, WITH OPTIMIZATION
LINEAR ALGEBRA, WITH OPTIMIZATIONLINEAR ALGEBRA, WITH OPTIMIZATION
LINEAR ALGEBRA, WITH OPTIMIZATIONCHARAK RAY
 
مدخل إلى تعلم الآلة
مدخل إلى تعلم الآلةمدخل إلى تعلم الآلة
مدخل إلى تعلم الآلةFares Al-Qunaieer
 
Intro matlab and convolution islam
Intro matlab and convolution islamIntro matlab and convolution islam
Intro matlab and convolution islamIslam Alabbasy
 
Linear Algebra Presentation including basic of linear Algebra
Linear Algebra Presentation including basic of linear AlgebraLinear Algebra Presentation including basic of linear Algebra
Linear Algebra Presentation including basic of linear AlgebraMUHAMMADUSMAN93058
 
Matlab ch1 (4)
Matlab ch1 (4)Matlab ch1 (4)
Matlab ch1 (4)mohsinggg
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functionsjoellivz
 
Module 1 Theory of Matrices.pdf
Module 1 Theory of Matrices.pdfModule 1 Theory of Matrices.pdf
Module 1 Theory of Matrices.pdfPrathamPatel560716
 
Data Mining Lecture_10(b).pptx
Data Mining Lecture_10(b).pptxData Mining Lecture_10(b).pptx
Data Mining Lecture_10(b).pptxSubrata Kumer Paul
 

Similar to Linear Algebra and Matlab tutorial (20)

Lines and planes in space
Lines and planes in spaceLines and planes in space
Lines and planes in space
 
matrix algebra
matrix algebramatrix algebra
matrix algebra
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Support Vector Machines is the the the the the the the the the
Support Vector Machines is the the the the the the the the theSupport Vector Machines is the the the the the the the the the
Support Vector Machines is the the the the the the the the the
 
Optimum Engineering Design - Day 2b. Classical Optimization methods
Optimum Engineering Design - Day 2b. Classical Optimization methodsOptimum Engineering Design - Day 2b. Classical Optimization methods
Optimum Engineering Design - Day 2b. Classical Optimization methods
 
machine learning.pptx
machine learning.pptxmachine learning.pptx
machine learning.pptx
 
Paper study: Learning to solve circuit sat
Paper study: Learning to solve circuit satPaper study: Learning to solve circuit sat
Paper study: Learning to solve circuit sat
 
Matlab tutorial and Linear Algebra Review.ppt
Matlab tutorial and Linear Algebra Review.pptMatlab tutorial and Linear Algebra Review.ppt
Matlab tutorial and Linear Algebra Review.ppt
 
1619 quantum computing
1619 quantum computing1619 quantum computing
1619 quantum computing
 
08-Regression.pptx
08-Regression.pptx08-Regression.pptx
08-Regression.pptx
 
LINEAR ALGEBRA, WITH OPTIMIZATION
LINEAR ALGEBRA, WITH OPTIMIZATIONLINEAR ALGEBRA, WITH OPTIMIZATION
LINEAR ALGEBRA, WITH OPTIMIZATION
 
Cg 04-math
Cg 04-mathCg 04-math
Cg 04-math
 
مدخل إلى تعلم الآلة
مدخل إلى تعلم الآلةمدخل إلى تعلم الآلة
مدخل إلى تعلم الآلة
 
Intro matlab and convolution islam
Intro matlab and convolution islamIntro matlab and convolution islam
Intro matlab and convolution islam
 
Data Mining Lecture_9.pptx
Data Mining Lecture_9.pptxData Mining Lecture_9.pptx
Data Mining Lecture_9.pptx
 
Linear Algebra Presentation including basic of linear Algebra
Linear Algebra Presentation including basic of linear AlgebraLinear Algebra Presentation including basic of linear Algebra
Linear Algebra Presentation including basic of linear Algebra
 
Matlab ch1 (4)
Matlab ch1 (4)Matlab ch1 (4)
Matlab ch1 (4)
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
 
Module 1 Theory of Matrices.pdf
Module 1 Theory of Matrices.pdfModule 1 Theory of Matrices.pdf
Module 1 Theory of Matrices.pdf
 
Data Mining Lecture_10(b).pptx
Data Mining Lecture_10(b).pptxData Mining Lecture_10(b).pptx
Data Mining Lecture_10(b).pptx
 

More from Jia-Bin Huang

How to write a clear paper
How to write a clear paperHow to write a clear paper
How to write a clear paperJia-Bin Huang
 
Real-time Face Detection and Recognition
Real-time Face Detection and RecognitionReal-time Face Detection and Recognition
Real-time Face Detection and RecognitionJia-Bin Huang
 
Pose aware online visual tracking
Pose aware online visual trackingPose aware online visual tracking
Pose aware online visual trackingJia-Bin Huang
 
Face Expression Enhancement
Face Expression EnhancementFace Expression Enhancement
Face Expression EnhancementJia-Bin Huang
 
Image Smoothing for Structure Extraction
Image Smoothing for Structure ExtractionImage Smoothing for Structure Extraction
Image Smoothing for Structure ExtractionJia-Bin Huang
 
Static and Dynamic Hand Gesture Recognition
Static and Dynamic Hand Gesture RecognitionStatic and Dynamic Hand Gesture Recognition
Static and Dynamic Hand Gesture RecognitionJia-Bin Huang
 
Real-Time Face Detection, Tracking, and Attributes Recognition
Real-Time Face Detection, Tracking, and Attributes RecognitionReal-Time Face Detection, Tracking, and Attributes Recognition
Real-Time Face Detection, Tracking, and Attributes RecognitionJia-Bin Huang
 
Estimating Human Pose from Occluded Images (ACCV 2009)
Estimating Human Pose from Occluded Images (ACCV 2009)Estimating Human Pose from Occluded Images (ACCV 2009)
Estimating Human Pose from Occluded Images (ACCV 2009)Jia-Bin Huang
 
Information Preserving Color Transformation for Protanopia and Deuteranopia (...
Information Preserving Color Transformation for Protanopia and Deuteranopia (...Information Preserving Color Transformation for Protanopia and Deuteranopia (...
Information Preserving Color Transformation for Protanopia and Deuteranopia (...Jia-Bin Huang
 
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)Jia-Bin Huang
 
Learning Moving Cast Shadows for Foreground Detection (VS 2008)
Learning Moving Cast Shadows for Foreground Detection (VS 2008)Learning Moving Cast Shadows for Foreground Detection (VS 2008)
Learning Moving Cast Shadows for Foreground Detection (VS 2008)Jia-Bin Huang
 
Learning Moving Cast Shadows for Foreground Detection (VS 2008)
Learning Moving Cast Shadows for Foreground Detection (VS 2008)Learning Moving Cast Shadows for Foreground Detection (VS 2008)
Learning Moving Cast Shadows for Foreground Detection (VS 2008)Jia-Bin Huang
 

More from Jia-Bin Huang (12)

How to write a clear paper
How to write a clear paperHow to write a clear paper
How to write a clear paper
 
Real-time Face Detection and Recognition
Real-time Face Detection and RecognitionReal-time Face Detection and Recognition
Real-time Face Detection and Recognition
 
Pose aware online visual tracking
Pose aware online visual trackingPose aware online visual tracking
Pose aware online visual tracking
 
Face Expression Enhancement
Face Expression EnhancementFace Expression Enhancement
Face Expression Enhancement
 
Image Smoothing for Structure Extraction
Image Smoothing for Structure ExtractionImage Smoothing for Structure Extraction
Image Smoothing for Structure Extraction
 
Static and Dynamic Hand Gesture Recognition
Static and Dynamic Hand Gesture RecognitionStatic and Dynamic Hand Gesture Recognition
Static and Dynamic Hand Gesture Recognition
 
Real-Time Face Detection, Tracking, and Attributes Recognition
Real-Time Face Detection, Tracking, and Attributes RecognitionReal-Time Face Detection, Tracking, and Attributes Recognition
Real-Time Face Detection, Tracking, and Attributes Recognition
 
Estimating Human Pose from Occluded Images (ACCV 2009)
Estimating Human Pose from Occluded Images (ACCV 2009)Estimating Human Pose from Occluded Images (ACCV 2009)
Estimating Human Pose from Occluded Images (ACCV 2009)
 
Information Preserving Color Transformation for Protanopia and Deuteranopia (...
Information Preserving Color Transformation for Protanopia and Deuteranopia (...Information Preserving Color Transformation for Protanopia and Deuteranopia (...
Information Preserving Color Transformation for Protanopia and Deuteranopia (...
 
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)
Enhancing Color Representation for the Color Vision Impaired (CVAVI 2008)
 
Learning Moving Cast Shadows for Foreground Detection (VS 2008)
Learning Moving Cast Shadows for Foreground Detection (VS 2008)Learning Moving Cast Shadows for Foreground Detection (VS 2008)
Learning Moving Cast Shadows for Foreground Detection (VS 2008)
 
Learning Moving Cast Shadows for Foreground Detection (VS 2008)
Learning Moving Cast Shadows for Foreground Detection (VS 2008)Learning Moving Cast Shadows for Foreground Detection (VS 2008)
Learning Moving Cast Shadows for Foreground Detection (VS 2008)
 

Recently uploaded

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 

Recently uploaded (20)

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 

Linear Algebra and Matlab tutorial

  • 1. Linear Algebra and MATLAB Tutorial Jia-Bin Huang University of Illinois, Urbana-Champaign www.jiabinhuang.com jbhuang1@Illinois.edu
  • 2. Today’s class • Introduction to MATLAB • Linear algebra refresher • Writing fast MATLAB code
  • 4. Learning by doing • Let’s work through an example! • Download the example script here • Topics • Basic types in Matlab • Operations on vectors and matrices • Control statements & vectorization • Saving/loading your work • Creating scripts or functions using m-files • Plotting • Working with images
  • 6. Linear algebra refresher • Linear algebra is the math tool du jour • Compact notation • Convenient set operations • Used in all modern texts • Interfaces well with MATLAB, numpy, R, etc. • We will use a lot of it!! Slides credits: Paris Smaragdis and Karianne Bergen
  • 7. Filtering, linear transformation -> extracting frequency sub-bands Vector dot products -> measure patch similarities Hybrid Image Image Quilting Gradient Domain Fusion Solving linear systems -> solve for pixel values Image-based Lighting Solving linear systems -> solve for radiance map Video Stitching and Processing Solving linear systems -> solve for geometric transform
  • 9. How will we see these? • Vector: an ordered collection of scalars (e.g., sounds) • Matrix: a two-dimensional collection of scalars (e.g., images) • Tensor: 3D signals (e.g., videos)
  • 10. Element-wise operations • Addition/subtraction • 𝒂 ± 𝒃 = 𝒄 ⇒ 𝑎𝑖 + 𝑏𝑖 = 𝑐𝑖 • Multiplication (Hadamard product) • 𝒂 𝒃 = 𝒄 ⇒ 𝑎𝑖 𝑏𝑖 = 𝑐𝑖 • No named operator for element-wise division • Just use Hadamard with inverted elements c = a + b; c = a – b; c = a.*b; c = a./b;
  • 11. Which division? Left Right Array division C = ldivide(A, B); C = A.B; C = rdivide(A, B); C = A./B; Matrix division C = mldivide(A, B); C = A/B; C = mldivide(A, B); C = AB; EX: Array division A = [1 2; 3, 4]; B = [1,1; 1, 1]; C1 = A.B; C2 = A./B; C1 = 1.0000 0.5000 0.3333 0.2500 C2 = 1 2 3 4 EX: Matrix division X = AB; -> the (least-square) solution to AX = B X = A/B; -> the (least-square) solution to XB = A B/A = (A'B')'
  • 12. Transpose • Change rows to columns (and vice versa) • Hermitian (conjugate transpose) • Notated as 𝑋H • Y = X’; % Hermitian transpose • Y = X.’; % Transpose (without conjugation)
  • 13. Visualizing transposition • Mostly pointless for 1D signals • Swap dimensions for 2D signals
  • 14. Reshaping operators • The vec operator • Unrolls elements column-wise • Useful for getting rid of matrices/tensors • B = A(:); • The reshape operator • B = reshape(A, sz); • prod(sz) must be the same as numel(A) EX: Reshape A = 1:12; B = reshape(A,[3,4]); B = 1 4 7 10 2 5 8 11 3 6 9 12
  • 15. Trace and diag • Matrix trace • Sum of diagonal elements • The diag operator EX: trace A = [1, 2; 3, 4]; t = trace(A); Q: What’s t? EX: diag x = diag(A); D = diag(x); Q: What’s x and D?
  • 16. Vector norm (how “big" a vector is) • Taxicab norm or Manhattan norm • | 𝑣 | 1 = ∑|𝑣𝑖| • Euclidean norm • | 𝑣 | 2 = ∑𝑣𝑖 2 1 2 = 𝑣⊤ 𝑣 • Infinity norm • | 𝑣 | ∞ = max 𝑖 |𝑣𝑖| • P-norm • | 𝑣 | 𝑝 = ∑𝑣𝑖 𝑝 1 𝑝 Unit circle (the set of all vectors of norm 1)
  • 17. Which norm to use? • Say residual 𝑣 = (measured value) – (model estimate) • | 𝑣 | 1: if you want to your measurement and estimate to match exactly for as many samples as possible • | 𝑣 | 2: use this if large errors are bad, but small errors are ok. • | 𝑣 | ∞: use this if no error should exceed a prescribed value .
  • 18. Vector-vector products • Inner product 𝐱⊤ 𝒚 • Shorthand for multiply and accumulate 𝐱⊤ 𝒚 = 𝒊 𝑥𝑖 𝑦𝑖 = 𝐱 𝐲 cos 𝜃 • Outer product: 𝐱𝒚⊤
  • 19. Matrix-vector product • Generalizing the dot product • Linear combination of the columns of A
  • 20. Matrix-matrix product C = AB Definition: as inner products 𝐶𝑖𝑗 = 𝑎𝑖 ⊤ 𝑏𝑗 As sum of outer productsAs a set of matrix-vector products • matrix 𝐴 and columns of B • rows of 𝐴 and matrix B
  • 21. Matrix products • Output rows == left matrix rows • Output columns == right matrix columns
  • 22. Matrix multiplication properties • Associative: 𝐴𝐵 𝐶 = 𝐴(𝐵𝐶) • Distributive: 𝐴 𝐵 + 𝐶 = 𝐴𝐵 + 𝐴𝐶 • NOT communitive: 𝐴𝐵 ≠ 𝐵𝐴
  • 23. Linear independence • Linear dependence: a set of vectors v1, v2, ⋯ , 𝑣𝑟 is linear dependent if there exists a set of scalars 𝛼1, 𝛼2, ⋯ , 𝛼 𝑟 ∈ ℝ with at least one 𝛼𝑖 ≠ 0 such that 𝛼1 𝑣1 + 𝛼2 𝑣2 + ⋯ + 𝛼 𝑟 𝑣𝑟 = 0 i.e., one of the vectors in the set can be written as a linear combination of one or more other vectors in the set. • Linear independence: a set of vectors v1, v2, ⋯ , 𝑣𝑟 is linear independent if it is NOT linearly dependent. 𝛼1 𝑣1 + 𝛼2 𝑣2 + ⋯ + 𝛼 𝑟 𝑣𝑟 = 0 ⟺ 𝛼𝑖 = ⋯ = 𝛼 𝑟 = 0
  • 24. Basis and dimension • Basis: a basis for a subspace 𝑆 is a linear independent set of vectors that span 𝑆 • 1 0 , 0 1 and 1 −1 , 1 1 are both bases that span ℝ2 • Not unique • Dimension dim(𝑆): the number of linearly independent vectors in the basis for 𝑆
  • 25. Range and nullspace of a matrix 𝐴 ∈ ℝ 𝑚×𝑛 • The range (column space, image) of a matrix 𝐴 ∈ ℝ 𝑚×𝑛 • Denoted by ℛ(𝐴) • The set of all linear combination of the columns of 𝐴 ℛ 𝐴 = 𝐴𝑥 𝑥 ∈ ℝ 𝑛 }, ℛ(𝐴) ⊆ ℝ 𝑚 • The nullspace (kernel) of a matrix 𝐴 ∈ ℝ 𝑚×𝑛 • Denoted by 𝒩(𝐴) • The set of vectors z such that 𝐴𝑧 = 0 𝒩 𝐴 = { 𝑧 ∈ ℝ 𝑛|𝐴𝑧 = 0}, 𝒩 𝐴 ⊆ ℝ 𝑚
  • 26. Rank of 𝐴 ∈ ℝ 𝑚×𝑛 • Column rank of 𝐴: dimension of ℛ(𝐴) • Row rank of 𝐴: dimension of ℛ 𝐴⊤ • Column rank == row rank • Matrix 𝐴 ∈ ℝ 𝑚×𝑛 is full rank if 𝑟𝑎𝑛𝑘 𝐴 = min {𝑚, 𝑛 }
  • 27. System of linear equations • Ex: Find values 𝑥1, 𝑥2, 𝑥3 ∈ ℝ that satisfy • 3𝑥1 + 2𝑥2 − 𝑥3 − 1 = 0 • 2𝑥1 − 2𝑥2 + 𝑥3 + 2 = 0 • −𝑥1 − 1 2 𝑥2 − 𝑥3 = 0 Solution: • Step 1: write the system of linear equations as a matrix equation 𝐴 = 3 2 −1 2 −2 1 −1 − 1 2 −1 , 𝑥 = 𝑥1 𝑥2 𝑥3 , 𝑏 = 1 −2 0 . • Step 2: Solve for 𝐴𝑥 = 𝑏
  • 28. Mini-quiz 1 • What’s the 𝐴, 𝑥, and 𝑏 for the following linear equations? • 2𝑥2 − 7 = 0 • 2𝑥1 − 3𝑥3 + 2 = 0 • 4𝑥2 + 2𝑥3 = 0 • 𝑥1 + 3𝑥3 = 0 𝐴 = 0 1 0 2 0 −3 0 1 4 0 2 3 , 𝑥 = 𝑥1 𝑥2 𝑥3 , 𝑏 = 7 −2 0 0 .
  • 29. Mini-quiz 2 • What’s the 𝐴, 𝑥, and 𝑏 for the following linear equation? • 𝑋 = 𝑥1 𝑥3 𝑥2 𝑥4 • 1 2 ⊤ 𝑋 −2 1 − 3 = 0 • 1 0 ⊤ 𝑋 1 1 + 1 = 0 𝐴 = −2 − 4 1 2 1 0 1 0 , 𝑥 = 𝑥1 𝑥2 𝑥3 𝑥4 , 𝑏 = 3 −1
  • 30. Solving system of linear equations • Given 𝐴 ∈ ℝ 𝑚×𝑛 and b ∈ ℝ 𝑚, find x ∈ ℝ 𝑛 such that 𝐴𝑥 = 𝑏 • Special case: a square matrix 𝐴 ∈ ℝ 𝑛×𝑛 • The solution: 𝐴−1 𝑏 • The matrix inverse A−1exists and is unique if and only if • 𝐴 is a squared matrix of full rank • “Undoes” a matrix multiplication • 𝐴−1 𝐴 = 𝐼 • 𝐴−1 𝐴𝑌 = 𝑌 • Y𝐴𝐴−1 = 𝑌
  • 31. Least square problems • What if 𝑏 ∉ ℛ(𝐴)? • No solution 𝑥 exists such that 𝐴𝑥 = 𝑏 • Least Squares problem: • Define residual 𝑟 = 𝐴𝑥 − 𝑏 • Find vector 𝑥 ∈ ℝ 𝑛 that minimizes ||𝑟||2 2 =||𝐴𝑥 − 𝑏||2 2
  • 32. Least square problems • Decompose b ∈ ℝm into components b = b1 + b2 with • 𝑏1 ∈ ℛ(𝐴) and • 𝑏2 ∈ 𝒩 A⊤ = ℛ A ⊥ . • Since 𝑏2 is in ℛ A ⊥ , the orthogonal complement of ℛ A , the residual norm ||𝑟||2 2 = ||𝐴𝑥 − 𝑏1 − 𝑏2||2 2 = ||𝐴𝑥 − 𝑏1||2 2 + ||𝑏2||2 2 which is minimized when 𝐴𝑥 = 𝑏1 and 𝑟 = 𝑏2 ∈ 𝒩 A⊤
  • 33. Normal equations • The least squares solution 𝑥 occurs when 𝑟 = 𝑏2 ∈ 𝒩 A⊤ , or equivalently 𝐴⊤ 𝑟 = 𝐴⊤ 𝑏 − 𝐴𝑥 = 0 • Normal equations: 𝐴⊤ 𝐴𝑥 = 𝐴⊤ 𝑏 • If 𝐴 has full column rank, then 𝐴⊤ 𝐴 is invertible. • Thus (𝐴⊤ 𝐴)𝑥 = (𝐴⊤ 𝑏) has a unique solution 𝑥 = (𝐴⊤ 𝐴)−1 𝐴⊤ 𝑏 • x = Ab; • x = inv(A’*A)*A’*b; % same as backslash operator
  • 36. Using the Profiler • Helps uncover performance problems • Timing functions: • tic, toc • The following timings were measured on - CPU i5 1.7 GHz - 4 GB RAM • http://www.mathworks.com/help/matlab/ref/profile.html
  • 37. Pre-allocation Memory 3.3071 s >> n = 1000; 2.1804 s2.5148 s
  • 38. Reducing Memory Operations >> x = 4; >> x(2) = 7; >> x(3) = 12; >> x = zeros(3,1); >> x = 4; >> x(2) = 7; >> x(3) = 12;
  • 40. Using Vectorization • Appearance • more like the mathematical expressions, easier to understand. • Less Error Prone • Vectorized code is often shorter. • Fewer opportunities to introduce programming errors. • Performance: • Often runs much faster than the corresponding code containing loops. See http://www.mathworks.com/help/matlab/matlab_prog/vectorization.html
  • 41. Binary Singleton Expansion Function • Make each column in A zero mean >> n1 = 5000; >> n2 = 10000; >> A = randn(n1, n2); • See http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun- performance/ 0.2994 s 0.2251 s Why bsxfun is faster than repmat? - bsxfun handles replication of the array implicitly, thus avoid memory allocation - Bsxfun supports multi-thread
  • 42. Loop, Vector and Boolean Indexing • Make odd entries in vector v zero • n = 1e6; • See http://www.mathworks.com/help/matlab/learn_matlab/array-indexing.html • See Fast manipulation of multi-dimensional arrays in Matlab by Kevin Murphy 0.3772 s 0.0081 s 0.0130 s
  • 43. Solving Linear Equation System 0.1620 s 0.0467 s
  • 44. Dense and Sparse Matrices • Dense: 16.1332 s • Sparse: 0.0040 s More than 4000x faster! Useful functions: sparse(), spdiags(), speye(), kron().0.6424 s 0.1157 s
  • 45. Repeated solution of an equation system with the same matrix 3.0897 s 0.0739 s 41x faster!
  • 46. Iterative Methods for Larger Problems • Iterative solvers in MATLAB: • bicg, bicgstab, cgs, gmres, lsqr, minres, pcg, symmlq, qmr • [x,flag,relres,iter,resvec] = method(A,b,tol,maxit,M1,M2,x0) • source: Writing Fast Matlab Code by Pascal Getreuer
  • 47. Solving Ax = b when A is a Special Matrix • Circulant matrices • Matrices corresponding to cyclic convolution Ax = conv(h, x) are diagonalized in the Fourier domain >> x = ifft( fft(b)./fft(h) ); • Triangular and banded • Efficiently solved by sparse LU factorization >> [L,U] = lu(sparse(A)); >> x = U(Lb); • Poisson problems • See http://www.cs.berkeley.edu/~demmel/cs267/lecture25/lecture25.html
  • 49. Inlining Simple Functions 1.1942 s 0.3065 s functions are worth inlining: - conv, cross, fft2, fliplr, flipud, ifft, ifft2, ifftn, ind2sub, ismember, linspace, logspace, mean, median, meshgrid, poly, polyval, repmat, roots, rot90, setdiff, setxor, sortrows, std, sub2ind, union, unique, var y = medfilt1(x,5); 0.2082 s
  • 50. Using the Right Type of Data “Do not use a cannon to kill a mosquito.” double image: 0.5295 s uint8 image: 0.1676 s Confucius
  • 51. Matlab Organize its Arrays as Column-Major • Assign A to zero row-by-row or column-by-column >> n = 1e4; >> A = randn(n, n); 0.1041 s2.1740 s 21x faster!
  • 52. Column-Major Memory Storage >> x = magic(3) x = 8 1 6 3 5 7 4 9 2 % Access one column >> y = x(:, 1); % Access one row >> y = x(1, :);
  • 53. Copy-on-Write (COW) >> n = 500; >> A = randn(n,n,n); 0.4794 s 0.0940 s
  • 54. Clip values >> n = 2000; >> lowerBound = 0; >> upperBound = 1; >> A = randn(n,n); 0.0121 s0.1285 s 10x faster!
  • 55. Moving Average Filter • Compute an N-sample moving average of x >> n = 1e7; >> N = 1000; >> x = randn(n,1); 3.2285 s 0.3847 s
  • 56. Find the min/max of a matrix or N-d array >> n = 500; >> A = randn(n,n,n); 0.5465 s 0.1938 s
  • 57. Acceleration using MEX (Matlab Executable) • Call your C, C++, or Fortran codes from the MATLAB • Speed up specific subroutines • See http://www.mathworks.com/help/matlab/matlab_external/introducing-mex- files.html
  • 58. MATLAB Coder • MATLAB Coder™ generates standalone C and C++ code from MATLAB® code • See video examples in http://www.mathworks.com/products/matlab- coder/videos.html • See http://www.mathworks.com/products/matlab-coder/
  • 60. parfor for parallel processing • Requirements • Task independent • Order independent See http://www.mathworks.com/products/parallel-computing/
  • 61. Parallel Processing in Matlab • MatlabMPI • multicore • pMatlab: Parallel Matlab Toolbox • Parallel Computing Toolbox (Mathworks) • Distributed Computing Server (Mathworks) • MATLAB plug-in for CUDA (CUDA is a library that used an nVidia board) • Source: http://www-h.eng.cam.ac.uk/help/tpl/programs/Matlab/faster_scripts.html
  • 62. Resources for your final projects • Awesome computer vision by Jia-Bin Huang • A curated list of computer vision resources • VLFeat • features extraction and matching, segmentation, clustering • Piotr's Computer Vision Matlab Toolbox • Filters, channels, detectors, image/video manipulation • OpenCV (MexOpenCV by Kota Yamaguchi) • General purpose computer vision library
  • 63. Resources • Linear Algebra • Linear Algebra Review and Reference • Linear algebra refresher course • Quick Review of Matrix and Real Linear Algebra • MATLAB Tutorial • Resource collection • MATLAB F&Q • Writing Fast MATLAB code • Techniques for Improving Performance by Mathwork • Writing Fast Matlab Code by Pascal Getreuer • Guidelines for writing clean and fast code in MATLAB by Nico Schlömer

Editor's Notes

  1. How is linear algebra applied to this course?
  2. Repeatedly expanding the size of an array over time, (for example, adding more elements to it each time through a programming loop), can adversely affect the performance of your program. This is because 1) MATLAB has to spend time allocating more memory each time you increase the size of the array. 2) This newly allocated memory is likely to be noncontiguous, thus slowing down any operations that MATLAB needs to perform on the array.