www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - dotProduct and sum unification

reply "Ilya Yaroshenko" <ilyayaroshenko gmail.com> writes:
Hello!

I have found that Phobos has sum, but in module std.algorithm!

refs:
  std.numeric.dotProduct:

  std_algorithm.sum:


Both sum and dotProduct are general purpose numeric algorithms 
(yes, very trivial) with the same summation logic. The summation 
method can be:

  a. Strongly Serial (it needed for numeric algorithms like in 
cephes(Netlib) library.)
  b. Fast (with SIMD instruction or loop unrolling like in 
dotProduct source code)
  c. Reversed Strongly Serial
  d. Reversed Fast
  e. Precise (like in sum source code) There are different ways of 
precise summation.  For example in Julia language you can choice 
an algorithm.
     e.1 Precise algorithm 1
     ...
     e.2 Precise algorithm N

So, can I make PR with that
  1. realize unification in single module (std.numeric?) and logic
  2. provide ability to select summation algorithm (default == 
Fast?)

Best regards,
Ilya
Sep 08 2014
parent reply "Ilya Yaroshenko" <ilyayaroshenko gmail.com> writes:
+ std.numeric.normalize
Sep 08 2014
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 9/8/14, 2:58 AM, Ilya Yaroshenko wrote:
 + std.numeric.normalize
One issue with std.numeric is it's rather disorganized - a grab bag of vaguely "numeric" stuff. However std.algorithm also includes stuff that's arguably numeric, e.g. min and max etc. I think the right way is to let the existing stuff be and improve the organization of std.numeric. Andrei
Sep 08 2014
next sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 09/08/2014 07:02 PM, Andrei Alexandrescu wrote:
 However std.algorithm also includes stuff that's arguably numeric, e.g.
 min and max etc.
How are min and max numeric?
Sep 08 2014
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 9/8/14, 11:10 AM, Timon Gehr wrote:
 On 09/08/2014 07:02 PM, Andrei Alexandrescu wrote:
 However std.algorithm also includes stuff that's arguably numeric, e.g.
 min and max etc.
How are min and max numeric?
Won't bite :o). -- Andrei
Sep 08 2014
prev sibling parent "Idan Arye" <GenericNPC gmail.com> writes:
On Monday, 8 September 2014 at 17:02:21 UTC, Andrei Alexandrescu 
wrote:
 On 9/8/14, 2:58 AM, Ilya Yaroshenko wrote:
 + std.numeric.normalize
One issue with std.numeric is it's rather disorganized - a grab bag of vaguely "numeric" stuff. However std.algorithm also includes stuff that's arguably numeric, e.g. min and max etc. I think the right way is to let the existing stuff be and improve the organization of std.numeric. Andrei
Not only numeric stuff - I'd argue that `levenshteinDistance` and `balancedParens` belong to `std.string`. Most of the stuff `std.algorithm` are building blocks for algorithms - things that you never need to explain when writing pseudo-code because they are so trivial, like "iterate in decreasing order over the elements of that array that are not members of that set". But somehow other stuff found it's place into `std.algorithm` - actual algorithms like `sum` or `levenshteinDistance`. These are, indeed, "algorithms", but that doesn't mean they should be in `std.algorithm` - if we used that logic Phobos would have been composed of two giant modules, `std.algorithm` and `std.type`...
Sep 08 2014