mirror of
https://github.com/pseXperiments/icicle.git
synced 2026-01-10 07:57:56 -05:00
## Describe the changes This PR adds golang examples --------- Co-authored-by: Leon Hibnik <107353745+LeonHibnik@users.noreply.github.com> Co-authored-by: Jeremy Felder <jeremy.felder1@gmail.com>
ICICLE example: Polynomials in Golang
ICICLE provides Golang bindings to CUDA-accelerated C++ implementation of Polynomials.
Usage
Backend Initialization
InitPolyBackend()
Construction
poly1 := CreateFromCoeffecitients(/* Coefficients of polynomial */ coeffs)
poly2 := CreateFromROUEvaluations(/* evaluations */ evals)
poly3 := Clone(/* polynomial to clone */ poly1)
Arithmetic
polyAdd := poly1.Add(&poly2)
polySub := poly1.Subtract(&poly2)
polyMul := poly1.Multiply(&poly2)
polyMulScalar := MultiplyByScalar(scalar)
quotient, remainder := poly1.Divide(&poly2)
Evaluation
ev := poly1.Eval(scalar)
ev2 := poly1.EvalOnDomain(scalars)
In this example we use BN254 and Babybear fields. The examples shows arithmetic operations and evaluations execution.
What's in the example
- Define the size of polynomials.
- Initialize backends.
- Generate random polynomials.
- Execute arithmetic operations.
- Execute evaluations.
- Execute slicing.
Running the example:
go run main.go