Increments {@code gradient} by
{@code count * features(dependency)} for all dependency
structures in {@code dependencies}.

@param gradient
@param parameters
@param posTags
@param dependencies
@param count
332208
public void incrementDependencySufficientStatistics(SufficientStatistics gradient,
      SufficientStatistics parameters, List<String> posTags,
      Collection<DependencyStructure> dependencies, double count) {

    int[] puncCounts = CcgParser.computeDistanceCounts(posTags, puncTagSet);
    int[] verbCounts = CcgParser.computeDistanceCounts(posTags, verbTagSet);

    SufficientStatistics dependencyGradient = gradient.coerceToList().getStatisticByName(DEPENDENCY_PARAMETERS);
    SufficientStatistics wordDistanceGradient = gradient.coerceToList().getStatisticByName(WORD_DISTANCE_PARAMETERS);
    SufficientStatistics puncDistanceGradient = gradient.coerceToList().getStatisticByName(PUNC_DISTANCE_PARAMETERS);
    SufficientStatistics verbDistanceGradient = gradient.coerceToList().getStatisticByName(VERB_DISTANCE_PARAMETERS);
    
    SufficientStatistics dependencyParameters = parameters.coerceToList().getStatisticByName(DEPENDENCY_PARAMETERS);
    SufficientStatistics wordDistanceParameters = parameters.coerceToList().getStatisticByName(WORD_DISTANCE_PARAMETERS);
    SufficientStatistics puncDistanceParameters = parameters.coerceToList().getStatisticByName(PUNC_DISTANCE_PARAMETERS);
    SufficientStatistics verbDistanceParameters = parameters.coerceToList().getStatisticByName(VERB_DISTANCE_PARAMETERS);
    
    for (DependencyStructure dependency : dependencies) {
      int headWordIndex = dependency.getHeadWordIndex();
      int objectWordIndex = dependency.getObjectWordIndex();

      Assignment predicateAssignment = Assignment.unionAll(
          dependencyHeadVar.outcomeArrayToAssignment(dependency.getHead()),
          dependencySyntaxVar.outcomeArrayToAssignment(dependency.getHeadSyntacticCategory()),
          dependencyArgNumVar.outcomeArrayToAssignment(dependency.getArgIndex()),
          dependencyHeadPosVar.outcomeArrayToAssignment(posTags.get(headWordIndex)),
          dependencyArgPosVar.outcomeArrayToAssignment(posTags.get(objectWordIndex)));
      Assignment assignment = predicateAssignment.union(
          dependencyArgVar.outcomeArrayToAssignment(dependency.getObject()));

      dependencyFamily.incrementSufficientStatisticsFromAssignment(dependencyGradient,
          dependencyParameters, assignment, count);

      // Update distance parameters.
      int wordDistance = CcgParser.computeWordDistance(headWordIndex, objectWordIndex);
      int puncDistance = CcgParser.computeArrayDistance(puncCounts, headWordIndex, objectWordIndex);
      int verbDistance = CcgParser.computeArrayDistance(verbCounts, headWordIndex, objectWordIndex);

      Assignment wordDistanceAssignment = predicateAssignment.union(
          wordDistanceVar.outcomeArrayToAssignment(wordDistance));
      wordDistanceFamily.incrementSufficientStatisticsFromAssignment(wordDistanceGradient,
          wordDistanceParameters, wordDistanceAssignment, count);

      Assignment puncDistanceAssignment = predicateAssignment.union(
          puncDistanceVar.outcomeArrayToAssignment(puncDistance));
      puncDistanceFamily.incrementSufficientStatisticsFromAssignment(puncDistanceGradient,
          puncDistanceParameters, puncDistanceAssignment, count);

      Assignment verbDistanceAssignment = predicateAssignment.union(
          verbDistanceVar.outcomeArrayToAssignment(verbDistance));
      verbDistanceFamily.incrementSufficientStatisticsFromAssignment(verbDistanceGradient,
          verbDistanceParameters, verbDistanceAssignment, count);
    }
  }
430665
public final static void addCountToMonomerNotation(PolymerNotation polymer, int position, String count) {
		polymer.getPolymerElements().getListOfElements().get(position).setCount(count);
	}
