Implementation of a conjugate gradient for solving a linear system Ax=b
when A is positive definite. In some cases, it is faster than the Matlab
function pcg
, especially when the library uses the Intel Math Kernel Library.
% % Usage: x =mexConjGrad(A,b,x0,tol,itermax) % % Name: mexConjGrad % % Description: Conjugate gradient algorithm, sometimes faster than the % equivalent Matlab function pcg. In order to solve Ax=b; % % Inputs: A: double square n x n matrix. HAS TO BE POSITIVE DEFINITE % b: double vector of length n. % x0: double vector of length n. (optional) initial guess. % tol: (optional) tolerance. % itermax: (optional) maximum number of iterations. % % Output: x: double vector of length n. % % Author: Julien Mairal, 2009
Apply a Bayer pattern to an input image
% % Usage: Y =mexBayer(X,offset); % % Description: mexBayer applies a Bayer pattern to an image X. % There are four possible offsets. % % Inputs: X: double m x n matrix % offset: scalar, 0,1,2 or 3 % % Output: Y: double m x m matrix % % Author: Julien Mairal, 2009
For an input sparse matrix A, this function returns AAT. For some reasons, when A has a lot more columns than rows, this function can be much faster than the equivalent matlab command X*A'
.
% % Usage: AAt =mexCalcAAt(A); % % Name: mexCalcAAt % % Description: Compute efficiently AAt = A*A', when A is sparse % and has a lot more columns than rows. In some cases, it is % up to 20 times faster than the equivalent Matlab expression % AAt=A*A'; % % Inputs: A: double sparse m x n matrix % % Output: AAt: double m x m matrix % % Author: Julien Mairal, 2009
For an input sparse matrix A and a matrix X, this function returns XAT. For some reasons, when A has a lot more columns than rows, this function can be much faster than the equivalent matlab command X*A'
.
% % Usage: XAt =mexCalcXAt(X,A); % % Name: mexCalcXAt % % Description: Compute efficiently XAt = X*A', when A is sparse and has a % lot more columns than rows. In some cases, it is up to 20 times % faster than the equivalent Matlab expression XAt=X*A'; % % Inputs: X: double m x n matrix % A: double sparse p x n matrix % % Output: XAt: double m x p matrix % % Author: Julien Mairal, 2009
For two input matrices X and Y, this function returns XY.
% % Usage: Z =mexCalcXY(X,Y); % % Name: mexCalcXY % % Description: Compute Z=XY using the BLAS library used by SPAMS. % % Inputs: X: double m x n matrix % Y: double n x p matrix % % Output: Z: double m x p matrix % % Author: Julien Mairal, 2009
For two input matrices X and Y, this function returns XYT.
% % Usage: Z =mexCalcXYt(X,Y); % % Name: mexCalcXYt % % Description: Compute Z=XY' using the BLAS library used by SPAMS. % % Inputs: X: double m x n matrix % Y: double p x n matrix % % Output: Z: double m x p matrix % % Author: Julien Mairal, 2009
For two input matrices X and Y, this function returns XTY.
% % Usage: Z =mexCalcXtY(X,Y); % % Name: mexCalcXtY % % Description: Compute Z=X'Y using the BLAS library used by SPAMS. % % Inputs: X: double n x m matrix % Y: double n x p matrix % % Output: Z: double m x p matrix % % Author: Julien Mairal, 2009
For an input symmetric matrices A in ℝn × n, this function returns A−1.
% % Usage: B =mexInvSym(A); % % Name: mexInvSym % % Description: returns the inverse of a symmetric matrix A % % Inputs: A: double n x n matrix % % Output: B: double n x n matrix % % Author: Julien Mairal, 2009
% % Usage: Y =mexNormalize(X); % % Name: mexNormalize % % Description: rescale the columns of X so that they have % unit l2-norm. % % Inputs: X: double m x n matrix % % Output: Y: double m x n matrix % % Author: Julien Mairal, 2010
% % Usage: Y =mexSort(X); % % Name: mexSort % % Description: sort the elements of X using quicksort % % Inputs: X: double vector of size n % % Output: Y: double vector of size n % % Author: Julien Mairal, 2010
Print to the screen a matrix containing as columns image patches.