Replace slice->view in tests and benches
This commit is contained in:
parent
234d61faa2
commit
6c8947ccc0
|
@ -53,7 +53,7 @@ fn mat_div_scalar(b: &mut criterion::Criterion) {
|
||||||
b.bench_function("mat_div_scalar", move |bh| {
|
b.bench_function("mat_div_scalar", move |bh| {
|
||||||
bh.iter(|| {
|
bh.iter(|| {
|
||||||
let mut aa = a.clone();
|
let mut aa = a.clone();
|
||||||
let mut b = aa.slice_mut((0, 0), (1000, 1000));
|
let mut b = aa.view_mut((0, 0), (1000, 1000));
|
||||||
b /= n
|
b /= n
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@ use na::{
|
||||||
RowVector5, RowVector6, Similarity3, Transform3, UnitQuaternion, Vector1, Vector2, Vector3,
|
RowVector5, RowVector6, Similarity3, Transform3, UnitQuaternion, Vector1, Vector2, Vector3,
|
||||||
Vector4, Vector5, Vector6,
|
Vector4, Vector5, Vector6,
|
||||||
};
|
};
|
||||||
use na::{DMatrix, DMatrixSlice, DMatrixSliceMut, MatrixSlice, MatrixSliceMut};
|
use na::{DMatrix, DMatrixView, DMatrixViewMut, MatrixView, MatrixViewMut};
|
||||||
use na::{U1, U3, U4};
|
use na::{U1, U3, U4};
|
||||||
|
|
||||||
use crate::proptest::*;
|
use crate::proptest::*;
|
||||||
|
@ -266,24 +266,24 @@ fn matrix_slice_from_matrix_ref() {
|
||||||
// Note: these have to be macros, and not functions, because the input type is different
|
// Note: these have to be macros, and not functions, because the input type is different
|
||||||
// across the different tests. Moreover, the output type depends on the stride of the input,
|
// across the different tests. Moreover, the output type depends on the stride of the input,
|
||||||
// which is different for static and dynamic matrices.
|
// which is different for static and dynamic matrices.
|
||||||
macro_rules! dynamic_slice {
|
macro_rules! dynamic_view {
|
||||||
($mref:expr) => {
|
($mref:expr) => {
|
||||||
DMatrixSlice::<_>::from($mref)
|
DMatrixView::<_>::from($mref)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
macro_rules! dynamic_slice_mut {
|
macro_rules! dynamic_view_mut {
|
||||||
($mref:expr) => {
|
($mref:expr) => {
|
||||||
DMatrixSliceMut::<_>::from($mref)
|
DMatrixViewMut::<_>::from($mref)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
macro_rules! fixed_slice {
|
macro_rules! fixed_view {
|
||||||
($mref:expr) => {
|
($mref:expr) => {
|
||||||
MatrixSlice::<_, U3, U4, U1, U3>::from($mref)
|
MatrixView::<_, U3, U4, U1, U3>::from($mref)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
macro_rules! fixed_slice_mut {
|
macro_rules! fixed_view_mut {
|
||||||
($mref:expr) => {
|
($mref:expr) => {
|
||||||
MatrixSliceMut::<_, U3, U4, U1, U3>::from($mref)
|
MatrixViewMut::<_, U3, U4, U1, U3>::from($mref)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,66 +291,66 @@ fn matrix_slice_from_matrix_ref() {
|
||||||
// Self and RHS. See issue #674. Once this is implemented, we can remove `into_owned`
|
// Self and RHS. See issue #674. Once this is implemented, we can remove `into_owned`
|
||||||
// from the below tests.
|
// from the below tests.
|
||||||
|
|
||||||
// Construct slices from reference to a
|
// Construct views from reference to a
|
||||||
{
|
{
|
||||||
assert_eq!(a, fixed_slice!(&a).into_owned());
|
assert_eq!(a, fixed_view!(&a).into_owned());
|
||||||
assert_eq!(d, dynamic_slice!(&a).into_owned());
|
assert_eq!(d, dynamic_view!(&a).into_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct slices from mutable reference to a
|
// Construct views from mutable reference to a
|
||||||
{
|
{
|
||||||
let mut a_clone = a.clone();
|
let mut a_clone = a.clone();
|
||||||
assert_eq!(a, fixed_slice!(&mut a_clone).into_owned());
|
assert_eq!(a, fixed_view!(&mut a_clone).into_owned());
|
||||||
assert_eq!(d, dynamic_slice!(&mut a_clone).into_owned());
|
assert_eq!(d, dynamic_view!(&mut a_clone).into_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct mutable slices from mutable reference to a
|
// Construct mutable slices from mutable reference to a
|
||||||
{
|
{
|
||||||
let mut a_clone = a.clone();
|
let mut a_clone = a.clone();
|
||||||
assert_eq!(a, fixed_slice_mut!(&mut a_clone).into_owned());
|
assert_eq!(a, fixed_view_mut!(&mut a_clone).into_owned());
|
||||||
assert_eq!(d, dynamic_slice_mut!(&mut a_clone).into_owned());
|
assert_eq!(d, dynamic_view_mut!(&mut a_clone).into_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct slices from reference to d
|
// Construct slices from reference to d
|
||||||
{
|
{
|
||||||
assert_eq!(a, fixed_slice!(&d).into_owned());
|
assert_eq!(a, fixed_view!(&d).into_owned());
|
||||||
assert_eq!(d, dynamic_slice!(&d).into_owned());
|
assert_eq!(d, dynamic_view!(&d).into_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct slices from mutable reference to d
|
// Construct slices from mutable reference to d
|
||||||
{
|
{
|
||||||
let mut d_clone = a.clone();
|
let mut d_clone = a.clone();
|
||||||
assert_eq!(a, fixed_slice!(&mut d_clone).into_owned());
|
assert_eq!(a, fixed_view!(&mut d_clone).into_owned());
|
||||||
assert_eq!(d, dynamic_slice!(&mut d_clone).into_owned());
|
assert_eq!(d, dynamic_view!(&mut d_clone).into_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct mutable slices from mutable reference to d
|
// Construct mutable slices from mutable reference to d
|
||||||
{
|
{
|
||||||
let mut d_clone = d.clone();
|
let mut d_clone = d.clone();
|
||||||
assert_eq!(a, fixed_slice_mut!(&mut d_clone).into_owned());
|
assert_eq!(a, fixed_view_mut!(&mut d_clone).into_owned());
|
||||||
assert_eq!(d, dynamic_slice_mut!(&mut d_clone).into_owned());
|
assert_eq!(d, dynamic_view_mut!(&mut d_clone).into_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct slices from a slice of a
|
// Construct slices from a slice of a
|
||||||
{
|
{
|
||||||
let mut a_slice = fixed_slice!(&a);
|
let mut a_slice = fixed_view!(&a);
|
||||||
assert_eq!(a, fixed_slice!(&a_slice).into_owned());
|
assert_eq!(a, fixed_view!(&a_slice).into_owned());
|
||||||
assert_eq!(a, fixed_slice!(&mut a_slice).into_owned());
|
assert_eq!(a, fixed_view!(&mut a_slice).into_owned());
|
||||||
assert_eq!(d, dynamic_slice!(&a_slice).into_owned());
|
assert_eq!(d, dynamic_view!(&a_slice).into_owned());
|
||||||
assert_eq!(d, dynamic_slice!(&mut a_slice).into_owned());
|
assert_eq!(d, dynamic_view!(&mut a_slice).into_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct slices from a slice mut of a
|
// Construct slices from a slice mut of a
|
||||||
{
|
{
|
||||||
// Need a clone of a here, so that we can both have a mutable borrow and compare equality
|
// Need a clone of a here, so that we can both have a mutable borrow and compare equality
|
||||||
let mut a_clone = a.clone();
|
let mut a_clone = a.clone();
|
||||||
let mut a_slice = fixed_slice_mut!(&mut a_clone);
|
let mut a_slice = fixed_view_mut!(&mut a_clone);
|
||||||
|
|
||||||
assert_eq!(a, fixed_slice!(&a_slice).into_owned());
|
assert_eq!(a, fixed_view!(&a_slice).into_owned());
|
||||||
assert_eq!(a, fixed_slice!(&mut a_slice).into_owned());
|
assert_eq!(a, fixed_view!(&mut a_slice).into_owned());
|
||||||
assert_eq!(d, dynamic_slice!(&a_slice).into_owned());
|
assert_eq!(d, dynamic_view!(&a_slice).into_owned());
|
||||||
assert_eq!(d, dynamic_slice!(&mut a_slice).into_owned());
|
assert_eq!(d, dynamic_view!(&mut a_slice).into_owned());
|
||||||
assert_eq!(a, fixed_slice_mut!(&mut a_slice).into_owned());
|
assert_eq!(a, fixed_view_mut!(&mut a_slice).into_owned());
|
||||||
assert_eq!(d, dynamic_slice_mut!(&mut a_slice).into_owned());
|
assert_eq!(d, dynamic_view_mut!(&mut a_slice).into_owned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1066,43 +1066,43 @@ fn partial_eq_different_types() {
|
||||||
let static_mat = Matrix2x4::new(1, 2, 3, 4, 5, 6, 7, 8);
|
let static_mat = Matrix2x4::new(1, 2, 3, 4, 5, 6, 7, 8);
|
||||||
|
|
||||||
let mut typenum_static_mat = OMatrix::<u8, Const<1024>, Const<4>>::zeros();
|
let mut typenum_static_mat = OMatrix::<u8, Const<1024>, Const<4>>::zeros();
|
||||||
let mut slice = typenum_static_mat.slice_mut((0, 0), (2, 4));
|
let mut view = typenum_static_mat.view_mut((0, 0), (2, 4));
|
||||||
slice += static_mat;
|
view += static_mat;
|
||||||
|
|
||||||
let fslice_of_dmat = dynamic_mat.fixed_slice::<2, 2>(0, 0);
|
let fview_of_dmat = dynamic_mat.fixed_view::<2, 2>(0, 0);
|
||||||
let dslice_of_dmat = dynamic_mat.slice((0, 0), (2, 2));
|
let dview_of_dmat = dynamic_mat.view((0, 0), (2, 2));
|
||||||
let fslice_of_smat = static_mat.fixed_slice::<2, 2>(0, 0);
|
let fview_of_smat = static_mat.fixed_view::<2, 2>(0, 0);
|
||||||
let dslice_of_smat = static_mat.slice((0, 0), (2, 2));
|
let dview_of_smat = static_mat.view((0, 0), (2, 2));
|
||||||
|
|
||||||
assert_eq!(dynamic_mat, static_mat);
|
assert_eq!(dynamic_mat, static_mat);
|
||||||
assert_eq!(static_mat, dynamic_mat);
|
assert_eq!(static_mat, dynamic_mat);
|
||||||
|
|
||||||
assert_eq!(dynamic_mat, slice);
|
assert_eq!(dynamic_mat, view);
|
||||||
assert_eq!(slice, dynamic_mat);
|
assert_eq!(view, dynamic_mat);
|
||||||
|
|
||||||
assert_eq!(static_mat, slice);
|
assert_eq!(static_mat, view);
|
||||||
assert_eq!(slice, static_mat);
|
assert_eq!(view, static_mat);
|
||||||
|
|
||||||
assert_eq!(fslice_of_dmat, dslice_of_dmat);
|
assert_eq!(fview_of_dmat, dview_of_dmat);
|
||||||
assert_eq!(dslice_of_dmat, fslice_of_dmat);
|
assert_eq!(dview_of_dmat, fview_of_dmat);
|
||||||
|
|
||||||
assert_eq!(fslice_of_dmat, fslice_of_smat);
|
assert_eq!(fview_of_dmat, fview_of_smat);
|
||||||
assert_eq!(fslice_of_smat, fslice_of_dmat);
|
assert_eq!(fview_of_smat, fview_of_dmat);
|
||||||
|
|
||||||
assert_eq!(fslice_of_dmat, dslice_of_smat);
|
assert_eq!(fview_of_dmat, dview_of_smat);
|
||||||
assert_eq!(dslice_of_smat, fslice_of_dmat);
|
assert_eq!(dview_of_smat, fview_of_dmat);
|
||||||
|
|
||||||
assert_eq!(dslice_of_dmat, fslice_of_smat);
|
assert_eq!(dview_of_dmat, fview_of_smat);
|
||||||
assert_eq!(fslice_of_smat, dslice_of_dmat);
|
assert_eq!(fview_of_smat, dview_of_dmat);
|
||||||
|
|
||||||
assert_eq!(dslice_of_dmat, dslice_of_smat);
|
assert_eq!(dview_of_dmat, dview_of_smat);
|
||||||
assert_eq!(dslice_of_smat, dslice_of_dmat);
|
assert_eq!(dview_of_smat, dview_of_dmat);
|
||||||
|
|
||||||
assert_eq!(fslice_of_smat, dslice_of_smat);
|
assert_eq!(fview_of_smat, dview_of_smat);
|
||||||
assert_eq!(dslice_of_smat, fslice_of_smat);
|
assert_eq!(dview_of_smat, fview_of_smat);
|
||||||
|
|
||||||
assert_ne!(dynamic_mat, dslice_of_smat);
|
assert_ne!(dynamic_mat, dview_of_smat);
|
||||||
assert_ne!(dslice_of_smat, dynamic_mat);
|
assert_ne!(dview_of_smat, dynamic_mat);
|
||||||
|
|
||||||
// TODO - implement those comparisons
|
// TODO - implement those comparisons
|
||||||
// assert_ne!(static_mat, typenum_static_mat);
|
// assert_ne!(static_mat, typenum_static_mat);
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use na::{
|
use na::{
|
||||||
DMatrix, DMatrixSlice, DMatrixSliceMut, Matrix2, Matrix2x3, Matrix2x4, Matrix2x6, Matrix3,
|
DMatrix, DMatrixView, DMatrixViewMut, Matrix2, Matrix2x3, Matrix2x4, Matrix2x6, Matrix3,
|
||||||
Matrix3x2, Matrix3x4, Matrix4x2, Matrix6x2, MatrixSlice2, MatrixSlice2x3, MatrixSlice2xX,
|
Matrix3x2, Matrix3x4, Matrix4x2, Matrix6x2, MatrixView2, MatrixView2x3, MatrixView2xX,
|
||||||
MatrixSlice3, MatrixSlice3x2, MatrixSliceMut2, MatrixSliceMut2x3, MatrixSliceMut2xX,
|
MatrixView3, MatrixView3x2, MatrixViewMut2, MatrixViewMut2x3, MatrixViewMut2xX,
|
||||||
MatrixSliceMut3, MatrixSliceMut3x2, MatrixSliceMutXx3, MatrixSliceXx3, RowVector4, Vector3,
|
MatrixViewMut3, MatrixViewMut3x2, MatrixViewMutXx3, MatrixViewXx3, RowVector4, Vector3,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn nested_fixed_slices() {
|
fn nested_fixed_views() {
|
||||||
let a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0,
|
let a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0,
|
||||||
21.0, 22.0, 23.0, 24.0,
|
21.0, 22.0, 23.0, 24.0,
|
||||||
31.0, 32.0, 33.0, 34.0);
|
31.0, 32.0, 33.0, 34.0);
|
||||||
|
|
||||||
let s1 = a.fixed_slice::<3, 3>(0, 1); // Simple slice.
|
let s1 = a.fixed_view::<3, 3>(0, 1); // Simple view.
|
||||||
let s2 = s1.fixed_slice::<2, 2>(1, 1); // Slice of slice.
|
let s2 = s1.fixed_view::<2, 2>(1, 1); // View of view.
|
||||||
let s3 = s1.fixed_slice_with_steps::<2, 2>((0, 0), (1, 1)); // Slice of slice with steps.
|
let s3 = s1.fixed_view_with_steps::<2, 2>((0, 0), (1, 1)); // View of view with steps.
|
||||||
|
|
||||||
let expected_owned_s1 = Matrix3::new(12.0, 13.0, 14.0,
|
let expected_owned_s1 = Matrix3::new(12.0, 13.0, 14.0,
|
||||||
22.0, 23.0, 24.0,
|
22.0, 23.0, 24.0,
|
||||||
|
@ -35,14 +35,14 @@ fn nested_fixed_slices() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn nested_slices() {
|
fn nested_views() {
|
||||||
let a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0,
|
let a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0,
|
||||||
21.0, 22.0, 23.0, 24.0,
|
21.0, 22.0, 23.0, 24.0,
|
||||||
31.0, 32.0, 33.0, 34.0);
|
31.0, 32.0, 33.0, 34.0);
|
||||||
|
|
||||||
let s1 = a.slice((0, 1), (3, 3));
|
let s1 = a.view((0, 1), (3, 3));
|
||||||
let s2 = s1.slice((1, 1), (2, 2));
|
let s2 = s1.view((1, 1), (2, 2));
|
||||||
let s3 = s1.slice_with_steps((0, 0), (2, 2), (1, 1));
|
let s3 = s1.view_with_steps((0, 0), (2, 2), (1, 1));
|
||||||
|
|
||||||
let expected_owned_s1 = DMatrix::from_row_slice(3, 3, &[ 12.0, 13.0, 14.0,
|
let expected_owned_s1 = DMatrix::from_row_slice(3, 3, &[ 12.0, 13.0, 14.0,
|
||||||
22.0, 23.0, 24.0,
|
22.0, 23.0, 24.0,
|
||||||
|
@ -61,14 +61,14 @@ fn nested_slices() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn slice_mut() {
|
fn view_mut() {
|
||||||
let mut a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0,
|
let mut a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0,
|
||||||
21.0, 22.0, 23.0, 24.0,
|
21.0, 22.0, 23.0, 24.0,
|
||||||
31.0, 32.0, 33.0, 34.0);
|
31.0, 32.0, 33.0, 34.0);
|
||||||
|
|
||||||
{
|
{
|
||||||
// We modify `a` through the mutable slice.
|
// We modify `a` through the mutable view.
|
||||||
let mut s1 = a.slice_with_steps_mut((0, 1), (2, 2), (1, 1));
|
let mut s1 = a.view_with_steps_mut((0, 1), (2, 2), (1, 1));
|
||||||
s1.fill(0.0);
|
s1.fill(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ fn slice_mut() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn nested_row_slices() {
|
fn nested_row_views() {
|
||||||
let a = Matrix6x2::new(11.0, 12.0,
|
let a = Matrix6x2::new(11.0, 12.0,
|
||||||
21.0, 22.0,
|
21.0, 22.0,
|
||||||
31.0, 32.0,
|
31.0, 32.0,
|
||||||
|
@ -105,7 +105,7 @@ fn nested_row_slices() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn row_slice_mut() {
|
fn row_view_mut() {
|
||||||
let mut a = Matrix6x2::new(11.0, 12.0,
|
let mut a = Matrix6x2::new(11.0, 12.0,
|
||||||
21.0, 22.0,
|
21.0, 22.0,
|
||||||
31.0, 32.0,
|
31.0, 32.0,
|
||||||
|
@ -113,7 +113,7 @@ fn row_slice_mut() {
|
||||||
51.0, 52.0,
|
51.0, 52.0,
|
||||||
61.0, 62.0);
|
61.0, 62.0);
|
||||||
{
|
{
|
||||||
// We modify `a` through the mutable slice.
|
// We modify `a` through the mutable view.
|
||||||
let mut s1 = a.rows_with_step_mut(1, 3, 1);
|
let mut s1 = a.rows_with_step_mut(1, 3, 1);
|
||||||
s1.fill(0.0);
|
s1.fill(0.0);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ fn row_slice_mut() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn nested_col_slices() {
|
fn nested_col_views() {
|
||||||
let a = Matrix2x6::new(11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
let a = Matrix2x6::new(11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
||||||
21.0, 22.0, 23.0, 24.0, 25.0, 26.0);
|
21.0, 22.0, 23.0, 24.0, 25.0, 26.0);
|
||||||
let s1 = a.fixed_columns::<4>(1);
|
let s1 = a.fixed_columns::<4>(1);
|
||||||
|
@ -148,12 +148,12 @@ fn nested_col_slices() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn col_slice_mut() {
|
fn col_view_mut() {
|
||||||
let mut a = Matrix2x6::new(11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
let mut a = Matrix2x6::new(11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
||||||
21.0, 22.0, 23.0, 24.0, 25.0, 26.0);
|
21.0, 22.0, 23.0, 24.0, 25.0, 26.0);
|
||||||
|
|
||||||
{
|
{
|
||||||
// We modify `a` through the mutable slice.
|
// We modify `a` through the mutable view.
|
||||||
let mut s1 = a.columns_with_step_mut(1, 3, 1);
|
let mut s1 = a.columns_with_step_mut(1, 3, 1);
|
||||||
s1.fill(0.0);
|
s1.fill(0.0);
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ fn columns_range_pair() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn new_slice() {
|
fn new_from_slice() {
|
||||||
let data = [ 1.0, 2.0, 3.0, 4.0,
|
let data = [ 1.0, 2.0, 3.0, 4.0,
|
||||||
5.0, 6.0, 7.0, 8.0,
|
5.0, 6.0, 7.0, 8.0,
|
||||||
9.0, 10.0, 11.0, 12.0 ];
|
9.0, 10.0, 11.0, 12.0 ];
|
||||||
|
@ -214,13 +214,13 @@ fn new_slice() {
|
||||||
let expected3x2 = Matrix3x2::from_column_slice(&data);
|
let expected3x2 = Matrix3x2::from_column_slice(&data);
|
||||||
|
|
||||||
{
|
{
|
||||||
let m2 = MatrixSlice2::from_slice(&data);
|
let m2 = MatrixView2::from_slice(&data);
|
||||||
let m3 = MatrixSlice3::from_slice(&data);
|
let m3 = MatrixView3::from_slice(&data);
|
||||||
let m2x3 = MatrixSlice2x3::from_slice(&data);
|
let m2x3 = MatrixView2x3::from_slice(&data);
|
||||||
let m3x2 = MatrixSlice3x2::from_slice(&data);
|
let m3x2 = MatrixView3x2::from_slice(&data);
|
||||||
let m2xX = MatrixSlice2xX::from_slice(&data, 3);
|
let m2xX = MatrixView2xX::from_slice(&data, 3);
|
||||||
let mXx3 = MatrixSliceXx3::from_slice(&data, 2);
|
let mXx3 = MatrixViewXx3::from_slice(&data, 2);
|
||||||
let mXxX = DMatrixSlice::from_slice(&data, 2, 3);
|
let mXxX = DMatrixView::from_slice(&data, 2, 3);
|
||||||
|
|
||||||
assert!(m2.eq(&expected2));
|
assert!(m2.eq(&expected2));
|
||||||
assert!(m3.eq(&expected3));
|
assert!(m3.eq(&expected3));
|
||||||
|
@ -234,7 +234,7 @@ fn new_slice() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn new_slice_mut() {
|
fn new_from_slice_mut() {
|
||||||
let data = [ 1.0, 2.0, 3.0, 4.0,
|
let data = [ 1.0, 2.0, 3.0, 4.0,
|
||||||
5.0, 6.0, 7.0, 8.0,
|
5.0, 6.0, 7.0, 8.0,
|
||||||
9.0, 10.0, 11.0, 12.0 ];
|
9.0, 10.0, 11.0, 12.0 ];
|
||||||
|
@ -252,31 +252,31 @@ fn new_slice_mut() {
|
||||||
9.0, 10.0, 11.0, 12.0 ];
|
9.0, 10.0, 11.0, 12.0 ];
|
||||||
|
|
||||||
let mut data_mut = data.clone();
|
let mut data_mut = data.clone();
|
||||||
MatrixSliceMut2::from_slice(&mut data_mut).fill(0.0);
|
MatrixViewMut2::from_slice(&mut data_mut).fill(0.0);
|
||||||
assert!(data_mut == expected2);
|
assert!(data_mut == expected2);
|
||||||
|
|
||||||
let mut data_mut = data.clone();
|
let mut data_mut = data.clone();
|
||||||
MatrixSliceMut3::from_slice(&mut data_mut).fill(0.0);
|
MatrixViewMut3::from_slice(&mut data_mut).fill(0.0);
|
||||||
assert!(data_mut == expected3);
|
assert!(data_mut == expected3);
|
||||||
|
|
||||||
let mut data_mut = data.clone();
|
let mut data_mut = data.clone();
|
||||||
MatrixSliceMut2x3::from_slice(&mut data_mut).fill(0.0);
|
MatrixViewMut2x3::from_slice(&mut data_mut).fill(0.0);
|
||||||
assert!(data_mut == expected2x3);
|
assert!(data_mut == expected2x3);
|
||||||
|
|
||||||
let mut data_mut = data.clone();
|
let mut data_mut = data.clone();
|
||||||
MatrixSliceMut3x2::from_slice(&mut data_mut).fill(0.0);
|
MatrixViewMut3x2::from_slice(&mut data_mut).fill(0.0);
|
||||||
assert!(data_mut == expected3x2);
|
assert!(data_mut == expected3x2);
|
||||||
|
|
||||||
let mut data_mut = data.clone();
|
let mut data_mut = data.clone();
|
||||||
MatrixSliceMut2xX::from_slice(&mut data_mut, 3).fill(0.0);
|
MatrixViewMut2xX::from_slice(&mut data_mut, 3).fill(0.0);
|
||||||
assert!(data_mut == expected2x3);
|
assert!(data_mut == expected2x3);
|
||||||
|
|
||||||
let mut data_mut = data.clone();
|
let mut data_mut = data.clone();
|
||||||
MatrixSliceMutXx3::from_slice(&mut data_mut, 2).fill(0.0);
|
MatrixViewMutXx3::from_slice(&mut data_mut, 2).fill(0.0);
|
||||||
assert!(data_mut == expected2x3);
|
assert!(data_mut == expected2x3);
|
||||||
|
|
||||||
let mut data_mut = data.clone();
|
let mut data_mut = data.clone();
|
||||||
DMatrixSliceMut::from_slice(&mut data_mut, 2, 3).fill(0.0);
|
DMatrixViewMut::from_slice(&mut data_mut, 2, 3).fill(0.0);
|
||||||
assert!(data_mut == expected2x3);
|
assert!(data_mut == expected2x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,14 +324,14 @@ fn columns_with_step_out_of_bounds() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn slice_out_of_bounds() {
|
fn view_out_of_bounds() {
|
||||||
let a = Matrix3x4::<f32>::zeros();
|
let a = Matrix3x4::<f32>::zeros();
|
||||||
a.slice((1, 2), (3, 1));
|
a.view((1, 2), (3, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn slice_with_steps_out_of_bounds() {
|
fn view_with_steps_out_of_bounds() {
|
||||||
let a = Matrix3x4::<f32>::zeros();
|
let a = Matrix3x4::<f32>::zeros();
|
||||||
a.slice_with_steps((1, 2), (2, 2), (0, 1));
|
a.view_with_steps((1, 2), (2, 2), (0, 1));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue