56
56
type Output = A :: Real ;
57
57
58
58
fn opnorm ( & self , t : NormType ) -> Result < Self :: Output > {
59
+ // `self` is a tridiagonal matrix like,
60
+ // [d0, u1, 0, ..., 0,
61
+ // l1, d1, u2, ...,
62
+ // 0, l2, d2,
63
+ // ... ..., u{n-1},
64
+ // 0, ..., l{n-1}, d{n-1},]
59
65
let arr = match t {
66
+ // opnorm_one() calculates muximum column sum.
67
+ // Therefore, This part align the columns and make a (3 x n) matrix like,
68
+ // [ 0, u1, u2, ..., u{n-1},
69
+ // d0, d1, d2, ..., d{n-1},
70
+ // l1, l2, l3, ..., 0,]
60
71
NormType :: One => {
61
72
let zl: Array1 < A > = Array :: zeros ( 1 ) ;
62
73
let zu: Array1 < A > = Array :: zeros ( 1 ) ;
70
81
] ;
71
82
arr
72
83
}
84
+ // opnorm_inf() calculates muximum row sum.
85
+ // Therefore, This part align the rows and make a (n x 3) matrix like,
86
+ // [ 0, d0, u1,
87
+ // l1, d1, u2,
88
+ // l2, d2, u3,
89
+ // ..., ..., ...,
90
+ // l{n-1}, d{n-1}, 0,]
73
91
NormType :: Infinity => {
74
92
let zl: Array1 < A > = Array :: zeros ( 1 ) ;
75
93
let zu: Array1 < A > = Array :: zeros ( 1 ) ;
@@ -83,6 +101,10 @@ where
83
101
] ;
84
102
arr
85
103
}
104
+ // opnorm_fro() calculates square root of sum of squares.
105
+ // Because it is independent of the shape of matrix,
106
+ // this part make a (1 x (3n-2)) matrix like,
107
+ // [l1, ..., l{n-1}, d0, ..., d{n-1}, u1, ..., u{n-1}]
86
108
NormType :: Frobenius => {
87
109
let arr = stack ! [
88
110
Axis ( 1 ) ,
0 commit comments