1use crate::{gate::Gate, pbit::GridPbit};
2use na::{DMatrix};
3
4pub struct Or {
5 pbits: Vec<GridPbit>,
6 weight: DMatrix<i32>,
7 bias: Vec<i32>,
8}
9
10impl Or {
11 pub fn new(m1: GridPbit, m2: GridPbit, m3: GridPbit) -> Or {
12 let weight = DMatrix::<i32>::from_vec(3, 3, vec![0, -1, 2, -1, 0, 2, 2, 2, 0]);
13 let bias = vec![-1, -1, 2];
14
15 Or { pbits: vec![m1, m2, m3], weight, bias }
16 }
17}
18
19impl Gate for Or {
20 fn pbits(&self) -> &Vec<GridPbit> {
21 &self.pbits
22 }
23
24 fn shape(&self) -> (usize, usize) {
25 (3, 3)
26 }
27
28 fn weight(&self) -> &DMatrix<i32> {
29 &self.weight
30 }
31
32 fn bias(&self) -> &Vec<i32> {
33 &self.bias
34 }
35}