Skip to content

Commit

Permalink
fix: from review
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Dec 25, 2024
1 parent 69cf05f commit fa3e799
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,15 @@ jobs:
# echo -e "\033[1;32mAll unique features across workspace:\033[0m" && cargo metadata --format-version=1 --no-deps | jq -r '.packages[].features | to_entries[] | .key' | sort -u | sed 's/^/• /'
cargo clippy --all-targets --all --tests --features "aggregation bench-metrics bls12_381 bn254 default entrypoint export-getrandom export-libm function-span getrandom halo2-compiler halo2curves heap-embedded-alloc k256 mimalloc nightly-features panic-handler parallel rust-runtime static-verifier std test-utils unstable" -- -D warnings
cargo clippy --all-targets --all --tests --no-default-features --features "jemalloc jemalloc-prof" -- -D warnings
- name: Run fmt for guest
run: |
# List all guest program crate paths
for crate_path in benchmarks/programs/* examples/*; do
# Check if Cargo.toml exists in the directory
if [ -f "$crate_path/Cargo.toml" ]; then
echo "Running cargo fmt for $crate_path"
cargo fmt --manifest-path "$crate_path/Cargo.toml" --all -- --check
else
echo "Skipping $crate_path as it does not contain a Cargo.toml"
fi
done
- name: Run clippy for guest
- name: Run fmt, clippy for guest
run: |
# List all guest program crate paths
for crate_path in benchmarks/programs/* examples/*; do
# Check if Cargo.toml exists in the directory
if [ -f "$crate_path/Cargo.toml" ]; then
echo "Running cargo clippy for $crate_path"
echo "Running cargo fmt, clippy for $crate_path"
cargo fmt --manifest-path "$crate_path/Cargo.toml" --all -- --check
cargo clippy --manifest-path "$crate_path/Cargo.toml" --all-targets --features std -- -D warnings
else
echo "Skipping $crate_path as it does not contain a Cargo.toml"
Expand Down
14 changes: 8 additions & 6 deletions examples/i256/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ pub fn get_matrix(val: i32) -> Matrix {
array::from_fn(|_| array::from_fn(|_| I256::from_i32(val)))
}

#[allow(clippy::needless_range_loop)]
pub fn mult(a: &Matrix, b: &Matrix) -> Matrix {
let mut c = get_matrix(0);
for (i, row_a) in a.iter().enumerate() {
for (j, _) in b[0].iter().enumerate() {
for (k, _) in b.iter().enumerate() {
c[i][j] += &row_a[k] * &b[k][j];
for i in 0..N {
for j in 0..N {
for k in 0..N {
c[i][j] += &a[i][k] * &b[k][j];
}
}
}
c
}

#[allow(clippy::needless_range_loop)]
pub fn get_identity_matrix() -> Matrix {
let mut res = get_matrix(0);
for (i, row) in res.iter_mut().enumerate() {
row[i] = I256::from_i32(1);
for i in 0..N {
res[i][i] = I256::from_i32(1);
}
res
}
Expand Down
12 changes: 7 additions & 5 deletions examples/u256/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ pub fn get_matrix(val: i32) -> Matrix {
array::from_fn(|_| array::from_fn(|_| I256::from_i32(val)))
}

#[allow(clippy::needless_range_loop)]
pub fn mult(a: &Matrix, b: &Matrix) -> Matrix {
let mut c = get_matrix(0);
for (i, row_a) in a.iter().enumerate() {
for (j, _) in row_a.iter().enumerate() {
for (k, _) in b.iter().enumerate() {
for i in 0..N {
for j in 0..N {
for k in 0..N {
c[i][j] += &a[i][k] * &b[k][j];
}
}
}
c
}

#[allow(clippy::needless_range_loop)]
pub fn get_identity_matrix() -> Matrix {
let mut res = get_matrix(0);
for (i, row) in res.iter_mut().enumerate() {
row[i] = I256::from_i32(1);
for i in 0..N {
res[i][i] = I256::from_i32(1);
}
res
}
Expand Down

0 comments on commit fa3e799

Please sign in to comment.