139197
protected void updateDependency(Dependency value, String xmlTag, Counter counter, Element element)
   {
      Element root = element;
      Counter innerCount = new Counter(counter.getDepth() + 1);
      findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null);
      findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null);
      findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null);
      findAndReplaceSimpleElement(innerCount, root, "type", value.getType(), "jar");
      findAndReplaceSimpleElement(innerCount, root, "classifier", value.getClassifier(), null);
      findAndReplaceSimpleElement(innerCount, root, "scope", value.getScope(), null);
      findAndReplaceSimpleElement(innerCount, root, "systemPath", value.getSystemPath(), null);
      iterateExclusion(innerCount, root, value.getExclusions(), "exclusions", "exclusion");
      findAndReplaceSimpleElement(innerCount, root, "optional",
               (value.isOptional() == false) ? null : String.valueOf(value.isOptional()), "false");
   }
543046
private void countPropertyQualifier(UsageStatistics usageStatistics,
			PropertyIdValue property, int count) {
		addPropertyCounters(usageStatistics, property);
		usageStatistics.propertyCountsQualifier.put(property,
				usageStatistics.propertyCountsQualifier.get(property) + count);
	}
450942
private void addDependent(String pathName, String relativeTo) {
        if (relativeTo != null) {
            Set<String> dependents = dependenctRelativePaths.get(relativeTo);
            if (dependents == null) {
                dependents = new HashSet<String>();
                dependenctRelativePaths.put(relativeTo, dependents);
            }
            dependents.add(pathName);
        }
    }
276048
@Override
    public final RESOLVESTAGETYPE addDependencies(final MavenDependency... dependencies)
        throws IllegalArgumentException {
        if (dependencies == null || dependencies.length == 0) {
            throw new IllegalArgumentException("At least one coordinate must be specified");
        }
        for (final MavenDependency dependency : dependencies) {
            if (dependency == null) {
                throw new IllegalArgumentException("null dependency not permitted");
            }
            final MavenDependency resolved = this.resolveDependency(dependency);
            this.session.getDependenciesForResolution().add(resolved);
        }
        return this.covarientReturn();
    }
1106700
public void updateParameterCount(final EquPart[] equParts, final int myLocInArray)
    {
        setParameterCount(0);

        for (int p = myLocInArray + 1; p < equParts.length; p++)
        {
            final EquPart part = equParts[p];

            if (part.getLevel() <= getLevel())
                break;

            if ((part.getLevel() == (getLevel() + 1)) && part instanceof OpComma)
                setParameterCount(getParameterCount() + 1);
        }

        if (getParameterCount() > 0)
            setParameterCount(getParameterCount() + 1);
    }
