LinqFaster icon indicating copy to clipboard operation
LinqFaster copied to clipboard

- Convert SumF functions for Array, Span, and List into a generic function

Open Smurf-IV opened this issue 5 years ago • 9 comments

  • 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

Smurf-IV avatar Jul 30 '19 13:07 Smurf-IV

This fixes #18 [Bug] using SumS on a ushort[] throws System.InvalidCastException #18

Smurf-IV avatar Jul 30 '19 16:07 Smurf-IV

Hey Simon, wanted to say thanks for all the experiments you are doing here. I'll need to some time to review/test some of this stuff out, and I'm pretty busy with family/work all the time so it might take a while. I'll try to take a deep look in a few days and let you know what I think.

jackmott avatar Jul 31 '19 13:07 jackmott

wanted to say thanks for all the experiments you are doing here.

No worries, Now that I have the templates in place, I can burn through the other types pretty quickly

Smurf-IV avatar Jul 31 '19 14:07 Smurf-IV

I would hold off on doing too much work until I've had some time to review and test. I don't want you to write a million lines of code and then I end up not using them!

jackmott avatar Jul 31 '19 14:07 jackmott

Hey Simon, wanted to say thanks for all the experiments you are doing here. I'll need to some time to review/test some of this stuff out, and I'm pretty busy with family/work all the time so it might take a while. I'll try to take a deep look in a few days and let you know what I think.

Just found a bog "No-no" in some of the "Optimisations" I've done When using the List's I have done the following

        int sourceCount = source.Count;
        T2 a = p.Zero();
        checked
        {
            for (int index = 0; index < sourceCount; index++)
            {
                a = p.Add(a, source[index]);
            }
        }

The big "No-No" is on the int sourceCount = source.Count; as the Items in the List could be changed externally "Darn threading !". One way would be to lock the list, another is to put the count Back into the for loop, I'll go with the latter, I think this may also need to be done for the IReadOnlyList but I'm not sure.

Smurf-IV avatar Aug 06 '19 14:08 Smurf-IV

    // Note: Lists can have items added and removed whilst these API's are in use
    // The IReadOnlyList<T> represents a list in which the _number_ and _order_ of list elements is read-only.
    //

Smurf-IV avatar Aug 06 '19 14:08 Smurf-IV

int sourceCount = source.Count; is a non optimization on List anyway. Did you mean IList?

jackmott avatar Aug 06 '19 14:08 jackmott

int sourceCount = source.Count; is a non optimization on List anyway. Did you mean IList?

No on the List<T> it did show "Some" improvement....

Smurf-IV avatar Aug 06 '19 14:08 Smurf-IV

No idea why AppVeyor is complaining, It runs on my machine !!

Smurf-IV avatar Aug 07 '19 15:08 Smurf-IV