|
47 | 47 |
|
48 | 48 | impl<S, D> ArrayBase<S, D>
|
49 | 49 | where
|
50 |
| - S: Data, |
| 50 | + S: RawData, |
51 | 51 | D: Dimension,
|
52 | 52 | {
|
53 | 53 | pub(crate) fn layout_impl(&self) -> Layout {
|
|
57 | 57 | } else {
|
58 | 58 | CORDER
|
59 | 59 | }
|
60 |
| - } else if self.ndim() > 1 && self.t().is_standard_layout() { |
| 60 | + } else if self.ndim() > 1 && self.raw_view().reversed_axes().is_standard_layout() { |
61 | 61 | FORDER
|
62 | 62 | } else {
|
63 | 63 | 0
|
@@ -192,6 +192,14 @@ pub trait Offset: Copy {
|
192 | 192 | private_decl! {}
|
193 | 193 | }
|
194 | 194 |
|
| 195 | +impl<T> Offset for *const T { |
| 196 | + type Stride = isize; |
| 197 | + unsafe fn stride_offset(self, s: Self::Stride, index: usize) -> Self { |
| 198 | + self.offset(s * (index as isize)) |
| 199 | + } |
| 200 | + private_impl! {} |
| 201 | +} |
| 202 | + |
195 | 203 | impl<T> Offset for *mut T {
|
196 | 204 | type Stride = isize;
|
197 | 205 | unsafe fn stride_offset(self, s: Self::Stride, index: usize) -> Self {
|
@@ -389,6 +397,112 @@ impl<'a, A, D: Dimension> NdProducer for ArrayViewMut<'a, A, D> {
|
389 | 397 | }
|
390 | 398 | }
|
391 | 399 |
|
| 400 | +impl<A, D: Dimension> NdProducer for RawArrayView<A, D> { |
| 401 | + type Item = *const A; |
| 402 | + type Dim = D; |
| 403 | + type Ptr = *const A; |
| 404 | + type Stride = isize; |
| 405 | + |
| 406 | + private_impl! {} |
| 407 | + #[doc(hidden)] |
| 408 | + fn raw_dim(&self) -> Self::Dim { |
| 409 | + self.raw_dim() |
| 410 | + } |
| 411 | + |
| 412 | + #[doc(hidden)] |
| 413 | + fn equal_dim(&self, dim: &Self::Dim) -> bool { |
| 414 | + self.dim.equal(dim) |
| 415 | + } |
| 416 | + |
| 417 | + #[doc(hidden)] |
| 418 | + fn as_ptr(&self) -> *const A { |
| 419 | + self.as_ptr() |
| 420 | + } |
| 421 | + |
| 422 | + #[doc(hidden)] |
| 423 | + fn layout(&self) -> Layout { |
| 424 | + self.layout_impl() |
| 425 | + } |
| 426 | + |
| 427 | + #[doc(hidden)] |
| 428 | + unsafe fn as_ref(&self, ptr: *const A) -> *const A { |
| 429 | + ptr |
| 430 | + } |
| 431 | + |
| 432 | + #[doc(hidden)] |
| 433 | + unsafe fn uget_ptr(&self, i: &Self::Dim) -> *const A { |
| 434 | + self.ptr.as_ptr().offset(i.index_unchecked(&self.strides)) |
| 435 | + } |
| 436 | + |
| 437 | + #[doc(hidden)] |
| 438 | + fn stride_of(&self, axis: Axis) -> isize { |
| 439 | + self.stride_of(axis) |
| 440 | + } |
| 441 | + |
| 442 | + #[inline(always)] |
| 443 | + fn contiguous_stride(&self) -> Self::Stride { |
| 444 | + 1 |
| 445 | + } |
| 446 | + |
| 447 | + #[doc(hidden)] |
| 448 | + fn split_at(self, axis: Axis, index: usize) -> (Self, Self) { |
| 449 | + self.split_at(axis, index) |
| 450 | + } |
| 451 | +} |
| 452 | + |
| 453 | +impl<A, D: Dimension> NdProducer for RawArrayViewMut<A, D> { |
| 454 | + type Item = *mut A; |
| 455 | + type Dim = D; |
| 456 | + type Ptr = *mut A; |
| 457 | + type Stride = isize; |
| 458 | + |
| 459 | + private_impl! {} |
| 460 | + #[doc(hidden)] |
| 461 | + fn raw_dim(&self) -> Self::Dim { |
| 462 | + self.raw_dim() |
| 463 | + } |
| 464 | + |
| 465 | + #[doc(hidden)] |
| 466 | + fn equal_dim(&self, dim: &Self::Dim) -> bool { |
| 467 | + self.dim.equal(dim) |
| 468 | + } |
| 469 | + |
| 470 | + #[doc(hidden)] |
| 471 | + fn as_ptr(&self) -> *mut A { |
| 472 | + self.as_ptr() as _ |
| 473 | + } |
| 474 | + |
| 475 | + #[doc(hidden)] |
| 476 | + fn layout(&self) -> Layout { |
| 477 | + self.layout_impl() |
| 478 | + } |
| 479 | + |
| 480 | + #[doc(hidden)] |
| 481 | + unsafe fn as_ref(&self, ptr: *mut A) -> *mut A { |
| 482 | + ptr |
| 483 | + } |
| 484 | + |
| 485 | + #[doc(hidden)] |
| 486 | + unsafe fn uget_ptr(&self, i: &Self::Dim) -> *mut A { |
| 487 | + self.ptr.as_ptr().offset(i.index_unchecked(&self.strides)) |
| 488 | + } |
| 489 | + |
| 490 | + #[doc(hidden)] |
| 491 | + fn stride_of(&self, axis: Axis) -> isize { |
| 492 | + self.stride_of(axis) |
| 493 | + } |
| 494 | + |
| 495 | + #[inline(always)] |
| 496 | + fn contiguous_stride(&self) -> Self::Stride { |
| 497 | + 1 |
| 498 | + } |
| 499 | + |
| 500 | + #[doc(hidden)] |
| 501 | + fn split_at(self, axis: Axis, index: usize) -> (Self, Self) { |
| 502 | + self.split_at(axis, index) |
| 503 | + } |
| 504 | +} |
| 505 | + |
392 | 506 | /// Lock step function application across several arrays or other producers.
|
393 | 507 | ///
|
394 | 508 | /// Zip allows matching several producers to each other elementwise and applying
|
|
0 commit comments