diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/seu-ml-assign/README.md | 30 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-doc.pdf | bin | 0 -> 483948 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-doc.tex | 214 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-sample.tex | 384 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/seu-ml-assign/seu-ml-assign.cls | 298 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/collection-publishers.tlpsrc | 1 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/seu-ml-assign.tlpsrc | 0 |
7 files changed, 927 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/seu-ml-assign/README.md b/Master/texmf-dist/doc/latex/seu-ml-assign/README.md new file mode 100644 index 00000000000..86702d38129 --- /dev/null +++ b/Master/texmf-dist/doc/latex/seu-ml-assign/README.md @@ -0,0 +1,30 @@ +# SEU-ML-Assign LaTeX Template +LaTeX Template for Southeast University Machine Learning Assignment + +> GitHub Project Site: https://tvj.one/ml-tex + +## Class and Options +This project provides the `seu-ml-assign` class. + +| Option | Explanation | +| - | - | +| `solution` | Write solutions (for students). **[default]** | +| `problem` | Write problem sets (for instructors). | +| `9pt` | Set font size as 9 points. | +| `10pt` | Set font size as 10 points. **[default]** | +| `11pt` | Set font size as 11 points. | +| `12pt` | Set font size as 12 points. | + +## Commands and Usage +Please refer to the [documentation](seu-ml-assign-doc.pdf). + +## TODOs +- [x] Class Definition +- [x] Example `tex` File +- [x] Class Documentation +- [ ] Class Website +- [ ] Submission to CTAN +- [ ] Demonstration Video + +## License +This project is licensed under the [MIT License](LICENSE). diff --git a/Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-doc.pdf b/Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-doc.pdf Binary files differnew file mode 100644 index 00000000000..43504378ae4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-doc.pdf diff --git a/Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-doc.tex b/Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-doc.tex new file mode 100644 index 00000000000..c9556da7395 --- /dev/null +++ b/Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-doc.tex @@ -0,0 +1,214 @@ +%! TEX program = pdflatex + +\documentclass{seu-ml-assign} + +\title{Documentation} +\author{Teddy van Jerry} +\studentID{} +\instructor{TeX - LaTeX Stack Exchange} +\date{\today} +\duedate{20:00 March 21, 2022} +\assignno{1.0} +\semester{LaTeX Template} + +\renewcommand{\sectionheadname}{Section} +\renewcommand{\pdftitleadditionalname}{} + +\usepackage{booktabs} +\usepackage{colortbl} +% option for tabular with '\midrule' +\aboverulesep = 0mm \belowrulesep = 0mm + +\newcommand{\grayrow}{\rowcolor[rgb]{ .906, .902, .902}} + +\begin{document} + \maketitle + + \section{Basic Information of This Template Class} + + Despite this \textit{SEU-ML-Assign} class is dedicated to Southeast University as the Machine Learning assignment \LaTeX{} template both for teachers and students, it can also be used for other schools. + In the near future, it will eventually become an elegant template for all assignment requirememts. + + \begin{table}[htbp] + \bgroup + \def\arraystretch{1.2} + \setlength{\tabcolsep}{1.5em} + \begin{tabular}{ll} + \toprule + \grayrow \textbf{Package Class Name} & seu-ml-assign \\ + \textbf{Version} & 1.0 (2022/03/20) \\ + \grayrow \textbf{Description} & \LaTeX{} Template for Southeast University Machine Learning Assignment \\ + \textbf{Author} & Teddy van Jerry (Wuqiong Zhao) \\ + \grayrow \textbf{Maintainer} & Teddy van Jerry (Wuqiong Zhao) \\ + \textbf{GitHub Repository} & \url{https://tvj.one/ml-tex} \\ + \grayrow \textbf{Issues} & \url{https://tvj.one/ml-tex/issues} \\ + \textbf{Open Source License} & MIT License (\url{https://tvj.one/ml-tex/blob/master/LICENSE}) \\ + \bottomrule + \end{tabular}% + \egroup + \end{table} + + You can contact me at \href{mailto:me@tvj.one}{me@tvj.one} for support. + + \section{Class Options} + + To use this template, put \texttt{seu-ml-assign.cls} file under the same directory with your main \texttt{tex} file. + \begin{lstlisting}[language=tex,numbers=none] +\documentclass{seu-ml-assign} % SEU Machine Learning Assignment Template + \end{lstlisting} + There are 6 supported options: + \begin{table}[htbp] + \bgroup + \def\arraystretch{1.2} + \setlength{\tabcolsep}{1.5em} + \begin{tabular}{ll} + \toprule + \textbf{Option} & \textbf{Description} \\ + \midrule\midrule + \grayrow \texttt{solution} & Write solutions (for students). \textbf{[Default]} \\ + \texttt{problem} & Write problem sets (for instructors). \\ + \grayrow \texttt{9pt} & Set font size as 9 points. \\ + \texttt{10pt} & Set font size as 10 points. \textbf{[Default]} \\ + \grayrow \texttt{11pt} & Set font size as 11 points. \\ + \texttt{12pt} & Set font size as 12 points. \\ + \bottomrule + \end{tabular}% + \egroup + \end{table} + + For example, a 10pt document for instructors to create an assignment consisting of problem sets should use + + \begin{lstlisting}[language=tex,numbers=none] +\documentclass[10pt,problem]{seu-ml-assign} % The 10pt option can be omitted. + \end{lstlisting} + + There are several differences between the \texttt{solution} mode and \texttt{problem} mode, + including the preset texts on the document (for example the student name is not shown in the \texttt{problem} mode) and some properties can only be used with the \texttt{problem} mode which will be elaborated on in \S\ref{subsec:prob_only_properties}. + + \section{Document Properties} + + \subsection{Fields} + + There are several fields to set. + Consider the following example used in the sample file: + \begin{lstlisting}[language=tex,numbers=none] +\title{Assignment} % Document Type: assignment, quiz, etc. +\author{Teddy van Jerry} % Your Name +\studentID{61520522} % Your Student ID +\instructor{TeX - LaTeX Stack Exchange} % The Name of Your Instructor +\date{\today} % The Submission or Release Date +\duedate{20:00 March 21, 2022} % The Time the Assignment is Due +\assignno{1} % Assignment Number +\semester{SEU --- 2022 Spring} % Semester + \end{lstlisting} + + With these fields set, you can use the command \verb|\maketitle| to print the title. + At the same time, the metadata for the PDF document is automatically set. + + \subsection{Problem Mode Only Properties}\label{subsec:prob_only_properties} + One of the fields \verb|\author{}| and \verb|\instructor{}| can be omitted or set as empty provided that they are the same. + + \section{Section Title (Problem) Settings} + + \subproblem{Normal Title} + + The title of a problem can be set as \verb|\section{This is a Section Title}| or uses a higher level command \verb|\problem{This is a Section Title}|. + + \subproblem{Problem with Points} + + The points of a problem can be set using command \verb|\problempts{xxx}| before calling the \verb|\section{}| command. + These two commands can be simplified to \verb|\problem[xxx]{}|. + For example, using the command \verb|\problem[15]{This is a Problem Worth 15 Points}| will have:\vspace{-8mm} + + \renewcommand{\sectionheadname}{Problem} + \setproblem{1} + + % \problem[15]{This is a Problem Worth 15 Points} + \problempts{15} + \section*{This is a Problem Worth 15 Points} + Note that if the point is an empty string, the point information will not be shown. + + \subproblem{Long Title Compatibility} + There is also no problem if the section title is too long.\vspace{-8mm} + + \setproblem{2} + \problempts{20} + \section*{I Don't Think that Anyone Will Enjoy Themselves Seeing a Very Very Long Problem That is Worth Twenty Points in this Machine Learning Course} + + \renewcommand{\sectionheadname}{Section} + \setproblem{4} + + \subproblem{Section Title Name} + The name of the section (default name as \texttt{problem}) can be changed by using \verb|\renewcommand{\sectionheadname}{Name}|. + + \subproblem{Section Number} + The number of the section can be changed, for example \verb|\texttt{\setproblem{4}}| will make the next section number be \texttt{5}. + For experienced \LaTeX{} users to understand, this command actually change the section counter. + + \subproblem{Solution Declaration} + You can use \verb|\startsolution| to declare you start writing the solution. + This will reset the section number and it is especially useful when your document contains problems and solutions as two separate parts. + There is an option \texttt{print} and if you use \verb|\startsolution[print]| you will get: + + \startsolution[print] + and the word \textsc{Solution} can be changed using command \verb|\renewcommand{\solutionname}{Other Name}|. + + + \setproblem{4} + \section{Subsection Title (Sub Problem) Settings} + + \subproblem{Normal Title} This is a normal title using command \verb|\subproblem{Normal Title}| or its equivalent command \verb|\subsection{Normal Title}|. + + \subproblem{} Use \verb|\subproblem{}| or \verb|\subsection{}| if only the sub problem number is required (like this line). + + \subproblem{Subsection Number} Similar to \verb|\setproblem{}|, there is also \verb|\setsubproblem{}|. + + \section{Other Tools} + + \subsection{Equation Numbering} The equation number is within the section (problem), for example + + \begin{equation}\label{eq:2-1-det} + \mathrm{det}(\mathbf{A})=1\times\begin{vNiceArray}{rr} + -5&3\\-6&4 + \end{vNiceArray}-(-3)\times\begin{vNiceArray}{rr} + 3&3\\6&4 + \end{vNiceArray}+3\times\begin{vNiceArray}{rr} + 3&-5\\6&-6 + \end{vNiceArray}=1\times(-2)+3\times(-6)+3\times 12=16. + \end{equation} + + \subsection{Maths Packages} Maths Package \texttt{mathtools}, \texttt{amssymb}, \texttt{amsthm}, \texttt{bm} and \texttt{nicematrix} are automatically loaded. + The \texttt{nicematrix} package is especially powerful in terms of writing a matrix. + You can find its documentation at \url{https://ctan.org/pkg/nicematrix}. + + \subsection{Fancy Box} A fancy box has been defined. + \begin{fancybox}{This is a Title} + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin viverra massa rutrum felis vulputate, ac faucibus velit accumsan. Vivamus aliquet felis nec interdum sollicitudin. Nullam ornare eu velit id cursus. Maecenas a sodales velit, vel cursus magna. Cras lobortis venenatis. + \end{fancybox} + + + You can use the following code to generate it. + \begin{lstlisting}[language=tex,numbers=none,morekeywords={begin}] +\begin{fancybox}{This is a Title} + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin viverra massa rutrum felis vulputate, ac faucibus velit accumsan. Vivamus aliquet felis nec interdum sollicitudin. Nullam ornare eu velit id cursus. Maecenas a sodales velit, vel cursus magna. Cras lobortis venenatis. +\end{fancybox} + \end{lstlisting} + + \appendix + \renewcommand{\sectionheadname}{Appendix} + + \section{Known Issues}\label{sec:known_issues} + + \begin{itemize} + \item \verb|\section*{}| still shows the section number except for it does not increment the section counter by one; + \item The section title background height may not be accurate; + \item The style of the footnote line has not been adapted to the current colorful theme. + \end{itemize} + + \section{Source Code} + + The source code of \texttt{SEU-ML-Assign.cls} is listed below. + + \lstinputlisting[language=tex,linerange={15-1000},firstnumber=15]{SEU-ML-Assign.cls} + +\end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-sample.tex b/Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-sample.tex new file mode 100644 index 00000000000..de5bf5f8330 --- /dev/null +++ b/Master/texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-sample.tex @@ -0,0 +1,384 @@ +%! TEX program = pdflatex + +\documentclass[solution]{seu-ml-assign} + +\title{Assignment} +\author{Teddy van Jerry} +\studentID{61520522} +\instructor{TeX - LaTeX Stack Exchange} +\date{\today} +\duedate{20:00 March 21, 2022} +\assignno{1} +\semester{SEU --- 2022 Spring} + +\begin{document} + +\maketitle + +% \startsolution[print] + +\problem{Basic Vector Operations} +\subproblem{} +$\|\mathbf{a}\|_2=\sqrt{1^2+2^2+3^2}=\sqrt{14},\quad \|\mathbf{b}\|_2=\sqrt{(-8)^2+1^2+2^2}=\sqrt{69}$. + +\subproblem{} +$\|\mathbf{a}-\mathbf{b}\|_2=\sqrt{9^2+1^2+1^2}=\sqrt{83}$. + +\subproblem{} +$\mathbf{a}$ and $\mathbf{b}$ are orthogonal. +\begin{proof} +The inner product of vectors $\mathbf{a}$ and $\mathbf{b}$ is +\begin{equation} +\langle\mathbf{a},\mathbf{b}\rangle=\mathbf{a}^T\mathbf{b}=1\times(-8)+2\times 1+3\times 2=0, +\end{equation} +therefore $\mathbf{a}$ and $\mathbf{b}$ are orthogonal. +\end{proof} + +\problem{Basic Matrix Operations} +According to the consensus, the matrix notation should be the bold upper-case letter like $\mathbf{A}$ or $\bm{A}$, not $A$. + +\subproblem{} +\begin{equation} + \begin{aligned} + [\mathbf{A}, \mathbf{I}_3]&= + \begin{bNiceArray}{rrr:rrr} + 1&-3&3&1&0&0\\3&-5&3&0&1&0\\6&-6&4&0&0&1 + \end{bNiceArray}\sim + \begin{bNiceArray}{rrr:rrr} + 1&-3&3&1&0&0\\0&4&-6&-3&1&0\\0&12&-14&-6&0&1 + \end{bNiceArray}\sim + \begin{bNiceArray}{rrr:rrr} + 1&-3&3&1&0&0\\0&4&-6&-3&1&0\\0&0&4&3&-3&1 + \end{bNiceArray}\\ + &\sim + \begin{bNiceArray}{rrr:rrr} + 1&-3&0&-\frac{5}{4}&\frac{9}{4}&\frac{3}{4}\\[0.3em]0&4&0&\frac{3}{2}&-\frac{7}{2}&-\frac{3}{2}\\[0.3em]0&0&1&\frac{3}{4}&-\frac{3}{4}&\frac{1}{4} + \end{bNiceArray}\sim + \begin{bNiceArray}{rrr:rrr} + 1&0&0&-\frac{1}{8}&-\frac{3}{8}&\frac{3}{8}\\[0.3em]0&1&0&\frac{3}{8}&-\frac{7}{8}&\frac{3}{8}\\[0.3em]0&0&1&\frac{3}{4}&-\frac{3}{4}&\frac{1}{4} + \end{bNiceArray}, + \end{aligned} +\end{equation} +where $\mathbf{I}_3$ is the $3\times 3$ identity matrix. +Therefore we have +\begin{equation}\label{eq:2-1-inv} + \mathbf{A}^{-1}= + \begin{bNiceArray}{rrr} + -\frac{1}{8}&-\frac{3}{8}&\frac{3}{8}\\[0.3em]\frac{3}{8}&-\frac{7}{8}&\frac{3}{8}\\[0.3em]\frac{3}{4}&-\frac{3}{4}&\frac{1}{4} + \end{bNiceArray}. +\end{equation} +The determinant of matrix $\mathbf{A}$ can be calculated as +\begin{equation}\label{eq:2-1-det} + \mathrm{det}(\mathbf{A})=1\times\begin{vNiceArray}{rr} + -5&3\\-6&4 + \end{vNiceArray}-(-3)\times\begin{vNiceArray}{rr} + 3&3\\6&4 + \end{vNiceArray}+3\times\begin{vNiceArray}{rr} + 3&-5\\6&-6 + \end{vNiceArray}=1\times(-2)+3\times(-6)+3\times 12=16, +\end{equation} +where $|\cdot|$ denotes the determinant. + +\subproblem{} +The rank of matrix $\mathbf{A}$ is $3$ because as is shown in Eq.~\eqref{eq:2-1-inv} the matrix $\mathbf{A}$ is invertible. + +\subproblem{} +The trace of matrix $\mathbf{A}$ is +\begin{equation} + \mathrm{tr}(\mathbf{A})=\sum_{i=1}^{3}a_{ii}=1+(-5)+4=0. +\end{equation} + +\begin{equation} + \mathbf{A}+\mathbf{A}^{T}=\begin{bNiceArray}{rrr} + 1&-3&3\\3&-5&3\\6&-6&4 + \end{bNiceArray}+ + \begin{bNiceArray}{rrr} + 1&3&6\\-3&-5&-6\\3&3&4 + \end{bNiceArray}= + \begin{bNiceArray}{rrr} + 2&0&9\\0&-10&-3\\9&-3&8 + \end{bNiceArray}. +\end{equation} + +\subproblem{} +\begin{equation} + \mathbf{A}+\mathbf{A}^{T}=\begin{bNiceArray}{rrr} + 1&-3&3\\3&-5&3\\6&-6&4 + \end{bNiceArray}+ + \begin{bNiceArray}{rrr} + 1&3&6\\-3&-5&-6\\3&3&4 + \end{bNiceArray}= + \begin{bNiceArray}{rrr} + 2&0&9\\0&-10&-3\\9&-3&8 + \end{bNiceArray}. +\end{equation} + +\subproblem{} +$\mathbf{A}$ is not an orthogonal matrix. +\begin{proof} + Assume $\mathbf{A}$ is an orthogonal matrix, + therefore + \begin{equation} + \mathbf{AA}^{T}=\mathbf{I}_3, + \end{equation} + Take the determinant at both side, it can be derived that + \begin{equation} + |\mathrm{det}(\mathbf{A})|=\sqrt{|\mathbf{A}||\mathbf{A}^T|}=|\mathrm{det}(\mathbf{I}_3)|=1, + \end{equation} + which contradicts with Eq.~\eqref{eq:2-1-det}. + Therefore, the assumption is false. +\end{proof} + +\subproblem{} +Let $f(\lambda)$ be the characteristic function of matrix $\mathbf{A}$ and +\begin{equation}\label{eq:2-6-f} + f(\lambda)=\begin{vNiceArray}{ccc} + \lambda-1&3&-3\\-3&\lambda+5&-3\\-6&6&\lambda-4 + \end{vNiceArray}=(\lambda-4)(\lambda+2)^2, +\end{equation} +therefore the eigenvalues are $\lambda_1=4, \lambda_2=\lambda_3=-2$. +Let the corresponding eigenvectors be $\bm{\alpha}_i$, $i=1,2,3$. +\begin{equation} + (\mathbf{A}-\lambda_i\mathbf{I}_3)\bm{\alpha}_i=\mathbf{0},\quad i=1,2,3, +\end{equation} +and the corresponding eigenvectors are +\begin{equation} + \bm{\alpha}_1=\begin{bNiceArray}{ccc}1&1&2\end{bNiceArray}^T,\quad + \bm{\alpha}_{2,3}=\begin{bNiceArray}{ccc}1&1+c_{2,3}&c_{2,3}\end{bNiceArray}^T, +\end{equation} +where $c_{2,3}\in\mathbb{R}$. +Without loss of generality, we take $c_2=0$ and $c_3=-1$, and we have $\bm{\alpha}_2=\begin{bNiceArray}{ccc}1&1&0\end{bNiceArray}^T$ and $\bm{\alpha}_2=\begin{bNiceArray}{ccc}1&0&-1\end{bNiceArray}^T$. + +\subproblem{} +Use the result from Eq.~\eqref{eq:2-6-f}, the matrix $\mathbf{A}$ can be diagonalized as +\begin{equation} + \bm{\Lambda}=\begin{bNiceArray}{rrr} + 4&0&0\\0&-2&0\\0&0&-2 + \end{bNiceArray}. +\end{equation} + +\subproblem{} +The $\ell_{2,1}$ norm of $\mathbf{A}$ is +\begin{equation} + \|\mathbf{A}\|_{2,1}=\sum_{i=1}^3\sqrt{\sum_{j=1}^3a_{ij}^2}=\sqrt{46}+\sqrt{70}+\sqrt{34}\approx 20.98, +\end{equation} +and the Frobenius norm of $\mathbf{A}$ is +\begin{equation} + \|\mathbf{A}\|_F=\sqrt{\sum_{i,j=1,\mathrlap{2,3}}a_{ij}^2}=\sqrt{150}=5\sqrt{6}\approx 12.247. +\end{equation} + +\subproblem{} +The nuclear norm of $\mathbf{A}$ is +\begin{equation} + \|\mathbf{A}\|_*=\mathrm{tr}(\sqrt{\mathbf{A}\mathbf{A^*}})=\sum_{i=1}^3\sigma_i(\mathbf{A})\approx 14.728, +\end{equation} +and the spectral norm of $\mathbf{A}$ is +\begin{equation} + \|\mathbf{A}\|_2=\max\sigma_i(\mathbf{A})\approx 12.065. +\end{equation} + +\vspace{2mm} +\begin{lstlisting}[language=Matlab, title={MATLAB Code for Check}] +A = [1, -3, 3; 3, -5, 3; 6, -6, 4]; % define the matrix A +inv(A) % calculate and print the inverse of A +det(A) % the determinant of A +rank(A) % the rank of A +trace(A) % the trace of A +A + A.' % the sum of A and the transpose of A +sum(sum(A * A.' ~= eye(3))) % check if A is orthogonal +[X, D] = eig(A) % the eigenvectors and the corresponding eigenvalues of A +sum(sqrt(sum(A .^ 2))) % l-2,1 norm of A +norm(A, 'fro') % Frobenius norm of A +sum(svd(A)) % nuclear norm of A +max(svd(A)) % spectral norm of A +\end{lstlisting} + +\problem{Linear Equations} +\subproblem{} +It is evident to solve the linear equation +\begin{equation}\label{eq:3-1} + \left\{ + \begin{aligned} + x_1&=-1, \\ + x_2&=0, \\ + x_3&=1. + \end{aligned} + \right. +\end{equation} + +\subproblem{} +Let +\begin{equation} + \mathbf{A}=\begin{bNiceArray}{rrr} + 2&2&3\\1&-1&0\\-1&2&1 + \end{bNiceArray},\quad + \mathbf{b}= + \begin{bNiceArray}{r} + 1\\-1\\2 + \end{bNiceArray}, +\end{equation} +and we have $\mathbf{Ax}=\mathbf{b}$ as +\begin{equation} + \begin{bNiceArray}{rrr} + 2&2&3\\1&-1&0\\-1&2&1 + \end{bNiceArray} + \begin{bNiceArray}{r} + x_1\\x_2\\x_3 + \end{bNiceArray}= + \begin{bNiceArray}{r} + 1\\-1\\2 + \end{bNiceArray}. +\end{equation} + +\subproblem{} +Since there is a unique solution shown in Eq.~\eqref{eq:3-1}, we know +\begin{equation}\label{eq:3-3} + \mathrm{rank}(\mathbf{A})=3. +\end{equation} + +\subproblem{} +\begin{equation} + \begin{aligned} + [\mathbf{A}, \mathbf{I}_3]&= + \begin{bNiceArray}{rrr:rrr} + 2&2&3&1&0&0\\1&-1&0&0&1&0\\-1&2&1&0&0&1 + \end{bNiceArray}\sim + \begin{bNiceArray}{rrr:rrr} + 2&2&3&1&0&0\\1&-1&0&0&1&0\\0&1&1&0&1&1 + \end{bNiceArray}\sim + \begin{bNiceArray}{rrr:rrr} + 1&1&\frac{3}{2}&\frac{1}{2}&0&0\\1&-1&0&0&1&0\\0&1&1&0&1&1 + \end{bNiceArray}\\ + &\sim + \begin{bNiceArray}{rrr:rrr} + 1&1&\frac{3}{2}&\frac{1}{2}&0&0\\[0.3em]0&-2&-\frac{3}{2}&-\frac{1}{2}&1&0\\[0.3em]0&1&1&0&1&1 + \end{bNiceArray}\sim + \begin{bNiceArray}{rrr:rrr} + 1&1&\frac{3}{2}&\frac{1}{2}&0&0\\[0.3em]0&-1&-\frac{3}{4}&-\frac{1}{4}&\frac{1}{2}&0\\[0.3em]0&0&\frac{1}{4}&-\frac{1}{4}&\frac{3}{2}&1 + \end{bNiceArray}\sim + \begin{bNiceArray}{rrr:rrr} + 1&1&0&2&-9&-6\\[0.3em]0&-1&0&-1&5&3\\[0.3em]0&0&1&-1&6&4 + \end{bNiceArray}\\ + &\sim + \begin{bNiceArray}{rrr:rrr} + 1&0&0&1&-4&-3\\0&1&0&1&-5&-3\\0&0&1&-1&6&4 + \end{bNiceArray}, + \end{aligned} +\end{equation} +therefore the inverse of $\mathbf{A}$ is +\begin{equation}\label{eq:3-4-inv} + \mathbf{A}^{-1}=\begin{bNiceArray}{rrr} + 1&-4&-3\\1&-5&-3\\-1&6&4 + \end{bNiceArray}. +\end{equation} +The determinant of $\mathbf{A}$ can be calculated as +\begin{equation} + \mathrm{det}(\mathbf{A})=2\times\begin{vNiceArray}{rr} + -1&0\\2&1 + \end{vNiceArray}-2\times\begin{vNiceArray}{rr} + 1&0\\-1&1 + \end{vNiceArray}+3\times\begin{vNiceArray}{rr} + 1&-1\\-1&2 + \end{vNiceArray}=2\times(-1)-2\times 1+3\times 1=-1. +\end{equation} + +\subproblem{} +As is shown in Eq.~\eqref{eq:3-3}, $\mathbf{A}$ is invertible and with the result in Eq.~\eqref{eq:3-4-inv} +\begin{equation} + \mathbf{x}=\mathbf{A}^{-1}\mathbf{b}= + \begin{bNiceArray}{rrr} + 1&-4&-3\\1&-5&-3\\-1&6&4 + \end{bNiceArray} + \begin{bNiceArray}{r} + 1\\-1\\2 + \end{bNiceArray}= + \begin{bNiceArray}{r} + -1\\0\\1 + \end{bNiceArray}, +\end{equation} +and it is exactly the same result with Eq.~\eqref{eq:3-1}. + +\subproblem{} +The inner product +\begin{equation} + \langle\mathbf{x},\mathbf{b}\rangle=\mathbf{x}^T\mathbf{b}=1\times 1+0\times(-1)+1\times 2=1, +\end{equation} +and the outer product is +\begin{equation} + \mathbf{x}\otimes\mathbf{b}=\mathbf{x}\mathbf{b}^T= + \begin{bNiceArray}{r} + -1\\0\\1 + \end{bNiceArray} + \begin{bNiceArray}{rrr} + 1&-1&2 + \end{bNiceArray}= + \begin{bNiceArray}{rrr} + -1&1&-2\\0&0&0\\1&-1&2 + \end{bNiceArray}. +\end{equation} + +\subproblem{} +$\|\mathbf{b}\|_1=|1|+|-1|+|2|=4,\quad\|\mathbf{b}\|_2=\sqrt{1^2+(-1)^2+2^2}=\sqrt{6},\quad\|\mathbf{b}\|_{\infty}=\max\{|1|,|-1|,|2|\}=2.$ + +\subproblem{} +Let $\mathbf{y}=\begin{bNiceArray}{rrr} + y_1&y_2&y_3 +\end{bNiceArray}^T$, +we have +\begin{equation} + \mathbf{y}^T\mathbf{Ay}= + \begin{bNiceArray}{rrr} + y_1&y_2&y_3 + \end{bNiceArray} + \begin{bNiceArray}{rrr} + 2&2&3\\1&-1&0\\-1&2&1 + \end{bNiceArray} + \begin{bNiceArray}{r} + y_1\\y_2\\y_3 + \end{bNiceArray}=2y_1^2-y_2^2+y_3^2+3y_1y_2+2y_2y_3+2y_1y_3, +\end{equation} +and +\begin{equation} + \bigtriangledown_{\mathbf{y}}\mathbf{y}^T\mathbf{Ay}= + \begin{bNiceArray}{r} + \frac{\partial}{\partial y_1}\mathbf{y}^T\mathbf{Ay} \\[.3em] + \frac{\partial}{\partial y_2}\mathbf{y}^T\mathbf{Ay} \\[.3em] + \frac{\partial}{\partial y_3}\mathbf{y}^T\mathbf{Ay} + \end{bNiceArray}= + \begin{bNiceArray}{r} + 4y_1+3y_2+2y_3 \\ + 3y_1-2y_2+2y_3 \\ + 2y_1+2y_2+2y_3 + \end{bNiceArray}. +\end{equation} + +\subproblem{} +The equation $\mathbf{A}_1\mathbf{x}=\mathbf{b}_1$ can be represented as +\begin{equation} + \begin{bNiceArray}{rrr} + 2&2&3\\1&-1&0\\-1&2&1\\-1&2&1 + \end{bNiceArray} + \begin{bNiceArray}{r} + x_1\\x_2\\x_3 + \end{bNiceArray}= + \begin{bNiceArray}{r} + 1\\-1\\2\\2 + \end{bNiceArray}. +\end{equation} + +\subproblem{} +$\mathrm{rank}(\mathbf{A}_1)=3$. +\begin{proof} + On one hand, $\mathrm{rank}(\mathbf{A}_1)\geq\mathrm{rank}(\mathbf{A})=3$ which is shown in Eq.~\eqref{eq:3-3}. + On the other hand, $\mathrm{rank}(\mathbf{A}_1)\leq\min\{3,4\}=3$. + Therefore, $\mathrm{rank}(\mathbf{A}_1)=3$. + We can also find the first three equations are linearly independent while the last equation is actually the same with the third equation which makes it meaningless. +\end{proof} + +\subproblem{} +Yes. +\begin{proof} + Since $\mathrm{rank}(\mathbf{A}_1)=\|\mathbf{x}\|_0$, i.e. rank of $\mathbf{A}_1$ is equal to the dimension of $\mathbf{x}$, the formula can be solved with a unique solution the same as Eq.~\eqref{eq:3-1}. +\end{proof} + +\end{document} diff --git a/Master/texmf-dist/tex/latex/seu-ml-assign/seu-ml-assign.cls b/Master/texmf-dist/tex/latex/seu-ml-assign/seu-ml-assign.cls new file mode 100644 index 00000000000..eedc7c2f0b5 --- /dev/null +++ b/Master/texmf-dist/tex/latex/seu-ml-assign/seu-ml-assign.cls @@ -0,0 +1,298 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% +%% seu-ml-assign.cls %% +%% %% +%% ================================================== %% +%% %% +%% Version: 1.0 (2022/03/20) %% +%% Author: Teddy van Jerry (Wuqiong Zhao) %% +%% License: MIT LICENSE %% +%% GitHub Repo: https://tvj.one/ml-tex %% +%% Compiler: pdflatex, xelatex, lualatex %% +%% %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{seu-ml-assign}[2022/02/20 SEU Machine Learning Assignment Template] + +%% Class and Options +\def\@@ptsize{10pt} % font size +\DeclareOption{9pt}{\def\@@ptsize{9pt}} +\DeclareOption{10pt}{\def\@@ptsize{10pt}} +\DeclareOption{11pt}{\def\@@ptsize{11pt}} +\DeclareOption{12pt}{\def\@@ptsize{12pt}} +\def\@@solutionmode{1} % default as the solution mode +\DeclareOption{solution}{\def\@@solutionmode{1}} % solution mode +\DeclareOption{problem}{\def\@@solutionmode{0}} % problem mode +\ProcessOptions\relax +\LoadClass[a4paper,onecolumn,\@@ptsize]{article} + +%% Page Settings +\RequirePackage[inner=2.0cm,outer=2.0cm,top=1.2cm,bottom=3.5cm]{geometry} +\newcommand{\firstfooteradditionalheight}{2em} % additional height for footer on the first page +\hfuzz=.5em % disable false positive of overfull \hbox + +%% Document Propertities +\global\let\@assignno\@empty +\global\let\@semester\@empty +\global\let\@studentID\@empty +\global\let\@instructor\@empty +\global\let\@duedate\@empty +\global\let\@author\@empty +\newcommand{\assignno}[1]{\gdef\@assignno{#1}} % Assignment Number +\newcommand{\semester}[1]{\gdef\@semester{#1}} % Semester +\newcommand{\studentID}[1]{\gdef\@studentID{#1}} % Student ID +\newcommand{\instructor}[1]{\gdef\@instructor{#1}} % Instructor +\newcommand{\duedate}[1]{\gdef\@duedate{#1}} % Due Date of the Assignment + +%% Fonts and Colors +\RequirePackage[T1]{fontenc} +\RequirePackage[usenames,dvipsnames]{xcolor} + +%% TikZ Rule +\RequirePackage{tikz} +\usetikzlibrary{fadings, calc} +\newcommand{\tikzrule}[3][]{\tikz{\fill[#1] (0,0) rectangle (#2,#3);}} + +%% Sections Settings +\RequirePackage[explicit]{titlesec} % explained in https://tex.stackexchange.com/a/292307/234654 +% http://mirrors.ctan.org/macros/latex/contrib/titlesec/titlesec.pdf +\pgfdeclarelayer{background} +\pgfsetlayers{background,main} +\global\let\@problempts\@empty +\newcommand{\problempts}[1]{\gdef\@problempts{#1}} % Points of the Problem +\newcommand{\problemptsprint}{\ifx\@problempts\@empty\else(\@problempts~points)\fi} +\newcommand{\sectionheadname}{Problem} % Name for the Section (default as 'Problem') +% Reference: https://tex.stackexchange.com/a/12269/234654 +\newcommand{\boxedsection}[3][blue!20]{{% + \begin{tikzpicture}[inner sep=0pt, inner ysep=0.3ex] + \node[anchor=base west] at (0,0) (counter) {#2}; + \path let \p1 = (counter.base east) in node[anchor=base west, text width={\textwidth-\x1-0.33em}] (content) + at ($(counter.base east)+(0.33em,0)$) {#3}; + \begin{pgfonlayer}{background} + \shade[left color=#1,right color=white] let \p1=(counter.north), \p2=(content.north) in + (0,{max(\y1,\y2)}) rectangle (content.south east); + \end{pgfonlayer} + \end{tikzpicture} +}} +% \titleformat{<command>} +% [<shape>]{<format>}{<label>}{<sep>}{<before-code>}[<after-code>] +\titleformat{\section}% + {\Large\bfseries}% + {}% + {0pt}% + {\boxedsection{\sectionheadname{} \thesection:}{#1}}% + [% + \vspace{-2.1\baselineskip}\hfill{\normalfont\small\problemptsprint}% + \problempts{}% clear the problem points + ]% +\newcommand{\setproblem}[1]{\ifx#1\@empty\else\setcounter{section}{#1}\fi} % force the number of problem +\newcommand{\setsubproblem}[1]{\ifx#1\@empty\else\setcounter{subsection}{#1}\fi} % force the number of subproblem +\newcommand{\problem}[2][]{\problempts{#1}\section{#2}}% +\newcommand{\solutionname}{Solution} +\newcommand{\startsolution}[1][print]{% + \setproblem{0}% reset the section counter + \def\startsolutionprintoption{print} + \def\startsolutionprintuseroption{#1} + \ifx\startsolutionprintuseroption\startsolutionprintoption{% + {% + \fontfamily{LinuxLibertineT-OsF}\selectfont% select font as Linux Libertine + \centering\LARGE\scshape% + \solutionname{}\\[-0.2em]% + }% + \noindent% + \tikzrule[WildStrawberry, path fading=west]{.5\textwidth}{.2em}% <-- Do not remove this + \tikzrule[WildStrawberry, path fading=east]{.5\textwidth}{.2em} + }\fi% +} +\titlespacing*{\section}{0em}{2.5\baselineskip}{1\baselineskip} +\titleformat{\subsection}[runin]{\large\bfseries}{}{0pt}{(\arabic{subsection}) #1}% +\newcommand{\subproblem}[2][]{\subsection[#1]{#2}} +\titleformat{\subsubsection}[runin]{}{}{0pt}{(\arabic{subsubsection}. #1} + +%% Maths Settings +\RequirePackage{mathtools} +\RequirePackage{amssymb} +\RequirePackage{amsthm} % proof environment and others +\RequirePackage{bm} % \bm command +\RequirePackage{nicematrix} +\numberwithin{equation}{section} + +%% Code Block Settings +\RequirePackage{listings} +\definecolor{dkgreen}{rgb}{0,0.5,0} +\definecolor{gray}{rgb}{0.5,0.5,0.5} +\definecolor{mauve}{rgb}{0.58,0,0.82} +\lstset{ + numbers=left, + frame=tb, + aboveskip=3mm, + belowskip=3mm, + showstringspaces=false, + columns=fixed, + framerule=1pt, + rulecolor=\color{gray!35}, + backgroundcolor=\color{gray!5}, + basicstyle={\ttfamily\small}, + numberstyle=\footnotesize\color{gray}, + keywordstyle=\bfseries\color{blue}, + commentstyle=\color{dkgreen}, + stringstyle=\color{mauve}, + breaklines=true, + breakatwhitespace=true, + tabsize=2, + extendedchars=false, + postbreak=\mbox{\hspace{-1.4em}\textcolor{purple}{$\hookrightarrow$}\space} +} + +%% Captions Settings +\RequirePackage[font=footnotesize,labelfont=bf]{caption} + +%% Color Boxes +\RequirePackage[many]{tcolorbox} +\RequirePackage{varwidth} +\newtcolorbox{fancybox}[2][]{enhanced,skin=enhancedlast jigsaw, + attach boxed title to top left={xshift=-4mm,yshift=-0.5mm}, + fonttitle=\bfseries\sffamily,varwidth boxed title=0.7\linewidth, + colbacktitle=blue!45!white,colframe=red!50!black, + interior style={top color=blue!10!white,bottom color=red!10!white}, + boxed title style={empty,arc=0pt,outer arc=0pt,boxrule=0pt}, + underlay boxed title={ + \fill[blue!45!white] (title.north west) -- (title.north east) + -- +(\tcboxedtitleheight-1mm,-\tcboxedtitleheight+1mm) + -- ([xshift=4mm,yshift=0.5mm]frame.north east) -- +(0mm,-1mm) + -- (title.south west) -- cycle; + \fill[blue!45!white!50!black] ([yshift=-0.5mm]frame.north west) + -- +(-0.4,0) -- +(0,-0.3) -- cycle; + \fill[blue!45!white!50!black] ([yshift=-0.5mm]frame.north east) + -- +(0,-0.3) -- +(0.4,0) -- cycle; }, + title={#2},#1 +} +\newtcolorbox{notice}[2][]{enhanced, + colframe=blue!50!black,colback=blue!10!white,colbacktitle=blue!5!yellow!10!white, + fonttitle=\bfseries,coltitle=black,attach boxed title to top center= + {yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2}, + boxed title style={boxrule=0.5mm, + frame code={ \path[tcb fill frame] ([xshift=-4mm]frame.west) + -- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east) + -- (frame.south east) -- (frame.south west) -- cycle; }, + interior code={ \path[tcb fill interior] ([xshift=-2mm]interior.west) + -- (interior.north west) -- (interior.north east) + -- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west) + -- cycle;} }, + title={#2},#1 +} + +%% Header and Footer +\RequirePackage{fancyhdr} +\RequirePackage[colorlinks=true,urlcolor=blue,linkcolor=purple,citecolor=red]{hyperref} +\setlength{\headheight}{52pt} +\setlength{\marginparwidth}{2cm} +\pagestyle{fancy} +\lhead{ + \fontfamily{LinuxLibertineT-OsF}\selectfont + \if\@@solutionmode1 + \textsc{\@title~\@assignno} -- \@studentID~\@author + \else + \textsc{Machine Learning \@title~\@assignno} + \fi +} + +\rhead{\thepage} +\renewcommand\headrule{\vspace{-0.7em}\tikzrule[BrickRed, path fading=east]{.5\textwidth}{0.3mm}} +\cfoot{} +% header and footer style for the first page +\fancypagestyle{firstpage}{ + \renewcommand\headrule{} + \lhead{} + \rhead{} + \cfoot{ + \fontfamily{LinuxLibertineT-OsF}\selectfont + \vspace*{-\firstfooteradditionalheight} + \vspace{-1.5em} + \tikzrule[purple, path fading=west]{.5\textwidth}{.15em}% <-- Do not remove this + \tikzrule[purple, path fading=east]{.5\textwidth}{.15em} + + \footnotesize\centering + \if\@@solutionmode1 + This \MakeLowercase{\@title{}} is due \@duedate{} and the date of submission is \@date. + \else + This \MakeLowercase{\@title{}} is due \textbf{\@duedate{}} and the version of the problem set is \@date. + \fi + + % LaTeX template information + \LaTeX{} template for this \MakeLowercase{\@title{}} is \textit{SEU-ML-Assign} + open source at \href{https://tvj.one/ml-tex}{tvj.one/ml-tex} under the MIT License. + E-mail \href{mailto:me@tvj.one}{me@tvj.one} for support. + } +} + +%% Title Settings +\RequirePackage{tabularx} +\RequirePackage{afterpage} +\newcommand{\pdftitleadditionalname}{Solution} +\makeatletter +\renewcommand\maketitle{ + + \if\@@solutionmode0 + \ifx\@instructor\@empty + \let\@instructor\@author % author is the instructor (if not specified) + \else + \ifx\@author\@empty + \let\@author\@instructor % instructor is the author (if not specified) + \fi + \fi + \fi + + \thispagestyle{firstpage} + \fontfamily{LinuxLibertineT-OsF}\selectfont % set font as Linux Libertine + \enlargethispage{-\firstfooteradditionalheight} % make room for the footer + \begin{minipage}{10.5cm} + \centering + { + \fontsize{36}{48}\selectfont + \textcolor{Plum}{\scshape Machine Learning} + }\\[.5em] + { + \if\@@solutionmode1 + \@studentID~\@author + \qquad + \fi + \textit{Instructor:~\@instructor} + } + \end{minipage} + \begin{minipage}{5cm} + \vspace{0.7em} + \centering + { + \large + \textcolor{BrickRed}{\sffamily \@semester} + \vspace{2mm} + } + \LARGE\@title~{\fontfamily{bch}\selectfont\@assignno} + \end{minipage} + \\[.3em] + \tikzrule[cyan, path fading=east]{\textwidth}{.4em} + \vspace{2mm} + + \fontfamily{cmr}\selectfont % Computer Modern + + % Set up document meta data + % Note that it should be placed here because + % by now \@author and \@title have been set. + \hypersetup{ + pdfauthor={\@author}, + pdftitle={% + \@title~\@assignno~ + \if\@@solutionmode1 + \pdftitleadditionalname{} + \fi + - Machine Learning + }, + pdfsubject={Machine Learning}, + pdfkeywords={Machine Learning, \@title}, + pdfcreator={LaTeX with SEU-ML-Assign class}, + pdfproducer={LaTeX} + } +} +\makeatother diff --git a/Master/tlpkg/tlpsrc/collection-publishers.tlpsrc b/Master/tlpkg/tlpsrc/collection-publishers.tlpsrc index b95aaa54bec..1a1df81012e 100644 --- a/Master/tlpkg/tlpsrc/collection-publishers.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-publishers.tlpsrc @@ -181,6 +181,7 @@ depend schule depend scrjrnl depend scientific-thesis-cover depend sduthesis +depend seu-ml-assign depend seuthesis depend seuthesix depend shortmathj diff --git a/Master/tlpkg/tlpsrc/seu-ml-assign.tlpsrc b/Master/tlpkg/tlpsrc/seu-ml-assign.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/seu-ml-assign.tlpsrc |