Files
nonam3e 4496520a10 golang examples init (#516)
## 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>
2024-05-16 19:40:13 +03:00
..
2024-05-16 19:40:13 +03:00
2024-05-16 19:40:13 +03:00

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

  1. Define the size of polynomials.
  2. Initialize backends.
  3. Generate random polynomials.
  4. Execute arithmetic operations.
  5. Execute evaluations.
  6. Execute slicing.

Running the example:

go run main.go