faer 0.24.0

linear algebra library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
use super::*;
use crate::utils::bound::{Array, Dim, Partition};
use crate::{ContiguousFwd, Idx, IdxInc};
use equator::{assert, debug_assert};
/// see [`super::RowMut`]
pub struct Mut<'a, T, Cols = usize, CStride = isize> {
	pub(crate) trans: ColMut<'a, T, Cols, CStride>,
}
impl<'short, T, Rows: Copy, RStride: Copy> Reborrow<'short>
	for Mut<'_, T, Rows, RStride>
{
	type Target = Ref<'short, T, Rows, RStride>;

	#[inline]
	fn rb(&'short self) -> Self::Target {
		Ref {
			trans: self.trans.rb(),
		}
	}
}
impl<'short, T, Rows: Copy, RStride: Copy> ReborrowMut<'short>
	for Mut<'_, T, Rows, RStride>
{
	type Target = Mut<'short, T, Rows, RStride>;

	#[inline]
	fn rb_mut(&'short mut self) -> Self::Target {
		Mut {
			trans: self.trans.rb_mut(),
		}
	}
}
impl<'a, T, Rows: Copy, RStride: Copy> IntoConst for Mut<'a, T, Rows, RStride> {
	type Target = Ref<'a, T, Rows, RStride>;

	#[inline]
	fn into_const(self) -> Self::Target {
		Ref {
			trans: self.trans.into_const(),
		}
	}
}
impl<'a, T> RowMut<'a, T> {
	/// creates a row view over the given element
	#[inline]
	pub fn from_mut(value: &'a mut T) -> Self {
		unsafe { RowMut::from_raw_parts_mut(value as *mut T, 1, 1) }
	}

	/// creates a `RowMut` from slice views over the row vector data, the result
	/// has the same number of columns as the length of the input slice
	#[inline]
	pub fn from_slice_mut(slice: &'a mut [T]) -> Self {
		let len = slice.len();
		unsafe { Self::from_raw_parts_mut(slice.as_mut_ptr(), len, 1) }
	}
}
impl<'a, T, Cols: Shape, CStride: Stride> RowMut<'a, T, Cols, CStride> {
	/// creates a `RowMut` from pointers to the column vector data, number of
	/// rows, and row stride
	///
	/// # safety
	/// this function has the same safety requirements as
	/// [`MatMut::from_raw_parts_mut(ptr, 1, ncols, 0, col_stride)`]
	#[inline(always)]
	#[track_caller]
	pub const unsafe fn from_raw_parts_mut(
		ptr: *mut T,
		ncols: Cols,
		col_stride: CStride,
	) -> Self {
		Self {
			0: Mut {
				trans: ColMut::from_raw_parts_mut(ptr, ncols, col_stride),
			},
		}
	}

	/// returns a pointer to the row data
	#[inline(always)]
	pub fn as_ptr(&self) -> *const T {
		self.trans.as_ptr()
	}

	/// returns the number of rows of the row (always 1)
	#[inline(always)]
	pub fn nrows(&self) -> usize {
		1
	}

	/// returns the number of columns of the row
	#[inline(always)]
	pub fn ncols(&self) -> Cols {
		self.trans.nrows()
	}

	/// returns the number of rows and columns of the row
	#[inline(always)]
	pub fn shape(&self) -> (usize, Cols) {
		(self.nrows(), self.ncols())
	}

	/// returns the column stride of the row
	#[inline(always)]
	pub fn col_stride(&self) -> CStride {
		self.trans.row_stride()
	}

	#[inline]
	pub fn map<U>(&self, f: impl Fn(&T) -> U) -> Row<U, Cols> {
		self.rb().map(f)
	}

	#[inline]
	pub fn for_each(&self, f: impl Fn(&T)) {
		self.rb().for_each(f)
	}

