@@ -44,6 +44,91 @@ function offset end
4444# Standard methods
4545# #
4646
47+ """
48+ multiplicable(a, b)
49+
50+ Check if any two subtypes of `StateVector`, `AbstractOperator`,
51+ or `AbstractSuperOperator` can be multiplied in the given order.
52+
53+ Spcefically this checks whether the right basis of a is equal
54+ to the left basis of b
55+ """
56+ function multiplicable end
57+
58+ """
59+ check_multiplicable(a, b)
60+
61+ Throw an [`IncompatibleBases`](@ref) error if the objects are
62+ not multiplicable as determined by `multiplicable(a, b)`.
63+
64+ If the macro `@compatiblebases` is used anywhere up the call stack,
65+ this check is disabled.
66+ """
67+ function check_multiplicable end
68+
69+ """
70+ addible(a, b)
71+
72+ Check if any two subtypes of `StateVector`, `AbstractOperator`,
73+ or `AbstractSuperOperator` can be added together.
74+
75+ Spcefically this checks whether the left basis of a is equal
76+ to the left basis of b and whether the right basis of a is equal
77+ to the right basis of b.
78+ """
79+ function addible end
80+
81+ """
82+ check_addible(a, b)
83+
84+ Throw an [`IncompatibleBases`](@ref) error if the objects are
85+ not addible as determined by `addible(a, b)`.
86+
87+ If the macro `@compatiblebases` is used anywhere up the call stack,
88+ this check is disabled.
89+ """
90+ function check_addible end
91+
92+ """
93+ issquare(a)
94+
95+ Check if any two subtypes of `StateVector`, `AbstractOperator`,
96+ or `AbstractSuperOperator` are square.
97+
98+ Spcefically this checks whether the left basis of a is equal
99+ to the right basis of a.
100+ For subtypes of `StateVector` this is always false.
101+ """
102+ function addible end
103+
104+ """
105+ check_issquare(a, b)
106+
107+ Throw an [`IncompatibleBases`](@ref) error if the objects are
108+ not addible as determined by `addible(a, b)`.
109+
110+ If the macro `@compatiblebases` is used anywhere up the call stack,
111+ this check is disabled.
112+ """
113+ function check_addible end
114+
115+ const BASES_CHECK = Ref (true )
116+
117+ """
118+ @compatiblebases
119+
120+ Macro to skip checks for compatible bases. Useful for `*`, `expect` and similar
121+ functions.
122+ """
123+ macro compatiblebases (ex)
124+ return quote
125+ BASES_CHECK. x = false
126+ local val = $ (esc (ex))
127+ BASES_CHECK. x = true
128+ val
129+ end
130+ end
131+
47132function apply! end
48133
49134function dagger end
0 commit comments