mech_logic/
not.rs

1use crate::*;
2use mech_core::*;
3
4// Not ------------------------------------------------------------------------
5
6macro_rules! not_op {
7    ($arg:expr, $out:expr) => {
8      unsafe {*$out = !*$arg;}
9      };}
10  
11  macro_rules! not_vec_op {
12    ($arg:expr, $out:expr) => {
13      unsafe {
14        for i in 0..(*$arg).len() {
15          (*$out)[i] = !(*$arg)[i];
16        }}};}
17  
18  impl_logic_urnop!(NotS, bool, bool, not_op);
19  #[cfg(feature = "Matrix1")]
20  impl_logic_urnop!(NotM1, Matrix1<bool>, Matrix1<bool>, not_vec_op);
21  #[cfg(feature = "Matrix2")]
22  impl_logic_urnop!(NotM2, Matrix2<bool>, Matrix2<bool>, not_vec_op);
23  #[cfg(feature = "Matrix3")]
24  impl_logic_urnop!(NotM3, Matrix3<bool>, Matrix3<bool>, not_vec_op);
25  #[cfg(feature = "Matrix4")]
26  impl_logic_urnop!(NotM4, Matrix4<bool>, Matrix4<bool>, not_vec_op);
27  #[cfg(feature = "Matrix2x3")]
28  impl_logic_urnop!(NotM2x3, Matrix2x3<bool>, Matrix2x3<bool>, not_vec_op);
29  #[cfg(feature = "Matrix3x2")]
30  impl_logic_urnop!(NotM3x2, Matrix3x2<bool>, Matrix3x2<bool>, not_vec_op);
31  #[cfg(feature = "MatrixD")]
32  impl_logic_urnop!(NotMD, DMatrix<bool>, DMatrix<bool>, not_vec_op);
33  #[cfg(feature = "RowVector2")]
34  impl_logic_urnop!(NotR2, RowVector2<bool>, RowVector2<bool>, not_vec_op);
35  #[cfg(feature = "RowVector3")]
36  impl_logic_urnop!(NotR3, RowVector3<bool>, RowVector3<bool>, not_vec_op);
37  #[cfg(feature = "RowVector4")]
38  impl_logic_urnop!(NotR4, RowVector4<bool>, RowVector4<bool>, not_vec_op);
39  #[cfg(feature = "RowVectorD")]
40  impl_logic_urnop!(NotRD, RowDVector<bool>, RowDVector<bool>, not_vec_op);
41  #[cfg(feature = "Vector2")]
42  impl_logic_urnop!(NotV2, Vector2<bool>, Vector2<bool>, not_vec_op);
43  #[cfg(feature = "Vector3")]
44  impl_logic_urnop!(NotV3, Vector3<bool>, Vector3<bool>, not_vec_op);
45  #[cfg(feature = "Vector4")]
46  impl_logic_urnop!(NotV4, Vector4<bool>, Vector4<bool>, not_vec_op);
47  #[cfg(feature = "VectorD")]
48  impl_logic_urnop!(NotVD, DVector<bool>, DVector<bool>, not_vec_op);
49  
50  fn impl_not_fxn(arg_value: Value) -> Result<Box<dyn MechFunction>, MechError> {
51    impl_urnop_match_arms!(
52      Not,
53      (arg_value),
54      Bool => MatrixBool, bool, false, "Bool";
55    )
56  }
57  
58  impl_mech_urnop_fxn!(LogicNot,impl_not_fxn);