mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 14:43:08 +02:00
Never give up
This commit is contained in:
parent
fc66144833
commit
6eeac9104a
@ -1,44 +1,52 @@
|
||||
function [eigenValues, whichIterationAreWeOn, Matrix] = QRNoShifts(Matrix)
|
||||
startingMatrix = Matrix;
|
||||
matlabEigen = eig(Matrix);
|
||||
[whichIterationAreWeOn, threshold] = initializeValues();
|
||||
[Matrix, whichIterationAreWeOn, eigenValues] = QRNoShiftsLoop(threshold, Matrix, whichIterationAreWeOn);
|
||||
|
||||
% convert eigenvalue matrix to vector
|
||||
|
||||
[whichIterationAreWeOn, threshold, startingMatrix, matlabEigen] = initializeValues(Matrix);
|
||||
[Matrix, whichIterationAreWeOn] = QRNoShiftsLoop(threshold, Matrix, whichIterationAreWeOn);
|
||||
eigenValues = diag(Matrix)';
|
||||
disp("Iterations it took: ");
|
||||
disp(whichIterationAreWeOn);
|
||||
disp("Final matrix: ");
|
||||
disp(Matrix);
|
||||
%displayResults(eigenValues, whichIterationAreWeOn, Matrix, startingMatrix, matlabEigen);
|
||||
end
|
||||
|
||||
function [Matrix, whichIterationAreWeOn, eigenValues] = QRNoShiftsLoop(threshold, Matrix, whichIterationAreWeOn)
|
||||
function [Matrix, whichIterationAreWeOn] = QRNoShiftsLoop(threshold, Matrix, whichIterationAreWeOn)
|
||||
while threshold > 1e-6
|
||||
[Q, R] = gramSchmidtAlgorithm(Matrix);
|
||||
Matrix = R * Q;
|
||||
whichIterationAreWeOn = whichIterationAreWeOn + 1;
|
||||
|
||||
% iterate until all non-diagonal elements are below the threshold
|
||||
matrixWithoutDiagonal = Matrix - diag(diag(Matrix)); % first diag converts Matrix
|
||||
% into vector consisting of values on the diagonal of matrix,
|
||||
% second diag converts this vector into matrix with zeros on
|
||||
% everything except diagonal
|
||||
% If we substract it from Matrix we get original Matrix with zeros
|
||||
% on a diagonal
|
||||
threshold = max(abs(matrixWithoutDiagonal));
|
||||
[Matrix, whichIterationAreWeOn, threshold] = QRNoShiftsInsideLoop(Matrix, whichIterationAreWeOn);
|
||||
end
|
||||
end
|
||||
|
||||
function [Matrix, whichIterationAreWeOn, threshold] = QRNoShiftsInsideLoop(Matrix, whichIterationAreWeOn)
|
||||
[Q, R] = gramSchmidtAlgorithm(Matrix);
|
||||
Matrix = R * Q;
|
||||
whichIterationAreWeOn = whichIterationAreWeOn + 1;
|
||||
|
||||
% iterate until all non-diagonal elements are below the threshold
|
||||
matrixWithoutDiagonal = Matrix - diag(diag(Matrix)); % first diag converts Matrix
|
||||
% into vector consisting of values on the diagonal of matrix,
|
||||
% second diag converts this vector into matrix with zeros on
|
||||
% everything except diagonal
|
||||
% If we substract it from Matrix we get original Matrix with zeros
|
||||
% on a diagonal
|
||||
threshold = max(max(abs(matrixWithoutDiagonal)));
|
||||
% first max returns vector of elements
|
||||
% second max returns max element from this vector
|
||||
end
|
||||
|
||||
function displayResults(eigenValues, whichIterationsAreWeOn, Matrix, startingMatrix, matlabEigen)
|
||||
disp("How many iterations it took:")
|
||||
disp(whichIterationsAreWeOn);
|
||||
disp("Starting matrix:")
|
||||
disp(M)
|
||||
disp(whichIterationsAreWeOn)
|
||||
disp("Starting Matrix:")
|
||||
disp(startingMatrix)
|
||||
disp("Final Matrix:")
|
||||
disp(Matrix)
|
||||
disp("eig(Matrix) eigen values:")
|
||||
disp(matlabEigen)
|
||||
disp("Our eigen values:")
|
||||
disp(eigenValues);
|
||||
end
|
||||
|
||||
function [whichIterationAreWeOn, threshold] = initializeValues()
|
||||
function [whichIterationAreWeOn, threshold, startingMatrix, matlabEigen] = initializeValues(Matrix)
|
||||
whichIterationAreWeOn = 0;
|
||||
threshold = inf;
|
||||
startingMatrix = Matrix;
|
||||
matlabEigen = eig(Matrix);
|
||||
end
|
||||
|
||||
% performs QR or QRdash decomposition of a matrix
|
||||
|
||||
@ -3,7 +3,7 @@ function [eigenValues, whichIterationAreWeOn, Matrix] = QRNoShifts(Matrix)
|
||||
[whichIterationAreWeOn, threshold, startingMatrix, matlabEigen] = initializeValues(Matrix);
|
||||
[Matrix, whichIterationAreWeOn] = QRNoShiftsLoop(threshold, Matrix, whichIterationAreWeOn);
|
||||
eigenValues = diag(Matrix)';
|
||||
displayResults(whichIterationAreWeOn, Matrix, startingMatrix, matlabEigen);
|
||||
%displayResults(eigenValues, whichIterationAreWeOn, Matrix, startingMatrix, matlabEigen);
|
||||
end
|
||||
|
||||
function [Matrix, whichIterationAreWeOn] = QRNoShiftsLoop(threshold, Matrix, whichIterationAreWeOn)
|
||||
@ -29,7 +29,7 @@ function [Matrix, whichIterationAreWeOn, threshold] = QRNoShiftsInsideLoop(Matri
|
||||
% second max returns max element from this vector
|
||||
end
|
||||
|
||||
function displayResults(whichIterationsAreWeOn, Matrix, startingMatrix, matlabEigen)
|
||||
function displayResults(eigenValues, whichIterationsAreWeOn, Matrix, startingMatrix, matlabEigen)
|
||||
disp("How many iterations it took:")
|
||||
disp(whichIterationsAreWeOn)
|
||||
disp("Starting Matrix:")
|
||||
@ -39,6 +39,7 @@ function displayResults(whichIterationsAreWeOn, Matrix, startingMatrix, matlabEi
|
||||
disp("eig(Matrix) eigen values:")
|
||||
disp(matlabEigen)
|
||||
disp("Our eigen values:")
|
||||
disp(eigenValues);
|
||||
end
|
||||
|
||||
function [whichIterationAreWeOn, threshold, startingMatrix, matlabEigen] = initializeValues(Matrix)
|
||||
|
||||
@ -1,121 +0,0 @@
|
||||
% finds the eigenValues of a matrix using QR with shifts
|
||||
function [eigenValues, whatIterationAreWeOn, Matrix] = QRShifts(Matrix)
|
||||
[eigenValues, whatIterationAreWeOn, matrixSize, minThreshold] = initiateValues(Matrix);
|
||||
[Matrix, whatIterationAreWeOn, eigenValues] = QRShiftLoop(matrixSize, Matrix, eigenValues, minThreshold, whatIterationAreWeOn);
|
||||
end
|
||||
|
||||
function [eigenValues, whatIterationAreWeOn, matrixSize, minThreshold] = initiateValues(Matrix)
|
||||
eigenValues = double.empty(1, 0);
|
||||
whatIterationAreWeOn = 0;
|
||||
matrixSize = size(Matrix, 1);
|
||||
minThreshold = 1e-6;
|
||||
end
|
||||
|
||||
function [finalMatrix, whatIterationAreWeOn, eigenValues] = QRShiftLoop(matrixSize, Matrix, eigenValues, minThreshold, whatIterationAreWeOn)
|
||||
while matrixSize >= 2
|
||||
flag = 0;
|
||||
[Matrix, matrixSize, whatIterationAreWeOn, eigenValues] = findEigenValue(Matrix, matrixSize, whatIterationAreWeOn, eigenValues, minThreshold, flag);
|
||||
[finalMatrix, matrixSize, Matrix] = deflateMatrix(Matrix, matrixSize);
|
||||
end
|
||||
eigenValues(size(eigenValues, 2) + 1) = Matrix(1, 1);
|
||||
end
|
||||
|
||||
function [Matrix, matrixSize, whatIterationAreWeOn, eigenValues] = findEigenValue(Matrix, matrixSize, whatIterationAreWeOn, eigenValues, minThreshold, flag)
|
||||
while flag == 0
|
||||
eigenValueCorner = getEigenValueFromCorner(Matrix, matrixSize);
|
||||
[Matrix, whatIterationAreWeOn] = shiftAndIterate(matrixSize, Matrix, eigenValueCorner, whatIterationAreWeOn);
|
||||
[flag, eigenValues] = thresholdBreached(Matrix, matrixSize, minThreshold, eigenValues);
|
||||
end
|
||||
end
|
||||
|
||||
function eigenValueCorner = getEigenValueFromCorner(Matrix, matrixSize)
|
||||
corner = Matrix((matrixSize - 1) : matrixSize, (matrixSize - 1) : matrixSize);
|
||||
% get 2 x 2 corner of the matrix
|
||||
eigenValueCorner = solveCharactersticEquation(corner);
|
||||
end
|
||||
|
||||
function [Matrix, whatIterationAreWeOn] = shiftAndIterate(matrixSize, Matrix, eigenValueCorner, whatIterationAreWeOn)
|
||||
% shift and iterate algorithm
|
||||
identityMatrix = eye(matrixSize);
|
||||
Matrix = Matrix - identityMatrix * eigenValueCorner;
|
||||
[Q, R] = gramSchmidtAlgorithm(Matrix);
|
||||
Matrix = R * Q + identityMatrix * eigenValueCorner;
|
||||
whatIterationAreWeOn = whatIterationAreWeOn + 1;
|
||||
end
|
||||
|
||||
function [finalMatrix, matrixSize, Matrix] = deflateMatrix(Matrix, matrixSize)
|
||||
finalMatrix(1 : matrixSize, 1 : matrixSize) = Matrix;
|
||||
matrixSize = matrixSize - 1;
|
||||
Matrix = Matrix(1:matrixSize, 1:matrixSize);
|
||||
end
|
||||
|
||||
function [flag, eigenValues] = thresholdBreached(Matrix, matrixSize, minThreshold, eigenValues)
|
||||
flag = 0;
|
||||
threshold = max(abs(Matrix(matrixSize, 1:(matrixSize - 1))));
|
||||
|
||||
% once we zero the row (or rather get close enough to zero) exit loop
|
||||
if (threshold <= minThreshold)
|
||||
eigenValues(size(eigenValues, 2) + 1) = Matrix(matrixSize, matrixSize);
|
||||
flag = 1;
|
||||
end
|
||||
end
|
||||
|
||||
% finds the eigenvalue of a 2x2 matrix that is closer to the lower right corner
|
||||
function eigen = solveCharactersticEquation(Matrix)
|
||||
[eigen1, eigen2] = calculateZeros(Matrix);
|
||||
|
||||
end
|
||||
|
||||
function eigen = valueCloserToLowerRightCorner(eigen1, eigen)
|
||||
if abs(Matrix(4) - eigen1) < abs(Matrix(4) - eigen2)
|
||||
eigen = eigen1;
|
||||
else
|
||||
eigen = eigen2;
|
||||
end
|
||||
end
|
||||
|
||||
function [zeroOne, zeroTwo] = calculateZeros(Matrix)
|
||||
b = Matrix(1) + Matrix(4);
|
||||
ac = Matrix(1) * Matrix(4) - Matrix(2) * Matrix(3);
|
||||
delta = (b) ^ 2 - 4 * ac;
|
||||
% get delta of quadratic equation
|
||||
squareRootDelta = sqrt(delta);
|
||||
% square delta
|
||||
zeroOne = (b - squareRootDelta) / 2;
|
||||
zeroTwo = (b + squareRootDelta) / 2;
|
||||
end
|
||||
|
||||
% performs QR or QRdash decomposition of a matrix
|
||||
function [Q, R] = gramSchmidtAlgorithm(Matrix)
|
||||
[columns, Q, R, d] = initializeGramSchmid(Matrix);
|
||||
[Q, R] = factorizeColumnsOfQ(columns, Q, Matrix, R, d);
|
||||
[Q, R] = normalizeColumns(columns, Q, R);
|
||||
end
|
||||
|
||||
function [columns, Q, R, d] = initializeGramSchmid(Matrix)
|
||||
% We start with empty matrices
|
||||
[rows, columns] = size(Matrix);
|
||||
Q = zeros(rows, columns);
|
||||
R = zeros(columns, columns);
|
||||
d = zeros(1, columns);
|
||||
end
|
||||
|
||||
function [Q, R] = factorizeColumnsOfQ(columns, Q, Matrix, R, d)
|
||||
for i = 1 : columns
|
||||
Q(:, i) = Matrix(:, i);
|
||||
R(i, i) = 1;
|
||||
d(i) = Q(:, i)' * Q(:, i);
|
||||
for i2 = i + 1 : columns
|
||||
R(i, i2) = (Q(:, i)' * Matrix(:, i2)) / d(i);
|
||||
Matrix(:, i2) = Matrix(:, i2) - R(i, i2) * Q(:, i);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function [Q, R] = normalizeColumns(columns, Q, R)
|
||||
for i = 1 : columns
|
||||
dd = norm(Q(:, i));
|
||||
Q(:, i) = Q(:, i) / dd;
|
||||
R(i, i:columns) = R(i, i : columns) * dd;
|
||||
end
|
||||
end
|
||||
@ -4,7 +4,7 @@ function [eigenValues, whatIterationAreWeOn, Matrix] = QRShifts(Matrix)
|
||||
initialMatrix = Matrix;
|
||||
[eigenValues, whatIterationAreWeOn, matrixSize, minThreshold] = initiateValues(Matrix);
|
||||
[Matrix, whatIterationAreWeOn, eigenValues] = QRShiftLoop(matrixSize, Matrix, eigenValues, minThreshold, whatIterationAreWeOn);
|
||||
dispResults(Matrix, whatIterationAreWeOn, eigenFromMatlab, initialMatrix);
|
||||
%dispResults(eigenValues, Matrix, whatIterationAreWeOn, eigenFromMatlab, initialMatrix);
|
||||
end
|
||||
|
||||
function [eigenValues, whatIterationAreWeOn, matrixSize, minThreshold] = initiateValues(Matrix)
|
||||
@ -122,7 +122,7 @@ function [Q, R] = normalizeColumns(columns, Q, R)
|
||||
end
|
||||
end
|
||||
|
||||
function dispResults(Matrix, whatIterationAreWeOn, eigenFromMatlab, initialMatrix)
|
||||
function dispResults(eigenValues, Matrix, whatIterationAreWeOn, eigenFromMatlab, initialMatrix)
|
||||
disp("Initial matrix: ");
|
||||
disp(initialMatrix);
|
||||
disp("Final matrix: ");
|
||||
@ -132,4 +132,5 @@ function dispResults(Matrix, whatIterationAreWeOn, eigenFromMatlab, initialMatri
|
||||
disp("Eigen values from eig(Matrix):");
|
||||
disp(eigenFromMatlab);
|
||||
disp("Our eigen values: ");
|
||||
disp(eigenValues);
|
||||
end
|
||||
@ -1,7 +1,6 @@
|
||||
function A = matrix4()
|
||||
A = [1, 1, 7, 5, 2;
|
||||
1, 8, 5, 4, 4;
|
||||
7, 5, 0, 8, 8;
|
||||
5, 4, 8, 0, 8;
|
||||
2, 4, 8, 8, 1];
|
||||
function A = matrix4(n)
|
||||
A = 10 * rand(n); % rand generates 5x5 matrix filled with random numbers
|
||||
% we multiply by 10 to get at lest one digit in front of the dot
|
||||
A = floor(A); % we floor the matrix we got to get nice natural numbers matrix
|
||||
A = A * A'; % we get symmetric matrix
|
||||
end
|
||||
@ -77,37 +77,63 @@
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.2}Theoretical introduction}{34}{section.4.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.2.1}Eigenvalues}{34}{subsection.4.2.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.2.2}QR method for finding eigenvalues}{34}{subsection.4.2.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.3}Solution}{35}{section.4.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.4}Discussion of the result}{35}{section.4.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {chapter}{\numberline {5}Code appendix}{36}{chapter.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.3}Results}{35}{section.4.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.3.1}Starting matrix}{35}{subsection.4.3.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.3.2}QR method with no shifts}{36}{subsection.4.3.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.3.3}QR method with shifts}{36}{subsection.4.3.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.4}Discussion of the result}{37}{section.4.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.4.1}Plot}{38}{subsection.4.4.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.4.2}Shift method superiority}{38}{subsection.4.4.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {chapter}{\numberline {5}Code appendix}{40}{chapter.5}\protected@file@percent }
|
||||
\@writefile{lof}{\addvspace {10\p@ }}
|
||||
\@writefile{lot}{\addvspace {10\p@ }}
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5.1}Task 2 Code}{36}{section.5.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.1}Main function}{36}{subsection.5.1.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.2}checkIfMatrixIsSquareMatrix}{37}{subsection.5.1.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.3}gaussianEliminationWithPartialPivoting}{38}{subsection.5.1.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.4}partialPivoting}{38}{subsection.5.1.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.5}partialPivotingSwapOneRow}{38}{subsection.5.1.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.6}swapRowMatrix}{39}{subsection.5.1.6}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.7}swapValueVector}{39}{subsection.5.1.7}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.8}gaussianElimination}{39}{subsection.5.1.8}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.9}substractRows}{40}{subsection.5.1.9}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.10}backSubstitutionPhase}{41}{subsection.5.1.10}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.11}iterativeResidualCorrection}{41}{subsection.5.1.11}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.12}improveSolution}{41}{subsection.5.1.12}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5.2}Task 3 code}{42}{section.5.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.1}initializeValues}{42}{subsection.5.2.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.2}decomposeMatrix}{43}{subsection.5.2.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.3}jacobiLoop}{43}{subsection.5.2.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.4}jacobiInsideLoop}{44}{subsection.5.2.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.5}jacobiEquation}{44}{subsection.5.2.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.6}gaussSeidelLoop}{44}{subsection.5.2.6}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.7}gaussiInsideLoop}{45}{subsection.5.2.7}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.8}gaussSeidelEquation}{45}{subsection.5.2.8}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.9}checkError}{45}{subsection.5.2.9}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.10}endOfLoop}{46}{subsection.5.2.10}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.11}dispFinalResults}{46}{subsection.5.2.11}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.12}plotIterations}{47}{subsection.5.2.12}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.13}plotIterations}{48}{subsection.5.2.13}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5.1}Task 2 Code}{40}{section.5.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.1}Main function}{40}{subsection.5.1.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.2}checkIfMatrixIsSquareMatrix}{41}{subsection.5.1.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.3}gaussianEliminationWithPartialPivoting}{42}{subsection.5.1.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.4}partialPivoting}{42}{subsection.5.1.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.5}partialPivotingSwapOneRow}{42}{subsection.5.1.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.6}swapRowMatrix}{43}{subsection.5.1.6}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.7}swapValueVector}{43}{subsection.5.1.7}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.8}gaussianElimination}{43}{subsection.5.1.8}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.9}substractRows}{44}{subsection.5.1.9}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.10}backSubstitutionPhase}{45}{subsection.5.1.10}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.11}iterativeResidualCorrection}{45}{subsection.5.1.11}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.12}improveSolution}{45}{subsection.5.1.12}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5.2}Task 3 code}{46}{section.5.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.1}initializeValues}{46}{subsection.5.2.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.2}decomposeMatrix}{47}{subsection.5.2.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.3}jacobiLoop}{47}{subsection.5.2.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.4}jacobiInsideLoop}{48}{subsection.5.2.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.5}jacobiEquation}{48}{subsection.5.2.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.6}gaussSeidelLoop}{48}{subsection.5.2.6}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.7}gaussiInsideLoop}{49}{subsection.5.2.7}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.8}gaussSeidelEquation}{49}{subsection.5.2.8}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.9}checkError}{49}{subsection.5.2.9}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.10}endOfLoop}{50}{subsection.5.2.10}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.11}dispFinalResults}{50}{subsection.5.2.11}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.12}plotIterations}{51}{subsection.5.2.12}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.13}plotIterations}{52}{subsection.5.2.13}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5.3}Task 4 Code}{53}{section.5.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.3.1}Gram-Schmid algorithm}{53}{subsection.5.3.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{initializeGramSchmid}{53}{section*.22}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{initializeGramSchmid}{53}{section*.23}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{initializeGramSchmid}{54}{section*.24}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.3.2}QRNoShifts}{54}{subsection.5.3.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{QRNoShiftsLoop}{55}{section*.25}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{QRNoShiftsInsideLoop}{55}{section*.26}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{displayResults}{56}{section*.27}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{initializeValues}{56}{section*.28}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.3.3}QRShifts}{56}{subsection.5.3.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{initiateValues}{57}{section*.29}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{QRShiftLoop}{57}{section*.30}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{findEigenValue}{58}{section*.31}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{getEigenValueFromCorner}{58}{section*.32}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{shiftAndIterate}{58}{section*.33}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{deflateMatrix}{59}{section*.34}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{thresholdBreached}{59}{section*.35}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{solveCharactersticEquation}{59}{section*.36}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{calculateZeros}{60}{section*.37}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{dispResults}{60}{section*.38}\protected@file@percent }
|
||||
\bibcite{texbook}{1}
|
||||
\gdef \@abspage@last{51}
|
||||
\gdef \@abspage@last{63}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# Fdb version 3
|
||||
["pdflatex"] 1636691043 "projectA.tex" "projectA.pdf" "projectA" 1636691044
|
||||
["pdflatex"] 1636706601 "projectA.tex" "projectA.pdf" "projectA" 1636706603
|
||||
"/etc/texmf/web2c/texmf.cnf" 1635008344 475 c0e671620eb5563b2130f56340a5fde8 ""
|
||||
"/usr/share/texlive/texmf-dist/fonts/enc/dvips/base/8r.enc" 1165713224 4850 80dc9bab7f31fb78a000ccfed0e27cab ""
|
||||
"/usr/share/texlive/texmf-dist/fonts/map/fontname/texfonts.map" 1577235249 3524 cb3e574dea2d1052e39280babc910dc8 ""
|
||||
@ -150,13 +150,14 @@
|
||||
"errorsA.eps" 1636686866 1613352 8726309b9c94c5647644a20db10b9a1f ""
|
||||
"errorsB.eps" 1636686908 1614432 a5ba1015251d54e816c9a68cee4a6856 ""
|
||||
"iterations.eps" 1636684222 67653 3e4ba61ec0de12fb403d5a37cff1a286 ""
|
||||
"projectA.aux" 1636691044 11277 caaf7da803404592e338d9a317e94cde "pdflatex"
|
||||
"projectA.out" 1636691044 4368 1c6cbb3ce7f06483447696a06c0d4a4f "pdflatex"
|
||||
"projectA.tex" 1636691043 47801 537dfc2ebcc72961c79d33220b0035f5 ""
|
||||
"projectA.toc" 1636691044 6807 31586b2bc1ebe1d5362c6d33d41b6823 "pdflatex"
|
||||
"projectA.aux" 1636706602 14241 86ef663ab8073bc8bca811eae34925ff "pdflatex"
|
||||
"projectA.out" 1636706602 4984 d11f91d75b715adaaddb49e174cbc6c9 "pdflatex"
|
||||
"projectA.tex" 1636706600 60296 60cf8eeb53ed9870b6e63400c9f8d5b6 ""
|
||||
"projectA.toc" 1636706602 8705 de5afb21a5f18673d63df94c69f3b031 "pdflatex"
|
||||
"task4plot.eps" 1636705312 98748 9802a6c7907f806b5ce644a47c5442a5 ""
|
||||
(generated)
|
||||
"projectA.pdf"
|
||||
"projectA.aux"
|
||||
"projectA.toc"
|
||||
"projectA.log"
|
||||
"projectA.out"
|
||||
"projectA.log"
|
||||
"projectA.pdf"
|
||||
|
||||
@ -863,6 +863,17 @@ INPUT /usr/share/texlive/texmf-dist/tex/latex/bera/ts1fvm.fd
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/latex/bera/ts1fvm.fd
|
||||
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/bera/fvmr8c.tfm
|
||||
INPUT /usr/share/texlive/texmf-dist/fonts/vf/public/bera/fvmr8c.vf
|
||||
INPUT ./task4plot.eps
|
||||
INPUT ./task4plot.eps
|
||||
INPUT task4plot.eps
|
||||
INPUT ./task4plot.eps
|
||||
INPUT ./task4plot.eps
|
||||
INPUT ./task4plot-eps-converted-to.pdf
|
||||
INPUT ./task4plot-eps-converted-to.pdf
|
||||
INPUT ./task4plot.eps
|
||||
INPUT ./task4plot-eps-converted-to.pdf
|
||||
INPUT ./task4plot-eps-converted-to.pdf
|
||||
INPUT ./task4plot-eps-converted-to.pdf
|
||||
INPUT projectA.aux
|
||||
INPUT ./projectA.out
|
||||
INPUT ./projectA.out
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=pdflatex 2021.10.23) 12 NOV 2021 05:24
|
||||
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=pdflatex 2021.10.23) 12 NOV 2021 09:43
|
||||
entering extended mode
|
||||
restricted \write18 enabled.
|
||||
file:line:error style messages enabled.
|
||||
@ -520,7 +520,7 @@ Package epstopdf Info: Source file: <errorsA.eps>
|
||||
(epstopdf) Command: <repstopdf --outfile=errorsA-eps-converted-to.pdf errorsA.eps>
|
||||
(epstopdf) \includegraphics on input line 336.
|
||||
Package epstopdf Info: Output file is already uptodate.
|
||||
<errorsA-eps-converted-to.pdf, id=417, 690.58pt x 712.6625pt>
|
||||
<errorsA-eps-converted-to.pdf, id=462, 690.58pt x 712.6625pt>
|
||||
File: errorsA-eps-converted-to.pdf Graphic file (type pdf)
|
||||
<use errorsA-eps-converted-to.pdf>
|
||||
Package pdftex.def Info: errorsA-eps-converted-to.pdf used on input line 336.
|
||||
@ -540,7 +540,7 @@ Package epstopdf Info: Source file: <errorsB.eps>
|
||||
(epstopdf) Command: <repstopdf --outfile=errorsB-eps-converted-to.pdf errorsB.eps>
|
||||
(epstopdf) \includegraphics on input line 340.
|
||||
Package epstopdf Info: Output file is already uptodate.
|
||||
<errorsB-eps-converted-to.pdf, id=422, 690.58pt x 712.6625pt>
|
||||
<errorsB-eps-converted-to.pdf, id=468, 690.58pt x 712.6625pt>
|
||||
File: errorsB-eps-converted-to.pdf Graphic file (type pdf)
|
||||
<use errorsB-eps-converted-to.pdf>
|
||||
Package pdftex.def Info: errorsB-eps-converted-to.pdf used on input line 340.
|
||||
@ -587,7 +587,7 @@ Package epstopdf Info: Source file: <iterations.eps>
|
||||
(epstopdf) Command: <repstopdf --outfile=iterations-eps-converted-to.pdf iterations.eps>
|
||||
(epstopdf) \includegraphics on input line 934.
|
||||
Package epstopdf Info: Output file is already uptodate.
|
||||
<iterations-eps-converted-to.pdf, id=539, 459.7175pt x 712.6625pt>
|
||||
<iterations-eps-converted-to.pdf, id=584, 459.7175pt x 712.6625pt>
|
||||
File: iterations-eps-converted-to.pdf Graphic file (type pdf)
|
||||
<use iterations-eps-converted-to.pdf>
|
||||
Package pdftex.def Info: iterations-eps-converted-to.pdf used on input line 934.
|
||||
@ -596,113 +596,180 @@ Package pdftex.def Info: iterations-eps-converted-to.pdf used on input line 934
|
||||
Chapter 4.
|
||||
[34
|
||||
|
||||
] [35]
|
||||
Chapter 5.
|
||||
LaTeX Font Info: Trying to load font information for TS1+fvm on input line 989.
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/bera/ts1fvm.fd
|
||||
]
|
||||
LaTeX Font Info: Trying to load font information for TS1+fvm on input line 981.
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/bera/ts1fvm.fd
|
||||
File: ts1fvm.fd 2004/09/07 scalable font definitions for TS1/fvm.
|
||||
)
|
||||
LaTeX Font Info: Font shape `TS1/fvm/m/n' will be
|
||||
(Font) scaled to size 10.20007pt on input line 989.
|
||||
[36
|
||||
(Font) scaled to size 10.20007pt on input line 981.
|
||||
[35] [36]
|
||||
Package epstopdf Info: Source file: <task4plot.eps>
|
||||
(epstopdf) date: 2021-11-12 09:21:52
|
||||
(epstopdf) size: 98748 bytes
|
||||
(epstopdf) Output file: <task4plot-eps-converted-to.pdf>
|
||||
(epstopdf) date: 2021-11-12 09:22:18
|
||||
(epstopdf) size: 16119 bytes
|
||||
(epstopdf) Command: <repstopdf --outfile=task4plot-eps-converted-to.pdf task4plot.eps>
|
||||
(epstopdf) \includegraphics on input line 1069.
|
||||
Package epstopdf Info: Output file is already uptodate.
|
||||
<task4plot-eps-converted-to.pdf, id=644, 690.58pt x 712.6625pt>
|
||||
File: task4plot-eps-converted-to.pdf Graphic file (type pdf)
|
||||
<use task4plot-eps-converted-to.pdf>
|
||||
Package pdftex.def Info: task4plot-eps-converted-to.pdf used on input line 1069.
|
||||
(pdftex.def) Requested size: 345.28915pt x 356.33038pt.
|
||||
[37] [38 <./task4plot-eps-converted-to.pdf>] [39]
|
||||
Chapter 5.
|
||||
[40
|
||||
|
||||
] [37] [38] [39]
|
||||
] [41] [42] [43]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1094.
|
||||
(textcomp) Default family used instead on input line 1203.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1096.
|
||||
[40]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1107.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1108.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1117.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1129.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1140.
|
||||
[41]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1143.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1144.
|
||||
[42]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1175.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1176.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1190.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1201.
|
||||
[43]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1223.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1234.
|
||||
(textcomp) Default family used instead on input line 1205.
|
||||
[44]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1256.
|
||||
(textcomp) Default family used instead on input line 1216.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1257.
|
||||
(textcomp) Default family used instead on input line 1217.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1226.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1238.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1249.
|
||||
[45]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1270.
|
||||
(textcomp) Default family used instead on input line 1252.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1272.
|
||||
(textcomp) Default family used instead on input line 1253.
|
||||
[46]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1307.
|
||||
(textcomp) Default family used instead on input line 1284.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1309.
|
||||
(textcomp) Default family used instead on input line 1285.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1311.
|
||||
(textcomp) Default family used instead on input line 1299.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1339.
|
||||
[47] [48] [49] [50
|
||||
(textcomp) Default family used instead on input line 1310.
|
||||
[47]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1332.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1343.
|
||||
[48]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1365.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1366.
|
||||
[49]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1379.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1381.
|
||||
[50]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1416.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1418.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1420.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1448.
|
||||
[51] [52] [53]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1534.
|
||||
[54]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1581.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1596.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1597.
|
||||
[55] [56]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1660.
|
||||
[57]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1698.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1698.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1712.
|
||||
[58]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1725.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1737.
|
||||
[59]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1758.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1758.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1772.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1773.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 1777.
|
||||
[60] [61] [62
|
||||
|
||||
] (./projectA.aux)
|
||||
Package rerunfilecheck Info: File `projectA.out' has not changed.
|
||||
(rerunfilecheck) Checksum: 1C6CBB3CE7F06483447696A06C0D4A4F;4368.
|
||||
(rerunfilecheck) Checksum: D11F91D75B715ADAADDB49E174CBC6C9;4984.
|
||||
)
|
||||
Here is how much of TeX's memory you used:
|
||||
12897 strings out of 479304
|
||||
223457 string characters out of 5869778
|
||||
882696 words of memory out of 5000000
|
||||
29411 multiletter control sequences out of 15000+600000
|
||||
13219 strings out of 479304
|
||||
228365 string characters out of 5869778
|
||||
881796 words of memory out of 5000000
|
||||
29490 multiletter control sequences out of 15000+600000
|
||||
423928 words of font info for 77 fonts, out of 8000000 for 9000
|
||||
1141 hyphenation exceptions out of 8191
|
||||
81i,17n,88p,715b,2253s stack positions out of 5000i,500n,10000p,200000b,80000s
|
||||
{/usr/share/texmf/fonts/enc/dvips/cm-super/cm-super-t1.enc}{/usr/share/texmf/fonts/enc/dvips/cm-super/cm-super-ts1.enc}{/usr/share/texlive/texmf-dist/fonts/enc/dvips/base/8r.enc}</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx8.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi8.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr6.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr8.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy8.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/bera/fvmr8a.pfb></usr/share/texmf/fonts/type1/pu
|
||||
blic/cm-super/sfbx1200.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfbx1440.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfbx1728.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfbx2488.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfrm1200.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfrm1440.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfrm2074.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfti1200.pfb>
|
||||
Output written on projectA.pdf (51 pages, 562613 bytes).
|
||||
Output written on projectA.pdf (63 pages, 604733 bytes).
|
||||
PDF statistics:
|
||||
1088 PDF objects out of 1200 (max. 8388607)
|
||||
993 compressed objects within 10 object streams
|
||||
458 named destinations out of 1000 (max. 500000)
|
||||
512 words of extra memory for PDF output out of 10000 (max. 10000000)
|
||||
1465 PDF objects out of 1728 (max. 8388607)
|
||||
1350 compressed objects within 14 object streams
|
||||
700 named destinations out of 1000 (max. 500000)
|
||||
589 words of extra memory for PDF output out of 10000 (max. 10000000)
|
||||
|
||||
|
||||
@ -30,33 +30,42 @@
|
||||
\BOOKMARK [1][-]{section.4.2}{Theoretical introduction}{chapter.4}% 30
|
||||
\BOOKMARK [2][-]{subsection.4.2.1}{Eigenvalues}{section.4.2}% 31
|
||||
\BOOKMARK [2][-]{subsection.4.2.2}{QR method for finding eigenvalues}{section.4.2}% 32
|
||||
\BOOKMARK [1][-]{section.4.3}{Solution}{chapter.4}% 33
|
||||
\BOOKMARK [1][-]{section.4.4}{Discussion of the result}{chapter.4}% 34
|
||||
\BOOKMARK [0][-]{chapter.5}{Code appendix}{}% 35
|
||||
\BOOKMARK [1][-]{section.5.1}{Task 2 Code}{chapter.5}% 36
|
||||
\BOOKMARK [2][-]{subsection.5.1.1}{Main function}{section.5.1}% 37
|
||||
\BOOKMARK [2][-]{subsection.5.1.2}{checkIfMatrixIsSquareMatrix}{section.5.1}% 38
|
||||
\BOOKMARK [2][-]{subsection.5.1.3}{gaussianEliminationWithPartialPivoting}{section.5.1}% 39
|
||||
\BOOKMARK [2][-]{subsection.5.1.4}{partialPivoting}{section.5.1}% 40
|
||||
\BOOKMARK [2][-]{subsection.5.1.5}{partialPivotingSwapOneRow}{section.5.1}% 41
|
||||
\BOOKMARK [2][-]{subsection.5.1.6}{swapRowMatrix}{section.5.1}% 42
|
||||
\BOOKMARK [2][-]{subsection.5.1.7}{swapValueVector}{section.5.1}% 43
|
||||
\BOOKMARK [2][-]{subsection.5.1.8}{gaussianElimination}{section.5.1}% 44
|
||||
\BOOKMARK [2][-]{subsection.5.1.9}{substractRows}{section.5.1}% 45
|
||||
\BOOKMARK [2][-]{subsection.5.1.10}{backSubstitutionPhase}{section.5.1}% 46
|
||||
\BOOKMARK [2][-]{subsection.5.1.11}{iterativeResidualCorrection}{section.5.1}% 47
|
||||
\BOOKMARK [2][-]{subsection.5.1.12}{improveSolution}{section.5.1}% 48
|
||||
\BOOKMARK [1][-]{section.5.2}{Task 3 code}{chapter.5}% 49
|
||||
\BOOKMARK [2][-]{subsection.5.2.1}{initializeValues}{section.5.2}% 50
|
||||
\BOOKMARK [2][-]{subsection.5.2.2}{decomposeMatrix}{section.5.2}% 51
|
||||
\BOOKMARK [2][-]{subsection.5.2.3}{jacobiLoop}{section.5.2}% 52
|
||||
\BOOKMARK [2][-]{subsection.5.2.4}{jacobiInsideLoop}{section.5.2}% 53
|
||||
\BOOKMARK [2][-]{subsection.5.2.5}{jacobiEquation}{section.5.2}% 54
|
||||
\BOOKMARK [2][-]{subsection.5.2.6}{gaussSeidelLoop}{section.5.2}% 55
|
||||
\BOOKMARK [2][-]{subsection.5.2.7}{gaussiInsideLoop}{section.5.2}% 56
|
||||
\BOOKMARK [2][-]{subsection.5.2.8}{gaussSeidelEquation}{section.5.2}% 57
|
||||
\BOOKMARK [2][-]{subsection.5.2.9}{checkError}{section.5.2}% 58
|
||||
\BOOKMARK [2][-]{subsection.5.2.10}{endOfLoop}{section.5.2}% 59
|
||||
\BOOKMARK [2][-]{subsection.5.2.11}{dispFinalResults}{section.5.2}% 60
|
||||
\BOOKMARK [2][-]{subsection.5.2.12}{plotIterations}{section.5.2}% 61
|
||||
\BOOKMARK [2][-]{subsection.5.2.13}{plotIterations}{section.5.2}% 62
|
||||
\BOOKMARK [1][-]{section.4.3}{Results}{chapter.4}% 33
|
||||
\BOOKMARK [2][-]{subsection.4.3.1}{Starting matrix}{section.4.3}% 34
|
||||
\BOOKMARK [2][-]{subsection.4.3.2}{QR method with no shifts}{section.4.3}% 35
|
||||
\BOOKMARK [2][-]{subsection.4.3.3}{QR method with shifts}{section.4.3}% 36
|
||||
\BOOKMARK [1][-]{section.4.4}{Discussion of the result}{chapter.4}% 37
|
||||
\BOOKMARK [2][-]{subsection.4.4.1}{Plot}{section.4.4}% 38
|
||||
\BOOKMARK [2][-]{subsection.4.4.2}{Shift method superiority}{section.4.4}% 39
|
||||
\BOOKMARK [0][-]{chapter.5}{Code appendix}{}% 40
|
||||
\BOOKMARK [1][-]{section.5.1}{Task 2 Code}{chapter.5}% 41
|
||||
\BOOKMARK [2][-]{subsection.5.1.1}{Main function}{section.5.1}% 42
|
||||
\BOOKMARK [2][-]{subsection.5.1.2}{checkIfMatrixIsSquareMatrix}{section.5.1}% 43
|
||||
\BOOKMARK [2][-]{subsection.5.1.3}{gaussianEliminationWithPartialPivoting}{section.5.1}% 44
|
||||
\BOOKMARK [2][-]{subsection.5.1.4}{partialPivoting}{section.5.1}% 45
|
||||
\BOOKMARK [2][-]{subsection.5.1.5}{partialPivotingSwapOneRow}{section.5.1}% 46
|
||||
\BOOKMARK [2][-]{subsection.5.1.6}{swapRowMatrix}{section.5.1}% 47
|
||||
\BOOKMARK [2][-]{subsection.5.1.7}{swapValueVector}{section.5.1}% 48
|
||||
\BOOKMARK [2][-]{subsection.5.1.8}{gaussianElimination}{section.5.1}% 49
|
||||
\BOOKMARK [2][-]{subsection.5.1.9}{substractRows}{section.5.1}% 50
|
||||
\BOOKMARK [2][-]{subsection.5.1.10}{backSubstitutionPhase}{section.5.1}% 51
|
||||
\BOOKMARK [2][-]{subsection.5.1.11}{iterativeResidualCorrection}{section.5.1}% 52
|
||||
\BOOKMARK [2][-]{subsection.5.1.12}{improveSolution}{section.5.1}% 53
|
||||
\BOOKMARK [1][-]{section.5.2}{Task 3 code}{chapter.5}% 54
|
||||
\BOOKMARK [2][-]{subsection.5.2.1}{initializeValues}{section.5.2}% 55
|
||||
\BOOKMARK [2][-]{subsection.5.2.2}{decomposeMatrix}{section.5.2}% 56
|
||||
\BOOKMARK [2][-]{subsection.5.2.3}{jacobiLoop}{section.5.2}% 57
|
||||
\BOOKMARK [2][-]{subsection.5.2.4}{jacobiInsideLoop}{section.5.2}% 58
|
||||
\BOOKMARK [2][-]{subsection.5.2.5}{jacobiEquation}{section.5.2}% 59
|
||||
\BOOKMARK [2][-]{subsection.5.2.6}{gaussSeidelLoop}{section.5.2}% 60
|
||||
\BOOKMARK [2][-]{subsection.5.2.7}{gaussiInsideLoop}{section.5.2}% 61
|
||||
\BOOKMARK [2][-]{subsection.5.2.8}{gaussSeidelEquation}{section.5.2}% 62
|
||||
\BOOKMARK [2][-]{subsection.5.2.9}{checkError}{section.5.2}% 63
|
||||
\BOOKMARK [2][-]{subsection.5.2.10}{endOfLoop}{section.5.2}% 64
|
||||
\BOOKMARK [2][-]{subsection.5.2.11}{dispFinalResults}{section.5.2}% 65
|
||||
\BOOKMARK [2][-]{subsection.5.2.12}{plotIterations}{section.5.2}% 66
|
||||
\BOOKMARK [2][-]{subsection.5.2.13}{plotIterations}{section.5.2}% 67
|
||||
\BOOKMARK [1][-]{section.5.3}{Task 4 Code}{chapter.5}% 68
|
||||
\BOOKMARK [2][-]{subsection.5.3.1}{Gram-Schmid algorithm}{section.5.3}% 69
|
||||
\BOOKMARK [2][-]{subsection.5.3.2}{QRNoShifts}{section.5.3}% 70
|
||||
\BOOKMARK [2][-]{subsection.5.3.3}{QRShifts}{section.5.3}% 71
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -970,11 +970,120 @@ Since this method can be slowly convergent we use shifts. Single iteration of QR
|
||||
\end{split}
|
||||
\end{equation}
|
||||
|
||||
Wher $p_k$ sholud be chosen as a best estimate of $\lambda_{i+1}$
|
||||
Wher $p_k$ should be chosen as a best estimate of $\lambda_{i+1}$
|
||||
|
||||
\section{Solution}
|
||||
\section{Results}
|
||||
\subsection{Starting matrix}
|
||||
I decided to generate random symmetric matrix using following code:
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function A = matrix4()
|
||||
A = 10 * rand(5); % rand generates 5x5 matrix filled with random numbers
|
||||
% we multiply by 10 to get at lest one digit in front of the dot
|
||||
A = floor(A); % we floor the matrix we got to get nice natural numbers matrix
|
||||
A = A * A'; % we get symmetric matrix
|
||||
disp(issymmetric(A)); % we check if matrix is symmetric
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
I got the following matrix:
|
||||
\[
|
||||
\begin{bmatrix}
|
||||
171 & 48 & 133 & 81 & 93 \\
|
||||
48 & 108 & 63 & 35 & 30 \\
|
||||
133 & 63 & 131 & 64 & 91 \\
|
||||
81 & 35 & 64 & 41 & 37 \\
|
||||
93 & 30 & 91 & 37 & 106
|
||||
\end{bmatrix}
|
||||
\]
|
||||
|
||||
Putting it through Matlab eig function I got eigen values equal to:
|
||||
\[
|
||||
10^{2} *
|
||||
\begin{bmatrix}
|
||||
0.000050598692964 \\
|
||||
0.105696602175690 \\
|
||||
0.454589544003707 \\
|
||||
0.870708987227002 \\
|
||||
4.138954267900641
|
||||
\end{bmatrix}
|
||||
\]
|
||||
|
||||
|
||||
\subsection{QR method with no shifts}
|
||||
Putting this matrix to my functions QRNoShifts and QRShifts I got:
|
||||
for qr method with no shifts:
|
||||
Final matrix:
|
||||
\[
|
||||
\begin{bmatrix}
|
||||
413.8954 & 0.0000 & -0.0000 & 0.0000 & 0.0000 \\
|
||||
0.0000 & 87.0709 & -0.0000 & -0.0000 & 0.0000 \\
|
||||
0.0000 & -0.0000 & 45.4590 & -0.0000 & -0.0000 \\
|
||||
-0.0000 & 0.0000 & -0.0000 & 10.5697 & -0.0000 \\
|
||||
0.0000 & -0.0000 & 0.0000 & 0 & 0.0051
|
||||
\end{bmatrix}
|
||||
\]
|
||||
|
||||
Eigen values:
|
||||
\[
|
||||
10^{2} *
|
||||
\begin{bmatrix}
|
||||
4.138954267900639 \\
|
||||
0.870708987227001 \\
|
||||
0.454589544003706 \\
|
||||
0.105696602175689 \\
|
||||
0.000050598692964 \\
|
||||
\end{bmatrix}
|
||||
\]
|
||||
|
||||
It took \textbf{26} iterations to get those values.
|
||||
|
||||
\subsection{QR method with shifts}
|
||||
For qr method with shiftts:
|
||||
Final matrix:
|
||||
\[
|
||||
\begin{bmatrix}
|
||||
413.8954
|
||||
\end{bmatrix}
|
||||
\]
|
||||
|
||||
Eigen values:
|
||||
\[
|
||||
10^{2} *
|
||||
\begin{bmatrix}
|
||||
0.454589544003706 \\
|
||||
0.870708987227001 \\
|
||||
0.105696602175689 \\
|
||||
0.000050598692964 \\
|
||||
4.138954267900639
|
||||
\end{bmatrix}
|
||||
\]
|
||||
|
||||
It took \textbf{12} iterations to get those values.
|
||||
|
||||
\section{Discussion of the result}
|
||||
Following plot was generated using task4Plot function, using maxMatrixSize = 25 and generating random symmetrical matrix of size i x i in each loop. Both QR methods were given exactly the same matrices.
|
||||
\subsection{Plot}
|
||||
|
||||
\begin{center}
|
||||
\includegraphics[scale=0.5]{task4plot.eps}
|
||||
\end{center}
|
||||
\subsection{Shift method superiority}
|
||||
As we can see:
|
||||
QR method with shifts is much more efficient and reliable.
|
||||
\begin{enumerate}
|
||||
\item For big enough matrices it requires ten times less iterations compared to QR method without shifts.
|
||||
\item It is more efficient in our chosen matrix.
|
||||
\item It can work with non-symetric matrices
|
||||
\item Has no problem with generating complex eigen values.
|
||||
\end{enumerate}
|
||||
One thing that does not change much is the precision, with both algorithms outputting similar results.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
\chapter{Code appendix}
|
||||
|
||||
@ -1385,6 +1494,311 @@ end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\section{Task 4 Code}
|
||||
\subsection{Gram-Schmid algorithm}
|
||||
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
% performs QR or QRdash decomposition of a matrix
|
||||
function [Q, R] = gramSchmidtAlgorithm(Matrix)
|
||||
[columns, Q, R, d] = initializeGramSchmid(Matrix);
|
||||
[Q, R] = factorizeColumnsOfQ(columns, Q, Matrix, R, d);
|
||||
[Q, R] = normalizeColumns(columns, Q, R);
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{initializeGramSchmid}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [columns, Q, R, d] = initializeGramSchmid(Matrix)
|
||||
% We start with empty matrices
|
||||
[rows, columns] = size(Matrix);
|
||||
Q = zeros(rows, columns);
|
||||
R = zeros(columns, columns);
|
||||
d = zeros(1, columns);
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{initializeGramSchmid}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [Q, R] = factorizeColumnsOfQ(columns, Q, Matrix, R, d)
|
||||
for i = 1 : columns
|
||||
Q(:, i) = Matrix(:, i);
|
||||
R(i, i) = 1;
|
||||
d(i) = Q(:, i)' * Q(:, i);
|
||||
for i2 = i + 1 : columns
|
||||
R(i, i2) = (Q(:, i)' * Matrix(:, i2)) / d(i);
|
||||
Matrix(:, i2) = Matrix(:, i2) - R(i, i2) * Q(:, i);
|
||||
end
|
||||
end
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{initializeGramSchmid}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [Q, R] = normalizeColumns(columns, Q, R)
|
||||
for i = 1 : columns
|
||||
dd = norm(Q(:, i));
|
||||
Q(:, i) = Q(:, i) / dd;
|
||||
R(i, i:columns) = R(i, i : columns) * dd;
|
||||
end
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [eigenValuesNoShifts, iterationsNoShifts, finalMatrixNoShifts, eigenValuesShifts, iterationsShifts, finalMatrixShifts] = task4(Matrix)
|
||||
[eigenValuesNoShifts, iterationsNoShifts, finalMatrixNoShifts] = QRNoShifts(Matrix);
|
||||
[eigenValuesShifts, iterationsShifts, finalMatrixShifts] = QRShifts(Matrix);
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsection{QRNoShifts}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [eigenValues, whichIterationAreWeOn, Matrix] = QRNoShifts(Matrix)
|
||||
|
||||
[whichIterationAreWeOn, threshold, startingMatrix, matlabEigen] = initializeValues(Matrix);
|
||||
[Matrix, whichIterationAreWeOn] = QRNoShiftsLoop(threshold, Matrix, whichIterationAreWeOn);
|
||||
eigenValues = diag(Matrix)';
|
||||
displayResults(eigenValues, whichIterationAreWeOn, Matrix, startingMatrix, matlabEigen);
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{QRNoShiftsLoop}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [Matrix, whichIterationAreWeOn] = QRNoShiftsLoop(threshold, Matrix, whichIterationAreWeOn)
|
||||
while threshold > 1e-6
|
||||
[Matrix, whichIterationAreWeOn, threshold] = QRNoShiftsInsideLoop(Matrix, whichIterationAreWeOn);
|
||||
end
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{QRNoShiftsInsideLoop}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [Matrix, whichIterationAreWeOn, threshold] = QRNoShiftsInsideLoop(Matrix, whichIterationAreWeOn)
|
||||
[Q, R] = gramSchmidtAlgorithm(Matrix);
|
||||
Matrix = R * Q;
|
||||
whichIterationAreWeOn = whichIterationAreWeOn + 1;
|
||||
|
||||
% iterate until all non-diagonal elements are below the threshold
|
||||
matrixWithoutDiagonal = Matrix - diag(diag(Matrix)); % first diag converts Matrix
|
||||
% into vector consisting of values on the diagonal of matrix,
|
||||
% second diag converts this vector into matrix with zeros on
|
||||
% everything except diagonal
|
||||
% If we substract it from Matrix we get original Matrix with zeros
|
||||
% on a diagonal
|
||||
threshold = max(max(abs(matrixWithoutDiagonal)));
|
||||
% first max returns vector of elements
|
||||
% second max returns max element from this vector
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{displayResults}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function displayResults(eigenValues, whichIterationsAreWeOn, Matrix, startingMatrix, matlabEigen)
|
||||
disp("How many iterations it took:")
|
||||
disp(whichIterationsAreWeOn)
|
||||
disp("Starting Matrix:")
|
||||
disp(startingMatrix)
|
||||
disp("Final Matrix:")
|
||||
disp(Matrix)
|
||||
disp("eig(Matrix) eigen values:")
|
||||
disp(matlabEigen)
|
||||
disp("Our eigen values:")
|
||||
disp(eigenValues);
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{initializeValues}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [whichIterationAreWeOn, threshold, startingMatrix, matlabEigen] = initializeValues(Matrix)
|
||||
whichIterationAreWeOn = 0;
|
||||
threshold = inf;
|
||||
startingMatrix = Matrix;
|
||||
matlabEigen = eig(Matrix);
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsection{QRShifts}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [eigenValues, whatIterationAreWeOn, Matrix] = QRShifts(Matrix)
|
||||
eigenFromMatlab = eig(Matrix);
|
||||
initialMatrix = Matrix;
|
||||
[eigenValues, whatIterationAreWeOn, matrixSize, minThreshold] = initiateValues(Matrix);
|
||||
[Matrix, whatIterationAreWeOn, eigenValues] = QRShiftLoop(matrixSize, Matrix, eigenValues, minThreshold, whatIterationAreWeOn);
|
||||
dispResults(eigenValues, Matrix, whatIterationAreWeOn, eigenFromMatlab, initialMatrix);
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{initiateValues}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [eigenValues, whatIterationAreWeOn, matrixSize, minThreshold] = initiateValues(Matrix)
|
||||
eigenValues = double.empty(1, 0);
|
||||
whatIterationAreWeOn = 0;
|
||||
matrixSize = size(Matrix, 1);
|
||||
minThreshold = 1e-6;
|
||||
end
|
||||
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{QRShiftLoop}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [Matrix, whatIterationAreWeOn, eigenValues] = QRShiftLoop(matrixSize, Matrix, eigenValues, minThreshold, whatIterationAreWeOn)
|
||||
while matrixSize >= 2
|
||||
flag = 0;
|
||||
[Matrix, matrixSize, whatIterationAreWeOn, eigenValues] = findEigenValue(Matrix, matrixSize, whatIterationAreWeOn, eigenValues, minThreshold, flag);
|
||||
[matrixSize, Matrix] = deflateMatrix(Matrix, matrixSize);
|
||||
end
|
||||
eigenValues(size(eigenValues, 2) + 1) = Matrix(1, 1);
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{findEigenValue}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [Matrix, matrixSize, whatIterationAreWeOn, eigenValues] = findEigenValue(Matrix, matrixSize, whatIterationAreWeOn, eigenValues, minThreshold, flag)
|
||||
while flag == 0
|
||||
eigenValueCorner = getEigenValueFromCorner(Matrix, matrixSize);
|
||||
[Matrix, whatIterationAreWeOn] = shiftAndIterate(matrixSize, Matrix, eigenValueCorner, whatIterationAreWeOn);
|
||||
[flag, eigenValues] = thresholdBreached(Matrix, matrixSize, minThreshold, eigenValues);
|
||||
end
|
||||
end
|
||||
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{getEigenValueFromCorner}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function eigenValueCorner = getEigenValueFromCorner(Matrix, matrixSize)
|
||||
corner = Matrix((matrixSize - 1) : matrixSize, (matrixSize - 1) : matrixSize);
|
||||
% get 2 x 2 corner of the matrix
|
||||
eigenValueCorner = solveCharactersticEquation(corner);
|
||||
end
|
||||
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{shiftAndIterate}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [Matrix, whatIterationAreWeOn] = shiftAndIterate(matrixSize, Matrix, eigenValueCorner, whatIterationAreWeOn)
|
||||
% shift and iterate algorithm
|
||||
identityMatrix = eye(matrixSize);
|
||||
Matrix = Matrix - identityMatrix * eigenValueCorner;
|
||||
[Q, R] = gramSchmidtAlgorithm(Matrix);
|
||||
Matrix = R * Q + identityMatrix * eigenValueCorner;
|
||||
whatIterationAreWeOn = whatIterationAreWeOn + 1;
|
||||
end
|
||||
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{deflateMatrix}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [matrixSize, Matrix] = deflateMatrix(Matrix, matrixSize)
|
||||
matrixSize = matrixSize - 1;
|
||||
Matrix = Matrix(1:matrixSize, 1:matrixSize);
|
||||
end
|
||||
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{thresholdBreached}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [flag, eigenValues] = thresholdBreached(Matrix, matrixSize, minThreshold, eigenValues)
|
||||
flag = 0;
|
||||
threshold = max(abs(Matrix(matrixSize, 1:(matrixSize - 1))));
|
||||
|
||||
% once we zero the row (or rather get close enough to zero) exit loop
|
||||
if (threshold <= minThreshold)
|
||||
eigenValues(size(eigenValues, 2) + 1) = Matrix(matrixSize, matrixSize);
|
||||
flag = 1;
|
||||
end
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{solveCharactersticEquation}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
% finds the eigenvalue of a 2x2 matrix that is closer to the lower right corner
|
||||
function eigen = solveCharactersticEquation(Matrix)
|
||||
[eigenOne, eigenTwo] = calculateZeros(Matrix);
|
||||
eigen = valueCloserToLowerRightCorner(eigenOne, eigenTwo, Matrix);
|
||||
end
|
||||
|
||||
function eigen = valueCloserToLowerRightCorner(eigenOne, eigenTwo, Matrix)
|
||||
if abs(Matrix(4) - eigenOne) < abs(Matrix(4) - eigenTwo)
|
||||
eigen = eigenOne;
|
||||
else
|
||||
eigen = eigenTwo;
|
||||
end
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{calculateZeros}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function [zeroOne, zeroTwo] = calculateZeros(Matrix)
|
||||
b = Matrix(1) + Matrix(4);
|
||||
ac = Matrix(1) * Matrix(4) - Matrix(2) * Matrix(3);
|
||||
delta = (b) ^ 2 - 4 * ac;
|
||||
% get delta of quadratic equation
|
||||
squareRootDelta = sqrt(delta);
|
||||
% square delta
|
||||
zeroOne = (b - squareRootDelta) / 2;
|
||||
zeroTwo = (b + squareRootDelta) / 2;
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
\subsubsection{dispResults}
|
||||
\begin{simplechar}
|
||||
\begin{lstlisting}
|
||||
function dispResults(eigenValues, Matrix, whatIterationAreWeOn, eigenFromMatlab, initialMatrix)
|
||||
disp("Initial matrix: ");
|
||||
disp(initialMatrix);
|
||||
disp("Final matrix: ");
|
||||
disp(Matrix);
|
||||
disp("Number of iterations: ");
|
||||
disp(whatIterationAreWeOn);
|
||||
disp("Eigen values from eig(Matrix):");
|
||||
disp(eigenFromMatlab);
|
||||
disp("Our eigen values: ");
|
||||
disp(eigenValues);
|
||||
end
|
||||
\end{lstlisting}
|
||||
\end{simplechar}
|
||||
|
||||
|
||||
\begin{thebibliography}{9}
|
||||
\bibitem{texbook}
|
||||
Piotr Tatjewski (2014) \emph{Numerical Methods}, Oficyna Wydawnicza Politechniki Warszawskiej
|
||||
|
||||
@ -51,33 +51,59 @@
|
||||
\contentsline {section}{\numberline {4.2}Theoretical introduction}{34}{section.4.2}%
|
||||
\contentsline {subsection}{\numberline {4.2.1}Eigenvalues}{34}{subsection.4.2.1}%
|
||||
\contentsline {subsection}{\numberline {4.2.2}QR method for finding eigenvalues}{34}{subsection.4.2.2}%
|
||||
\contentsline {section}{\numberline {4.3}Solution}{35}{section.4.3}%
|
||||
\contentsline {section}{\numberline {4.4}Discussion of the result}{35}{section.4.4}%
|
||||
\contentsline {chapter}{\numberline {5}Code appendix}{36}{chapter.5}%
|
||||
\contentsline {section}{\numberline {5.1}Task 2 Code}{36}{section.5.1}%
|
||||
\contentsline {subsection}{\numberline {5.1.1}Main function}{36}{subsection.5.1.1}%
|
||||
\contentsline {subsection}{\numberline {5.1.2}checkIfMatrixIsSquareMatrix}{37}{subsection.5.1.2}%
|
||||
\contentsline {subsection}{\numberline {5.1.3}gaussianEliminationWithPartialPivoting}{38}{subsection.5.1.3}%
|
||||
\contentsline {subsection}{\numberline {5.1.4}partialPivoting}{38}{subsection.5.1.4}%
|
||||
\contentsline {subsection}{\numberline {5.1.5}partialPivotingSwapOneRow}{38}{subsection.5.1.5}%
|
||||
\contentsline {subsection}{\numberline {5.1.6}swapRowMatrix}{39}{subsection.5.1.6}%
|
||||
\contentsline {subsection}{\numberline {5.1.7}swapValueVector}{39}{subsection.5.1.7}%
|
||||
\contentsline {subsection}{\numberline {5.1.8}gaussianElimination}{39}{subsection.5.1.8}%
|
||||
\contentsline {subsection}{\numberline {5.1.9}substractRows}{40}{subsection.5.1.9}%
|
||||
\contentsline {subsection}{\numberline {5.1.10}backSubstitutionPhase}{41}{subsection.5.1.10}%
|
||||
\contentsline {subsection}{\numberline {5.1.11}iterativeResidualCorrection}{41}{subsection.5.1.11}%
|
||||
\contentsline {subsection}{\numberline {5.1.12}improveSolution}{41}{subsection.5.1.12}%
|
||||
\contentsline {section}{\numberline {5.2}Task 3 code}{42}{section.5.2}%
|
||||
\contentsline {subsection}{\numberline {5.2.1}initializeValues}{42}{subsection.5.2.1}%
|
||||
\contentsline {subsection}{\numberline {5.2.2}decomposeMatrix}{43}{subsection.5.2.2}%
|
||||
\contentsline {subsection}{\numberline {5.2.3}jacobiLoop}{43}{subsection.5.2.3}%
|
||||
\contentsline {subsection}{\numberline {5.2.4}jacobiInsideLoop}{44}{subsection.5.2.4}%
|
||||
\contentsline {subsection}{\numberline {5.2.5}jacobiEquation}{44}{subsection.5.2.5}%
|
||||
\contentsline {subsection}{\numberline {5.2.6}gaussSeidelLoop}{44}{subsection.5.2.6}%
|
||||
\contentsline {subsection}{\numberline {5.2.7}gaussiInsideLoop}{45}{subsection.5.2.7}%
|
||||
\contentsline {subsection}{\numberline {5.2.8}gaussSeidelEquation}{45}{subsection.5.2.8}%
|
||||
\contentsline {subsection}{\numberline {5.2.9}checkError}{45}{subsection.5.2.9}%
|
||||
\contentsline {subsection}{\numberline {5.2.10}endOfLoop}{46}{subsection.5.2.10}%
|
||||
\contentsline {subsection}{\numberline {5.2.11}dispFinalResults}{46}{subsection.5.2.11}%
|
||||
\contentsline {subsection}{\numberline {5.2.12}plotIterations}{47}{subsection.5.2.12}%
|
||||
\contentsline {subsection}{\numberline {5.2.13}plotIterations}{48}{subsection.5.2.13}%
|
||||
\contentsline {section}{\numberline {4.3}Results}{35}{section.4.3}%
|
||||
\contentsline {subsection}{\numberline {4.3.1}Starting matrix}{35}{subsection.4.3.1}%
|
||||
\contentsline {subsection}{\numberline {4.3.2}QR method with no shifts}{36}{subsection.4.3.2}%
|
||||
\contentsline {subsection}{\numberline {4.3.3}QR method with shifts}{36}{subsection.4.3.3}%
|
||||
\contentsline {section}{\numberline {4.4}Discussion of the result}{37}{section.4.4}%
|
||||
\contentsline {subsection}{\numberline {4.4.1}Plot}{38}{subsection.4.4.1}%
|
||||
\contentsline {subsection}{\numberline {4.4.2}Shift method superiority}{38}{subsection.4.4.2}%
|
||||
\contentsline {chapter}{\numberline {5}Code appendix}{40}{chapter.5}%
|
||||
\contentsline {section}{\numberline {5.1}Task 2 Code}{40}{section.5.1}%
|
||||
\contentsline {subsection}{\numberline {5.1.1}Main function}{40}{subsection.5.1.1}%
|
||||
\contentsline {subsection}{\numberline {5.1.2}checkIfMatrixIsSquareMatrix}{41}{subsection.5.1.2}%
|
||||
\contentsline {subsection}{\numberline {5.1.3}gaussianEliminationWithPartialPivoting}{42}{subsection.5.1.3}%
|
||||
\contentsline {subsection}{\numberline {5.1.4}partialPivoting}{42}{subsection.5.1.4}%
|
||||
\contentsline {subsection}{\numberline {5.1.5}partialPivotingSwapOneRow}{42}{subsection.5.1.5}%
|
||||
\contentsline {subsection}{\numberline {5.1.6}swapRowMatrix}{43}{subsection.5.1.6}%
|
||||
\contentsline {subsection}{\numberline {5.1.7}swapValueVector}{43}{subsection.5.1.7}%
|
||||
\contentsline {subsection}{\numberline {5.1.8}gaussianElimination}{43}{subsection.5.1.8}%
|
||||
\contentsline {subsection}{\numberline {5.1.9}substractRows}{44}{subsection.5.1.9}%
|
||||
\contentsline {subsection}{\numberline {5.1.10}backSubstitutionPhase}{45}{subsection.5.1.10}%
|
||||
\contentsline {subsection}{\numberline {5.1.11}iterativeResidualCorrection}{45}{subsection.5.1.11}%
|
||||
\contentsline {subsection}{\numberline {5.1.12}improveSolution}{45}{subsection.5.1.12}%
|
||||
\contentsline {section}{\numberline {5.2}Task 3 code}{46}{section.5.2}%
|
||||
\contentsline {subsection}{\numberline {5.2.1}initializeValues}{46}{subsection.5.2.1}%
|
||||
\contentsline {subsection}{\numberline {5.2.2}decomposeMatrix}{47}{subsection.5.2.2}%
|
||||
\contentsline {subsection}{\numberline {5.2.3}jacobiLoop}{47}{subsection.5.2.3}%
|
||||
\contentsline {subsection}{\numberline {5.2.4}jacobiInsideLoop}{48}{subsection.5.2.4}%
|
||||
\contentsline {subsection}{\numberline {5.2.5}jacobiEquation}{48}{subsection.5.2.5}%
|
||||
\contentsline {subsection}{\numberline {5.2.6}gaussSeidelLoop}{48}{subsection.5.2.6}%
|
||||
\contentsline {subsection}{\numberline {5.2.7}gaussiInsideLoop}{49}{subsection.5.2.7}%
|
||||
\contentsline {subsection}{\numberline {5.2.8}gaussSeidelEquation}{49}{subsection.5.2.8}%
|
||||
\contentsline {subsection}{\numberline {5.2.9}checkError}{49}{subsection.5.2.9}%
|
||||
\contentsline {subsection}{\numberline {5.2.10}endOfLoop}{50}{subsection.5.2.10}%
|
||||
\contentsline {subsection}{\numberline {5.2.11}dispFinalResults}{50}{subsection.5.2.11}%
|
||||
\contentsline {subsection}{\numberline {5.2.12}plotIterations}{51}{subsection.5.2.12}%
|
||||
\contentsline {subsection}{\numberline {5.2.13}plotIterations}{52}{subsection.5.2.13}%
|
||||
\contentsline {section}{\numberline {5.3}Task 4 Code}{53}{section.5.3}%
|
||||
\contentsline {subsection}{\numberline {5.3.1}Gram-Schmid algorithm}{53}{subsection.5.3.1}%
|
||||
\contentsline {subsubsection}{initializeGramSchmid}{53}{section*.22}%
|
||||
\contentsline {subsubsection}{initializeGramSchmid}{53}{section*.23}%
|
||||
\contentsline {subsubsection}{initializeGramSchmid}{54}{section*.24}%
|
||||
\contentsline {subsection}{\numberline {5.3.2}QRNoShifts}{54}{subsection.5.3.2}%
|
||||
\contentsline {subsubsection}{QRNoShiftsLoop}{55}{section*.25}%
|
||||
\contentsline {subsubsection}{QRNoShiftsInsideLoop}{55}{section*.26}%
|
||||
\contentsline {subsubsection}{displayResults}{56}{section*.27}%
|
||||
\contentsline {subsubsection}{initializeValues}{56}{section*.28}%
|
||||
\contentsline {subsection}{\numberline {5.3.3}QRShifts}{56}{subsection.5.3.3}%
|
||||
\contentsline {subsubsection}{initiateValues}{57}{section*.29}%
|
||||
\contentsline {subsubsection}{QRShiftLoop}{57}{section*.30}%
|
||||
\contentsline {subsubsection}{findEigenValue}{58}{section*.31}%
|
||||
\contentsline {subsubsection}{getEigenValueFromCorner}{58}{section*.32}%
|
||||
\contentsline {subsubsection}{shiftAndIterate}{58}{section*.33}%
|
||||
\contentsline {subsubsection}{deflateMatrix}{59}{section*.34}%
|
||||
\contentsline {subsubsection}{thresholdBreached}{59}{section*.35}%
|
||||
\contentsline {subsubsection}{solveCharactersticEquation}{59}{section*.36}%
|
||||
\contentsline {subsubsection}{calculateZeros}{60}{section*.37}%
|
||||
\contentsline {subsubsection}{dispResults}{60}{section*.38}%
|
||||
|
||||
4
ENUME/projectA/task4.m
Normal file
4
ENUME/projectA/task4.m
Normal file
@ -0,0 +1,4 @@
|
||||
function [eigenValuesNoShifts, iterationsNoShifts, finalMatrixNoShifts, eigenValuesShifts, iterationsShifts, finalMatrixShifts] = task4(Matrix)
|
||||
[eigenValuesNoShifts, iterationsNoShifts, finalMatrixNoShifts] = QRNoShifts(Matrix);
|
||||
[eigenValuesShifts, iterationsShifts, finalMatrixShifts] = QRShifts(Matrix);
|
||||
end
|
||||
19
ENUME/projectA/task4Plot.m
Normal file
19
ENUME/projectA/task4Plot.m
Normal file
@ -0,0 +1,19 @@
|
||||
function task4Plot(maxMatrixSize)
|
||||
iterationsNoShiftsVector = zeros(maxMatrixSize);
|
||||
iterationsShiftsVector = zeros(maxMatrixSize);
|
||||
for i = 1 : maxMatrixSize
|
||||
[~, iterationsNoShifts, ~, ~, iterationsShifts, ~] = task4(matrix4(i));
|
||||
iterationsNoShiftsVector(i) = iterationsNoShifts;
|
||||
iterationsShiftsVector(i) = iterationsShifts;
|
||||
end
|
||||
nexttile
|
||||
plot(iterationsNoShiftsVector, '.');
|
||||
title('Number of iterations for different sizes of matrices for no shift method');
|
||||
xlabel('Size of matrix A');
|
||||
ylabel('Number of iterations');
|
||||
nexttile
|
||||
plot(iterationsShiftsVector, '.');
|
||||
title('Number of iterations for different sizes of matrices for shift method');
|
||||
xlabel('Size of matrix A');
|
||||
ylabel('Number of iterations');
|
||||
end
|
||||
BIN
ENUME/projectA/task4plot-eps-converted-to.pdf
Normal file
BIN
ENUME/projectA/task4plot-eps-converted-to.pdf
Normal file
Binary file not shown.
8330
ENUME/projectA/task4plot.eps
Normal file
8330
ENUME/projectA/task4plot.eps
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user