184085
@Override
    public void postStep(INDArray gradient) {
        INDArray previousParameters = (INDArray) searchState.get("oldparams");
        INDArray parameters = model.params();
        INDArray previousGradient = (INDArray) searchState.get(GRADIENT_KEY);

        LinkedList<Double> rho = (LinkedList<Double>) searchState.get("rho");
        LinkedList<INDArray> s = (LinkedList<INDArray>) searchState.get("s");
        LinkedList<INDArray> y = (LinkedList<INDArray>) searchState.get("y");

        double sy = Nd4j.getBlasWrapper().dot(previousParameters, previousGradient) + Nd4j.EPS_THRESHOLD;
        double yy = Nd4j.getBlasWrapper().dot(previousGradient, previousGradient) + Nd4j.EPS_THRESHOLD;

        INDArray sCurrent;
        INDArray yCurrent;
        if (s.size() >= m) {
            //Optimization: Remove old (no longer needed) INDArrays, and use assign for re-use.
            //Better to do this: fewer objects created -> less memory overall + less garbage collection
            sCurrent = s.removeLast();
            yCurrent = y.removeLast();
            rho.removeLast();
            sCurrent.assign(parameters).subi(previousParameters);
            yCurrent.assign(gradient).subi(previousGradient);
        } else {
            //First few iterations. Need to allocate new INDArrays for storage (via copy operation sub)
            sCurrent = parameters.sub(previousParameters);
            yCurrent = gradient.sub(previousGradient);
        }

        rho.addFirst(1.0 / sy); //Most recent first
        s.addFirst(sCurrent); //Most recent first. si = currParams - oldParams
        y.addFirst(yCurrent); //Most recent first. yi = currGradient - oldGradient

        //assert (s.size()==y.size()) : "Gradient and parameter sizes are not equal";
        if (s.size() != y.size())
            throw new IllegalStateException("Gradient and parameter sizes are not equal");

        //In general: have m elements in s,y,rho.
        //But for first few iterations, have less.
        int numVectors = Math.min(m, s.size());

        double[] alpha = new double[numVectors];

        // First work backwards, from the most recent difference vectors
        Iterator<INDArray> sIter = s.iterator();
        Iterator<INDArray> yIter = y.iterator();
        Iterator<Double> rhoIter = rho.iterator();

        //searchDir: first used as equivalent to q as per N&W, then later used as r as per N&W.
        //Re-using existing array for performance reasons
        INDArray searchDir = (INDArray) searchState.get(SEARCH_DIR);
        searchDir.assign(gradient);

        for (int i = 0; i < numVectors; i++) {
            INDArray si = sIter.next();
            INDArray yi = yIter.next();
            double rhoi = rhoIter.next();

            if (si.length() != searchDir.length())
                throw new IllegalStateException("Gradients and parameters length not equal");

            alpha[i] = rhoi * Nd4j.getBlasWrapper().dot(si, searchDir);
            Nd4j.getBlasWrapper().level1().axpy(searchDir.length(), -alpha[i], yi, searchDir); //q = q-alpha[i]*yi
        }

        //Use Hessian approximation initialization scheme
        //searchDir = H0*q = (gamma*IdentityMatrix)*q = gamma*q
        double gamma = sy / yy;
        searchDir.muli(gamma);

        //Reverse iterators: end to start. Java LinkedLists are doubly-linked,
        // so still O(1) for reverse iteration operations.
        sIter = s.descendingIterator();
        yIter = y.descendingIterator();
        rhoIter = rho.descendingIterator();
        for (int i = 0; i < numVectors; i++) {
            INDArray si = sIter.next();
            INDArray yi = yIter.next();
            double rhoi = rhoIter.next();

            double beta = rhoi * Nd4j.getBlasWrapper().dot(yi, searchDir); //beta = rho_i * y_i^T * r
            //r = r + s_i * (alpha_i - beta)
            Nd4j.getBlasWrapper().level1().axpy(gradient.length(), alpha[i] - beta, si, searchDir);
        }

        previousParameters.assign(parameters);
        previousGradient.assign(gradient); //Update gradient. Still in searchState map keyed by GRADIENT_KEY
    }
775934
private String[] createResolversIncludesPattern(Collection<AbstractDependencyResolver> dependencyResolvers) {
        Collection<String> resultIncludes = new ArrayList<>();
        // TODO - check if can be done with lambda
        for (AbstractDependencyResolver dependencyResolver : dependencyResolvers) {
            for (String manifestFile : dependencyResolver.getManifestFiles()){
                if (!manifestFile.isEmpty()) {
                    resultIncludes.add(Constants.PATTERN + manifestFile);
                }
            }
        }
        String[] resultArray = new String[resultIncludes.size()];
        resultIncludes.toArray(resultArray);
        return resultArray;
    }
516553
@SuppressWarnings("unchecked")
    protected void addPostRunDependent(Executable<? extends Indexable> executable) {
        TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) executable;
        this.addPostRunDependent(dependency);
    }
1201212
private ClassicCounter<Pair<F, L>> convertSVMStructWeights(ClassicCounter<Integer> weights, Index<F> featureIndex, Index<L> labelIndex) {
    // int numLabels = labelIndex.size();
    int numFeatures = featureIndex.size();
    ClassicCounter<Pair<F, L>> newWeights = new ClassicCounter<Pair<F, L>>();
    for (int i : weights.keySet()) {
      L l = labelIndex.get((i-1) / numFeatures); // integer division on purpose
      F f = featureIndex.get((i-1) % numFeatures);
      double w = weights.getCount(i);
      newWeights.incrementCount(new Pair<F, L>(f, l),w);
    }

    return newWeights;
  }
865067
@Override
    public void addParameterAnnotation(int param, AnnotationValue annotationValue) {
        HashMap<Integer, Map<ClassDescriptor, AnnotationValue>> updatedAnnotations = new HashMap<>(
                methodParameterAnnotations);
        Map<ClassDescriptor, AnnotationValue> paramMap = updatedAnnotations.get(param);
        if (paramMap == null) {
            paramMap = new HashMap<>();
            updatedAnnotations.put(param, paramMap);
        }
        paramMap.put(annotationValue.getAnnotationClass(), annotationValue);

        methodParameterAnnotations = updatedAnnotations;
        TypeQualifierApplications.updateAnnotations(this);
    }
