@@ -158,7 +158,7 @@ where
158
158
impl < C , const ROWS : usize , const COLS : usize , const Q : usize > Mul < Matrix < C , Q , COLS > >
159
159
for Matrix < C , ROWS , Q >
160
160
where
161
- //clone may be more appropriate here, is there a way not to require neither Copy nor Clone?
161
+ //clone may be more appropriate here, is there a way to require neither Copy nor Clone?
162
162
C : Add + Mul < C , Output = C > + Sum + Clone ,
163
163
{
164
164
type Output = Matrix < C , ROWS , COLS > ;
@@ -188,7 +188,16 @@ impl<C, const SIZE: usize> Matrix<C, SIZE, SIZE>
188
188
where
189
189
C : One + Zero + Copy ,
190
190
{
191
- ///Returns the identity matrix of size `SIZE`
191
+ ///Returns the identity matrix of size `SIZE`.
192
+ /// Note that this often requires type annotation.
193
+ ///
194
+ /// # Example
195
+ ///
196
+ /// ```
197
+ ///# use matrix::Matrix;
198
+ /// let identity: Matrix<u8, 2, 2> = Matrix::identity();
199
+ /// assert_eq!(identity, [[1, 0], [0, 1]].into());
200
+ /// ```
192
201
pub fn identity ( ) -> Self {
193
202
let mut m = Self :: nil ( ) ;
194
203
for i in 0 ..SIZE {
@@ -197,7 +206,16 @@ where
197
206
m
198
207
}
199
208
200
- ///Returns the nil matrix of size `SIZE`
209
+ ///Returns the nil matrix of size `SIZE`.
210
+ /// Note that this often requires type annotation.
211
+ ///
212
+ /// # Example
213
+ ///
214
+ /// ```
215
+ ///# use matrix::Matrix;
216
+ /// let identity: Matrix<u8, 2, 2> = Matrix::nil();
217
+ /// assert_eq!(identity, [[0, 0], [0, 0]].into());
218
+ /// ```
201
219
pub fn nil ( ) -> Self {
202
220
[ [ C :: zero ( ) ; SIZE ] ; SIZE ] . into ( )
203
221
}
0 commit comments