# minij
对称正定矩阵 min(i,j)
函数库: TyMath
# 语法
A = TestArrays.minij([T],n)
# 说明
A = minij([T], n) 返回包含项 A[i,j] = min(i,j) 的 n×n 对称正定矩阵。示例
# 示例
minij 矩阵的生成与性质
指定 n 为 5,生成 5x5 的 minij 矩阵。
using TyMath
n = 5
M = TestArrays.minij(n)
M = 5×5 Matrix{Int64}:
1 1 1 1 1
1 2 2 2 2
1 2 3 3 3
1 2 3 4 4
1 2 3 4 5
M 的特征值为 0.25.*sec.((1:n).*(pi/(2*n+1))).^2。
eigM = eigvals(M)
computeEigM = 0.25.*sec.((1:n).*(pi/(2*n+1))).^2
snorm = norm(eigM-computeEigM)
snorm = 5.427049055750751e-15
M 的逆为三对角阵且最右下角元素为 1。
inv(M)
ans = 5×5 Matrix{Float64}:
2.0 -1.0 0.0 0.0 -0.0
-1.0 2.0 -1.0 0.0 -0.0
0.0 -1.0 2.0 -1.0 -0.0
0.0 0.0 -1.0 2.0 -1.0
0.0 0.0 0.0 -1.0 1.0
指定 r 为 1.5,则 M.^r 为对称半正定矩阵。
r = 1.5
eigvals(M.^r)
ans = 5-element Vector{Float64}:
0.5188985379011614
0.8192858607397594
1.30710318520316
3.0921019003849484
22.467529950722742
使用 2.*M-ones(n,n) 可以得到 Givens 矩阵,该矩阵逆矩阵为三对角阵且特征值为 0.5.*sec.((2.*(1:n).-1).*(pi/(4*n))).^2。
G = 2 .*M - ones(n,n)
eigG = eigvals(G)
computeEigG = 0.5.*sec.((2 .*(1:n) .-1).*(pi/(4*n))).^2
gnorm = norm(eigG-computeEigG)
inv(G)
ans = 5×5 Matrix{Float64}:
1.5 -0.5 0.0 0.0 -0.0
-0.5 1.0 -0.5 0.0 -0.0
0.0 -0.5 1.0 -0.5 -0.0
0.0 0.0 -0.5 1.0 -0.5
0.0 0.0 0.0 -0.5 0.5
gnorm = 1.1049368807067472e-14
# 输入参数
n - 矩阵阶数正整数标量
矩阵阶数,指定为正整数标量。
T - 输出类型类型
输出类型,指定为类型(Type)。该参数为可选参数,如果不指定,会依据输入的默认值。如果可能,函数将会输出 T 指定类型的矩阵。
# 输出参数
A - 输出矩阵矩阵
输出矩阵,以矩形形式返回。
# 参考
[1] R. Bhatia, Infinitely divisible matrices, Amer. Math. Monthly, (2005), to appear.
[2] J. Fortiana and C. M. Cuadras, A family of matrices, the discretized Brownian bridge, and distance-based regression, Linear Algebra Appl., 264 (1997), pp. 173-188.
[3] J. Todd, Basic Numerical Mathematics, Vol 2: Numerical Algebra, Birkhauser, Basel, and Academic Press, New York, 1977, p. 158.
[4] D.E. Rutherford, Some continuant determinants arising in physics and chemistry---II, Proc. Royal Soc. Edin., 63, A (1952), pp. 232-241.