mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-11-10 20:47:09 +01:00
The 250-line cap applies to prose too, and the reports were the worst
offenders -- ENUME's projectA.tex alone was 1,876 lines. Each is now a
preamble plus one \input{} per section, which is how a long LaTeX document is
normally organised; not one byte of prose was rewritten.
"The PDF is unchanged" is checked by a script rather than by eye, because
hashing the PDF cannot work: pdflatex stamps a /CreationDate and an /ID into
every build, so two runs of the SAME source already differ. tex_fingerprint.sh
compares what a reader sees instead -- page count plus a hash of the extracted
text -- and it is stable across rebuilds of untouched sources, which is the
property that makes it usable as a gate.
It earned its keep immediately. Both ECOTE reports quote an example LaTeX
document inside an lstlisting block, so \end{document} appears in the middle
of the file; splitting on the FIRST one stranded everything after it. Same
page count, different text, caught automatically. EOPSY lab3 exposed a second
bug: a \section{} title that runs onto the next line.
Result: 19 .tex over the cap -> 1. The survivor,
ELAC/.../03-building-nfa-...tex, is 418 lines of consecutive tikz figures
with no subsection to split on and needs a hand-placed boundary.
Verified: 29 splits across two passes (section, then subsection for the
pieces still over), every one reporting `unchanged` from
scripts/tex_fingerprint.sh --check.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172dj34FDpao6wsix8ZuCzE
121 lines
4.3 KiB
TeX
121 lines
4.3 KiB
TeX
\section{AdamsPCMethod.m}
|
|
\subsection{AdamsPCMethod}
|
|
\begin{simplechar}
|
|
\begin{lstlisting}
|
|
function x = AdamsPCMethod(functions, initialValues, interval, stepSize)
|
|
[x, derrivatives, explicitCoefficients, implicitCoefficients, stepCount] = initialize(functions, initialValues, interval, stepSize);
|
|
x = adamsPcLoop(x, derrivatives, explicitCoefficients, implicitCoefficients, stepCount, functions, stepSize);
|
|
% append arguments to output
|
|
x = [interval(1):stepSize:(stepCount * stepSize); x];
|
|
end
|
|
\end{lstlisting}
|
|
\end{simplechar}
|
|
|
|
\subsection{initialize}
|
|
\begin{simplechar}
|
|
\begin{lstlisting}
|
|
function [x, derrivatives, explicitCoefficients, implicitCoefficients, stepCount] = initialize(functions, initialValues, interval, stepSize)
|
|
% obtain first five steps from RK4
|
|
[x, derrivatives] = RK4(functions, initialValues, interval, stepSize, 5);
|
|
x = x(2:end, :);
|
|
|
|
% define coefficient
|
|
explicitCoefficients = [1901, -2774, 1616, -1274, 251] / 720;
|
|
% Constants that can be found on the Internet or in Mister Tatjewski
|
|
% book on page 177, notice how beta(3) = 1616 instead of 2616
|
|
% I have found on the internet different value for this parameter and
|
|
% got better results with it so I decided to stick with it
|
|
implicitCoefficients = [475, 1427, -798, 482, -173, 27] / 1440;
|
|
% Constants that can be found on the Internet or in Mister Tatjewski
|
|
% book on page 178
|
|
% build output based on preceding values
|
|
stepCount = ceil((interval(2) - interval(1)) / stepSize);
|
|
end
|
|
\end{lstlisting}
|
|
\end{simplechar}
|
|
|
|
\subsection{adamsPcLoop}
|
|
\begin{simplechar}
|
|
\begin{lstlisting}
|
|
function x = adamsPcLoop(x, derrivatives, explicitCoefficients, implicitCoefficients, stepCount, functions, stepSize)
|
|
for step = 6: (stepCount + 1)
|
|
[x, derrivatives] = PECE(x, derrivatives, explicitCoefficients, implicitCoefficients, step, functions, stepSize);
|
|
end
|
|
end
|
|
\end{lstlisting}
|
|
\end{simplechar}
|
|
|
|
\subsection{PECE}
|
|
\begin{simplechar}
|
|
\begin{lstlisting}
|
|
function [x, derrivatives] = PECE(x, derrivatives, explicitCoefficients, implicitCoefficients, step, functions, stepSize)
|
|
% P
|
|
predictionOfX = adamsPredict(x, step, stepSize, explicitCoefficients, derrivatives);
|
|
|
|
% E
|
|
derrivativePrediction = zeros(size(functions, 1), 1);
|
|
derrivativePrediction = adamsEvaluate(functions, predictionOfX, derrivativePrediction);
|
|
|
|
% C
|
|
x = adamsCorrect(step, functions, stepSize, implicitCoefficients, derrivatives, derrivativePrediction, x);
|
|
|
|
% E
|
|
derrivatives = adamsEvaluateTwo(functions, step, x, derrivatives);
|
|
end
|
|
\end{lstlisting}
|
|
\end{simplechar}
|
|
|
|
\subsection{adamsPredict}
|
|
\begin{simplechar}
|
|
\begin{lstlisting}
|
|
function predictionOfX = adamsPredict(x, step, stepSize, explicitCoefficients, derrivatives)
|
|
% predict
|
|
predictionOfX = x(:, step - 1);
|
|
for equationNumber = 1 : 2
|
|
for previous = 1:5
|
|
predictionOfX(equationNumber) = predictionOfX(equationNumber) ...
|
|
+ stepSize * explicitCoefficients(previous) * derrivatives(equationNumber, step - previous);
|
|
end
|
|
end
|
|
end
|
|
\end{lstlisting}
|
|
\end{simplechar}
|
|
|
|
\subsection{adamsEvaluate}
|
|
\begin{simplechar}
|
|
\begin{lstlisting}
|
|
function derrivativePrediction = adamsEvaluate(functions, predictionOfX, derrivativePrediction)
|
|
for equationNumber = 1:size(functions, 1)
|
|
derrivativePrediction(equationNumber) = functions{equationNumber}(predictionOfX);
|
|
end
|
|
end
|
|
\end{lstlisting}
|
|
\end{simplechar}
|
|
|
|
\subsection{adamsCorrect}
|
|
\begin{simplechar}
|
|
\begin{lstlisting}
|
|
function x = adamsCorrect(step, functions, stepSize, implicitCoefficients, derrivatives, derrivativePrediction, x)
|
|
x(:, step) = x(:, step - 1);
|
|
for equationNumber = 1:size(functions, 1)
|
|
for previous = 1:5
|
|
x(equationNumber, step) = x(equationNumber, step) + stepSize * implicitCoefficients(previous + 1) * derrivatives(equationNumber, step - previous);
|
|
end
|
|
x(equationNumber, step) = x(equationNumber, step) + stepSize * implicitCoefficients(1) * derrivativePrediction(equationNumber);
|
|
end
|
|
end
|
|
\end{lstlisting}
|
|
\end{simplechar}
|
|
|
|
\subsection{adamsEvaluateTwo}
|
|
\begin{simplechar}
|
|
\begin{lstlisting}
|
|
function derrivatives = adamsEvaluateTwo(functions, step, x, derrivatives)
|
|
for equationNumber = 1:size(functions, 1)
|
|
derrivatives(equationNumber, step) = functions{equationNumber}(x(:, step));
|
|
end
|
|
end
|
|
\end{lstlisting}
|
|
\end{simplechar}
|
|
|