Skip to content

Commit

Permalink
rename Size to Dim
Browse files Browse the repository at this point in the history
  • Loading branch information
sarah-quinones committed Oct 1, 2024
1 parent 7b851a0 commit 3a7465a
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 40 deletions.
8 changes: 6 additions & 2 deletions src/perm/permown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ impl<I: Index, N: Shape> Perm<I, N> {
assert!(self.len().unbound() == dim.unbound());

Perm {
forward: unsafe { Box::from_raw(Box::into_raw(self.forward) as _) },
inverse: unsafe { Box::from_raw(Box::into_raw(self.inverse) as _) },
forward: unsafe {
alloc::boxed::Box::from_raw(alloc::boxed::Box::into_raw(self.forward) as _)
},
inverse: unsafe {
alloc::boxed::Box::from_raw(alloc::boxed::Box::into_raw(self.inverse) as _)
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/sparse/linalg/cholesky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ pub mod simplicial {

#[inline]
#[track_caller]
pub(crate) fn ghost_inner<'n>(self, N: ghost::Size<'n>) -> &'a Array<'n, MaybeIdx<'n, I>> {
pub(crate) fn ghost_inner<'n>(self, N: ghost::Dim<'n>) -> &'a Array<'n, MaybeIdx<'n, I>> {
assert!(self.inner.len() == *N);
unsafe { Array::from_ref(MaybeIdx::from_slice_ref_unchecked(self.inner), N) }
}
Expand Down
4 changes: 2 additions & 2 deletions src/sparse/linalg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ mod ghost {
pub const NONE_BYTE: u8 = u8::MAX;

#[inline]
pub fn fill_zero<'n, 'a, I: Index>(slice: &'a mut [I], size: Size<'n>) -> &'a mut [Idx<'n, I>] {
pub fn fill_zero<'n, 'a, I: Index>(slice: &'a mut [I], size: Dim<'n>) -> &'a mut [Idx<'n, I>] {
let len = slice.len();
if len > 0 {
assert!(*size > 0);
Expand All @@ -259,7 +259,7 @@ mod ghost {
#[inline]
pub fn fill_none<'n, 'a, I: Index>(
slice: &'a mut [I::Signed],
size: Size<'n>,
size: Dim<'n>,
) -> &'a mut [MaybeIdx<'n, I>] {
let _ = size;
let len = slice.len();
Expand Down
10 changes: 5 additions & 5 deletions src/sparse/linalg/qr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
perm::PermRef,
sparse::{SparseColMatRef, SymbolicSparseColMatRef},
unzipped,
utils::{constrained::Size, slice::*},
utils::{constrained::Dim, slice::*},
zipped, Conj, MatMut, Parallelism, SignedIndex,
};
use core::iter::zip;
Expand Down Expand Up @@ -151,8 +151,8 @@ pub(crate) fn ghost_column_counts_aat<'m, 'n, I: Index>(
post: &Array<'m, Idx<'m, I>>,
stack: &mut PodStack,
) {
let M: Size<'m> = A.nrows();
let N: Size<'n> = A.ncols();
let M: Dim<'m> = A.nrows();
let N: Dim<'n> = A.ncols();
let n = *N;
let m = *M;

Expand Down Expand Up @@ -559,8 +559,8 @@ pub mod supernodal {

fn ghost_factorize_supernodal_householder_symbolic<'m, 'n, I: Index>(
L_symbolic: &SymbolicSupernodalCholesky<I>,
M: Size<'m>,
N: Size<'n>,
M: Dim<'m>,
N: Dim<'n>,
min_col: &Array<'m, MaybeIdx<'n, I>>,
etree: &Array<'n, MaybeIdx<'n, I>>,
stack: &mut PodStack,
Expand Down
20 changes: 10 additions & 10 deletions src/utils/constrained/mat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'nrows, 'ncols, 'a, E: Entity> MatRef<'nrows, 'ncols, 'a, E> {
/// dimensions tied to `('nrows, 'ncols)`.
#[inline]
#[track_caller]
pub fn new(inner: mat::MatRef<'a, E>, nrows: Size<'nrows>, ncols: Size<'ncols>) -> Self {
pub fn new(inner: mat::MatRef<'a, E>, nrows: Dim<'nrows>, ncols: Dim<'ncols>) -> Self {
assert!(all(
inner.nrows() == nrows.unbound(),
inner.ncols() == ncols.unbound(),
Expand All @@ -33,14 +33,14 @@ impl<'nrows, 'ncols, 'a, E: Entity> MatRef<'nrows, 'ncols, 'a, E> {

/// Returns the number of rows of the matrix.
#[inline]
pub fn nrows(&self) -> Size<'nrows> {
unsafe { Size::new_unbound(self.0.inner.inner.nrows()) }
pub fn nrows(&self) -> Dim<'nrows> {
unsafe { Dim::new_unbound(self.0.inner.inner.nrows()) }
}

/// Returns the number of columns of the matrix.
#[inline]
pub fn ncols(&self) -> Size<'ncols> {
unsafe { Size::new_unbound(self.0.inner.inner.ncols()) }
pub fn ncols(&self) -> Dim<'ncols> {
unsafe { Dim::new_unbound(self.0.inner.inner.ncols()) }
}

/// Returns the unconstrained matrix.
Expand All @@ -62,7 +62,7 @@ impl<'nrows, 'ncols, 'a, E: Entity> MatMut<'nrows, 'ncols, 'a, E> {
/// dimensions tied to `('nrows, 'ncols)`.
#[inline]
#[track_caller]
pub fn new(inner: mat::MatMut<'a, E>, nrows: Size<'nrows>, ncols: Size<'ncols>) -> Self {
pub fn new(inner: mat::MatMut<'a, E>, nrows: Dim<'nrows>, ncols: Dim<'ncols>) -> Self {
assert!(all(
inner.nrows() == nrows.unbound(),
inner.ncols() == ncols.unbound(),
Expand All @@ -78,14 +78,14 @@ impl<'nrows, 'ncols, 'a, E: Entity> MatMut<'nrows, 'ncols, 'a, E> {

/// Returns the number of rows of the matrix.
#[inline]
pub fn nrows(&self) -> Size<'nrows> {
unsafe { Size::new_unbound(self.0.inner.inner.nrows()) }
pub fn nrows(&self) -> Dim<'nrows> {
unsafe { Dim::new_unbound(self.0.inner.inner.nrows()) }
}

/// Returns the number of columns of the matrix.
#[inline]
pub fn ncols(&self) -> Size<'ncols> {
unsafe { Size::new_unbound(self.0.inner.inner.ncols()) }
pub fn ncols(&self) -> Dim<'ncols> {
unsafe { Dim::new_unbound(self.0.inner.inner.ncols()) }
}

/// Returns the unconstrained matrix.
Expand Down
14 changes: 7 additions & 7 deletions src/utils/constrained/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct Branded<'a, T: ?Sized> {
inner: T,
}

pub(crate) type Size<'n> = crate::utils::bound::Dim<'n>;
pub(crate) type Dim<'n> = crate::utils::bound::Dim<'n>;
pub(crate) type Idx<'n, I> = crate::utils::bound::Idx<'n, I>;
pub(crate) type IdxInclusive<'n, I> = crate::utils::bound::IdxInc<'n, I>;
pub(crate) type MaybeIdx<'n, I> = crate::utils::bound::MaybeIdx<'n, I>;
Expand Down Expand Up @@ -100,7 +100,7 @@ impl<'n, 'a, E: Entity> ArrayGroupMut<'n, 'a, E> {
/// Returns an array group with length after checking that its length matches
/// the value tied to `'n`.
#[inline]
pub fn new(slice: GroupFor<E, &'a mut [E::Unit]>, len: Size<'n>) -> Self {
pub fn new(slice: GroupFor<E, &'a mut [E::Unit]>, len: Dim<'n>) -> Self {
let slice = slice::SliceGroupMut::<'_, E>::new(slice);
assert!(slice.rb().len() == len.unbound());
ArrayGroupMut(Branded {
Expand Down Expand Up @@ -145,7 +145,7 @@ impl<'n, 'a, E: Entity> ArrayGroup<'n, 'a, E> {
/// Returns an array group with length after checking that its length matches
/// the value tied to `'n`.
#[inline]
pub fn new(slice: GroupFor<E, &'a [E::Unit]>, len: Size<'n>) -> Self {
pub fn new(slice: GroupFor<E, &'a [E::Unit]>, len: Dim<'n>) -> Self {
let slice = slice::SliceGroup::<'_, E>::new(slice);
assert!(slice.rb().len() == len.unbound());
ArrayGroup(Branded {
Expand Down Expand Up @@ -181,15 +181,15 @@ impl<'n, T> Array<'n, T> {
/// Returns a constrained array after checking that its length matches `size`.
#[inline]
#[track_caller]
pub fn from_ref<'a>(slice: &'a [T], size: Size<'n>) -> &'a Self {
pub fn from_ref<'a>(slice: &'a [T], size: Dim<'n>) -> &'a Self {
assert!(slice.len() == size.unbound());
unsafe { &*(slice as *const [T] as *const Self) }
}

/// Returns a constrained array after checking that its length matches `size`.
#[inline]
#[track_caller]
pub fn from_mut<'a>(slice: &'a mut [T], size: Size<'n>) -> &'a mut Self {
pub fn from_mut<'a>(slice: &'a mut [T], size: Dim<'n>) -> &'a mut Self {
assert!(slice.len() == size.unbound());
unsafe { &mut *(slice as *mut [T] as *mut Self) }
}
Expand All @@ -210,8 +210,8 @@ impl<'n, T> Array<'n, T> {

/// Returns the length of `self`.
#[inline]
pub fn len(&self) -> Size<'n> {
unsafe { Size::new_unbound(self.0.inner.len()) }
pub fn len(&self) -> Dim<'n> {
unsafe { Dim::new_unbound(self.0.inner.len()) }
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/utils/constrained/perm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ impl<'n, 'a, I: Index> PermRef<'n, 'a, I> {
/// Returns a new permutation after checking that it matches the size tied to `'n`.
#[inline]
#[track_caller]
pub fn new(perm: perm::PermRef<'a, I>, size: Size<'n>) -> Self {
pub fn new(perm: perm::PermRef<'a, I>, size: Dim<'n>) -> Self {
let (fwd, inv) = perm.arrays();
assert!(all(
fwd.len() == size.unbound(),
Expand Down Expand Up @@ -49,8 +49,8 @@ impl<'n, 'a, I: Index> PermRef<'n, 'a, I> {

/// Returns the length of the permutation.
#[inline]
pub fn len(&self) -> Size<'n> {
unsafe { Size::new_unbound(self.into_inner().len()) }
pub fn len(&self) -> Dim<'n> {
unsafe { Dim::new_unbound(self.into_inner().len()) }
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/utils/constrained/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ impl<'nrows, 'ncols, 'a, I: Index> SymbolicSparseColMatRef<'nrows, 'ncols, 'a, I
#[inline]
pub fn new(
inner: crate::sparse::SymbolicSparseColMatRef<'a, I>,
nrows: Size<'nrows>,
ncols: Size<'ncols>,
nrows: Dim<'nrows>,
ncols: Dim<'ncols>,
) -> Self {
assert!(all(
inner.nrows() == nrows.unbound(),
Expand All @@ -50,14 +50,14 @@ impl<'nrows, 'ncols, 'a, I: Index> SymbolicSparseColMatRef<'nrows, 'ncols, 'a, I

/// Returns the number of rows of the matrix.
#[inline]
pub fn nrows(&self) -> Size<'nrows> {
unsafe { Size::new_unbound(self.0.inner.inner.nrows()) }
pub fn nrows(&self) -> Dim<'nrows> {
unsafe { Dim::new_unbound(self.0.inner.inner.nrows()) }
}

/// Returns the number of columns of the matrix.
#[inline]
pub fn ncols(&self) -> Size<'ncols> {
unsafe { Size::new_unbound(self.0.inner.inner.ncols()) }
pub fn ncols(&self) -> Dim<'ncols> {
unsafe { Dim::new_unbound(self.0.inner.inner.ncols()) }
}

#[inline]
Expand Down Expand Up @@ -103,8 +103,8 @@ impl<'nrows, 'ncols, 'a, I: Index, E: Entity> SparseColMatRef<'nrows, 'ncols, 'a
/// dimensions tied to `('nrows, 'ncols)`.
pub fn new(
inner: crate::sparse::SparseColMatRef<'a, I, E>,
nrows: Size<'nrows>,
ncols: Size<'ncols>,
nrows: Dim<'nrows>,
ncols: Dim<'ncols>,
) -> Self {
assert!(all(
inner.nrows() == nrows.unbound(),
Expand Down Expand Up @@ -144,8 +144,8 @@ impl<'nrows, 'ncols, 'a, I: Index, E: Entity> SparseColMatMut<'nrows, 'ncols, 'a
/// dimensions tied to `('nrows, 'ncols)`.
pub fn new(
inner: crate::sparse::SparseColMatMut<'a, I, E>,
nrows: Size<'nrows>,
ncols: Size<'ncols>,
nrows: Dim<'nrows>,
ncols: Dim<'ncols>,
) -> Self {
assert!(all(
inner.nrows() == nrows.unbound(),
Expand Down

0 comments on commit 3a7465a

Please sign in to comment.