施密特正交化 GramSchmidt

施密特正交化的原名是 Gram–Schmidt process,是由Gram和schmidt两个人一起发明的,但是后来因为施密特名气更大,所以该方法被简记为施密特正交化。

借用 《线性代数》P117-例2 的例子来运行代码。

\[a_1 = (1,2,-1)^T \\
a_2 = (-1,3,1)^T \\
a_3 = (4,-1,0)^T
\]

正交化后:

\[a_1 = (1,2,-1)^T \\
a_2 = \frac{5}{3}(-1,1,1)^T \\
a_3 = 2(1,0,1)^T
\]

单位化后:

\[a_1 = \frac{1}{\sqrt{6}}(1,2,-1)^T \\
a_2 = \frac{1}{\sqrt{3}}(-1,3,1)^T \\
a_3 = \frac{1}{\sqrt{2}}(4,-1,0)^T
\]

代码实现

python3 的 sympy 包实现了 GramSchmidt 方法。

from sympy.matrices import Matrix, GramSchmidt
l = [Matrix([1,2,-1]), Matrix([-1,3,1]), Matrix([4,1,0])]
o = GramSchmidt(l)

计算结果如下:

[Matrix([
[ 1],
[ 2],
[-1]]),
Matrix([
[-5/3],
[ 5/3],
[ 5/3]]),
Matrix([
[2],
[0],
[2]])]

单位化也就是在调用函数的时候传入参数。

from sympy.matrices import Matrix, GramSchmidt
l = [Matrix([1,2,-1]), Matrix([-1,3,1]), Matrix([4,1,0])]
o = GramSchmidt(l, True)

计算结果如下:

[Matrix([
[ sqrt(6)/6],
[ sqrt(6)/3],
[-sqrt(6)/6]]),
Matrix([
[-sqrt(3)/3],
[ sqrt(3)/3],
[ sqrt(3)/3]]),
Matrix([
[sqrt(2)/2],
[ 0],
[sqrt(2)/2]])]

sympy.Matrix 与 Numpy 的互操作

Matrix 转 Numpy.array

import numpy as np
from sympy.matrices import Matrix, GramSchmidt
l = [Matrix([1,2,-1]), Matrix([-1,3,1]), Matrix([4,1,0])]
o = GramSchmidt(l, True)
m = np.array(o)

内积计算

(m[0] * m[1]).sum()

References

[1] https://en.wikipedia.org/wiki/Gram–Schmidt_process

[2] GramSchmidt. sympy: https://docs.sympy.org/latest/modules/matrices/matrices.html?highlight=gramschmidt#sympy.matrices.dense.GramSchmidt

施密特正交化 GramSchmidt的更多相关文章

  1. 浅谈压缩感知(十九):MP、OMP与施密特正交化

    关于MP.OMP的相关算法与收敛证明,可以参考:http://www.cnblogs.com/AndyJee/p/5047174.html,这里仅简单陈述算法流程及二者的不同之处. 主要内容: MP的 ...

  2. Gram-Schmidt图像融合

    遥感图像融合的定义是通过将多光谱低分辨率的图像和高分辨率的全色波段进行融合从而得到信息量更丰富的遥感图像.常用的遥感图像融合方法有Brovey\PCA\Gram-Schmidt方法.其中Gram-Sc ...

  3. 数字信号处理Day2-小波基与规范正交化

    我们有这么一张灰度图64*64 我们能够定义出4096个基,各自是某一位是0其它是1,在这样的情况下,假设我们传输图片,那么就相当于传输原始数据 如果传到一半,网络坏了. 于是,我们得到 我们能够计算 ...

  4. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第一章:向量代数

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第一章:向量代数 学习目标: 学习如何使用几何学和数字描述 Vecto ...

  5. DX12龙书 01 - 向量在几何学和数学中的表示以及运算定义

    0x00 向量 向量 ( vector ) 是一种兼具大小 ( magnitude ) 和方向的量. 0x01 几何表示 几何方法中用一条有向线段来表示一个向量,其中,线段长度代表向量的模,箭头的指向 ...

  6. 《3D Math Primer for Graphics and Game Development》读书笔记2

    <3D Math Primer for Graphics and Game Development>读书笔记2 上一篇得到了"矩阵等价于变换后的基向量"这一结论. 本篇 ...

  7. Differential Geometry之第一章欧式空间

    书籍:<微分几何>彭家贵 局部微分几何 第一章.欧式空间 1.1向量空间 (1)向量空间 a.向量空间是集合,集合中的元素需要定义加法和乘法运算.向量空间和n维数组空间R^n不是同一个概念 ...

  8. Python爬取CSDN博客文章

    0 url :http://blog.csdn.net/youyou1543724847/article/details/52818339Redis一点基础的东西目录 1.基础底层数据结构 2.win ...

  9. 自适应滤波:奇异值分解SVD

    作者:桂. 时间:2017-04-03  19:41:26 链接:http://www.cnblogs.com/xingshansi/p/6661230.html 声明:欢迎被转载,不过记得注明出处哦 ...

随机推荐

  1. EXSI6怎么设置虚拟机从光驱启动

    EXSI在安装完系统以后会默认从磁盘启动,假如需要进入救援模式则需要设置成光驱启动 设置

  2. jQuery实现图片懒加载

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. complex类

    #include<iostream> #include<cmath> using namespace std; class complex{ public: complex() ...

  4. 严重:one or more listeners failed. Full details will be found in the appropriate container log file

    one or more listeners failed. Full details will be found in the appropriate container log file   这句话 ...

  5. jmeter 之系统参数根据条件修改

    背景:在setup 线程组定义了一个全局变量a:${__setProperty(a,2,)},线程组里有两个线程通过判断a的值来决定是否执行sample,线程组的最后通过beanshell sampl ...

  6. Elasticsearch学习笔记(十)批量查询mget、批量增删改bulk

    一.批量查询  mget             GET /_mget {   "docs":[       {         "_index":" ...

  7. Win10 +gtx1660 +CUDA10.0+CNDNN7.5+Tensorflow 1.13.1

    硬件环境:ASUS Z370 + i7 8700K + 16G + GTX1660 软件环境:win10 x64    anaconda 3.5    python 3.6   pycharm 201 ...

  8. Oracle查询重复数据并删除,只保留一条记录

    前言 项目中,在“资源目录-在线编目”中,资源项子表存在多条重发数据,需要进行数据清理,删除重发的数据,最终只保留一条相同的数据. 操作的表名:R_RESOURCE_DETAILS 操作步骤 一.重复 ...

  9. ceph的正常卸载与非正常卸载

    一.ceph的正常卸载与非正常卸载 一.正常卸载(通过ceph-deploy卸载) 环境已安装ceph-deploy 1.查看ceph-deploy的帮助信息 [cephde@controller03 ...

  10. FB面经 Prepare: Make Parentheses valid

    给一组括号,remove最少的括号使得它valid 从左从右各scan一次 package fb; public class removeParen { public static String fi ...