Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelDkhn committed Dec 10, 2023
1 parent 1c5c140 commit 64eea8a
Show file tree
Hide file tree
Showing 67 changed files with 3,582 additions and 3,568 deletions.
2 changes: 1 addition & 1 deletion src/numbers/fixed_point/core.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ trait FixedTrait<T, MAG> {
/// ```
///
fn erf(self: T) -> T;

fn ZERO() -> T;
fn HALF() -> T;
fn ONE() -> T;
Expand Down
4 changes: 3 additions & 1 deletion src/numbers/fixed_point/implementations/fp16x16/core.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use core::traits::{TryInto, Into};

use orion::numbers::signed_integer::{i32::i32, i8::i8};
use orion::numbers::fixed_point::core::FixedTrait;
use orion::numbers::fixed_point::implementations::fp16x16::math::{core as core_math, trig, hyp, erf};
use orion::numbers::fixed_point::implementations::fp16x16::math::{
core as core_math, trig, hyp, erf
};
use orion::numbers::fixed_point::utils;

/// A struct representing a fixed point number.
Expand Down
10 changes: 4 additions & 6 deletions src/numbers/fixed_point/implementations/fp16x16/math/erf.cairo
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use core::traits::Into;
use orion::numbers::fixed_point::implementations::fp16x16::core::{
ONE, FP16x16, FixedTrait
};
use orion::numbers::fixed_point::implementations::fp16x16::core::{ONE, FP16x16, FixedTrait};
use orion::numbers::fixed_point::implementations::fp16x16::math::lut::erf_lut;

const ERF_COMPUTATIONAL_ACCURACY: u32 = 100;
const ERF_COMPUTATIONAL_ACCURACY: u32 = 100;
const ROUND_CHECK_NUMBER: u32 = 10;
// Values > MAX_ERF_NUMBER return 1
const MAX_ERF_NUMBER: u32 = 229376;
// Values <= ERF_TRUNCATION_NUMBER -> two decimal places, and values > ERF_TRUNCATION_NUMBER -> one decimal place
const ERF_TRUNCATION_NUMBER: u32 = 131072;

fn erf(x: FP16x16) -> FP16x16{
fn erf(x: FP16x16) -> FP16x16 {
// Lookup
// 1. if x.mag < 3.5 { lookup table }
// 2. else{ return 1}
Expand All @@ -23,4 +21,4 @@ fn erf(x: FP16x16) -> FP16x16{
erf_value = ONE;
}
FP16x16 { mag: erf_value, sign: x.sign }
}
}
Loading

0 comments on commit 64eea8a

Please sign in to comment.