Skip to content

Commit bf93c9d

Browse files
Shaturadamreichold
authored andcommitted
Update to nalgebra 0.32
1 parent 65b6693 commit bf93c9d

File tree

4 files changed

+30
-34
lines changed

4 files changed

+30
-34
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ license = "BSD-2-Clause"
1717
[dependencies]
1818
half = { version = "2.0", default-features = false, optional = true }
1919
libc = "0.2"
20-
nalgebra = { version = "0.31", default-features = false, optional = true }
20+
nalgebra = { version = "0.32", default-features = false, optional = true }
2121
num-complex = ">= 0.2, < 0.5"
2222
num-integer = "0.1"
2323
num-traits = "0.2"
@@ -27,7 +27,7 @@ rustc-hash = "1.1"
2727

2828
[dev-dependencies]
2929
pyo3 = { version = "0.17", default-features = false, features = ["auto-initialize"] }
30-
nalgebra = { version = "0.31", default-features = false, features = ["std"] }
30+
nalgebra = { version = "0.32", default-features = false, features = ["std"] }
3131

3232
[package.metadata.docs.rs]
3333
all-features = true

src/array.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,15 +1101,15 @@ where
11011101
Some((shape, strides))
11021102
}
11031103

1104-
/// Try to convert this array into a [`nalgebra::MatrixSlice`] using the given shape and strides.
1104+
/// Try to convert this array into a [`nalgebra::MatrixView`] using the given shape and strides.
11051105
///
11061106
/// # Safety
11071107
///
11081108
/// Calling this method invalidates all exclusive references to the internal data, e.g. `ArrayViewMut` or `MatrixSliceMut`.
11091109
#[doc(alias = "nalgebra")]
11101110
pub unsafe fn try_as_matrix<R, C, RStride, CStride>(
11111111
&self,
1112-
) -> Option<nalgebra::MatrixSlice<N, R, C, RStride, CStride>>
1112+
) -> Option<nalgebra::MatrixView<N, R, C, RStride, CStride>>
11131113
where
11141114
R: nalgebra::Dim,
11151115
C: nalgebra::Dim,
@@ -1118,20 +1118,20 @@ where
11181118
{
11191119
let (shape, strides) = self.try_as_matrix_shape_strides()?;
11201120

1121-
let storage = nalgebra::SliceStorage::from_raw_parts(self.data(), shape, strides);
1121+
let storage = nalgebra::ViewStorage::from_raw_parts(self.data(), shape, strides);
11221122

11231123
Some(nalgebra::Matrix::from_data(storage))
11241124
}
11251125

1126-
/// Try to convert this array into a [`nalgebra::MatrixSliceMut`] using the given shape and strides.
1126+
/// Try to convert this array into a [`nalgebra::MatrixViewMut`] using the given shape and strides.
11271127
///
11281128
/// # Safety
11291129
///
11301130
/// Calling this method invalidates all other references to the internal data, e.g. `ArrayView`, `MatrixSlice`, `ArrayViewMut` or `MatrixSliceMut`.
11311131
#[doc(alias = "nalgebra")]
11321132
pub unsafe fn try_as_matrix_mut<R, C, RStride, CStride>(
11331133
&self,
1134-
) -> Option<nalgebra::MatrixSliceMut<N, R, C, RStride, CStride>>
1134+
) -> Option<nalgebra::MatrixViewMut<N, R, C, RStride, CStride>>
11351135
where
11361136
R: nalgebra::Dim,
11371137
C: nalgebra::Dim,
@@ -1140,7 +1140,7 @@ where
11401140
{
11411141
let (shape, strides) = self.try_as_matrix_shape_strides()?;
11421142

1143-
let storage = nalgebra::SliceStorageMut::from_raw_parts(self.data(), shape, strides);
1143+
let storage = nalgebra::ViewStorageMut::from_raw_parts(self.data(), shape, strides);
11441144

11451145
Some(nalgebra::Matrix::from_data(storage))
11461146
}