	#[inline]
	pub fn map_mut<U>(&mut self, f: impl FnMut(&mut T) -> U) -> Row<U, Cols> {
		let mut f = f;
		zip!(self).map(|unzip!(x)| f(x))
	}

	#[inline]
	pub fn for_each_mut(&mut self, f: impl FnMut(&mut T)) {
		let mut f = f;
		zip!(self).for_each(|unzip!(x)| f(x))
	}

	/// returns a raw pointer to the element at the given index
	#[inline(always)]
	pub fn ptr_at(&self, col: IdxInc<Cols>) -> *const T {
		self.trans.ptr_at(col)
	}

	/// returns a raw pointer to the element at the given index, assuming the
	/// provided index is within the row bounds
	///
	/// # safety
	/// the behavior is undefined if any of the following conditions are
	/// violated:
	/// * `col < self.ncols()`
	#[inline(always)]
	#[track_caller]
	pub unsafe fn ptr_inbounds_at(&self, col: Idx<Cols>) -> *const T {
		debug_assert!(all(col < self.ncols()));
		self.trans.ptr_inbounds_at(col)
	}

	#[inline]
	#[track_caller]
	/// see [`RowRef::split_at_col`]
	pub fn split_at_col(
		self,
		col: IdxInc<Cols>,
	) -> (RowRef<'a, T, usize, CStride>, RowRef<'a, T, usize, CStride>) {
		self.into_const().split_at_col(col)
	}

