Skip to content

Commit 3abb200

Browse files
committed
Moc trati
1 parent 4f0ef55 commit 3abb200

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/krylov/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use ndarray::*;
66
pub mod arnoldi;
77
pub mod householder;
88
pub mod mgs;
9+
pub mod operator;
910

1011
pub use arnoldi::{arnoldi_householder, arnoldi_mgs, Arnoldi};
1112
pub use householder::{householder, Householder};

src/krylov/operator.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//! Linear operator algebra
2+
3+
use ndarray::*;
4+
5+
pub trait LinearOperator {
6+
/// Apply operator out-place
7+
fn apply<S: Data>(&self, a: &ArrayBase<S, Ix1>) -> Array1<S::Elem> {
8+
self.apply_tensor(a, 0)
9+
}
10+
/// Apply operator in-place
11+
fn apply_mut<S: DataMut>(&self, a: &mut ArrayBase<S, Ix1>) {
12+
self.apply_tensor_mut(a, 0)
13+
}
14+
/// Apply operator with move
15+
fn apply_into<S: DataOwned + DataMut>(&self, a: ArrayBase<S, Ix1>) -> ArrayBase<S, Ix1> {
16+
self.apply_tensor_into(a, 0)
17+
}
18+
19+
/// Apply operator to matrix out-place
20+
fn apply2<S: Data>(&self, a: &ArrayBase<S, Ix2>) -> Array2<S::Elem> {
21+
self.apply_tensor(a, 0)
22+
}
23+
/// Apply operator to matrix in-place
24+
fn apply2_mut<S: DataMut>(&self, a: &mut ArrayBase<S, Ix2>) {
25+
self.apply_tensor_mut(a, 0)
26+
}
27+
/// Apply operator to matrix with move
28+
fn apply2_into<S: DataOwned + DataMut>(&self, a: ArrayBase<S, Ix2>) -> ArrayBase<S, Ix2> {
29+
self.apply_tensor_into(a, 0)
30+
}
31+
32+
/// Apply operator to the n-th index of the tensor (out-place)
33+
fn apply_tensor<S, D>(&self, a: &ArrayBase<S, D>, n: usize) -> Array<S::Elem, D>
34+
where
35+
S: Data,
36+
D: Dimension;
37+
/// Apply operator to the n-th index of the tensor (in-place)
38+
fn apply_tensor_mut<S, D>(&self, a: &mut ArrayBase<S, D>, n: usize)
39+
where
40+
S: DataMut,
41+
D: Dimension;
42+
/// Apply operator to the n-th index of the tensor (with move)
43+
fn apply_tensor_into<S, D>(&self, a: ArrayBase<S, D>, n: usize) -> ArrayBase<S, D>
44+
where
45+
S: DataOwned + DataMut,
46+
D: Dimension;
47+
}

0 commit comments

Comments
 (0)