364491
public static <E> void divideInPlace(Counter<E> target, Counter<E> denominator) {
    for (E key : target.keySet()) {
      target.setCount(key, target.getCount(key) / denominator.getCount(key));
    }
  }
251896
@Override
    @SuppressWarnings("ReferenceEquality")
    protected boolean evaluateDependencies(final Dependency dependency, final Dependency nextDependency, final Set<Dependency> dependenciesToRemove) {
        Dependency main;
        //CSOFF: InnerAssignment
        if ((main = getMainGemspecDependency(dependency, nextDependency)) != null) {
            if (main == dependency) {
                mergeDependencies(dependency, nextDependency, dependenciesToRemove);
            } else {
                mergeDependencies(nextDependency, dependency, dependenciesToRemove);
                return true; //since we merged into the next dependency - skip forward to the next in mainIterator
            }
        } else if ((main = getMainSwiftDependency(dependency, nextDependency)) != null) {
            if (main == dependency) {
                mergeDependencies(dependency, nextDependency, dependenciesToRemove);
            } else {
                mergeDependencies(nextDependency, dependency, dependenciesToRemove);
                return true; //since we merged into the next dependency - skip forward to the next in mainIterator
            }
        } else if ((main = getMainAndroidDependency(dependency, nextDependency)) != null) {
            if (main == dependency) {
                mergeDependencies(dependency, nextDependency, dependenciesToRemove);
            } else {
                mergeDependencies(nextDependency, dependency, dependenciesToRemove);
                return true; //since we merged into the next dependency - skip forward to the next in mainIterator
            }
        } else if ((main = getMainDotnetDependency(dependency, nextDependency)) != null) {
            if (main == dependency) {
                mergeDependencies(dependency, nextDependency, dependenciesToRemove);
            } else {
                mergeDependencies(nextDependency, dependency, dependenciesToRemove);
                return true; //since we merged into the next dependency - skip forward to the next in mainIterator
            }
        }
        //CSON: InnerAssignment
        return false;
    }
654113
public void addDependency(Dependency dependency) {
        Dependency newDep = null;
        String classifier = dependency.getArtifact().getClassifier();
        if ( Const.TEST.equals( classifier ) || Const.TEST_JAR.equals( classifier ) ) {
            ArtifactType artifactType = new DefaultArtifactType( Const.TEST_JAR, Const.JAR, Const.TEST_JAR, null );
            
            Artifact artifact = dependency.getArtifact();
            
            artifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
                    null, Const.JAR, artifact.getBaseVersion(), artifactType );
            newDep =  new Dependency(artifact, dependency.getScope());
        } else {
            newDep = dependency;
        }
        dependencies.add(newDep);
    }
540740
function (classpath, dependencies) {
            if (this.__cssDependencies[classpath]) {
                dependencies = this.__cssDependencies[classpath];
            } else {

                // Look at in the parents for the css inheritance.
                var tpl = Aria.getClassRef(classpath);
                var css = {};
                if (dependencies) {
                    for (var i = 0, ii = dependencies.length; i < ii; i++) {
                        css[Aria.getClasspath(dependencies[i])] = true;
                    }
                }

                tpl = tpl.superclass;
                while (tpl) {
                    var $css = tpl.$css;
                    if ($css) {
                        for (var i = 0, ii = $css.length; i < ii; i++) {
                            css[Aria.getClasspath($css[i])] = true;
                        }
                    }
                    tpl = tpl.constructor.superclass;
                }

                dependencies = ariaUtilsObject.keys(css);

                // Store the css dependencies for performance reason
                this.__cssDependencies[classpath] = dependencies;
            }

            var contextArgs = {
                isWidget : true
            };

            this.loadClassPathDependencies(classpath, dependencies, contextArgs);
        }
814996
function(compiler, compilation, params){
    compilation.dependencyFactories.set(AngularModuleDependency,
                                        params.normalModuleFactory);
    compilation.dependencyTemplates.set(AngularModuleDependency,
                                        new AngularModuleDependency.Template());
    compilation.dependencyFactories.set(AngularModuleDefinition,
                                        new NullFactory());
    compilation.dependencyTemplates.set(AngularModuleDefinition,
                                        new AngularModuleDefinition.Template());
  }