src/borrow/mod.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ where
274274
N: nalgebra::Scalar + Element,
275275
D: Dimension,
276276
{
277-
/// Try to convert this array into a [`nalgebra::MatrixSlice`] using the given shape and strides.
277+
/// Try to convert this array into a [`nalgebra::MatrixView`] using the given shape and strides.
278278
#[doc(alias = "nalgebra")]
279279
pub fn try_as_matrix<R, C, RStride, CStride>(
280280
&self,
281-
) -> Option<nalgebra::MatrixSlice<N, R, C, RStride, CStride>>
281+
) -> Option<nalgebra::MatrixView<N, R, C, RStride, CStride>>
282282
where
283283
R: nalgebra::Dim,
284284
C: nalgebra::Dim,
@@ -294,13 +294,13 @@ impl<'py, N> PyReadonlyArray<'py, N, Ix1>
294294
where
295295
N: nalgebra::Scalar + Element,
296296
{
297-
/// Convert this one-dimensional array into a [`nalgebra::DMatrixSlice`] using dynamic strides.
297+
/// Convert this one-dimensional array into a [`nalgebra::DMatrixView`] using dynamic strides.
298298
///
299299
/// # Panics
300300
///
301301
/// Panics if the array has negative strides.
302302
#[doc(alias = "nalgebra")]
303-
pub fn as_matrix(&self) -> nalgebra::DMatrixSlice<N, nalgebra::Dynamic, nalgebra::Dynamic> {
303+
pub fn as_matrix(&self) -> nalgebra::DMatrixView<N, nalgebra::Dyn, nalgebra::Dyn> {
304304
self.try_as_matrix().unwrap()
305305
}
306306
}
@@ -310,13 +310,13 @@ impl<'py, N> PyReadonlyArray<'py, N, Ix2>
310310
where
311311
N: nalgebra::Scalar + Element,
312312
{
313-
/// Convert this two-dimensional array into a [`nalgebra::DMatrixSlice`] using dynamic strides.
313+
/// Convert this two-dimensional array into a [`nalgebra::DMatrixView`] using dynamic strides.
314314
///
315315
/// # Panics
316316
///
317317
/// Panics if the array has negative strides.
318318
#[doc(alias = "nalgebra")]
319-
pub fn as_matrix(&self) -> nalgebra::DMatrixSlice<N, nalgebra::Dynamic, nalgebra::Dynamic> {
319+
pub fn as_matrix(&self) -> nalgebra::DMatrixView<N, nalgebra::Dyn, nalgebra::Dyn> {
320320
self.try_as_matrix().unwrap()
321321
}
322322
}
@@ -456,11 +456,11 @@ where
456456
N: nalgebra::Scalar + Element,
457457
D: Dimension,
458458
{
459-
/// Try to convert this array into a [`nalgebra::MatrixSliceMut`] using the given shape and strides.
459+
/// Try to convert this array into a [`nalgebra::MatrixViewMut`] using the given shape and strides.
460460
#[doc(alias = "nalgebra")]
461461
pub fn try_as_matrix_mut<R, C, RStride, CStride>(
462462
&self,
463-
) -> Option<nalgebra::MatrixSliceMut<N, R, C, RStride, CStride>>
463+
) -> Option<nalgebra::MatrixViewMut<N, R, C, RStride, CStride>>
464464
where
465465
R: nalgebra::Dim,
466466
C: nalgebra::Dim,
@@ -476,15 +476,13 @@ impl<'py, N> PyReadwriteArray<'py, N, Ix1>
476476
where
477477
N: nalgebra::Scalar + Element,
478478
{
479-
/// Convert this one-dimensional array into a [`nalgebra::DMatrixSliceMut`] using dynamic strides.
479+
/// Convert this one-dimensional array into a [`nalgebra::DMatrixViewMut`] using dynamic strides.
480480
///
481481
/// # Panics
482482
///
483483
/// Panics if the array has negative strides.
484484
#[doc(alias = "nalgebra")]
485-
pub fn as_matrix_mut(
486-
&self,
487-
) -> nalgebra::DMatrixSliceMut<N, nalgebra::Dynamic, nalgebra::Dynamic> {
485+
pub fn as_matrix_mut(&self) -> nalgebra::DMatrixViewMut<N, nalgebra::Dyn, nalgebra::Dyn> {
488486
self.try_as_matrix_mut().unwrap()
489487
}
490488
}
@@ -494,15 +492,13 @@ impl<'py, N> PyReadwriteArray<'py, N, Ix2>
494492
where
495493
N: nalgebra::Scalar + Element,
496494
{
497-
/// Convert this two-dimensional array into a [`nalgebra::DMatrixSliceMut`] using dynamic strides.
495+
/// Convert this two-dimensional array into a [`nalgebra::DMatrixViewMut`] using dynamic strides.
498496
///
499497
/// # Panics
500498
///
501499
/// Panics if the array has negative strides.
502500
#[doc(alias = "nalgebra")]
503-
pub fn as_matrix_mut(
504-
&self,
505-
) -> nalgebra::DMatrixSliceMut<N, nalgebra::Dynamic, nalgebra::Dynamic> {
501+
pub fn as_matrix_mut(&self) -> nalgebra::DMatrixViewMut<N, nalgebra::Dyn, nalgebra::Dyn> {
506502
self.try_as_matrix_mut().unwrap()
507503
}
508504
}

tests/borrow.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ fn matrix_from_numpy() {
355355
let matrix = array.as_matrix();
356356
assert_eq!(matrix, nalgebra::Matrix3::new(0, 1, 2, 3, 4, 5, 6, 7, 8));
357357

358-
let matrix: nalgebra::MatrixSlice<
358+
let matrix: nalgebra::MatrixView<
359359
i32,
360360
nalgebra::Const<3>,
361361
nalgebra::Const<3>,
@@ -371,7 +371,7 @@ fn matrix_from_numpy() {
371371
let matrix = array.as_matrix_mut();
372372
assert_eq!(matrix, nalgebra::Matrix3::new(0, 1, 2, 3, 4, 5, 6, 7, 8));
373373

374-
let matrix: nalgebra::MatrixSliceMut<
374+
let matrix: nalgebra::MatrixViewMut<
375375
i32,
376376
nalgebra::Const<3>,
377377
nalgebra::Const<3>,
@@ -391,7 +391,7 @@ fn matrix_from_numpy() {
391391
let matrix = array.as_matrix();
392392
assert_eq!(matrix, nalgebra::Matrix3x1::new(0, 1, 2));
393393

394-
let matrix: nalgebra::MatrixSlice<i32, nalgebra::Const<3>, nalgebra::Const<1>> =
394+
let matrix: nalgebra::MatrixView<i32, nalgebra::Const<3>, nalgebra::Const<1>> =
395395
array.try_as_matrix().unwrap();
396396
assert_eq!(matrix, nalgebra::Matrix3x1::new(0, 1, 2));
397397
}
@@ -402,7 +402,7 @@ fn matrix_from_numpy() {
402402
let matrix = array.as_matrix_mut();
403403
assert_eq!(matrix, nalgebra::Matrix3x1::new(0, 1, 2));
404404

405-
let matrix: nalgebra::MatrixSliceMut<i32, nalgebra::Const<3>, nalgebra::Const<1>> =
405+
let matrix: nalgebra::MatrixViewMut<i32, nalgebra::Const<3>, nalgebra::Const<1>> =
406406
array.try_as_matrix_mut().unwrap();
407407
assert_eq!(matrix, nalgebra::Matrix3x1::new(0, 1, 2));
408408
}
@@ -412,7 +412,7 @@ fn matrix_from_numpy() {
412412
let array = PyArray::<i32, _>::zeros(py, (2, 2, 2), false);
413413
let array = array.readonly();
414414

415-
let matrix: Option<nalgebra::DMatrixSlice<i32, nalgebra::Dynamic, nalgebra::Dynamic>> =
415+
let matrix: Option<nalgebra::DMatrixView<i32, nalgebra::Dyn, nalgebra::Dyn>> =
416416
array.try_as_matrix();
417417
assert!(matrix.is_none());
418418
});
@@ -426,7 +426,7 @@ fn matrix_from_numpy() {
426426
.unwrap();
427427
let array = array.readonly();
428428

429-
let matrix: Option<nalgebra::DMatrixSlice<i32, nalgebra::Dynamic, nalgebra::Dynamic>> =
429+
let matrix: Option<nalgebra::DMatrixView<i32, nalgebra::Dyn, nalgebra::Dyn>> =
430430
array.try_as_matrix();
431431
assert!(matrix.is_none());
432432
});
@@ -436,7 +436,7 @@ fn matrix_from_numpy() {
436436
let array = array.readonly();
437437

438438
let matrix: Option<
439-
nalgebra::MatrixSlice<
439+
nalgebra::MatrixView<
440440
i32,
441441
nalgebra::Const<2>,
442442
nalgebra::Const<3>,
@@ -447,7 +447,7 @@ fn matrix_from_numpy() {
447447
assert!(matrix.is_none());
448448

449449
let matrix: Option<
450-
nalgebra::MatrixSlice<
450+
nalgebra::MatrixView<
451451
i32,
452452
nalgebra::Const<3>,
453453
nalgebra::Const<2>,
@@ -458,7 +458,7 @@ fn matrix_from_numpy() {
458458
assert!(matrix.is_none());
459459

460460
let matrix: Option<
461-
nalgebra::MatrixSlice<
461+
nalgebra::MatrixView<
462462
i32,
463463
nalgebra::Const<3>,
464464
nalgebra::Const<3>,
@@ -469,7 +469,7 @@ fn matrix_from_numpy() {
469469
assert!(matrix.is_none());
470470

471471
let matrix: Option<
472-
nalgebra::MatrixSlice<
472+
nalgebra::MatrixView<
473473
i32,
474474
nalgebra::Const<3>,
475475
nalgebra::Const<3>,

0 commit comments

Comments
 (0)