(args ...vector.Any)
| 145 | } |
| 146 | |
| 147 | func (l *Log) Call(args ...vector.Any) vector.Any { |
| 148 | if vec, ok := expr.CheckForNullThenError(args); ok { |
| 149 | return vec |
| 150 | } |
| 151 | arg := vector.Under(args[0]) |
| 152 | if !super.IsNumber(arg.Type().ID()) { |
| 153 | return vector.NewWrappedError(l.sctx, "log: not a number", arg) |
| 154 | } |
| 155 | // No error casting number to float so no need to Apply. |
| 156 | vec := cast.To(l.sctx, arg, super.TypeFloat64) |
| 157 | var errs []uint32 |
| 158 | var floats []float64 |
| 159 | for i := range vec.Len() { |
| 160 | v := vector.FloatValue(vec, i) |
| 161 | if v <= 0 { |
| 162 | errs = append(errs, i) |
| 163 | continue |
| 164 | } |
| 165 | floats = append(floats, math.Log(v)) |
| 166 | } |
| 167 | out := vector.NewFloat(super.TypeFloat64, floats) |
| 168 | if len(errs) > 0 { |
| 169 | err := vector.NewWrappedError(l.sctx, "log: illegal argument", vector.Pick(arg, errs)) |
| 170 | return vector.Combine(out, errs, err) |
| 171 | } |
| 172 | return out |
| 173 | } |
| 174 | |
| 175 | type Pow struct { |
| 176 | sctx *super.Context |
nothing calls this directly
no test coverage detected