[Bug] using SumS on a ushort[] throws System.InvalidCastException
Code:
ushort[] pRowArrayClip = samePool.Rent(countClip);
Array.Copy(pRowArrayFull, pRowArrayClip, countClip);
double average = pRowArrayClip.SumS();
Exception:
System.InvalidCastException : Specified cast is not valid.
at JM.LinqFaster.SIMD.LinqFasterSIMD.SumS[T](T[] source)
at #########
Should ushort not be supported
not sure, it looks like it should work, I'll investigate
ushort[].Sum() from normal linq does not appear to be supported (And also not in SumF)
What would the expected result be a Double ? Decimal ????
the result of a sum on ushort should be a ushort, the way it is currently implemented.
which, won't typically be useful!
probably why linq doesn't support it.
ok the problem is that a ushort + a ushort = an int32. So, this could be supported if instead of using a generic sum method, we made one for each type, and ushort returned an int32 for the sum.
that's a bunch of grunt work though.
output type always the same as input type currently, same as linq.
On Fri, Jul 19, 2019 at 10:11 AM Simon Coghlan [email protected] wrote:
What would the expected result be a Double ? Decimal ????
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jackmott/LinqFaster/issues/18?email_source=notifications&email_token=ABD3XZR4UZSJLSUCKOXOQ6DQAHKR7A5CNFSM4IFGOQQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2L5IKI#issuecomment-513266729, or mute the thread https://github.com/notifications/unsubscribe-auth/ABD3XZQONZFFV4QNGDBSTNDQAHKR7ANCNFSM4IFGOQQQ .
probably why linq doesn't support it. So this should mean that this implementation not allow it to be used for ushort's, and not allow it to compile (As per linq)
ok the problem is that a ushort + a ushort = an int32. So, this could be supported if instead of using a generic sum method, we made one for each type, and ushort returned an int32 for the sum.
that's a bunch of grunt work though.
Work done in the pending #20
Convert SumF function into a generic function
Add new managed types (sbyte, byte, short, ushort, int, uint, long, ulong)
Add tests for some of the new types
Add new Benchmark tests