The Strategy of Algorithmic Swap
Define a family of matrix factorization spells and make them interchangeable.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Divination // Tactics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MATLAB PATTERN //
classdef (Abstract) FactorizationStrategy
methods (Abstract)
[L, U] = decompose(obj, matrix)
end
end
classdef LUStrategy < FactorizationStrategy
methods
function [L, U] = decompose(obj, matrix)
[L, U] = lu(matrix);
end
end
end
classdef CholeskyStrategy < FactorizationStrategy
methods
function [L, U] = decompose(obj, matrix)
L = chol(matrix, 'lower');
U = L';
end
end
end
Strategy
Do not hardcode your decomposition path. Let the strategy be swapped at the last microsecond of execution.
Runic Tags:
#strategy
#factorization
#swapping