Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
feat: add homework_7 report
Browse files Browse the repository at this point in the history
  • Loading branch information
tiankaima committed Jan 3, 2024
1 parent 068a107 commit f568ae0
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
77 changes: 77 additions & 0 deletions homeworks/reports/data/report_8_output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
iterations: 61053
time spent: 2837150us
eigenvalues = [ -8.666483 -4.981007 -1.140182 -0.703989 0.375993 0.880006 1.898629 2.602050 3.144497 5.947023 32.297933 214.310227 ]
ep = 0.000000
eq = 0.000000
et = 0.000215
T=
[[ 214.310227 ],
[ 0.375993 ],
[ -0.703989 ],
[ 1.898629 ],
[ 2.602050 ],
[ 0.880006 ],
[ -1.140182 ],
[ 3.144497 ],
[ 5.947023 ],
[ -4.981007 ],
[ -8.666483 ],
[ 32.297933 ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ]]
P=
[[ -0.201521 -0.290610 -0.190181 -0.254386 -0.201216 -0.262533 -0.243492 -0.159834 -0.216831 -0.092888 -0.158165 -0.147892 -0.147795 -0.158657 -0.218459 -0.159834 -0.242183 -0.114773 -0.093357 -0.122810 -0.194173 -0.113186 -0.245103 -0.212867 -0.235342 -0.032580 -0.159496 -0.153544 ],
[ -0.240911 0.091983 0.165372 0.042807 0.062961 -0.316217 0.066812 0.225143 0.082553 -0.148776 0.296058 0.092212 -0.183622 0.217375 0.083576 0.225143 -0.210723 -0.103036 -0.136730 -0.127714 0.389903 0.200737 -0.236992 -0.228177 -0.260677 0.009042 0.073778 0.131944 ],
[ 0.197714 0.124192 0.059551 -0.062472 -0.011076 0.080930 -0.299423 -0.017047 -0.337266 0.277632 -0.001570 0.277625 0.142855 -0.029391 0.089154 -0.017047 -0.353302 0.044776 0.217531 -0.242887 0.151998 0.220644 -0.031675 0.133882 0.006444 -0.089931 -0.391654 0.242128 ],
[ 0.086592 -0.231328 0.081913 -0.097873 -0.044376 -0.088771 0.420548 -0.076500 -0.017163 -0.038264 -0.224470 0.045082 -0.090758 -0.235778 0.409184 -0.076500 -0.179162 0.524552 -0.104771 -0.036389 0.192274 -0.020685 0.043867 -0.217018 0.113708 0.092602 -0.102224 -0.030344 ],
[ -0.123676 0.090646 -0.164856 -0.035850 -0.054280 -0.038613 -0.002685 -0.282975 -0.253231 0.088804 0.275850 -0.177341 -0.111085 0.322421 -0.177225 -0.282975 0.061941 0.098210 -0.108534 -0.052621 0.435183 -0.299806 0.250617 -0.028294 0.242395 0.119175 -0.047212 0.100385 ],
[ 0.404673 0.267761 -0.067119 -0.019984 -0.035964 -0.091020 0.006447 0.090883 0.054218 0.212876 -0.214334 0.163920 -0.254242 -0.197156 -0.045151 0.090883 -0.118267 -0.408227 -0.276885 0.246138 0.118659 -0.268270 0.102554 -0.275608 0.079554 0.052919 -0.030809 0.079982 ],
[ -0.348918 0.171102 -0.001016 0.150389 -0.077997 -0.035229 -0.123297 -0.169319 0.340394 0.188990 -0.073066 0.315819 -0.029595 -0.131297 0.058224 -0.169319 -0.035508 0.002407 -0.241269 0.047456 0.195914 0.041950 -0.037483 0.337477 -0.022353 0.064734 -0.179289 -0.462953 ],
[ 0.256882 0.056149 0.089276 -0.021786 0.027355 -0.044497 -0.032291 0.047854 0.112188 0.321640 0.009097 -0.132956 -0.461001 0.005771 -0.192067 0.047854 0.099420 0.197557 0.078498 -0.494989 -0.004088 0.084586 0.001420 -0.001275 0.052602 -0.292798 0.210924 -0.300947 ],
[ -0.077259 0.342983 0.078513 -0.245351 -0.133406 0.030305 0.058282 -0.055982 0.349371 -0.238470 0.120002 0.119417 0.105017 -0.040314 -0.340070 -0.055982 -0.091295 0.140527 -0.067972 -0.161751 -0.267383 0.218760 0.223658 -0.322301 0.227410 0.044241 -0.224787 0.097173 ],
[ -0.322814 -0.113258 -0.223696 -0.013067 -0.086074 -0.013205 0.062361 0.088610 0.317595 0.158839 -0.087846 -0.254439 0.028424 -0.076087 0.250534 0.088610 -0.082287 -0.198150 -0.043135 -0.187379 0.010745 -0.115964 0.212710 0.099881 0.128819 -0.477682 -0.123585 0.354714 ],
[ 0.139859 0.051203 0.173717 0.081373 0.051263 -0.077748 -0.062964 -0.442066 0.235113 0.024558 -0.127586 -0.048936 -0.049614 -0.099967 0.014312 -0.442066 0.249362 -0.026642 -0.020288 0.028490 0.076068 0.190976 -0.249797 -0.043220 -0.208583 -0.089712 0.129762 0.459664 ],
[ 0.091140 0.264505 0.119826 0.207301 0.088033 0.237432 0.116939 -0.089307 -0.278039 -0.547772 -0.046330 -0.030093 -0.039627 -0.055052 0.130461 -0.089307 0.046414 -0.158967 -0.230244 -0.233625 0.027306 -0.127864 -0.037900 0.040841 -0.034212 -0.390962 -0.174221 -0.170361 ],
[ 0.017673 -0.129713 0.250287 -0.029447 0.191129 -0.072986 -0.196687 0.055783 -0.023777 0.184725 -0.182303 -0.112729 0.638237 0.026994 -0.091549 0.024010 0.097404 -0.014562 -0.348509 -0.158028 0.195950 -0.003942 0.052657 -0.287306 0.058600 -0.104726 0.128170 -0.165358 ],
[ 0.217549 -0.194737 0.329738 -0.039312 -0.179997 -0.274096 0.222521 -0.163936 0.081010 0.088341 0.002684 0.121324 0.038178 0.599482 0.084220 -0.060640 -0.108985 -0.154016 -0.075439 0.075876 -0.284525 -0.082418 0.036547 0.133114 0.016081 -0.155627 -0.182757 -0.090178 ],
[ 0.109832 0.199099 -0.013608 -0.319297 -0.046228 -0.004195 -0.521790 0.021653 0.155827 -0.153201 0.031961 -0.171715 -0.067385 0.187933 0.612805 -0.067482 0.072647 0.012550 0.026804 -0.035238 -0.065881 -0.055253 0.043382 -0.095230 0.044294 0.154788 0.070913 -0.127987 ],
[ 0.319241 -0.109619 -0.160351 0.031931 0.235666 -0.097533 -0.064688 -0.391865 0.229727 -0.041053 0.398798 -0.198230 0.103311 -0.167699 -0.019419 0.435496 -0.025339 0.101905 -0.131768 0.014589 0.014849 -0.102355 -0.113337 0.103352 -0.073906 0.032871 -0.290496 -0.034078 ],
[ 0.028356 0.079477 -0.140856 0.104175 -0.410109 -0.351879 0.041168 0.141508 -0.190813 0.077837 0.102057 0.120147 0.091778 -0.109431 0.115887 0.102038 0.660923 0.042799 -0.021387 -0.089320 -0.034304 0.071832 -0.029922 -0.094996 -0.037548 -0.016642 -0.267671 0.014895 ],
[ 0.204913 -0.031749 0.049083 0.056245 -0.078064 -0.042888 -0.193775 0.540240 0.196276 -0.133456 0.044012 -0.085721 0.023510 0.022231 -0.206599 -0.271746 -0.053379 0.385468 -0.157435 0.141246 0.064845 -0.292095 -0.084507 0.216425 -0.169321 -0.110141 -0.174687 0.141069 ],
[ 0.004588 -0.268255 0.063603 0.055836 0.414204 -0.297513 -0.118273 0.078406 0.131412 -0.203285 0.059313 0.230549 -0.069832 -0.118297 -0.026682 -0.213332 0.130421 -0.171806 0.465802 0.032937 0.142297 -0.101005 0.191159 -0.156490 0.186961 -0.113296 -0.197640 -0.131781 ],
[ -0.080926 -0.121089 0.115358 0.338733 -0.194218 0.076263 -0.364739 -0.133658 -0.087117 -0.041902 -0.015635 -0.052910 -0.202744 0.059971 -0.028580 0.199587 -0.051038 0.224319 -0.053148 0.466794 0.018720 0.252610 0.140691 -0.244084 0.159976 -0.338967 -0.020899 -0.021368 ],
[ 0.114699 0.021411 0.231153 -0.253273 -0.471498 -0.036336 0.027690 -0.108029 0.111339 -0.246584 -0.168542 -0.157578 0.129175 -0.119294 -0.162630 0.213747 -0.013669 -0.118910 0.339082 0.059256 0.454612 -0.031733 0.033961 0.208054 -0.007795 -0.045055 0.088429 -0.091682 ],
[ 0.258142 -0.290079 -0.344275 -0.213282 -0.005136 0.173699 0.099870 0.160214 0.042334 -0.088186 0.062389 -0.081221 -0.043820 0.094729 -0.023048 -0.215199 0.060087 -0.215646 -0.231688 0.089200 0.212791 0.585665 0.063849 0.075416 0.041000 -0.026680 -0.108163 -0.132964 ],
[ 0.014521 0.188472 0.151327 0.109336 0.073548 -0.296973 0.065238 0.021761 -0.142878 0.066172 0.073937 -0.354912 0.016932 -0.200511 0.050568 -0.134096 -0.144889 -0.032564 0.012072 0.082563 -0.101550 0.202158 0.583883 0.112250 -0.407153 0.086427 -0.013922 -0.081717 ],
[ 0.020901 0.072466 -0.231190 0.005500 0.219390 -0.400814 -0.131602 -0.062957 -0.069763 -0.277215 -0.490599 0.108287 -0.069460 0.180555 -0.118497 0.232812 0.034037 0.155124 -0.161575 -0.100716 -0.009335 0.135156 0.130682 0.324070 0.145078 0.081303 0.102836 0.175527 ],
[ -0.009081 0.176073 0.132460 0.125366 0.018174 -0.292688 0.062210 0.124682 -0.093763 0.036349 0.077314 -0.391230 0.040072 -0.159921 0.030323 -0.140117 -0.148838 -0.104843 0.008934 0.100567 -0.084045 0.152462 -0.397614 0.140605 0.594529 0.075012 -0.029847 -0.043146 ],
[ 0.058469 -0.343131 0.222884 0.435922 -0.209465 0.160523 -0.162586 0.046453 0.111044 -0.103120 -0.054681 -0.080566 -0.136299 -0.035272 -0.009662 0.030849 -0.012032 -0.187668 -0.102000 -0.380861 -0.016023 0.001126 0.140045 0.013165 0.099219 0.489293 -0.104377 0.128751 ],
[ 0.183148 -0.104515 -0.213133 0.151119 -0.261031 -0.193329 -0.074984 -0.063760 -0.013809 -0.140564 0.346084 0.323582 0.195220 -0.193161 0.083072 -0.154488 -0.244382 -0.005837 -0.080205 -0.116152 -0.073166 -0.036507 0.107705 0.070175 0.110496 -0.143249 0.534584 0.007088 ],
[ -0.146504 -0.193299 0.433599 -0.444720 0.091684 0.032010 -0.096718 0.022122 -0.190623 0.003602 0.228771 0.158621 -0.220370 -0.277192 -0.005381 0.085109 0.192548 -0.044606 -0.315397 0.069423 -0.072648 -0.018330 0.106066 0.279555 0.128561 -0.038549 0.060917 0.171746 ]]
Q=
[[ -0.023441 0.701569 -0.543044 0.051581 -0.059810 -0.376752 0.195630 -0.088925 -0.028024 0.123836 0.009631 -0.042222 ],
[ -0.161979 0.029451 0.037443 -0.103041 -0.117624 0.045145 0.123336 -0.210980 0.224297 -0.384544 -0.521551 -0.644267 ],
[ -0.029272 -0.586387 -0.479029 0.015141 -0.102774 -0.555609 -0.239010 0.185247 0.016862 -0.043029 -0.063077 -0.093680 ],
[ -0.144910 -0.015625 0.003565 -0.074682 0.116501 -0.004917 0.013389 -0.028985 -0.226692 -0.188343 0.759487 -0.543018 ],
[ -0.034957 0.356323 0.116399 -0.060663 -0.202739 0.028402 -0.866506 0.211431 0.057046 -0.005674 -0.018683 -0.116199 ],
[ -0.031283 0.035100 0.011911 -0.252482 0.891957 -0.143020 -0.167625 -0.052811 0.156338 0.191302 -0.135289 -0.087354 ],
[ -0.157212 -0.016320 0.369697 0.365929 -0.095100 -0.225775 0.152762 0.257032 0.089820 0.642165 -0.049656 -0.363467 ],
[ -0.077918 -0.065281 -0.493513 -0.212761 -0.012577 0.618588 0.080218 0.432263 0.060128 0.296523 -0.048006 -0.175794 ],
[ -0.956374 -0.003824 0.001462 -0.014985 -0.002504 0.001526 -0.004488 -0.028466 0.022774 -0.055601 0.011259 0.283782 ],
[ -0.054455 0.007225 0.025970 0.002971 0.088595 0.013291 -0.042974 0.045866 -0.924485 0.034716 -0.348422 -0.083952 ],
[ -0.026271 -0.172767 -0.194835 0.086754 -0.119503 0.200298 -0.252191 -0.778870 -0.029804 0.436250 0.035131 -0.083057 ],
[ -0.008001 0.014112 -0.204110 0.852383 0.300706 0.228276 -0.122650 0.049615 0.042122 -0.260623 -0.030200 -0.029492 ]]
Binary file added homeworks/reports/report_8.pdf
Binary file not shown.
56 changes: 56 additions & 0 deletions homeworks/reports/report_8.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
\documentclass{article}
\usepackage[UTF8]{ctex}
\usepackage{hyperref,float,indentfirst,verbatim,fancyhdr,graphicx,listings,longtable,amsmath, amsfonts,amssymb}
\newenvironment{metaverbatim}{\verbatim}{\endverbatim}

