Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: math
    • Labels:
      None

      Description

      This is my old map/reduce code to get the determinant of a matrix.

      Map:

      public void map(HStoreKey key, MapWritable value,
      OutputCollector<Text, MapWritable> output, Reporter reporter)
      throws IOException

      { int r = Integer.parseInt(String.valueOf(key.getRow())); checkObj.set(r, 0, 0.0); double d = matrix_a.get(r, 0) * Math.pow(-1.0, r) * minor(r, 1); checkObj.set(r, 0, 1.0); MapWritable val = new MapWritable(); val.put(Constants.COLUMN, getBytesWritable(d)); output.collect(Constants.DETERMINANT, val); }

      private double minor(int processRow, int processColumn)
      throws IOException {
      double result = 0.0;
      int i = 0;
      if ((row - processColumn) == 0)

      { return 1.0; }

      for (int r = 0; r < row; r++) {
      double trans = checkObj.get(r, 0);
      if (trans != 0.0)

      { checkObj.set(r, 0, 0.0); result += matrix_a.get(r, processColumn) * Math.pow(-1.0, i) * minor(r, processColumn + 1); checkObj.set(r, 0, 1.0); i++; }

      }

      return result;
      }

      Reduce:

      public void reduce(Text key, Iterator<MapWritable> values,
      OutputCollector<Text, MapWritable> output, Reporter reporter)
      throws IOException {

      double sum = 0;
      while (values.hasNext())

      { sum += getDouble(values.next().get(Constants.COLUMN)); }

      MapWritable value = new MapWritable();
      value.put(Constants.COLUMN, getBytesWritable(sum));
      output.collect(key, value);
      }

        Activity

        Hide
        Edward J. Yoon added a comment -

        This operation will be based on BSP instead of M/R.

        Show
        Edward J. Yoon added a comment - This operation will be based on BSP instead of M/R.
        Hide
        Edward J. Yoon added a comment -

        http://www.math.tu-berlin.de/EuroComb05/Talks/Poster/p12-Teimoori_Faal.ppt

        If we adapt this idea to map/reduce, determinants can be processed sequentially.

        Each map task computes the determinant of 2 by 2 matrix, reduce task writes all of its output.
        This Map/Reduce job will run order times, then we can get a determinant of original matrix.

        Show
        Edward J. Yoon added a comment - http://www.math.tu-berlin.de/EuroComb05/Talks/Poster/p12-Teimoori_Faal.ppt If we adapt this idea to map/reduce, determinants can be processed sequentially. Each map task computes the determinant of 2 by 2 matrix, reduce task writes all of its output. This Map/Reduce job will run order times, then we can get a determinant of original matrix.
        Hide
        Edward J. Yoon added a comment -

        this is a good approach to distributed computing – http://www.math.tu-berlin.de/EuroComb05/Talks/Poster/p12-Teimoori_Faal.ppt

        Show
        Edward J. Yoon added a comment - this is a good approach to distributed computing – http://www.math.tu-berlin.de/EuroComb05/Talks/Poster/p12-Teimoori_Faal.ppt
        Hide
        Edward J. Yoon added a comment -

        We should think about more efficient algorithm.

        Show
        Edward J. Yoon added a comment - We should think about more efficient algorithm.

          People

          • Assignee:
            Unassigned
            Reporter:
            Edward J. Yoon
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development