Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint & Typos #15

Merged
merged 7 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- name: Cache dependencies
uses: actions/cache@v2
env:
Expand All @@ -40,6 +40,9 @@ jobs:
cargo test $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml;
zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`;
grcov ccov.zip -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info;

- name: Run linter
run: cargo fmt --all -- --check
- name: Upload test results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# householder
A native Rust library for advanced Linear Algebra routines.
# Householder
A Rust native library for advanced Linear Algebra routines.

The library is in a very early development stage and not recommended yet
for production use.
17 changes: 8 additions & 9 deletions src/data_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ pub trait DataContainer {
self.number_of_elements()
);

unsafe {
std::slice::from_raw_parts(self.get_pointer().offset(first as isize), last - first)
}
unsafe { std::slice::from_raw_parts(self.get_pointer().add(first), last - first) }
}

/// Return the number of elements in the container.
Expand Down Expand Up @@ -74,12 +72,7 @@ pub trait DataContainerMut: DataContainer {
self.number_of_elements()
);

unsafe {
std::slice::from_raw_parts_mut(
self.get_pointer_mut().offset(first as isize),
last - first,
)
}
unsafe { std::slice::from_raw_parts_mut(self.get_pointer_mut().add(first), last - first) }
}
}

Expand Down Expand Up @@ -121,6 +114,12 @@ impl<Item: HScalar, const N: usize> ArrayContainer<Item, N> {
}
}

impl<Item: HScalar, const N: usize> Default for ArrayContainer<Item, N> {
fn default() -> Self {
Self::new()
}
}

impl<'a, Item: HScalar> SliceContainer<'a, Item> {
/// New slice container from a reference.
pub fn new(slice: &'a [Item]) -> SliceContainer<Item> {
Expand Down
4 changes: 2 additions & 2 deletions src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
//! A matrix is generic over the following parameters:
//! - `Item`. Implements the [HScalar] trait and represents the underlying scalar type
//! of the matrix.
//! - `MatImpl`. he actual implementation of the matrix. It must itself implement the
//! trait [MatrixTrait] or [MatrixTraitMut] depending on wheter mutable access
//! - `MatImpl`. The actual implementation of the matrix. It must itself implement the
//! trait [MatrixTrait] or [MatrixTraitMut] depending on whether mutable access
//! is required.
//! - `L`. A given type that implements the [LayoutType] trait and specifies the memory layout
//! of the matrix.
Expand Down
4 changes: 2 additions & 2 deletions src/matrix/matrix_slices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ macro_rules! block_matrix {
let start_index = self.layout().convert_2d_raw(top_left.0, top_left.1);
unsafe {
SliceMatrix::<'a, Item, $StrideLayout, $RS, $CS>::from_pointer(
self.get_pointer().offset(start_index as isize),
self.get_pointer().add(start_index),
dim,
self.layout().stride(),
)
Expand Down Expand Up @@ -61,7 +61,7 @@ macro_rules! block_matrix {

unsafe {
SliceMatrixMut::<'a, Item, $StrideLayout, $RS, $CS>::from_pointer(
self.get_pointer_mut().offset(start_index as isize),
self.get_pointer_mut().add(start_index),
dim,
self.layout().stride(),
)
Expand Down