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

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

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1
    • Labels:
      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

            • Assignee:
              erans Gilles
              Reporter:
              erans Gilles
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: