矩阵特征值和奇异值

1. 方阵

这里我们讨论的都是方阵情况,即m=n ,结论如下:
当矩阵 A 的奇异值和特征值通常不一样!!! 当矩阵A的奇异值和特征值通常不一样!!! 当矩阵A的奇异值和特征值通常不一样!!!

  • 当矩阵A为对称的正定矩阵时,奇异值和特征值一样。特征向量的绝对值等于V矩阵的绝对值。

2. Python代码验证

python 复制代码
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :eigen_sigular_test.py
# @Time      :2024/10/26 14:41
# @Author    :Jason Zhang
import numpy as np

np.set_printoptions(suppress=True, precision=3)


class EigenSingularTest(object):
    def __init__(self, matrix):
        self.matrix = matrix
        self._e_value = np.zeros_like(self.matrix)
        self._e_vector = np.zeros_like(self.matrix)
        self._s_value = np.zeros_like(self.matrix)
        self._su_vector = np.zeros_like(self.matrix)
        self._svt_vector = np.zeros_like(self.matrix)

    def init_method(self):
        pass

    @property
    def e_value(self):
        self._e_value, _ = np.linalg.eig(self.matrix)
        self._e_value = np.diag(self._e_value)
        return self._e_value

    @property
    def e_vector(self):
        _, self._e_vector = np.linalg.eig(self.matrix)
        return self._e_vector

    @property
    def su_vector(self):
        self._su_vector, _, _ = np.linalg.svd(self.matrix)
        return self._su_vector

    @property
    def s_value(self):
        _, self._s_value, _ = np.linalg.svd(self.matrix)
        self._s_value = np.diag(self._s_value)
        return self._s_value

    @property
    def svt_vector(self):
        _, _, self._svt_vector = np.linalg.svd(self.matrix)
        return self._svt_vector

    def check_result(self):
        check_e_value = self.e_value
        check_e_vector = self.e_vector
        check_su_vector = self.su_vector
        check_s_value = self.s_value
        check_svt_vector = self.svt_vector
        print(f"$"*50)
        print(f"e_value=\n{check_e_value}")
        print(f"e_vector=\n{check_e_vector}")
        print("*" * 50)
        print(f"u_vector=\n{check_su_vector}")
        print(f"s_value=\n{check_s_value}")
        print(f"vt_vector=\n{check_svt_vector}")
        check_result_value = np.allclose(check_e_value, check_s_value)
        check_result_vector = np.allclose(np.abs(check_svt_vector.T), np.abs(check_e_vector))
        print(f"e_value is {check_result_value} same with s_value")
        print(f"e_vector is {check_result_vector} same with abs(svt_vector.T)")
        print(f"$"*50)


if __name__ == "__main__":
    run_code = 0
    matrix_n = 5
    # test_matrix = np.random.randint(1, 10, (matrix_n, matrix_n))
    test_matrix = np.arange(9).reshape((3, 3))
    test1 = EigenSingularTest(test_matrix)
    test1.check_result()
    s_matrix = test_matrix @ test_matrix.T
    s_matrix1 = EigenSingularTest(s_matrix)
    s_matrix1.check_result()
  • 结果如下:
python 复制代码
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
e_value=
[[13.348  0.     0.   ]
 [ 0.    -1.348  0.   ]
 [ 0.     0.    -0.   ]]
e_vector=
[[ 0.165  0.8    0.408]
 [ 0.506  0.104 -0.816]
 [ 0.847 -0.591  0.408]]
**************************************************
u_vector=
[[-0.135  0.903  0.408]
 [-0.496  0.295 -0.816]
 [-0.858 -0.313  0.408]]
s_value=
[[14.227  0.     0.   ]
 [ 0.     1.265  0.   ]
 [ 0.     0.     0.   ]]
vt_vector=
[[-0.466 -0.571 -0.676]
 [-0.785 -0.085  0.614]
 [-0.408  0.816 -0.408]]
e_value is False same with s_value
e_vector is False same with abs(svt_vector.T)
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
e_value=
[[202.399   0.      0.   ]
 [  0.      1.601   0.   ]
 [  0.      0.     -0.   ]]
e_vector=
[[-0.135 -0.903  0.408]
 [-0.496 -0.295 -0.816]
 [-0.858  0.313  0.408]]
**************************************************
u_vector=
[[-0.135  0.903  0.408]
 [-0.496  0.295 -0.816]
 [-0.858 -0.313  0.408]]
s_value=
[[202.399   0.      0.   ]
 [  0.      1.601   0.   ]
 [  0.      0.      0.   ]]
vt_vector=
[[-0.135 -0.496 -0.858]
 [ 0.903  0.295 -0.313]
 [-0.408  0.816 -0.408]]
e_value is True same with s_value
e_vector is True same with abs(svt_vector.T)
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
相关推荐
尘浮7289 分钟前
60天python训练计划----day59
开发语言·python
wh393313 分钟前
使用Python将PDF转换成word、PPT
python·pdf·word
船长@Quant30 分钟前
数学视频动画引擎Python库 -- Manim Voiceover 语音服务 Speech Services
python·数学·manim·动画引擎·语音旁白
张晓~183399481212 小时前
数字人分身+矩阵系统聚合+碰一碰发视频: 源码搭建-支持OEM
线性代数·矩阵·音视频
好开心啊没烦恼2 小时前
Python 数据分析:计算,分组统计1,df.groupby()。听故事学知识点怎么这么容易?
开发语言·python·数据挖掘·数据分析·pandas
lljss20203 小时前
Python11中创建虚拟环境、安装 TensorFlow
开发语言·python·tensorflow
空中湖3 小时前
tensorflow武林志第二卷第九章:玄功九转
人工智能·python·tensorflow
山登绝顶我为峰 3(^v^)34 小时前
如何录制带备注的演示文稿(LaTex Beamer + Pympress)
c++·线性代数·算法·计算机·密码学·音视频·latex
CodeCraft Studio4 小时前
CAD文件处理控件Aspose.CAD教程:使用 Python 将绘图转换为 Photoshop
python·photoshop·cad·aspose·aspose.cad
Python×CATIA工业智造6 小时前
Frida RPC高级应用:动态模拟执行Android so文件实战指南
开发语言·python·pycharm