Skip to content

Commit 4e43817

Browse files
committed
add comments on opnorm
1 parent 4771438 commit 4e43817

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/opnorm.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,18 @@ where
5656
type Output = A::Real;
5757

5858
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},]
5965
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,]
6071
NormType::One => {
6172
let zl: Array1<A> = Array::zeros(1);
6273
let zu: Array1<A> = Array::zeros(1);
@@ -70,6 +81,13 @@ where
7081
];
7182
arr
7283
}
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,]
7391
NormType::Infinity => {
7492
let zl: Array1<A> = Array::zeros(1);
7593
let zu: Array1<A> = Array::zeros(1);
@@ -83,6 +101,10 @@ where
83101
];
84102
arr
85103
}
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}]
86108
NormType::Frobenius => {
87109
let arr = stack![
88110
Axis(1),

0 commit comments

Comments
 (0)