Calculate the integral with the simpson method of the equation implemented in the method
equation

@return
@throws Exception
179644
protected double simpson() {
        double s = 0f;
        double st = 0f;
        double ost = 0f;
        double os = 0f;

        for( int i = 1; i < maxsteps; i++ ) {
            st = trapezoid(i);

            s = (4f * st - ost) / 3f;

            if (i > 5) {
                if (Math.abs(s - os) < accuracy * Math.abs(os) || (s == 0f && os == 0f)) {
                    return s;
                }
            }
            os = s;
            ost = st;

        }
        return 0d;
    }
495146
public void calculate() throws IOException {
        OggStreamAudioData data;

        // Calculate the headers sizing
        OggAudioInfoHeader info = headers.getInfo();
        handleHeader(info);
        handleHeader(headers.getTags());
        handleHeader(headers.getSetup());

        // Have each audio packet handled, tracking at least granules
        while ((data = audio.getNextAudioPacket()) != null) {
            handleAudioData(data);
        }

        // Calculate the duration from the granules, if found
        if (lastGranule > 0) {
            long samples = lastGranule - info.getPreSkip();
            double sampleRate = info.getSampleRate();
            if (info instanceof OpusInfo) {
                // Opus is a special case - granule *always* runs at 48kHz
                sampleRate = OpusAudioData.OPUS_GRANULE_RATE;
            }
            durationSeconds = samples / sampleRate;
        }
    }
35672
public static Double computeAspect(Geometry geometry) throws IllegalArgumentException {
        if (geometry == null) {
            return null;
        }
        Vector3D vector = TriMarkers.getSteepestVector(TriMarkers.getNormalVector(TINFeatureFactory.createTriangle(geometry)), TINFeatureFactory.EPSILON);
        if (vector.length() < TINFeatureFactory.EPSILON) {
            return 0d;
        } else {
            Vector2D v = new Vector2D(vector.getX(), vector.getY());
            return measureFromNorth(Math.toDegrees(v.angle()));
        }
    }
1187742
@Override
  public void evaluate(DoubleSolution solution) {

    int numberOfVariables_ = solution.getNumberOfVariables();
    int numberOfObjectives_ = solution.getNumberOfObjectives();

    double[] x = new double[numberOfVariables_];
    double[] f = new double[numberOfObjectives_];

    for (int i = 0; i < numberOfVariables_; i++) {
      x[i] = solution.getVariableValue(i);
    }
    double[] thet = new double[numberOfObjectives_ - 1];
    double g = 0, sub1, sub2;
    // evaluate g,thet
    for (int i = numberOfObjectives_ - 1; i < numberOfVariables_; i++) {
      g += Math.pow(x[i] - 0.5, 2);
    }
    sub1 = 100 * g + 1;
    sub2 = 1 + g;
    for (int i = 0; i < 1; i++) {
      thet[i] = Math.PI * x[i] / 2;
    }
    for (int i = 1; i < numberOfObjectives_ - 1; i++) {
      thet[i] = Math.PI * (1 + 2 * g * x[i]) / (4 * sub2);
    }
    // evaluate fm,fm-1,...,2,f1
    f[numberOfObjectives_ - 1] = Math.sin(thet[0]) * sub1;
    double subf1 = 1;
    // fi=cos(thet1)cos(thet2)...cos(thet[m-i])*sin(thet(m-i+1))*(1+g[i]),fi=subf1*subf2*subf3
    for (int i = numberOfObjectives_ - 2; i > 0; i--) {
      subf1 *= Math.cos(thet[numberOfObjectives_ - i - 2]);
      f[i] = subf1 * Math.sin(thet[numberOfObjectives_ - i - 1]) * sub1;
    }
    f[0] = subf1 * Math.cos(thet[numberOfObjectives_ - 2]) * sub1;

    for (int i = 0; i < numberOfObjectives_; i++) {
      solution.setObjective(i, f[i]);
    }
  }
