github.com/consensys/gnark-crypto@v0.14.0/internal/generator/tower/template/fq12over6over2/base.go.tmpl (about) 1 {{ define "base" }} 2 3 {{ $TypeTitle := print "E" .TotalDegree}} 4 // Select is conditional move. 5 // If cond = 0, it sets z to caseZ and returns it. otherwise caseNz. 6 func (z *{{$TypeTitle}}) Select(cond int, caseZ *{{$TypeTitle}}, caseNz *{{$TypeTitle}}) *{{$TypeTitle}}{ 7 //Might be able to save a nanosecond or two by an aggregate implementation 8 {{range $i := interval 0 .RecursionDegree}}{{$ii := print $.BaseElementName $i}} 9 z.{{$ii}}.Select(cond, &caseZ.{{$ii}}, &caseNz.{{$ii}}){{end}} 10 11 return z 12 } 13 14 // Div divides an element in {{$TypeTitle}} by an element in {{$TypeTitle}} 15 func (z *{{$TypeTitle}}) Div(x *{{$TypeTitle}}, y *{{$TypeTitle}}) *{{$TypeTitle}} { 16 var r {{$TypeTitle}} 17 r.Inverse(y).Mul(x, &r) 18 return z.Set(&r) 19 } 20 21 {{ end }}