summaryrefslogtreecommitdiff
path: root/src/simulation/two_level.rs
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2019-12-12 21:25:04 +0100
committerDennis Kobert <dennis@kobert.dev>2019-12-12 21:25:04 +0100
commit5fa0d5d889dff17a8e011971d80de7661ae130eb (patch)
treefc6b27022e9d57a38391e0705d3e49c41742f1c6 /src/simulation/two_level.rs
parentaa98e4dba7d771bd1e9519442f830542cff2860c (diff)
Add rust code
Diffstat (limited to 'src/simulation/two_level.rs')
-rw-r--r--src/simulation/two_level.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/simulation/two_level.rs b/src/simulation/two_level.rs
new file mode 100644
index 0000000..38a65d9
--- /dev/null
+++ b/src/simulation/two_level.rs
@@ -0,0 +1,26 @@
+use super::c64;
+use super::time_evolution::State;
+use ndarray::prelude::*;
+
+pub struct TwoLevel {
+ state: Array1<c64>,
+}
+
+impl TwoLevel {
+ pub fn new(alpha: c64, beta: c64) -> TwoLevel {
+ TwoLevel {
+ state: array![alpha, beta],
+ }
+ }
+}
+
+impl State for TwoLevel {
+ fn fibrate(&self) -> Array1<c64> {
+ self.state.clone()
+ }
+
+ fn evolve<G: super::time_evolution::MatrixGen>(mut self, t: f64) -> Self {
+ self.state = self.state.dot(&G::gen(t));
+ self
+ }
+}