Skip to content

Commit

Permalink
[cleanup]: Remove some useless checked_log_2 calls
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Feb 12, 2025
1 parent 3f20331 commit f843656
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
5 changes: 2 additions & 3 deletions crates/core/src/reed_solomon/reed_solomon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::marker::PhantomData;
use binius_field::{BinaryField, ExtensionField, PackedField, RepackedExtension};
use binius_maybe_rayon::prelude::*;
use binius_ntt::{AdditiveNTT, DynamicDispatchNTT, Error, NTTOptions, ThreadingSettings};
use binius_utils::{bail, checked_arithmetics::checked_log_2};
use binius_utils::bail;
use getset::CopyGetters;
use tracing::instrument;

Expand Down Expand Up @@ -169,7 +169,6 @@ where
PE: RepackedExtension<P>,
PE::Scalar: ExtensionField<<P as PackedField>::Scalar>,
{
let log_degree = checked_log_2(PE::Scalar::DEGREE);
self.encode_batch_inplace(PE::cast_bases_mut(code), log_batch_size + log_degree)
self.encode_batch_inplace(PE::cast_bases_mut(code), log_batch_size + PE::Scalar::LOG_DEGREE)
}
}
3 changes: 1 addition & 2 deletions crates/core/src/tensor_algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::{
use binius_field::{
square_transpose, util::inner_product_unchecked, ExtensionField, Field, PackedExtension,
};
use binius_utils::checked_arithmetics::checked_log_2;

/// An element of the tensor algebra defined as the tensor product of `FE` and `FE` as fields.
///
Expand Down Expand Up @@ -64,7 +63,7 @@ where

/// Returns $\kappa$, the base-2 logarithm of the extension degree.
pub const fn kappa() -> usize {
checked_log_2(FE::DEGREE)
FE::LOG_DEGREE
}

/// Returns the byte size of an element.
Expand Down
15 changes: 2 additions & 13 deletions crates/ntt/src/additive_ntt.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2024-2025 Irreducible Inc.

use binius_field::{ExtensionField, PackedField, RepackedExtension};
use binius_utils::checked_arithmetics::log2_strict_usize;

use super::error::Error;

Expand Down Expand Up @@ -51,24 +50,14 @@ pub trait AdditiveNTT<P: PackedField> {
PE: RepackedExtension<P>,
PE::Scalar: ExtensionField<P::Scalar>,
{
if !PE::Scalar::DEGREE.is_power_of_two() {
return Err(Error::PowerOfTwoExtensionDegreeRequired);
}

let log_batch_size = log2_strict_usize(PE::Scalar::DEGREE);
self.forward_transform(PE::cast_bases_mut(data), coset, log_batch_size)
self.forward_transform(PE::cast_bases_mut(data), coset, PE::Scalar::LOG_DEGREE)
}

fn inverse_transform_ext<PE>(&self, data: &mut [PE], coset: u32) -> Result<(), Error>
where
PE: RepackedExtension<P>,
PE::Scalar: ExtensionField<P::Scalar>,
{
if !PE::Scalar::DEGREE.is_power_of_two() {
return Err(Error::PowerOfTwoExtensionDegreeRequired);
}

let log_batch_size = log2_strict_usize(PE::Scalar::DEGREE);
self.inverse_transform(PE::cast_bases_mut(data), coset, log_batch_size)
self.inverse_transform(PE::cast_bases_mut(data), coset, PE::Scalar::LOG_DEGREE)
}
}

0 comments on commit f843656

Please sign in to comment.