	#[inline(always)]
	/// see [`RowRef::transpose`]
	pub fn transpose(self) -> ColRef<'a, T, Cols, CStride> {
		self.into_const().transpose()
	}

	#[inline(always)]
	/// see [`RowRef::conjugate`]
	pub fn conjugate(self) -> RowRef<'a, T::Conj, Cols, CStride>
	where
		T: Conjugate,
	{
		self.into_const().conjugate()
	}

	#[inline(always)]
	/// see [`RowRef::canonical`]
	pub fn canonical(self) -> RowRef<'a, T::Canonical, Cols, CStride>
	where
		T: Conjugate,
	{
		self.into_const().canonical()
	}

	#[inline(always)]
	/// see [`RowRef::adjoint`]
	pub fn adjoint(self) -> ColRef<'a, T::Conj, Cols, CStride>
	where
		T: Conjugate,
	{
		self.into_const().adjoint()
	}

	#[track_caller]
	#[inline(always)]
	/// see [`RowRef::get`]
	pub fn get<ColRange>(
		self,
		col: ColRange,
	) -> <RowRef<'a, T, Cols, CStride> as RowIndex<ColRange>>::Target
	where
		RowRef<'a, T, Cols, CStride>: RowIndex<ColRange>,
	{
		<RowRef<'a, T, Cols, CStride> as RowIndex<ColRange>>::get(
			self.into_const(),
			col,
		)
	}

	#[track_caller]
	#[inline(always)]
	/// see [`RowRef::get_unchecked`]
	pub unsafe fn get_unchecked<ColRange>(
		self,
		col: ColRange,
	) -> <RowRef<'a, T, Cols, CStride> as RowIndex<ColRange>>::Target
	where
		RowRef<'a, T, Cols, CStride>: RowIndex<ColRange>,
	{
		unsafe {
			<RowRef<'a, T, Cols, CStride> as RowIndex<ColRange>>::get_unchecked(
				self.into_const(),
				col,
			)
		}
	}

	#[inline]
	/// see [`RowRef::reverse_cols`]
	pub fn reverse_cols(self) -> RowRef<'a, T, Cols, CStride::Rev> {
		self.into_const().reverse_cols()
	}

	#[inline]
	/// see [`RowRef::subcols`]
	pub fn subcols<V: Shape>(
		self,
		col_start: IdxInc<Cols>,
		ncols: V,
	) -> RowRef<'a, T, V, CStride> {
		self.into_const().subcols(col_start, ncols)
	}

	#[inline]
	#[track_caller]
	/// see [`RowRef::as_col_shape`]
	pub fn as_col_shape<V: Shape>(self, ncols: V) -> RowRef<'a, T, V, CStride> {
		self.into_const().as_col_shape(ncols)
	}

	#[inline]
	/// see [`RowRef::as_dyn_cols`]
	pub fn as_dyn_cols(self) -> RowRef<'a, T, usize, CStride> {
		self.into_const().as_dyn_cols()
	}

	#[inline]
	/// see [`RowRef::as_dyn_stride`]
	pub fn as_dyn_stride(self) -> RowRef<'a, T, Cols, isize> {
		self.into_const().as_dyn_stride()
	}

	#[inline]
	/// see [`RowRef::iter`]
	pub fn iter(
		self,
	) -> impl 'a + ExactSizeIterator + DoubleEndedIterator<Item = &'a T>
	where
		Cols: 'a,
	{
		self.0.trans.iter()
	}

	#[inline]
	#[cfg(feature = "rayon")]
	/// see [`RowRef::par_iter`]
	pub fn par_iter(
		self,
	) -> impl 'a + rayon::iter::IndexedParallelIterator<Item = &'a T>
	where
		T: Sync,
		Cols: 'a,
	{
		self.0.trans.par_iter()
	}

	#[inline]
	/// see [`RowRef::try_as_row_major`]
	pub fn try_as_row_major(
		self,
	) -> Option<RowRef<'a, T, Cols, ContiguousFwd>> {
		self.into_const().try_as_row_major()
	}

	#[inline]
	/// see [`RowRef::as_diagonal`]
	pub fn as_diagonal(self) -> DiagRef<'a, T, Cols, CStride> {
		DiagRef {
			0: crate::diag::Ref {
				inner: self.0.trans.into_const(),
			},
		}
	}

	#[inline(always)]
	#[doc(hidden)]
	pub unsafe fn const_cast(self) -> RowMut<'a, T, Cols, CStride> {
		RowMut {
			0: Mut {
				trans: self.0.trans.const_cast(),
			},
		}
	}

	#[inline]
	/// see [`RowRef::as_mat`]
	pub fn as_mat(self) -> MatRef<'a, T, usize, Cols, isize, CStride> {
		self.into_const().as_mat()
	}

	#[inline]
	/// see [`RowRef::as_mat`]
	pub fn as_mat_mut(self) -> MatMut<'a, T, usize, Cols, isize, CStride> {
		unsafe { self.into_const().as_mat().const_cast() }
	}
}
impl<
	T,
	Cols: Shape,
	CStride: Stride,
	Inner: for<'short> ReborrowMut<'short, Target = Mut<'short, T, Cols, CStride>>,
> generic::Row<Inner>
{
	#[inline]
	/// returns a view over `self`
	pub fn as_mut(&mut self) -> RowMut<'_, T, Cols, CStride> {
		self.rb_mut()
	}

	#[inline]
	/// copies `other` into `self`
	pub fn copy_from<RhsT: Conjugate<Canonical = T>>(
		&mut self,
		other: impl AsRowRef<T = RhsT, Cols = Cols>,
	) where
		T: ComplexField,
	{
		self.rb_mut()
			.transpose_mut()
			.copy_from(other.as_row_ref().transpose());
	}

	/// fills all the elements of `self` with `value`
	pub fn fill(&mut self, value: T)
	where
		T: Clone,
	{
		self.rb_mut().transpose_mut().fill(value)
	}
}
impl<'a, T, Cols: Shape, CStride: Stride> RowMut<'a, T, Cols, CStride> {
	#[inline(always)]
	/// see [`RowRef::as_ptr`]
	pub fn as_ptr_mut(&self) -> *mut T {
		self.trans.as_ptr_mut()
	}

	#[inline(always)]
	/// see [`RowRef::ptr_at`]
	pub fn ptr_at_mut(&self, col: IdxInc<Cols>) -> *mut T {
		self.trans.ptr_at_mut(col)
	}

