public static void incrementalAggregation(
     MatrixValue valueAgg,
     MatrixValue correction,
     MatrixValue valueAdd,
     AggregateOperator op,
     boolean imbededCorrection)
     throws DMLRuntimeException {
   if (op.correctionExists) {
     if (!imbededCorrection || op.correctionLocation == CorrectionLocationType.NONE)
       valueAgg.incrementalAggregate(op, correction, valueAdd);
     else valueAgg.incrementalAggregate(op, valueAdd);
   } else valueAgg.binaryOperationsInPlace(op.increOp, valueAdd);
 }
  public static void performAggregateBinaryIgnoreIndexes(
      MatrixValue value1, MatrixValue value2, MatrixValue valueOut, AggregateBinaryOperator op)
      throws DMLRuntimeException {

    // perform on the value
    value1.aggregateBinaryOperations(value1, value2, valueOut, op);
  }
 public static void performZeroOut(
     MatrixIndexes indexesIn,
     MatrixValue valueIn,
     MatrixIndexes indexesOut,
     MatrixValue valueOut,
     IndexRange range,
     boolean complementary)
     throws DMLRuntimeException {
   valueIn.zeroOutOperations(valueOut, range, complementary);
   indexesOut.setIndexes(indexesIn);
 }
Example #4
0
  /**
   * Method to create data values for the formal arguments of a vocab element.
   *
   * @param tokens The array of string tokens.
   * @param startI The starting index to
   * @param destValue The destination value that we are populating.
   */
  private void parseFormalArgs(
      final String[] tokens,
      final int startI,
      final Argument destPattern,
      final MatrixValue destValue) {

    for (int i = 0; i < destValue.getArguments().size(); i++) {
      Argument fa = destPattern.childArguments.get(i);
      boolean emptyArg = false;

      // If the field doesn't contain anything or matches the FargName
      // we consider the argument to be 'empty'.
      if ((tokens[startI + i].length() == 0) || tokens[startI + i].equals(fa.name)) {
        emptyArg = true;
      }

      tokens[startI + i] = tokens[startI + i].trim();
      destValue.getArguments().get(i).set(tokens[startI + i]);
    }
  }
 // tertiary where first input is a matrix, and second and third inputs are scalars (double)
 public static void performTernary(
     MatrixIndexes indexesIn1,
     MatrixValue valueIn1,
     double scalarIn2,
     double scalarIn3,
     CTableMap resultMap,
     MatrixBlock resultBlock,
     Operator op)
     throws DMLRuntimeException {
   // operation on the cells inside the value
   valueIn1.ternaryOperations(op, scalarIn2, scalarIn3, resultMap, resultBlock);
 }
 public static void performAppend(
     MatrixValue valueIn1,
     MatrixValue valueIn2,
     ArrayList<IndexedMatrixValue> outlist,
     int blockRowFactor,
     int blockColFactor,
     boolean cbind,
     boolean m2IsLast,
     int nextNCol)
     throws DMLRuntimeException {
   valueIn1.appendOperations(
       valueIn2, outlist, blockRowFactor, blockColFactor, cbind, m2IsLast, nextNCol);
 }
  public static void performAggregateBinary(
      MatrixIndexes indexes1,
      MatrixValue value1,
      MatrixIndexes indexes2,
      MatrixValue value2,
      MatrixIndexes indexesOut,
      MatrixValue valueOut,
      AggregateBinaryOperator op)
      throws DMLRuntimeException {
    // compute output index
    indexesOut.setIndexes(indexes1.getRowIndex(), indexes2.getColumnIndex());

    // perform on the value
    value1.aggregateBinaryOperations(indexes1, value1, indexes2, value2, valueOut, op);
  }
  public static void performAggregateUnary(
      MatrixIndexes indexesIn,
      MatrixValue valueIn,
      MatrixIndexes indexesOut,
      MatrixValue valueOut,
      AggregateUnaryOperator op,
      int brlen,
      int bclen)
      throws DMLRuntimeException {
    // operate on the value indexes first
    op.indexFn.execute(indexesIn, indexesOut);

    // perform on the value
    valueIn.aggregateUnaryOperations(op, valueOut, brlen, bclen, indexesIn);
  }
  public static void performReorg(
      MatrixIndexes indexesIn,
      MatrixValue valueIn,
      MatrixIndexes indexesOut,
      MatrixValue valueOut,
      ReorgOperator op,
      int startRow,
      int startColumn,
      int length)
      throws DMLRuntimeException {
    // operate on the value indexes first
    op.fn.execute(indexesIn, indexesOut);

    // operation on the cells inside the value
    valueIn.reorgOperations(op, valueOut, startRow, startColumn, length);
  }
 public static void performUnaryIgnoreIndexesInPlace(MatrixValue valueIn, UnaryOperator op)
     throws DMLRuntimeException {
   valueIn.unaryOperationsInPlace(op);
 }
 public static void performUnaryIgnoreIndexes(
     MatrixValue valueIn, MatrixValue valueOut, UnaryOperator op) throws DMLRuntimeException {
   valueIn.unaryOperations(op, valueOut);
 }
 public static void performScalarIgnoreIndexes(
     MatrixValue valueIn, MatrixValue valueOut, ScalarOperator op) throws DMLRuntimeException {
   valueIn.scalarOperations(op, valueOut);
 }
  /**
   * @param valueOut
   * @param correction
   * @param op
   * @param rlen
   * @param clen
   * @param sparseHint
   * @param imbededCorrection
   * @throws DMLRuntimeException
   */
  public static void startAggregation(
      MatrixValue valueOut,
      MatrixValue correction,
      AggregateOperator op,
      int rlen,
      int clen,
      boolean sparseHint,
      boolean imbededCorrection)
      throws DMLRuntimeException {
    int outRow = 0, outCol = 0, corRow = 0, corCol = 0;
    if (op.correctionExists) {
      if (!imbededCorrection) {
        switch (op.correctionLocation) {
          case NONE:
            outRow = rlen;
            outCol = clen;
            corRow = rlen;
            corCol = clen;
            break;
          case LASTROW:
            outRow = rlen - 1;
            outCol = clen;
            corRow = 1;
            corCol = clen;
            break;
          case LASTCOLUMN:
            if (op.increOp.fn instanceof Builtin
                && (((Builtin) (op.increOp.fn)).bFunc == Builtin.BuiltinFunctionCode.MAXINDEX
                    || ((Builtin) (op.increOp.fn)).bFunc == Builtin.BuiltinFunctionCode.MININDEX)) {
              outRow = rlen;
              outCol = 1;
              corRow = rlen;
              corCol = 1;
            } else {
              outRow = rlen;
              outCol = clen - 1;
              corRow = rlen;
              corCol = 1;
            }
            break;
          case LASTTWOROWS:
            outRow = rlen - 2;
            outCol = clen;
            corRow = 2;
            corCol = clen;
            break;
          case LASTTWOCOLUMNS:
            outRow = rlen;
            outCol = clen - 2;
            corRow = rlen;
            corCol = 2;
            break;
          case LASTFOURROWS:
            outRow = rlen - 4;
            outCol = clen;
            corRow = 4;
            corCol = clen;
            break;
          case LASTFOURCOLUMNS:
            outRow = rlen;
            outCol = clen - 4;
            corRow = rlen;
            corCol = 4;
            break;
          default:
            throw new DMLRuntimeException(
                "unrecognized correctionLocation: " + op.correctionLocation);
        }
      } else {
        outRow = rlen;
        outCol = clen;
        corRow = rlen;
        corCol = clen;
      }

      // set initial values according to operator
      if (op.initialValue == 0) {
        valueOut.reset(outRow, outCol, sparseHint);
        correction.reset(corRow, corCol, false);
      } else {
        valueOut.resetDenseWithValue(outRow, outCol, op.initialValue);
        correction.resetDenseWithValue(corRow, corCol, op.initialValue);
      }

    } else {
      if (op.initialValue == 0) valueOut.reset(rlen, clen, sparseHint);
      else valueOut.resetDenseWithValue(rlen, clen, op.initialValue);
    }
  }
 // binary operations are those that the indexes of both cells have to be matched
 public static void performBinaryIgnoreIndexes(
     MatrixValue value1, MatrixValue value2, MatrixValue valueOut, BinaryOperator op)
     throws DMLRuntimeException {
   value1.binaryOperations(op, value2, valueOut);
 }