You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Big complex number calculation library for Go (with [math/big](https://pkg.go.dev/math/big)).
9
+
Big complex number calculation library in Go (with [math/big](https://pkg.go.dev/math/big)).
10
10
11
11
Currently, the library supports:
12
12
13
-
1. Gaussian integer, complex numbers whose real and imaginary parts are both integers:
13
+
1.**Gaussian Integers**
14
+
Complex numbers whose real and imaginary parts are both integers:
15
+
$$
16
+
\mathbb{Z}[i] = \{ a + bi \mid a, b \in \mathbb{Z} \}, \quad \text{where } i^2 = -1.
17
+
$$
14
18
15
-
$$
16
-
Z[i] = \{ a + bi \ |\ a, b \in \mathbb{Z} \}, \quad \text{where } i^2 = -1.
17
-
$$
18
-
19
-
2. Hurwitz quaternion, quaternions whose components are either all integers or all half-integers (halves of odd
20
-
integers; a mixture of integers and half-integers is excluded):
21
-
22
-
$$
23
-
H = \{ a + bi + cj + dk \in \mathbb{H} \ |\ a, b, c, d \in \mathbb{Z} \ \text{or} \ b, c, d \in \mathbb{Z} + \frac{1}{2} \}.
24
-
$$
19
+
2.**Hurwitz Quaternions**
20
+
Quaternions whose components are either all integers or all half‑integers (half‑integers being halves of odd integers; mixing integers and half‑integers is not allowed):
21
+
$$
22
+
H = \{ a + bi + cj + dk \in \mathbb{H} \mid a, b, c, d \in \mathbb{Z} \text{ or } a, b, c, d \in \mathbb{Z} + \tfrac{1}{2} \}.
23
+
$$
25
24
26
25
## Installation
27
26
@@ -64,24 +63,21 @@ func main() {
64
63
65
64
## WhyThisLibrary?
66
65
67
-
Fan fact: Golang has native complex number types: ```complex64``` and ```complex128```.
66
+
Fan fact: Golang has native complex number types: `complex64` and `complex128`.
68
67
69
68
```go
70
-
c1 := complex(10, 11) // constructor init
71
-
c2 := 10 + 11i // complex number init syntax
69
+
c1 := complex(10, 11) // Using the complex constructor
70
+
c2 := 10 + 11i // Using literal syntax
72
71
73
-
realPart := real(c1) // gets real part
74
-
imagPart := imag(c1) // gets imaginary part
72
+
realPart := real(c1) // Retrieves the real part
73
+
imagPart := imag(c1) // Retrieves the imaginary part
75
74
```
76
75
77
-
```complex64``` represents ```float64``` real and imaginary data, and ```complex128``` represents ```float128``` real
78
-
and imaginary data.
79
-
They are easy to use, but unfortunately they are incapable for handling very large complex numbers.
76
+
However, `complex64` (composed of two `float32` values) and `complex128` (composed of two `float64` values) are limited to fixed‑precision arithmetic and cannot handle very large numbers.
77
+
For example, in finding the LagrangeFourSquareSum of a very large integer (1792 bits in size) for cryptographic range proof, we need to compute the GreatestCommonDivisor (GCD) of Gaussian integers and the GreatestCommonRightDivisor of Hurwitz integers. And the built-in complex number types cannot handle such large numbers.
78
+
79
+
This motivated the development of BigComplex: a library for large‑scale complex number calculations using Go’s math/big package.
80
80
81
-
For instance, in finding the LagrangeFourSquareSum of a very large integer (1792 bits in size) for cryptographic
82
-
range proof,
83
-
we need to compute the GreatestCommonDivisor (GCD) of Gaussian integers and the GreatestCommonRightDivisor of
84
-
Hurwitz integers. And the built-in complex number types can not handle such large numbers.
81
+
## License
85
82
86
-
So I came up with the idea of building a library for large complex number calculation with Golang```math/big```
0 commit comments