From 5fa0d5d889dff17a8e011971d80de7661ae130eb Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Thu, 12 Dec 2019 21:25:04 +0100 Subject: Add rust code --- src/simulation/two_level.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/simulation/two_level.rs (limited to 'src/simulation/two_level.rs') 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, +} + +impl TwoLevel { + pub fn new(alpha: c64, beta: c64) -> TwoLevel { + TwoLevel { + state: array![alpha, beta], + } + } +} + +impl State for TwoLevel { + fn fibrate(&self) -> Array1 { + self.state.clone() + } + + fn evolve(mut self, t: f64) -> Self { + self.state = self.state.dot(&G::gen(t)); + self + } +} -- cgit v1.2.3-70-g09d2