499248
@Override
    public double calcJ(int i, int j) {
        double result = 0d;
        for (int l = 1; l <= N2; l++)
            result += Math.cos(l * 2 * Math.PI * (i - j) / N) * Tl * l * l;
        return result * 2d / N;
    }

    /*
     * public Matrix calcT() { int i,j,l; Matrix T = new Matrix(N,N); double Tl
     * = (2/m)*(hdash*Math.PI/(N*dx))*(hdash*Math.PI/(N*dx)); int n = (N-1)/2;
     * for(i=0; i<N; i++) for(j=0; j<N; j++) { T.matrix[i][j] = 0d; for(l=1;
     * l<=n; l++) T.matrix[i][j] += Math.cos(l*2*Math.PI*(i-j)/N)*Tl*l*l;
     * T.matrix[i][j] *= 2d/N; } return T; }
     */

    @Override
    public double calcV(int i, int j) {
        if (i == j) return potential.getValue(minx + dx * i, 0d, 0d);
        return 0d;
    }

    /*
     * public Matrix calcV() { int i,j; Matrix V = new Matrix(N,N); for(i=0;
     * i<N; i++) for(j=0; j<N; j++) V.matrix[i][j] = 0d; for(i=0; i<N; i++)
     * V.matrix[i][i] = potential.getValue(minx+dx*i, 0d, 0d); return V; }
     */

    /*
     * public Matrix getS() { return S; } public Matrix getT() { return T; }
     * public Matrix getV() { return V; }
     */

    @Override
    public double calcI(int i, int j, int k, int l) {
        return 0d;
    }
512260
Double getSum() {
      if (count == 0) {
         return null;
      }
      // Better error bounds to add both terms as the final sum
      double tmp = sum + sumCompensation;
      if (Double.isNaN(tmp) && Double.isInfinite(simpleSum)) {
         // If the compensated sum is spuriously NaN from
         // accumulating one or more same-signed infinite values,
         // return the correctly-signed infinity stored in simpleSum.
         return simpleSum;
      } else {
         return tmp;
      }
   }
618330
public int getTotalTriples() throws Exception {
		int total = 0;
		for (HashMap<String, Integer> mappingStat : statistics.values()) {
			for (Integer triplesCount : mappingStat.values()) {
				int triples = triplesCount.intValue();
				if (triples == -1) {
					throw new Exception("An error was occurred in the counting process.");
				}
				total = total + triples;
			}
		}
		return total;
	}
906400
private RuntimeException unpackExecutionException(Throwable exc) {
    while (exc instanceof ExecutionException || exc instanceof UncheckedExecutionException) {
      exc = exc.getCause();
    }
    return Throwables.propagate(exc);
  }
302387
@Override
    public INDArray toDense() {
        // TODO support view conversion
        INDArray result = Nd4j.zeros(shape());

        switch (data().dataType()) {
            case DOUBLE:
                for (int i = 0; i < length; i++) {
                    int[] idx = getUnderlyingIndicesOf(i).asInt();
                    double value = values.getDouble(i);
                    result.putScalar(idx, value);
                }
                break;
            case FLOAT:
                for (int i = 0; i < length; i++) {
                    int[] idx = getUnderlyingIndicesOf(i).asInt();
                    float value = values.getFloat(i);
                    result.putScalar(idx, value);
                }
                break;
            default:
                throw new UnsupportedOperationException();
        }
        return result;
    }
232466
def run(self, series, exponent=None):
        '''
        
        '''
        try:
            return self.calculateHurst(series, exponent)
        except Exception as e:
            print("   Error: %s" % e)
1112943
public static void main(String[] args) throws Exception {

    DoubleProblem problem;
    Algorithm<DoubleSolution> algorithm;
    SolutionListEvaluator<DoubleSolution> evaluator ;

    String problemName = "org.uma.jmetal.problem.singleobjective.Sphere" ;

    problem = (DoubleProblem) ProblemUtils.<DoubleSolution> loadProblem(problemName);

    int numberOfCores ;
    if (args.length == 1) {
      numberOfCores = Integer.valueOf(args[0]) ;
    } else {
      numberOfCores = DEFAULT_NUMBER_OF_CORES ;
    }

    if (numberOfCores == 1) {
      evaluator = new SequentialSolutionListEvaluator<DoubleSolution>() ;
    } else {
      evaluator = new MultithreadedSolutionListEvaluator<DoubleSolution>(numberOfCores, problem) ;
    }

    algorithm = new StandardPSO2011(problem,
            10 + (int) (2 * Math.sqrt(problem.getNumberOfVariables())),
            25000, 3, evaluator) ;

    AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
        .execute() ;

    DoubleSolution solution = algorithm.getResult() ;
    long computingTime = algorithmRunner.getComputingTime() ;

    List<DoubleSolution> population = new ArrayList<>(1) ;
    population.add(solution) ;
    new SolutionListOutput(population)
        .setSeparator("\t")
        .setVarFileOutputContext(new DefaultFileOutputContext("VAR.tsv"))
        .setFunFileOutputContext(new DefaultFileOutputContext("FUN.tsv"))
        .print();

    JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");
    JMetalLogger.logger.info("Objectives values have been written to file FUN.tsv");
    JMetalLogger.logger.info("Variables values have been written to file VAR.tsv");

    JMetalLogger.logger.info("Fitness: " + solution.getObjective(0)) ;
    JMetalLogger.logger.info("Solution: " + solution.getVariableValueString(0)) ;
    evaluator.shutdown();
  }
