Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-910

"ebe..." basic operations in "MathArrays"

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 3.1
    • None
    • None

    Description

      I propose to add element-by-element addition, subtraction, division and multiplication in the "MathArrays" class. E.g. "ebeDivide" would be defined as:

          /**
           * Creates an array whose contents will be the element-by-element
           * division of the first argument by the second.
           *
           * @param numer Numerator of the division.
           * @param denom Denominator of the division.
           * @return a new array {@code r} where {@code r[i] = numer[i] / denom[i]}.
           * @throws DimensionMismatchException if the array lengths differ.
           */
          public static double[] ebeDivide(double[] numer,
                                           double[] denom) {
              if (numer.length != denom.length) {
                  throw new DimensionMismatchException(numer.length, denom.length);
              }
      
              final double[] result = numer.clone();
              for (int i = 0; i < numer.length; i++) {
                  result[i] /= denom[i];
              }
              return result;
          }
      

      This would allow to resolve MATH-895 without settling the discussion on how the API of RealVector should change.

      Attachments

        Activity

          People

            erans Gilles Sadowski
            erans Gilles Sadowski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: