Folds non-zero elements (in a column-by-column manner) of this matrix with given {@code accumulator}.

@param accumulator the matrix accumulator

@return the accumulated vector
323564
public double[] foldNonZeroInColumns(VectorAccumulator accumulator) {
        double[] result = new double[columns];

        for (int j = 0; j < columns; j++) {
            result[j] = foldNonZeroInColumn(j, accumulator);
        }

        return result;
    }
383561
@Override
	public final MutableObjectIterator<T> getIterator() {
		final SingleSegmentInputView startIn = new SingleSegmentInputView(this.recordsPerSegment * this.recordSize);
		startIn.set(this.sortBuffer.get(0), 0);
		
		return new MutableObjectIterator<T>() {
			
			private final SingleSegmentInputView in = startIn;
			private final TypeComparator<T> comp = comparator;
			
			private final int numTotal = size();
			private final int numPerSegment = recordsPerSegment;
			
			private int currentTotal = 0;
			private int currentInSegment = 0;
			private int currentSegmentIndex = 0;

			@Override
			public T next(T reuse) {
				if (this.currentTotal < this.numTotal) {
					
					if (this.currentInSegment >= this.numPerSegment) {
						this.currentInSegment = 0;
						this.currentSegmentIndex++;
						this.in.set(sortBuffer.get(this.currentSegmentIndex), 0);
					}
					
					this.currentTotal++;
					this.currentInSegment++;
					
					try {
						return this.comp.readWithKeyDenormalization(reuse, this.in);
					}
					catch (IOException ioe) {
						throw new RuntimeException(ioe);
					}
				}
				else {
					return null;
				}
			}
		};
	}
459781
public static VectorAccumulator asSumAccumulator(final double neutral) {
        return new VectorAccumulator() {
            private BigDecimal result = BigDecimal.valueOf(neutral);

            @Override
            public void update(int i, double value) {
                result = result.add(BigDecimal.valueOf(value));
            }

            @Override
            public double accumulate() {
                double value = result.setScale(Vectors.ROUND_FACTOR, RoundingMode.CEILING).doubleValue();
                result = BigDecimal.valueOf(neutral);
                return value;
            }
        };
    }
150519
public void accumulate(Object workingMemoryContext,
                           Object context,
                           Tuple tuple,
                           InternalFactHandle handle,
                           Declaration[] declarations,
                           Declaration[] innerDeclarations,
                           WorkingMemory workingMemory) throws Exception {
        
        VariableResolverFactory factory = unit.getFactory( null, null, null, handle, tuple, null, (InternalWorkingMemory) workingMemory, workingMemory.getGlobalResolver()  );
        
        final Object value = MVEL.executeExpression( this.expression,
                                                     handle.getObject(),
                                                     factory );
        if ( this.function.supportsReverse() ) {
            ((MVELAccumulatorFunctionContext) context).reverseSupport.put( handle.getId(), value );
        }
        this.function.accumulate( ((MVELAccumulatorFunctionContext) context).context,
                                  value );
    }
393851
function (projection = '') {

      //prepare projections
      let fields = _.compact(projection.split(','));
      fields = _.map(fields, _.trim);
      fields = _.uniq(fields);
      const accumulator = {};

      _.forEach(fields, function (field) {

        //if exclude e.g -name
        if (field[0] === '-') {
          accumulator[field.substring(1)] = 0;
        }

        //if include i.e name
        else {
          accumulator[field] = 1;
        }

      });

      return accumulator;
    }
941150
public static MatrixAccumulator mkManhattanNormAccumulator() {
        return new MatrixAccumulator() {
            private double result = 0.0;

            @Override
            public void update(int i, int j, double value) {
                result += Math.abs(value);
            }

            @Override
            public double accumulate() {
                double value = result;
                result = 0.0;
                return value;
            }
        };
    }
1020822
public ShuffleSorterIterator getSortedIterator() {
    int offset = 0;
    if (useRadixSort) {
      offset = RadixSort.sort(
        array, pos,
        PackedRecordPointer.PARTITION_ID_START_BYTE_INDEX,
        PackedRecordPointer.PARTITION_ID_END_BYTE_INDEX, false, false);
    } else {
      MemoryBlock unused = new MemoryBlock(
        array.getBaseObject(),
        array.getBaseOffset() + pos * 8L,
        (array.size() - pos) * 8L);
      LongArray buffer = new LongArray(unused);
      Sorter<PackedRecordPointer, LongArray> sorter =
        new Sorter<>(new ShuffleSortDataFormat(buffer));

      sorter.sort(array, 0, pos, SORT_COMPARATOR);
    }
    return new ShuffleSorterIterator(pos, array, offset);
  }
292292
public void getAllExpressions(Collection<Expression2> accumulator) {
    accumulator.add(rootExpression);

    for (int i = 0; i < substitutions.size(); i++) {
      substitutions.get(i).getAllExpressions(accumulator);
    }

    for (int i = 0; i < lefts.size(); i++) {
      lefts.get(i).getAllExpressions(accumulator);
      rights.get(i).getAllExpressions(accumulator);
    }
  }