\textheight 23.5cm \textwidth 15.8cm
\topmargin -1.5cm \oddsidemargin 0.3cm \evensidemargin -0.3cm

\title{数值代数实验报告 8}
\author{马天开}

\begin{document}
\maketitle

\section{问题描述}

\subsection{SVD 迭代}

参考课本 7.6.2 节 (P234-240)SVD 迭代完成 SVD 算法 7.6.3, 并对附件 svddata.txt 中的矩阵作 SVD 分解 $A = P\Sigma Q$。并计算 $PP^T-I, QQ^T-I, P\Sigma Q-A$ 的绝对值最大的元素,依次用 ep, eq, et 表示。

\begin{metaverbatim}
输出格式为:
迭代次数:x
奇异值从小到大:
ep = xx
eq = xx
et = xx

A=PTQ
T= [矩阵]
P= [矩阵]
Q= [矩阵]
\end{metaverbatim}


\section{算法说明}

必须实现的算法有:

\begin{enumerate}
\item SVD 迭代 $\Rightarrow$ \verb|SVDMethod/SVDMethod|
\end{enumerate}

其中 SVD 分解中 2x2 的实现参考了:
\url{https://www.math.ucla.edu/~cffjiang/research/svd/svd.pdf},
在此表示感谢。

\section{运行结果}

也可在 \verb|homeworks/reports/data/report_8_output.txt| 中查看。

\verbatiminput{data/report_8_output.txt}

\newpage

\end{document}
7 changes: 7 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,12 @@ int main() {
<< "eq = " << MatrixNorm_Infinity(r.V.transpose() * r.V - Matrix::identity(n)) << std::endl
<< "et = " << MatrixNorm_Infinity(r.U * A * r.V - r.B) << std::endl;

std::cout << "T=" << std::endl;
r.B.print();
std::cout << "P=" << std::endl;
r.U.print();
std::cout << "Q=" << std::endl;
r.V.print();

return 0;
}

0 comments on commit f568ae0

Please sign in to comment.