	#[inline(always)]
	#[track_caller]
	/// see [`RowRef::ptr_inbounds_at`]
	pub unsafe fn ptr_inbounds_at_mut(&self, col: Idx<Cols>) -> *mut T {
		debug_assert!(all(col < self.ncols()));
		self.trans.ptr_inbounds_at_mut(col)
	}

	#[inline]
	#[track_caller]
	/// see [`RowRef::split_at_col`]
	pub fn split_at_col_mut(
		self,
		col: IdxInc<Cols>,
	) -> (RowMut<'a, T, usize, CStride>, RowMut<'a, T, usize, CStride>) {
		let (a, b) = self.into_const().split_at_col(col);
		unsafe { (a.const_cast(), b.const_cast()) }
	}

	#[inline(always)]
	/// see [`RowRef::transpose`]
	pub fn transpose_mut(self) -> ColMut<'a, T, Cols, CStride> {
		self.0.trans
	}

	#[inline(always)]
	/// see [`RowRef::conjugate`]
	pub fn conjugate_mut(self) -> RowMut<'a, T::Conj, Cols, CStride>
	where
		T: Conjugate,
	{
		unsafe { self.into_const().conjugate().const_cast() }
	}

	#[inline(always)]
	/// see [`RowRef::canonical`]
	pub fn canonical_mut(self) -> RowMut<'a, T::Canonical, Cols, CStride>
	where
		T: Conjugate,
	{
		unsafe { self.into_const().canonical().const_cast() }
	}

	#[inline(always)]
	/// see [`RowRef::adjoint`]
	pub fn adjoint_mut(self) -> ColMut<'a, T::Conj, Cols, CStride>
	where
		T: Conjugate,
	{
		unsafe { self.into_const().adjoint().const_cast() }
	}

	#[inline(always)]
	#[track_caller]
	pub(crate) fn at_mut(self, col: Idx<Cols>) -> &'a mut T {
		assert!(all(col < self.ncols()));
		unsafe { self.at_mut_unchecked(col) }
	}

	#[inline(always)]
	#[track_caller]
	pub(crate) unsafe fn at_mut_unchecked(self, col: Idx<Cols>) -> &'a mut T {
		&mut *self.ptr_inbounds_at_mut(col)
	}

	#[track_caller]
	#[inline(always)]
	/// see [`RowRef::get`]
	pub fn get_mut<ColRange>(
		self,
		col: ColRange,
	) -> <RowMut<'a, T, Cols, CStride> as RowIndex<ColRange>>::Target
	where
		RowMut<'a, T, Cols, CStride>: RowIndex<ColRange>,
	{
		<RowMut<'a, T, Cols, CStride> as RowIndex<ColRange>>::get(self, col)
	}

	#[track_caller]
	#[inline(always)]
	/// see [`RowRef::get`]
	pub unsafe fn get_mut_unchecked<ColRange>(
		self,
		col: ColRange,
	) -> <RowMut<'a, T, Cols, CStride> as RowIndex<ColRange>>::Target
	where
		RowMut<'a, T, Cols, CStride>: RowIndex<ColRange>,
	{
		unsafe {
			<RowMut<'a, T, Cols, CStride> as RowIndex<ColRange>>::get_unchecked(
				self, col,
			)
		}
	}

	#[inline]
	/// see [`RowRef::reverse_cols`]
	pub fn reverse_cols_mut(self) -> RowMut<'a, T, Cols, CStride::Rev> {
		unsafe { self.into_const().reverse_cols().const_cast() }
	}

	#[inline]
	/// see [`RowRef::subcols`]
	pub fn subcols_mut<V: Shape>(
		self,
		col_start: IdxInc<Cols>,
		ncols: V,
	) -> RowMut<'a, T, V, CStride> {
		unsafe { self.into_const().subcols(col_start, ncols).const_cast() }
	}

	#[inline]
	#[track_caller]
	/// see [`RowRef::as_col_shape`]
	pub fn as_col_shape_mut<V: Shape>(
		self,
		ncols: V,
	) -> RowMut<'a, T, V, CStride> {
		unsafe { self.into_const().as_col_shape(ncols).const_cast() }
	}

	#[inline]
	/// see [`RowRef::as_dyn_cols`]
	pub fn as_dyn_cols_mut(self) -> RowMut<'a, T, usize, CStride> {
		unsafe { self.into_const().as_dyn_cols().const_cast() }
	}

	#[inline]
	/// see [`RowRef::as_dyn_stride`]
	pub fn as_dyn_stride_mut(self) -> RowMut<'a, T, Cols, isize> {
		unsafe { self.into_const().as_dyn_stride().const_cast() }
	}

	#[inline]
	/// see [`RowRef::iter`]
	pub fn iter_mut(
		self,
	) -> impl 'a + ExactSizeIterator + DoubleEndedIterator<Item = &'a mut T>
	where
		Cols: 'a,
	{
		self.0.trans.iter_mut()
	}

	#[inline]
	#[cfg(feature = "rayon")]
	/// see [`RowRef::par_iter`]
	pub fn par_iter_mut(
		self,
	) -> impl 'a + rayon::iter::IndexedParallelIterator<Item = &'a mut T>
	where
		T: Send,
		Cols: 'a,
	{
		self.0.trans.par_iter_mut()
	}

	#[inline]
	#[track_caller]
	#[cfg(feature = "rayon")]
	/// see [`RowRef::par_partition`]
	pub fn par_partition(
		self,
		count: usize,
	) -> impl 'a
	+ rayon::iter::IndexedParallelIterator<
		Item = RowRef<'a, T, usize, CStride>,
	>
	where
		T: Sync,
		Cols: 'a,
	{
		self.into_const().par_partition(count)
	}

	#[inline]
	#[track_caller]
	#[cfg(feature = "rayon")]
	/// see [`RowRef::par_partition`]
	pub fn par_partition_mut(
		self,
		count: usize,
	) -> impl 'a
	+ rayon::iter::IndexedParallelIterator<
		Item = RowMut<'a, T, usize, CStride>,
	>
	where
		T: Send,
		Cols: 'a,
	{
		use crate::mat::matmut::SyncCell;
		use rayon::prelude::*;
		unsafe {
			self.as_type::<SyncCell<T>>()
				.into_const()
				.par_partition(count)
				.map(|col| col.const_cast().as_type::<T>())
		}
	}

	pub(crate) unsafe fn as_type<U>(self) -> RowMut<'a, U, Cols, CStride> {
		RowMut::from_raw_parts_mut(
			self.as_ptr_mut() as *mut U,
			self.ncols(),
			self.col_stride(),
		)
	}

	#[inline]
	/// see [`RowRef::try_as_row_major`]
	pub fn try_as_row_major_mut(
		self,
	) -> Option<RowMut<'a, T, Cols, ContiguousFwd>> {
		self.into_const()
			.try_as_row_major()
			.map(|x| unsafe { x.const_cast() })
	}

	#[inline]
	/// see [`RowRef::as_diagonal`]
	pub fn as_diagonal_mut(self) -> DiagMut<'a, T, Cols, CStride> {
		DiagMut {
			0: crate::diag::Mut {
				inner: self.0.trans,
			},
		}
	}

	#[inline]
	pub(crate) fn __at_mut(self, i: Idx<Cols>) -> &'a mut T {
		self.at_mut(i)
	}
}
impl<'a, T, Rows: Shape> RowMut<'a, T, Rows, ContiguousFwd> {
	/// returns a reference over the elements as a slice
	#[inline]
	pub fn as_slice(self) -> &'a [T] {
		self.transpose().as_slice()
	}
}
impl<'a, 'ROWS, T> RowMut<'a, T, Dim<'ROWS>, ContiguousFwd> {
	/// returns a reference over the elements as a lifetime-bound slice
	#[inline]
	pub fn as_array(self) -> &'a Array<'ROWS, T> {
		self.transpose().as_array()
	}
}
impl<'a, T, Cols: Shape> RowMut<'a, T, Cols, ContiguousFwd> {
	/// returns a reference over the elements as a slice
	#[inline]
	pub fn as_slice_mut(self) -> &'a mut [T] {
		self.transpose_mut().as_slice_mut()
	}
}
impl<'a, 'COLS, T> RowMut<'a, T, Dim<'COLS>, ContiguousFwd> {
	/// returns a reference over the elements as a lifetime-bound slice
	#[inline]
	pub fn as_array_mut(self) -> &'a mut Array<'COLS, T> {
		self.transpose_mut().as_array_mut()
	}
}
impl<'COLS, 'a, T, CStride: Stride> RowMut<'a, T, Dim<'COLS>, CStride> {
	#[doc(hidden)]
	#[inline]
	pub fn split_cols_with<'LEFT, 'RIGHT>(
		self,
		col: Partition<'LEFT, 'RIGHT, 'COLS>,
	) -> (
		RowRef<'a, T, Dim<'LEFT>, CStride>,
		RowRef<'a, T, Dim<'RIGHT>, CStride>,
	) {
		let (a, b) = self.split_at_col(col.midpoint());
		(a.as_col_shape(col.head), b.as_col_shape(col.tail))
	}
}
impl<'COLS, 'a, T, CStride: Stride> RowMut<'a, T, Dim<'COLS>, CStride> {
	#[doc(hidden)]
	#[inline]
	pub fn split_cols_with_mut<'LEFT, 'RIGHT>(
		self,
		col: Partition<'LEFT, 'RIGHT, 'COLS>,
	) -> (
		RowMut<'a, T, Dim<'LEFT>, CStride>,
		RowMut<'a, T, Dim<'RIGHT>, CStride>,
	) {
		let (a, b) = self.split_at_col_mut(col.midpoint());
		(a.as_col_shape_mut(col.head), b.as_col_shape_mut(col.tail))
	}
}
impl<T: core::fmt::Debug, Cols: Shape, CStride: Stride> core::fmt::Debug
	for Mut<'_, T, Cols, CStride>
{
	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
		self.rb().fmt(f)
	}
}
impl<'a, T, Cols: Shape, CStride: Stride> RowMut<'a, T, Cols, CStride>
where
	T: RealField,
{
	/// Returns the maximum element in the row, or `None` if the row is empty
	pub fn max(&self) -> Option<T> {
		self.rb().as_dyn_cols().as_dyn_stride().internal_max()
	}

	/// Returns the minimum element in the row, or `None` if the row is empty
	pub fn min(&self) -> Option<T> {
		self.rb().as_dyn_cols().as_dyn_stride().internal_min()
	}
}
#[cfg(test)]
mod tests {
	use crate::Row;
	#[test]
	fn test_row_min() {
		let row: Row<f64> = Row::from_fn(5, |x| (x + 1) as f64);
		let rowmut = row.as_ref();
		assert_eq!(rowmut.min(), Some(1.0));
		let empty: Row<f64> = Row::from_fn(0, |_| 0.0);
		let emptymut = empty.as_ref();
		assert_eq!(emptymut.min(), None);
	}
	#[test]
	fn test_row_max() {
		let row: Row<f64> = Row::from_fn(5, |x| (x + 1) as f64);
		let rowmut = row.as_ref();
		assert_eq!(rowmut.max(), Some(5.0));
		let empty: Row<f64> = Row::from_fn(0, |_| 0.0);
		let emptymut = empty.as_ref();
		assert_eq!(emptymut.max(), None);
	}
}