1215049
public VectorIterator nonZeroIteratorOfRow(int i) {
        final int ii = i;
        return new VectorIterator(columns) {
            private int j = -1;

            @Override
            public int index() {
                return j;
            }

            @Override
            public double get() {
                return SparseMatrix.this.get(ii, j);
            }

            @Override
            public void set(double value) {
                SparseMatrix.this.set(ii, j, value);
            }

            @Override
            public boolean hasNext() {
                while (j + 1 < columns && SparseMatrix.this.isZeroAt(ii, j + 1)) {
                    j++;
                }

                return j + 1 < columns;
            }

            @Override
            public Double next() {
                if(!hasNext()) {
                    throw new NoSuchElementException();
                }
                j++;
                return get();
            }
        };
    }
920548
public double[] foldNonZeroInRows(VectorAccumulator accumulator) {
        double[] result = new double[rows];

        for (int i = 0; i < rows; i++) {
            result[i] = foldNonZeroInRow(i, accumulator);
        }

        return result;
    }
414554
private void createAccumulators(final OnDemandStatsProducer<S> producer, final Class producerClass, AccumulateWithSubClasses... annotations) {
		for (final AccumulateWithSubClasses annotation : annotations)
			if (annotation != null)
				AccumulatorUtil.getInstance(producerClass).createAccumulator(producer, annotation);
	}
675926
public VectorIterator iteratorOfColumn(int j) {
         final int jj = j;
         return new VectorIterator(rows) {
             private int i = -1;
             @Override
             public int index() {
                 return i;
             }

             @Override
             public double get() {
                 return Matrix.this.get(i, jj);
             }

             @Override
             public void set(double value) {
                 Matrix.this.set(i, jj, value);
             }

             @Override
             public boolean hasNext() {
                 return i + 1 < rows;
             }

             @Override
             public Double next() {
                 if(!hasNext()) {
                     throw new NoSuchElementException();
                 }
                 i++;
                 return get();
             }
         };
     }
1220346
@Override
  public Iterator<Row> iterator()
  {
    return new MovingAverageIterator(seq, dims, factories, emptyEvents, aggMap);
  }
1231034
public static Collection<IteratorSetting> getMetricIterators(AccumuloTable table)
    {
        String cardQualifier = new String(CARDINALITY_CQ);
        String rowsFamily = new String(METRICS_TABLE_ROWS_CF.array());

        // Build a string for all columns where the summing combiner should be applied,
        // i.e. all indexed columns
        StringBuilder cardBuilder = new StringBuilder(rowsFamily + ":" + cardQualifier + ",");
        for (String s : getLocalityGroups(table).keySet()) {
            cardBuilder.append(s).append(":").append(cardQualifier).append(',');
        }
        cardBuilder.deleteCharAt(cardBuilder.length() - 1);

        // Configuration rows for the Min/Max combiners
        String firstRowColumn = rowsFamily + ":" + new String(METRICS_TABLE_FIRST_ROW_CQ.array());
        String lastRowColumn = rowsFamily + ":" + new String(METRICS_TABLE_LAST_ROW_CQ.array());

        // Summing combiner for cardinality columns
        IteratorSetting s1 = new IteratorSetting(1, SummingCombiner.class, ImmutableMap.of("columns", cardBuilder.toString(), "type", "STRING"));

        // Min/Max combiner for the first/last rows of the table
        IteratorSetting s2 = new IteratorSetting(2, MinByteArrayCombiner.class, ImmutableMap.of("columns", firstRowColumn));
        IteratorSetting s3 = new IteratorSetting(3, MaxByteArrayCombiner.class, ImmutableMap.of("columns", lastRowColumn));

        return ImmutableList.of(s1, s2, s3);
    }
129771
private void createClassLevelAccumulators(OnDemandStatsProducer<T> producer, Class producerClass) {
        //several @Accumulators in accumulators holder
        Accumulates accAnnotationHolder = AnnotationUtils.findAnnotation(producerClass, Accumulates.class);//(Accumulates) producerClass.getAnnotation(Accumulates.class);
        if (accAnnotationHolder != null) {
            Accumulate[] accAnnotations  = accAnnotationHolder.value();
            for (Accumulate accAnnotation : accAnnotations) {
                createAccumulator(
                        producer.getProducerId(),
                        accAnnotation,
                        formAccumulatorNameForClass(producer, accAnnotation),
                        "cumulated");
            }
        }

        //If there is no @Accumulates annotation but @Accumulate is present
        Accumulate annotation = AnnotationUtils.findAnnotation(producerClass, Accumulate.class);//producerClass.getAnnotation(Accumulate.class);
        createAccumulator(
                producer.getProducerId(),
                annotation,
                formAccumulatorNameForClass(producer, annotation),
                "cumulated"
        );
    }
995042
public static RealMatrix shuffleRows (RealMatrix matrix, RandomGenerator randomGenerator) {
        // Create an index vector to be shuffled:
        int[] index = MathArrays.sequence(matrix.getRowDimension(), 0, 1);
        MathArrays.shuffle(index, randomGenerator);

        // Create a new matrix:
        RealMatrix retval = MatrixUtils.createRealMatrix(matrix.getRowDimension(), matrix.getColumnDimension());

        // Populate:
        for (int row = 0; row < index.length; row++) {
            retval.setRowVector(row, matrix.getRowVector(index[row]));
        }

        // Done, return:
        return retval;
    }
687757
function resolve (accumulator, resolveReducer) {
  // get Entity Spec
  const spec = accumulator.reducer.spec
  // execute lodash template against
  // accumulator value
  const value = spec.template(accumulator.value)
  // set new accumulator.value
  // this method creates a new acc object
  return Object.assign({}, accumulator, {
    value
  })
}