Skip to content

Commit 950b7da

Browse files
committed
Rename UVTFlag to JobSvd, and Full to All
1 parent 62e40d1 commit 950b7da

File tree

5 files changed

+42
-42
lines changed

5 files changed

+42
-42
lines changed

lax/src/flags.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,26 @@ impl JobEv {
9595
/// For an input array of shape *m*×*n*, the following are computed:
9696
#[derive(Clone, Copy, Eq, PartialEq)]
9797
#[repr(u8)]
98-
pub enum UVTFlag {
98+
pub enum JobSvd {
9999
/// All *m* columns of *U* and all *n* rows of *V*ᵀ.
100-
Full = b'A',
100+
All = b'A',
101101
/// The first min(*m*,*n*) columns of *U* and the first min(*m*,*n*) rows of *V*ᵀ.
102102
Some = b'S',
103103
/// No columns of *U* or rows of *V*ᵀ.
104104
None = b'N',
105105
}
106106

107-
impl UVTFlag {
107+
impl JobSvd {
108108
pub fn from_bool(calc_uv: bool) -> Self {
109109
if calc_uv {
110-
UVTFlag::Full
110+
JobSvd::All
111111
} else {
112-
UVTFlag::None
112+
JobSvd::None
113113
}
114114
}
115115

116116
pub fn as_ptr(&self) -> *const i8 {
117-
self as *const UVTFlag as *const i8
117+
self as *const JobSvd as *const i8
118118
}
119119
}
120120

lax/src/svd.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@ macro_rules! impl_svd {
3232
impl SVD_ for $scalar {
3333
fn svd(l: MatrixLayout, calc_u: bool, calc_vt: bool, a: &mut [Self],) -> Result<SVDOutput<Self>> {
3434
let ju = match l {
35-
MatrixLayout::F { .. } => UVTFlag::from_bool(calc_u),
36-
MatrixLayout::C { .. } => UVTFlag::from_bool(calc_vt),
35+
MatrixLayout::F { .. } => JobSvd::from_bool(calc_u),
36+
MatrixLayout::C { .. } => JobSvd::from_bool(calc_vt),
3737
};
3838
let jvt = match l {
39-
MatrixLayout::F { .. } => UVTFlag::from_bool(calc_vt),
40-
MatrixLayout::C { .. } => UVTFlag::from_bool(calc_u),
39+
MatrixLayout::F { .. } => JobSvd::from_bool(calc_vt),
40+
MatrixLayout::C { .. } => JobSvd::from_bool(calc_u),
4141
};
4242

4343
let m = l.lda();
4444
let mut u = match ju {
45-
UVTFlag::Full => Some(unsafe { vec_uninit( (m * m) as usize) }),
46-
UVTFlag::None => None,
45+
JobSvd::All => Some(unsafe { vec_uninit( (m * m) as usize) }),
46+
JobSvd::None => None,
4747
_ => unimplemented!("SVD with partial vector output is not supported yet")
4848
};
4949

5050
let n = l.len();
5151
let mut vt = match jvt {
52-
UVTFlag::Full => Some(unsafe { vec_uninit( (n * n) as usize) }),
53-
UVTFlag::None => None,
52+
JobSvd::All => Some(unsafe { vec_uninit( (n * n) as usize) }),
53+
JobSvd::None => None,
5454
_ => unimplemented!("SVD with partial vector output is not supported yet")
5555
};
5656

lax/src/svddc.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use cauchy::*;
33
use num_traits::{ToPrimitive, Zero};
44

55
pub trait SVDDC_: Scalar {
6-
fn svddc(l: MatrixLayout, jobz: UVTFlag, a: &mut [Self]) -> Result<SVDOutput<Self>>;
6+
fn svddc(l: MatrixLayout, jobz: JobSvd, a: &mut [Self]) -> Result<SVDOutput<Self>>;
77
}
88

99
macro_rules! impl_svddc {
@@ -15,33 +15,33 @@ macro_rules! impl_svddc {
1515
};
1616
(@body, $scalar:ty, $gesdd:path, $($rwork_ident:ident),*) => {
1717
impl SVDDC_ for $scalar {
18-
fn svddc(l: MatrixLayout, jobz: UVTFlag, a: &mut [Self],) -> Result<SVDOutput<Self>> {
18+
fn svddc(l: MatrixLayout, jobz: JobSvd, a: &mut [Self],) -> Result<SVDOutput<Self>> {
1919
let m = l.lda();
2020
let n = l.len();
2121
let k = m.min(n);
2222
let mut s = unsafe { vec_uninit( k as usize) };
2323

2424
let (u_col, vt_row) = match jobz {
25-
UVTFlag::Full | UVTFlag::None => (m, n),
26-
UVTFlag::Some => (k, k),
25+
JobSvd::All | JobSvd::None => (m, n),
26+
JobSvd::Some => (k, k),
2727
};
2828
let (mut u, mut vt) = match jobz {
29-
UVTFlag::Full => (
29+
JobSvd::All => (
3030
Some(unsafe { vec_uninit( (m * m) as usize) }),
3131
Some(unsafe { vec_uninit( (n * n) as usize) }),
3232
),
33-
UVTFlag::Some => (
33+
JobSvd::Some => (
3434
Some(unsafe { vec_uninit( (m * u_col) as usize) }),
3535
Some(unsafe { vec_uninit( (n * vt_row) as usize) }),
3636
),
37-
UVTFlag::None => (None, None),
37+
JobSvd::None => (None, None),
3838
};
3939

4040
$( // for complex only
4141
let mx = n.max(m) as usize;
4242
let mn = n.min(m) as usize;
4343
let lrwork = match jobz {
44-
UVTFlag::None => 7 * mn,
44+
JobSvd::None => 7 * mn,
4545
_ => std::cmp::max(5*mn*mn + 5*mn, 2*mx*mn + 2*mn*mn + mn),
4646
};
4747
let mut $rwork_ident: Vec<MaybeUninit<Self::Real>> = unsafe { vec_uninit( lrwork) };

ndarray-linalg/src/svddc.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
use super::{convert::*, error::*, layout::*, types::*};
44
use ndarray::*;
55

6-
pub use lax::UVTFlag;
6+
pub use lax::JobSvd;
77

88
/// Singular-value decomposition of matrix (copying) by divide-and-conquer
99
pub trait SVDDC {
1010
type U;
1111
type VT;
1212
type Sigma;
13-
fn svddc(&self, uvt_flag: UVTFlag) -> Result<(Option<Self::U>, Self::Sigma, Option<Self::VT>)>;
13+
fn svddc(&self, uvt_flag: JobSvd) -> Result<(Option<Self::U>, Self::Sigma, Option<Self::VT>)>;
1414
}
1515

1616
/// Singular-value decomposition of matrix by divide-and-conquer
@@ -20,7 +20,7 @@ pub trait SVDDCInto {
2020
type Sigma;
2121
fn svddc_into(
2222
self,
23-
uvt_flag: UVTFlag,
23+
uvt_flag: JobSvd,
2424
) -> Result<(Option<Self::U>, Self::Sigma, Option<Self::VT>)>;
2525
}
2626

@@ -31,7 +31,7 @@ pub trait SVDDCInplace {
3131
type Sigma;
3232
fn svddc_inplace(
3333
&mut self,
34-
uvt_flag: UVTFlag,
34+
uvt_flag: JobSvd,
3535
) -> Result<(Option<Self::U>, Self::Sigma, Option<Self::VT>)>;
3636
}
3737

@@ -44,7 +44,7 @@ where
4444
type VT = Array2<A>;
4545
type Sigma = Array1<A::Real>;
4646

47-
fn svddc(&self, uvt_flag: UVTFlag) -> Result<(Option<Self::U>, Self::Sigma, Option<Self::VT>)> {
47+
fn svddc(&self, uvt_flag: JobSvd) -> Result<(Option<Self::U>, Self::Sigma, Option<Self::VT>)> {
4848
self.to_owned().svddc_into(uvt_flag)
4949
}
5050
}
@@ -60,7 +60,7 @@ where
6060

6161
fn svddc_into(
6262
mut self,
63-
uvt_flag: UVTFlag,
63+
uvt_flag: JobSvd,
6464
) -> Result<(Option<Self::U>, Self::Sigma, Option<Self::VT>)> {
6565
self.svddc_inplace(uvt_flag)
6666
}
@@ -77,17 +77,17 @@ where
7777

7878
fn svddc_inplace(
7979
&mut self,
80-
uvt_flag: UVTFlag,
80+
uvt_flag: JobSvd,
8181
) -> Result<(Option<Self::U>, Self::Sigma, Option<Self::VT>)> {
8282
let l = self.layout()?;
8383
let svd_res = A::svddc(l, uvt_flag, self.as_allocated_mut()?)?;
8484
let (m, n) = l.size();
8585
let k = m.min(n);
8686

8787
let (u_col, vt_row) = match uvt_flag {
88-
UVTFlag::Full => (m, n),
89-
UVTFlag::Some => (k, k),
90-
UVTFlag::None => (0, 0),
88+
JobSvd::All => (m, n),
89+
JobSvd::Some => (k, k),
90+
JobSvd::None => (0, 0),
9191
};
9292

9393
let u = svd_res

ndarray-linalg/tests/svddc.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use ndarray::*;
22
use ndarray_linalg::*;
33

4-
fn test<T: Scalar + Lapack>(a: &Array2<T>, flag: UVTFlag) {
4+
fn test<T: Scalar + Lapack>(a: &Array2<T>, flag: JobSvd) {
55
let (n, m) = a.dim();
66
let k = n.min(m);
77
let answer = a.clone();
88
println!("a = \n{:?}", a);
99
let (u, s, vt): (_, Array1<_>, _) = a.svddc(flag).unwrap();
1010
let mut sm: Array2<T> = match flag {
11-
UVTFlag::Full => Array::zeros((n, m)),
12-
UVTFlag::Some => Array::zeros((k, k)),
13-
UVTFlag::None => {
11+
JobSvd::All => Array::zeros((n, m)),
12+
JobSvd::Some => Array::zeros((k, k)),
13+
JobSvd::None => {
1414
assert!(u.is_none());
1515
assert!(vt.is_none());
1616
return;
@@ -33,37 +33,37 @@ macro_rules! test_svd_impl {
3333
#[test]
3434
fn [<svddc_ $scalar _full_ $n x $m>]() {
3535
let a = random(($n, $m));
36-
test::<$scalar>(&a, UVTFlag::Full);
36+
test::<$scalar>(&a, JobSvd::All);
3737
}
3838

3939
#[test]
4040
fn [<svddc_ $scalar _some_ $n x $m>]() {
4141
let a = random(($n, $m));
42-
test::<$scalar>(&a, UVTFlag::Some);
42+
test::<$scalar>(&a, JobSvd::Some);
4343
}
4444

4545
#[test]
4646
fn [<svddc_ $scalar _none_ $n x $m>]() {
4747
let a = random(($n, $m));
48-
test::<$scalar>(&a, UVTFlag::None);
48+
test::<$scalar>(&a, JobSvd::None);
4949
}
5050

5151
#[test]
5252
fn [<svddc_ $scalar _full_ $n x $m _t>]() {
5353
let a = random(($n, $m).f());
54-
test::<$scalar>(&a, UVTFlag::Full);
54+
test::<$scalar>(&a, JobSvd::All);
5555
}
5656

5757
#[test]
5858
fn [<svddc_ $scalar _some_ $n x $m _t>]() {
5959
let a = random(($n, $m).f());
60-
test::<$scalar>(&a, UVTFlag::Some);
60+
test::<$scalar>(&a, JobSvd::Some);
6161
}
6262

6363
#[test]
6464
fn [<svddc_ $scalar _none_ $n x $m _t>]() {
6565
let a = random(($n, $m).f());
66-
test::<$scalar>(&a, UVTFlag::None);
66+
test::<$scalar>(&a, JobSvd::None);
6767
}
6868
}
6969
};

0 commit comments

Comments
 (0)