【PLA】基于Python实现的线性代数算法库之斯密特正交化
2022/2/6 20:13:13
本文主要是介绍【PLA】基于Python实现的线性代数算法库之斯密特正交化,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
【PLA】基于Python实现的线性代数算法库之斯密特正交化
算法包下载链接:https://download.csdn.net/download/qq_42629529/79481514
from PLA.Vector import Vector from PLA.GramSchmidtProcess import gram_schmidt_process from itertools import product if __name__ == "__main__": #1 basis1 = [Vector([2, 1]), Vector([1, 1])] res1 = gram_schmidt_process(basis1) for row in res1: print(row) res1 = [row / row.norm() for row in res1] for row in res1: print(row) print(res1[0].dot(res1[1])) print() #2 basis2 = [Vector([2, 3]), Vector([4, 5])] res2 = gram_schmidt_process(basis2) res2 = [row / row.norm() for row in res2] for row in res2: print(row) print(res2[0].dot(res2[1])) print() #3 basis3 = [Vector([1, 0, 1]), Vector([3, 1, 1]), Vector([-1, -1, -1])] res3 = gram_schmidt_process(basis3) res3 = [row / row.norm() for row in res3] for row in res3: print(row) print(sum(res3[i].dot(res3[j]) for i, j in product(range(3), repeat=2) if i != j)) print() #4 basis4 = [Vector([1, 1, 5, 2]), Vector([-3, 3, 4, -2]), Vector([-1, -2, 2, 5])] res4 = gram_schmidt_process(basis4) res4 = [row / row.norm() for row in res4] for row in res4: print(row)#标准正交基 print(sum(res4[i].dot(res4[j]) for i, j in product(range(3), repeat=2) if i != j)) print() #5 basis5 = [Vector([1, 2, 3, 4]), Vector([2, 1, 1, 0]), Vector([3, 0, -1, 3])] res5 = gram_schmidt_process(basis5) res5 = [row / row.norm() for row in res5] for row in res5: print(row) print(sum(res5[i].dot(res5[j]) for i, j in product(range(3), repeat=2) if i != j)) print()
这篇关于【PLA】基于Python实现的线性代数算法库之斯密特正交化的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python