399407
private static BigDecimal[] calculateInlineFormula(int start, String formula) throws Exception {
        BigDecimal[] result = new BigDecimal[2];
        StringBuilder inlineFormula = new StringBuilder();
        for (; start < formula.length(); start++) {
            char c = formula.charAt(start);
            if (c == '(') {
                BigDecimal[] res = calculateInlineFormula(start + 1, formula);
                inlineFormula.append(res[0]);
                start = res[1].intValue();
            } else if (c == ')') {
                break;
            } else {
                inlineFormula.append(c);
            }
        }
        result[0] = calculate(inlineFormula.toString());
        result[1] = BigDecimal.valueOf(start);
        return result;
    }
595361
final public void Math() throws ParseException {
    Multiplication();
    label_12:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case PLUS:
      case MINUS:
        ;
        break;
      default:
        jj_la1[25] = jj_gen;
        break label_12;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case PLUS:
        jj_consume_token(PLUS);
                  AstPlus jjtn001 = new AstPlus(JJTPLUS);
                  boolean jjtc001 = true;
                  jjtree.openNodeScope(jjtn001);
        try {
          Multiplication();
        } catch (Throwable jjte001) {
                  if (jjtc001) {
                    jjtree.clearNodeScope(jjtn001);
                    jjtc001 = false;
                  } else {
                    jjtree.popNode();
                  }
                  if (jjte001 instanceof RuntimeException) {
                    {if (true) throw (RuntimeException)jjte001;}
                  }
                  if (jjte001 instanceof ParseException) {
                    {if (true) throw (ParseException)jjte001;}
                  }
                  {if (true) throw (Error)jjte001;}
        } finally {
                  if (jjtc001) {
                    jjtree.closeNodeScope(jjtn001,  2);
                  }
        }
        break;
      case MINUS:
        jj_consume_token(MINUS);
                   AstMinus jjtn002 = new AstMinus(JJTMINUS);
                   boolean jjtc002 = true;
                   jjtree.openNodeScope(jjtn002);
        try {
          Multiplication();
        } catch (Throwable jjte002) {
                   if (jjtc002) {
                     jjtree.clearNodeScope(jjtn002);
                     jjtc002 = false;
                   } else {
                     jjtree.popNode();
                   }
                   if (jjte002 instanceof RuntimeException) {
                     {if (true) throw (RuntimeException)jjte002;}
                   }
                   if (jjte002 instanceof ParseException) {
                     {if (true) throw (ParseException)jjte002;}
                   }
                   {if (true) throw (Error)jjte002;}
        } finally {
                   if (jjtc002) {
                     jjtree.closeNodeScope(jjtn002,  2);
                   }
        }
        break;
      default:
        jj_la1[26] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
  }
