Mahout
  1. Mahout
  2. MAHOUT-209

Add aggregate() methods for Vector

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.3
    • Component/s: Math
    • Labels:
      None
    • Environment:

      all

      Description

      As discussed in MAHOUT-165 at some point, Vector (and Matrix, but let's put that on a separate ticket) could do with a nice exposure of methods like the following:

      // this can get optimized, of course
      
        public double aggregate(Vector other, BinaryFunction aggregator, BinaryFunction combiner) {
          double result = 0;
          for(int i=0; i<size(); i++) {
            result = aggregator.apply(result, combiner.apply(getQuick(i), other.getQuick(i)));
          }
          return result;
        }
      

      this is good for generalized inner products and distances. Also nice:

        public double aggregate(BinaryFunction aggregator, UnaryFunction map) {
          double result = 0;
          for(int i=0; i<size(); i++) {
            result = aggregator.apply(result, map.apply(getQuick(i)) );
          }
          return result;
        }
      

      Which generalizes norms and statistics (mean, median, stdDev) and things like that (number of positive values, or negative values, etc...).

      These kind of thing exists in Colt, and we could just surface it up to the top.

        Activity

        Jake Mannix created issue -
        Jake Mannix made changes -
        Field Original Value New Value
        Assignee Jake Mannix [ jake.mannix ]
        Hide
        Ted Dunning added a comment -

        These look nearly good enough to commit as they stand. I am sure that there will be 1-2 more patterns that we would like to add in this style, but I think that these are good enough to start with. If we need specialized versions for speed, we can file additional JIRA's (after 0.3).

        Show
        Ted Dunning added a comment - These look nearly good enough to commit as they stand. I am sure that there will be 1-2 more patterns that we would like to add in this style, but I think that these are good enough to start with. If we need specialized versions for speed, we can file additional JIRA's (after 0.3).
        Hide
        Jake Mannix added a comment -

        fixed in r903965

        Show
        Jake Mannix added a comment - fixed in r903965
        Jake Mannix made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Sean Owen made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        64d 10h 25m 1 Jake Mannix 28/Jan/10 06:15
        Resolved Resolved Closed Closed
        477d 21h 8m 1 Sean Owen 21/May/11 04:23

          People

          • Assignee:
            Jake Mannix
            Reporter:
            Jake Mannix
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development