1use std::ops::{Index, Sub};
2
3use crate::matrix::Matrix;
4use crate::matrix_transpose_view::MatrixTransposeView;
5use crate::matrix_transpose_view_mut::MatrixTransposeViewMut;
6use crate::matrix_view::MatrixView;
7use crate::matrix_view_mut::MatrixViewMut;
8use crate::row_vector::RowVector;
9use crate::row_vector_view::RowVectorView;
10use crate::row_vector_view_mut::RowVectorViewMut;
11use crate::vector::Vector;
12use crate::vector_view::VectorView;
13use crate::vector_view_mut::VectorViewMut;
14
15generate_op_all_macros!(Sub, sub, -);
17
18impl_vv_op!(Vector<T, N>); impl_vv_op!(Vector<T, N>, Vector<T, N>);
24impl_vv_op_view!(Vector<T, M>, VectorView<'_, V, T, N, M>);
25impl_vv_op_view!(Vector<T, M>, VectorViewMut<'_, V, T, N, M>);
26
27impl_vv_op!(Vector<T, N>, Matrix<T, N, 1>);
28impl_vm_op_mat_view!(Vector<T, M>, MatrixView<'_, T, A, B, M, 1>);
29impl_vm_op_mat_view!(Vector<T, M>, MatrixViewMut<'_, T, A, B, M, 1>);
30impl_vm_op_mat_view!(Vector<T, M>, MatrixTransposeView<'_, T, A, B, M, 1>);
31impl_vm_op_mat_view!(Vector<T, M>, MatrixTransposeViewMut<'_, T, A, B, M, 1>);
32
33impl_vv_op_view!(VectorView<'_, V, T, N, M>); impl_vv_op_view!(VectorView<'_, V, T, N, M>, Vector<T, M>);
39impl_vv_op_view_view!(VectorView<'_, V1, T, A, M>, VectorView<'_, V2, T, N, M>);
40impl_vv_op_view_view!(VectorView<'_, V1, T, A, M>, VectorViewMut<'_, V2, T, N, M>);
41
42impl_vm_op_vec_view!(VectorView<'_, V, T, N, M>, Matrix<T, M, 1>);
43impl_vm_op_view_view!(VectorView<'_, V, T, N, M>, MatrixView<'_, T, A, B, M, 1>);
44impl_vm_op_view_view!(VectorView<'_, V, T, N, M>, MatrixViewMut<'_, T, A, B, M, 1>);
45impl_vm_op_view_view!(VectorView<'_, V, T, N, M>, MatrixTransposeView<'_, T, A, B, M, 1>);
46impl_vm_op_view_view!(VectorView<'_, V, T, N, M>, MatrixTransposeViewMut<'_, T, A, B, M, 1>);
47
48impl_vv_op_view!(VectorViewMut<'_, V, T, N, M>); impl_vv_op_view!(VectorViewMut<'_, V, T, N, M>, Vector<T, M>);
54impl_vv_op_view_view!(VectorViewMut<'_, V1, T, A, M>, VectorView<'_, V2, T, N, M>);
55impl_vv_op_view_view!(VectorViewMut<'_, V1, T, A, M>, VectorViewMut<'_, V2, T, N, M>);
56
57impl_vm_op_vec_view!(VectorViewMut<'_, V, T, N, M>, Matrix<T, M, 1>);
58impl_vm_op_view_view!(VectorViewMut<'_, V, T, N, M>, MatrixView<'_, T, A, B, M, 1>);
59impl_vm_op_view_view!(VectorViewMut<'_, V, T, N, M>, MatrixViewMut<'_, T, A, B, M, 1>);
60impl_vm_op_view_view!(VectorViewMut<'_, V, T, N, M>, MatrixTransposeView<'_, T, A, B, M, 1>);
61impl_vm_op_view_view!(VectorViewMut<'_, V, T, N, M>, MatrixTransposeViewMut<'_, T, A, B, M, 1>);
62
63impl_vv_op_row!(RowVector<T, N>); impl_vv_op_row!(RowVector<T, N>, RowVector<T, N>);
69impl_vv_op_view_row!(RowVector<T, M>, RowVectorView<'_, V, T, N, M>);
70impl_vv_op_view_row!(RowVector<T, M>, RowVectorViewMut<'_, V, T, N, M>);
71
72impl_vv_op!(RowVector<T, N>, Matrix<T, 1, N>);
73impl_vm_op_mat_view_row!(RowVector<T, M>, MatrixView<'_, T, A, B, 1, M>);
74impl_vm_op_mat_view_row!(RowVector<T, M>, MatrixViewMut<'_, T, A, B, 1, M>);
75impl_vm_op_mat_view_row!(RowVector<T, M>, MatrixTransposeView<'_, T, A, B, 1, M>);
76impl_vm_op_mat_view_row!(RowVector<T, M>, MatrixTransposeViewMut<'_, T, A, B, 1, M>);
77
78impl_vv_op_view_row!(RowVectorView<'_, V, T, N, M>); impl_vv_op_view_row!(RowVectorView<'_, V, T, N, M>, RowVector<T, M>);
84impl_vv_op_view_view_row!(RowVectorView<'_, V1, T, A, M>, RowVectorView<'_, V2, T, N, M>);
85impl_vv_op_view_view_row!(RowVectorView<'_, V1, T, A, M>, RowVectorViewMut<'_, V2, T, N, M>);
86
87impl_vm_op_vec_view_row!(RowVectorView<'_, V, T, N, M>, Matrix<T, 1, M>);
88impl_vm_op_view_view_row!(RowVectorView<'_, V, T, N, M>, MatrixView<'_, T, A, B, 1, M>);
89impl_vm_op_view_view_row!(RowVectorView<'_, V, T, N, M>, MatrixViewMut<'_, T, A, B, 1, M>);
90impl_vm_op_view_view_row!(RowVectorView<'_, V, T, N, M>, MatrixTransposeView<'_, T, A, B, 1, M>);
91impl_vm_op_view_view_row!(RowVectorView<'_, V, T, N, M>, MatrixTransposeViewMut<'_, T, A, B, 1, M>);
92
93impl_vv_op_view_row!(RowVectorViewMut<'_, V, T, N, M>); impl_vv_op_view_row!(RowVectorViewMut<'_, V, T, N, M>, RowVector<T, M>);
99impl_vv_op_view_view_row!(RowVectorViewMut<'_, V1, T, A, M>, RowVectorView<'_, V2, T, N, M>);
100impl_vv_op_view_view_row!(RowVectorViewMut<'_, V1, T, A, M>, RowVectorViewMut<'_, V2, T, N, M>);
101
102impl_vm_op_vec_view_row!(RowVectorViewMut<'_, V, T, N, M>, Matrix<T, 1, M>);
103impl_vm_op_view_view_row!(RowVectorViewMut<'_, V, T, N, M>, MatrixView<'_, T, A, B, 1, M>);
104impl_vm_op_view_view_row!(RowVectorViewMut<'_, V, T, N, M>, MatrixViewMut<'_, T, A, B, 1, M>);
105impl_vm_op_view_view_row!(RowVectorViewMut<'_, V, T, N, M>, MatrixTransposeView<'_, T, A, B, 1, M>);
106impl_vm_op_view_view_row!(RowVectorViewMut<'_, V, T, N, M>, MatrixTransposeViewMut<'_, T, A, B, 1, M>);
107
108impl_mv_op!(Matrix<T, N, 1>, Vector<T, N>);
113impl_mv_op_vec_view!(Matrix<T, M, 1>, VectorView<'_, V, T, N, M>);
114impl_mv_op_vec_view!(Matrix<T, M, 1>, VectorViewMut<'_, V, T, N, M>);
115
116impl_mv_op_row!(Matrix<T, 1, N>, RowVector<T, N>);
117impl_mv_op_vec_view_row!(Matrix<T, 1, M>, RowVectorView<'_, V, T, N, M>);
118impl_mv_op_vec_view_row!(Matrix<T, 1, M>, RowVectorViewMut<'_, V, T, N, M>);
119
120impl_mm_op!(Matrix<T, M, N>); impl_mm_op!(Matrix<T, M, N>, Matrix<T, M, N>);
122impl_mm_op_view!(Matrix<T, M, N>, MatrixView<'_, T, A, B, M, N>);
123impl_mm_op_view!(Matrix<T, M, N>, MatrixViewMut<'_, T, A, B, M, N>);
124impl_mm_op_view!(Matrix<T, M, N>, MatrixTransposeView<'_, T, A, B, M, N>);
125impl_mm_op_view!(Matrix<T, M, N>, MatrixTransposeViewMut<'_, T, A, B, M, N>);
126
127impl_mv_op_mat_view!(MatrixView<'_, T, A, B, M, 1>, Vector<T, M>);
132impl_mv_op_view_view!(MatrixView<'_, T, A, B, M, 1>, VectorView<'_, V, T, N, M>);
133impl_mv_op_view_view!(MatrixView<'_, T, A, B, M, 1>, VectorViewMut<'_, V, T, N, M>);
134
135impl_mv_op_mat_view_row!(MatrixView<'_, T, A, B, 1, M>, RowVector<T, M>);
136impl_mv_op_view_view_row!(MatrixView<'_, T, A, B, 1, M>, RowVectorView<'_, V, T, N, M>);
137impl_mv_op_view_view_row!(MatrixView<'_, T, A, B, 1, M>, RowVectorViewMut<'_, V, T, N, M>);
138
139impl_mm_op_view!(MatrixView<'_, T, A, B, M, N>); impl_mm_op_view!(MatrixView<'_, T, A, B, M, N>, Matrix<T, M, N>);
141impl_mm_op_view_view!(MatrixView<'_, T, A, B, M, N>, MatrixView<'_, T, C, D, M, N>);
142impl_mm_op_view_view!(MatrixView<'_, T, A, B, M, N>, MatrixViewMut<'_, T, C, D, M, N>);
143impl_mm_op_view_view!(MatrixView<'_, T, A, B, M, N>, MatrixTransposeView<'_, T, C, D, M, N>);
144impl_mm_op_view_view!(MatrixView<'_, T, A, B, M, N>, MatrixTransposeViewMut<'_, T, C, D, M, N>);
145
146impl_mv_op_mat_view!(MatrixViewMut<'_, T, A, B, M, 1>, Vector<T, M>);
151impl_mv_op_view_view!(MatrixViewMut<'_, T, A, B, M, 1>, VectorView<'_, V, T, N, M>);
152impl_mv_op_view_view!(MatrixViewMut<'_, T, A, B, M, 1>, VectorViewMut<'_, V, T, N, M>);
153
154impl_mv_op_mat_view_row!(MatrixViewMut<'_, T, A, B, 1, M>, RowVector<T, M>);
155impl_mv_op_view_view_row!(MatrixViewMut<'_, T, A, B, 1, M>, RowVectorView<'_, V, T, N, M>);
156impl_mv_op_view_view_row!(MatrixViewMut<'_, T, A, B, 1, M>, RowVectorViewMut<'_, V, T, N, M>);
157
158impl_mm_op_view!(MatrixViewMut<'_, T, A, B, M, N>); impl_mm_op_view!(MatrixViewMut<'_, T, A, B, M, N>, Matrix<T, M, N>);
160impl_mm_op_view_view!(MatrixViewMut<'_, T, A, B, M, N>, MatrixView<'_, T, C, D, M, N>);
161impl_mm_op_view_view!(MatrixViewMut<'_, T, A, B, M, N>, MatrixViewMut<'_, T, C, D, M, N>);
162impl_mm_op_view_view!(MatrixViewMut<'_, T, A, B, M, N>, MatrixTransposeView<'_, T, C, D, M, N>);
163impl_mm_op_view_view!(MatrixViewMut<'_, T, A, B, M, N>, MatrixTransposeViewMut<'_, T, C, D, M, N>);
164
165impl_mv_op_mat_view!(MatrixTransposeView<'_, T, A, B, M, 1>, Vector<T, M>);
170impl_mv_op_view_view!(MatrixTransposeView<'_, T, A, B, M, 1>, VectorView<'_, V, T, N, M>);
171impl_mv_op_view_view!(MatrixTransposeView<'_, T, A, B, M, 1>, VectorViewMut<'_, V, T, N, M>);
172
173impl_mv_op_mat_view_row!(MatrixTransposeView<'_, T, A, B, 1, M>, RowVector<T, M>);
174impl_mv_op_view_view_row!(MatrixTransposeView<'_, T, A, B, 1, M>, RowVectorView<'_, V, T, N, M>);
175impl_mv_op_view_view_row!(MatrixTransposeView<'_, T, A, B, 1, M>, RowVectorViewMut<'_, V, T, N, M>);
176
177impl_mm_op_view!(MatrixTransposeView<'_, T, A, B, M, N>); impl_mm_op_view!(MatrixTransposeView<'_, T, A, B, M, N>, Matrix<T, M, N>);
179impl_mm_op_view_view!(MatrixTransposeView<'_, T, A, B, M, N>, MatrixView<'_, T, C, D, M, N>);
180impl_mm_op_view_view!(MatrixTransposeView<'_, T, A, B, M, N>, MatrixViewMut<'_, T, C, D, M, N>);
181impl_mm_op_view_view!(MatrixTransposeView<'_, T, A, B, M, N>, MatrixTransposeView<'_, T, C, D, M, N>);
182impl_mm_op_view_view!(MatrixTransposeView<'_, T, A, B, M, N>, MatrixTransposeViewMut<'_, T, C, D, M, N>);
183
184impl_mv_op_mat_view!(MatrixTransposeViewMut<'_, T, A, B, M, 1>, Vector<T, M>);
189impl_mv_op_view_view!(MatrixTransposeViewMut<'_, T, A, B, M, 1>, VectorView<'_, V, T, N, M>);
190impl_mv_op_view_view!(MatrixTransposeViewMut<'_, T, A, B, M, 1>, VectorViewMut<'_, V, T, N, M>);
191
192impl_mv_op_mat_view_row!(MatrixTransposeViewMut<'_, T, A, B, 1, M>, RowVector<T, M>);
193impl_mv_op_view_view_row!(MatrixTransposeViewMut<'_, T, A, B, 1, M>, RowVectorView<'_, V, T, N, M>);
194impl_mv_op_view_view_row!(MatrixTransposeViewMut<'_, T, A, B, 1, M>, RowVectorViewMut<'_, V, T, N, M>);
195
196impl_mm_op_view!(MatrixTransposeViewMut<'_, T, A, B, M, N>); impl_mm_op_view!(MatrixTransposeViewMut<'_, T, A, B, M, N>, Matrix<T, M, N>);
198impl_mm_op_view_view!(MatrixTransposeViewMut<'_, T, A, B, M, N>, MatrixView<'_, T, C, D, M, N>);
199impl_mm_op_view_view!(MatrixTransposeViewMut<'_, T, A, B, M, N>, MatrixViewMut<'_, T, C, D, M, N>);
200impl_mm_op_view_view!(MatrixTransposeViewMut<'_, T, A, B, M, N>, MatrixTransposeView<'_, T, C, D, M, N>);
201impl_mm_op_view_view!(MatrixTransposeViewMut<'_, T, A, B, M, N>, MatrixTransposeViewMut<'_, T, C, D, M, N>);