go-hep.org/x/hep@v0.38.1/groot/rtree/rfunc/rfunc_f64s_gen.go (about)

     1  // Copyright ©2020 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Automatically generated. DO NOT EDIT.
     6  
     7  package rfunc
     8  
     9  import (
    10  	"fmt"
    11  )
    12  
    13  // FuncF32sToF64s implements rfunc.Formula
    14  type FuncF32sToF64s struct {
    15  	rvars []string
    16  	arg0  *[]float32
    17  	fct   func(arg00 []float32) []float64
    18  }
    19  
    20  // NewFuncF32sToF64s return a new formula, from the provided function.
    21  func NewFuncF32sToF64s(rvars []string, fct func(arg00 []float32) []float64) *FuncF32sToF64s {
    22  	return &FuncF32sToF64s{
    23  		rvars: rvars,
    24  		fct:   fct,
    25  	}
    26  }
    27  
    28  // RVars implements rfunc.Formula
    29  func (f *FuncF32sToF64s) RVars() []string { return f.rvars }
    30  
    31  // Bind implements rfunc.Formula
    32  func (f *FuncF32sToF64s) Bind(args []any) error {
    33  	if got, want := len(args), 1; got != want {
    34  		return fmt.Errorf(
    35  			"rfunc: invalid number of bind arguments (got=%d, want=%d)",
    36  			got, want,
    37  		)
    38  	}
    39  	{
    40  		ptr, ok := args[0].(*[]float32)
    41  		if !ok {
    42  			return fmt.Errorf(
    43  				"rfunc: argument type 0 (name=%s) mismatch: got=%T, want=*[]float32",
    44  				f.rvars[0], args[0],
    45  			)
    46  		}
    47  		f.arg0 = ptr
    48  	}
    49  	return nil
    50  }
    51  
    52  // Func implements rfunc.Formula
    53  func (f *FuncF32sToF64s) Func() any {
    54  	return func() []float64 {
    55  		return f.fct(
    56  			*f.arg0,
    57  		)
    58  	}
    59  }
    60  
    61  var (
    62  	_ Formula = (*FuncF32sToF64s)(nil)
    63  )
    64  
    65  // FuncF64sToF64s implements rfunc.Formula
    66  type FuncF64sToF64s struct {
    67  	rvars []string
    68  	arg0  *[]float64
    69  	fct   func(arg00 []float64) []float64
    70  }
    71  
    72  // NewFuncF64sToF64s return a new formula, from the provided function.
    73  func NewFuncF64sToF64s(rvars []string, fct func(arg00 []float64) []float64) *FuncF64sToF64s {
    74  	return &FuncF64sToF64s{
    75  		rvars: rvars,
    76  		fct:   fct,
    77  	}
    78  }
    79  
    80  // RVars implements rfunc.Formula
    81  func (f *FuncF64sToF64s) RVars() []string { return f.rvars }
    82  
    83  // Bind implements rfunc.Formula
    84  func (f *FuncF64sToF64s) Bind(args []any) error {
    85  	if got, want := len(args), 1; got != want {
    86  		return fmt.Errorf(
    87  			"rfunc: invalid number of bind arguments (got=%d, want=%d)",
    88  			got, want,
    89  		)
    90  	}
    91  	{
    92  		ptr, ok := args[0].(*[]float64)
    93  		if !ok {
    94  			return fmt.Errorf(
    95  				"rfunc: argument type 0 (name=%s) mismatch: got=%T, want=*[]float64",
    96  				f.rvars[0], args[0],
    97  			)
    98  		}
    99  		f.arg0 = ptr
   100  	}
   101  	return nil
   102  }
   103  
   104  // Func implements rfunc.Formula
   105  func (f *FuncF64sToF64s) Func() any {
   106  	return func() []float64 {
   107  		return f.fct(
   108  			*f.arg0,
   109  		)
   110  	}
   111  }
   112  
   113  var (
   114  	_ Formula = (*FuncF64sToF64s)(nil)
   115  )