mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-19 11:38:05 +02:00
Legendre-Symbol
This commit is contained in:
parent
a28f787179
commit
943a5c4aee
6 changed files with 137 additions and 3 deletions
BIN
source-code/Pseudocode/Calculate-Legendre/Calculate-Legendre.png
Normal file
BIN
source-code/Pseudocode/Calculate-Legendre/Calculate-Legendre.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
|
@ -0,0 +1,59 @@
|
|||
\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
|
||||
\usepackage[utf8]{inputenc} % this is needed for umlauts
|
||||
\usepackage[ngerman]{babel} % this is needed for umlauts
|
||||
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
|
||||
\usepackage{amssymb,amsmath,amsfonts} % nice math rendering
|
||||
\usepackage{braket} % needed for \Set
|
||||
\usepackage{algorithm,algpseudocode}
|
||||
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{decorations.pathreplacing,calc}
|
||||
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
|
||||
\newcommand*{\AddNote}[4]{%
|
||||
\begin{tikzpicture}[overlay, remember picture]
|
||||
\draw [decoration={brace,amplitude=0.5em},decorate,very thick]
|
||||
($(#3)!(#1.north)!($(#3)-(0,1)$)$) --
|
||||
($(#3)!(#2.south)!($(#3)-(0,1)$)$)
|
||||
node [align=center, text width=2.5cm, pos=0.5, anchor=west] {#4};
|
||||
\end{tikzpicture}
|
||||
}%
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{algorithm}[H]
|
||||
\begin{algorithmic}
|
||||
\Require $p \in \mathbb{P}, a \in \mathbb{Z}, p \geq 3$
|
||||
\If{$a \geq p$}\Comment{Regel (III)}
|
||||
\State \Return $\Call{CalculateLegendre}{a \mod p, p}$ \Comment{nun: $a \in [0, \dots, p-1]$}
|
||||
\ElsIf{$a \equiv 0 \mod p$} \Comment{Null-Fall}
|
||||
\State \Return 0
|
||||
\ElsIf{$a \equiv 1 \mod p$} \Comment{Eins-Fall}
|
||||
\State \Return 1
|
||||
\ElsIf{$a \equiv -1 \mod p$} \Comment{Regel (VI)}
|
||||
\If{$p \equiv 1 \mod 4$}
|
||||
\State \Return 1
|
||||
\Else
|
||||
\State \Return -1
|
||||
\EndIf
|
||||
\ElsIf{!$\Call{isPrime}{|a|}$} \Comment{Regel (II)}
|
||||
\State $p_1, p_2, \dots, p_n \gets \Call{Faktorisiere}{a}$
|
||||
\State \Return $\prod_{i=1}^n \Call{CalculateLegendre}{p_i, a}$
|
||||
\ElsIf{$p == 3$} \Comment{Regel (IV)}
|
||||
\State $t \gets p \mod 3$
|
||||
\If{$t == 2$}
|
||||
\State $t \gets -1$
|
||||
\EndIf
|
||||
\State \Return $t$
|
||||
\Else
|
||||
\State \Return $a^\frac{p-1}{2} \mod p$
|
||||
\EndIf
|
||||
\end{algorithmic}
|
||||
\caption{Calculate Legendre-Symbol}
|
||||
%\AddNote{top}{bottom}{right}{calclulate $p$ such that: $b^p \leq Z < b^{p+1}$} %\tikzmark{top},\tikzmark{right},\tikzmark{bottom}
|
||||
\label{alg:euclidBaseTransformation}
|
||||
\end{algorithm}
|
||||
\end{preview}
|
||||
\end{document}
|
36
source-code/Pseudocode/Calculate-Legendre/Makefile
Normal file
36
source-code/Pseudocode/Calculate-Legendre/Makefile
Normal file
|
@ -0,0 +1,36 @@
|
|||
SOURCE = Calculate-Legendre
|
||||
DELAY = 80
|
||||
DENSITY = 300
|
||||
WIDTH = 500
|
||||
|
||||
make:
|
||||
pdflatex $(SOURCE).tex -output-format=pdf
|
||||
pdflatex $(SOURCE).tex -output-format=pdf
|
||||
make clean
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot
|
||||
|
||||
gif:
|
||||
pdfcrop $(SOURCE).pdf
|
||||
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
|
||||
make clean
|
||||
|
||||
png:
|
||||
make
|
||||
make svg
|
||||
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
|
||||
|
||||
transparentGif:
|
||||
convert $(SOURCE).pdf -transparent white result.gif
|
||||
make clean
|
||||
|
||||
svg:
|
||||
make
|
||||
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
|
||||
pdf2svg $(SOURCE).pdf $(SOURCE).svg
|
||||
# Necessary, as pdf2svg does not always create valid svgs:
|
||||
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg
|
||||
rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg
|
||||
inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg
|
||||
rm $(SOURCE)2.svg
|
3
source-code/Pseudocode/Calculate-Legendre/Readme.md
Normal file
3
source-code/Pseudocode/Calculate-Legendre/Readme.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Compiled example
|
||||
----------------
|
||||

|
Loading…
Add table
Add a link
Reference in a new issue