Skip to content

Commit

Permalink
Update used go version to 1.23.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Oct 2, 2024
1 parent 18fa5af commit 87f0bc6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
### Fixed-point math library
# Fixed-point math library

The library implements basic math operations for 72/56 fixed-point values, and Log, Exp, Lgamma, BinCDF functions.

### Motivation
## Motivation

There is no efficient golang implementation for fixed-point math with a high-precision bincdf function.

The library uses a 56-bit fractional part to achieve maximum performance on math functions like Log, Exp, and Lgamma.

### Implementation
## Implementation

[BinCDF](https://github.com/spacemeshos/fixed/blob/master/fixed.go#L110) is implemented with
[incomplete Beta function](https://github.com/spacemeshos/fixed/blob/master/beta.go#L5) in standart way:
```
[BinCDF](https://github.com/spacemeshos/fixed/blob/master/fixed.go#L110) is implemented with
[incomplete Beta function](https://github.com/spacemeshos/fixed/blob/master/beta.go#L5) in standard way:

```text
Iₓ(a,b) = (xᵃ*(1-x)ᵇ)/(a*B(a,b)) * (1/(1+(d₁/(1+(d₂/(1+...))))))
(xᵃ*(1-x)ᵇ)/B(a,b) = exp(lgamma(a+b) - lgamma(a) - lgamma(b) + a*log(x) + b*log(1-x))
d_{2m+1} = -(a+m)(a+b+m)x/((a+2m)(a+2m+1))
d_{2m} = m(b-m)x/((a+2m-1)(a+2m))
```
Fixed-point arithmetics and
[Log](https://github.com/spacemeshos/fixed/blob/master/log.go#L19),

Fixed-point arithmetics and [Log](https://github.com/spacemeshos/fixed/blob/master/log.go#L19),
[Exp](https://github.com/spacemeshos/fixed/blob/master/exp.go#L10),
[Lgamma](https://github.com/spacemeshos/fixed/blob/master/lgamma.go#L4)
functions are implemented with the **bits** go module and raw operations over 56-bit fractional part values in range [-7..7].
[Lgamma](https://github.com/spacemeshos/fixed/blob/master/lgamma.go#L4) functions are implemented with the
**bits** go module and raw operations over 56-bit fractional part values in range [-7..7].
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/spacemeshos/fixed

go 1.20
go 1.23.2

0 comments on commit 87f0bc6

Please sign in to comment.