1018890
private  void pldltpt() throws Exception{
		//matrix S will be changed by the factorization, ad we do not want to change the matrix passed in by the client
		DoubleMatrix2D S = (rescaler==null)? this.Q.copy() : this.Q;
		int n = S.rows();
		DoubleMatrix2D A = S.copy();
		this.P = DoubleFactory2D.sparse.identity(n);
		this.D = DoubleFactory2D.sparse.make(n, n);
		this.L = DoubleFactory2D.sparse.make(n, n);
		DoubleMatrix2D LT = ALG.transpose(L);//remove and work only with L
		int s = 0;
		for(int j=0; j<n; j++){
			//log.debug("j: " + j);
			DoubleMatrix2D LPart = null;
			DoubleMatrix2D LTPart = null;
			DoubleMatrix2D APart = null;
			DoubleMatrix2D DPart = null;
			double ajj = A.getQuick(j, j);
			if(Math.abs(ajj) > 1.e-16){
				//1 x pivot
				D.setQuick(j, j, ajj);
				s = 1;
			}else{
				//ajj = 0, so the 2x2 matrix with ajj in its upper left position
				//is non singular if a(j+1, j)=a(j, j+1) !=0 
				int k=-1;
				for (int r = j + 1; r < n; r++) {
					if (Math.abs(A.getQuick(r, j)) > 1.e-16) {
						k = r;
						break;
					}
				}
				if(k<0){
					throw new Exception("singular matrix");
				}
				//Symmetrically permute row/column k to position j + 1.
				A = ColtUtils.symmPermutation(A, k, j+1);
				P.setQuick(k, k, 0);
				P.setQuick(j + 1, j + 1, 0);
				P.setQuick(k, j + 1, 1);
				P.setQuick(j + 1, k, 1);
				//Choose a 2 � 2 pivot,
				//D(j:j+1)(j:j+1) =  A(j:j+1)(j:j+1)
				D.setQuick(j, j, A.getQuick(j, j));
				D.setQuick(j, j+1, A.getQuick(j, j+1));
				D.setQuick(j+1, j, A.getQuick(j+1, j));
				D.setQuick(j+1, j+1, A.getQuick(j+1, j+1));
				s=2;
			}
			//log.debug("s: " + s);
			
			// L(j:n)(j:j+s-1) = A(j:n)(j:j+s-1).DInv(j:j+s-1)(j:j+s-1)
			APart = A.viewPart(j, j, n - j, 1 + s - 1);
			DPart = ALG.inverse(D.viewPart(j, j, 1 + s - 1, 1 + s - 1));
			LPart = L.viewPart(j, j, n - j, 1 + s - 1);
			DoubleMatrix2D AD = ALG.mult(APart, DPart);
			for (int r = 0; r < LPart.rows(); r++) {
				for (int c = 0; c < LPart.columns(); c++) {
					LPart.setQuick(r, c, AD.getQuick(r, c));
				}
			}
			
			// A(j+s-1:n)(j+s-1:n) = A(j+s-1:n)(j+s-1:n) - L(j+s-1:n)(j:j+s-1).D(j:j+s-1)(j:j+s-1).LT(j:j+s-1)(j+s-1:n)
			LPart = L.viewPart(j + s - 1, j, n - (j + s - 1), 1 + s - 1);
			DPart = D.viewPart(j, j, 1 + s - 1, 1 + s - 1);
			LTPart = LT.viewPart(j, j + s - 1, s, n - (j + s - 1));
			APart = A.viewPart(j + s - 1, j + s - 1, n - (j + s - 1), n - (j + s - 1));
			DoubleMatrix2D LDLT = ALG.mult(LPart, ALG.mult(DPart, LTPart));
			for (int r = 0; r < APart.rows(); r++) {
				for (int c = 0; c < APart.columns(); c++) {
					APart.setQuick(r, c, APart.getQuick(r, c) - LDLT.getQuick(r, c));
				}
			}
			//logger.debug("L: " + ArrayUtils.toString(L.toArray()));
			//logger.debug("A: " + ArrayUtils.toString(A.toArray()));
			
			j = j + s - 1;
		}
	}
265572
@Override
	public float calc(Object l1, Object l2) {
		if (!l1.getClass().equals(l2.getClass()))
			throw new IllegalArgumentException("Exception in HammingLoss: l1 and l2 have different types");
		
		float ret = 0;
		if (l1 instanceof int[])	{
			ret = calc((int[])l1, (int[])l2);
		}else if (l1 instanceof String[])	{
			ret = calc((String[])l1, (String[])l2);
		}
557506
public function integrate()
	{
		$sum		= 0;
		$nodes		= $this->getSamplingNodes();
		$distance	= $this->getNodeDistance();
		$sum		+= $this->formula->getValue( array_pop( $nodes ) );
		$sum		+= $this->formula->getValue( array_shift ( $nodes ) );
		foreach( $nodes as $node )
			$sum += 2 * $this->formula->getValue( $node );
		$sum = $sum * $distance / 2;
		return $sum;			
	}
604905
public void write() throws Exception {
    PrintWriter out;
    String output = output();

    if (outFile != null) {
      out = new PrintWriter(Files.newBufferedWriter(outFile.toPath(), UTF_8));
    } else if (inPlace) {
      assert docFile != null
          : "@AssumeAssertion(nullness): dependent: docFile is non-null if inPlace is true";
      out = new PrintWriter(Files.newBufferedWriter(docFile.toPath(), UTF_8));
    } else {
      out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out, UTF_8)));
    }

    out.println(output);
    out.flush();
    out.close();
  }