當前位置: 首頁>>代碼示例>>Java>>正文


Java FastMath類代碼示例

本文整理匯總了Java中org.apache.commons.math3.util.FastMath的典型用法代碼示例。如果您正苦於以下問題:Java FastMath類的具體用法?Java FastMath怎麽用?Java FastMath使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FastMath類屬於org.apache.commons.math3.util包,在下文中一共展示了FastMath類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertFromGeoToEarthCentred

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/**
 * 
 * @param lat
 * @param lon
 * @return
 */
public static double[] convertFromGeoToEarthCentred(final double lat, final double lon){
	double pH=GeoUtils.getGeoidH(lon, lat);
	
	double radLat=FastMath.toRadians(lat);
	double radLon=FastMath.toRadians(lon);
	
	// Convert from geographic coordinates to Earth centred Earth fixed coordinates
	double cosLat=FastMath.cos(radLat);
	double sinLat = FastMath.sin(radLat);
	double cosLon =FastMath.cos(radLon);
	double sinLon = FastMath.sin(radLon);
	
	double denomTmp = FastMath.sqrt((semiMajorAxis2) *(cosLat*cosLat) + (semiMinorAxis2)*(sinLat*sinLat));
	
	double pX = (semiMajorAxis2/denomTmp + pH) * cosLat * cosLon;
	double pY = (semiMajorAxis2/denomTmp + pH) * cosLat * sinLon;
	double pZ = (semiMinorAxis2/denomTmp + pH) * sinLat;
	
	double[] pXYZ = {pX ,pY, pZ};
	//double[] pXYZ = {4740162.032532615 , 787287.082659188, 4180253.542739194};
	return pXYZ;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:29,代碼來源:GeoUtils.java

示例2: gcpSlantRangeAndIncidenceAngleForComplex

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/**
 *			 ( Parameters have the names used in radarsat2 metadata )
 *
 * @param complex
 * @param slantRangenearEdge 
 * @param samplePixelSpacing
 * @param ngrd
 * @param nsam
 * @return
 */
public static double gcpSlantRangeAndIncidenceAngleForComplex(double slantRangeNearEdge,double sizeXPixel,double samplePixelSpacing,double xPix,double hsat,double earthRad,String timeOrdering){
	double slantAndIA=0;
	
	//calculate the slant range for the gpc
	double slantRangeFarGpc=slantRangeNearEdge+sizeXPixel*samplePixelSpacing;

	double slntRangePixel=0;
	if(timeOrdering.equalsIgnoreCase("Increasing")){		
		//calculate the gnd range for the gpc
		slntRangePixel=slantRangeFarGpc+xPix*samplePixelSpacing;
	}else{
		slntRangePixel=slantRangeFarGpc-xPix*samplePixelSpacing;
	}
	
	//incidence angle
	slantAndIA=FastMath.acos(hsat*(1+hsat/(2*earthRad))/slntRangePixel-slntRangePixel/(2*earthRad));
	
	return slantAndIA;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:30,代碼來源:GeoUtils.java

示例3: gcpIncidenceAngleForGRD

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/**
 *			 ( Parameters have the names used in radarsat2 metadata )
 *
 * @param complex
 * @param gndRange 
 * @param samplePixelSpacing
 * @param ngrd
 * @param nsam
 * @return
 */
public static double gcpIncidenceAngleForGRD(double slntRangeInNearRange,double sizeXPixel,double samplePixelSpacing,double xPix,double hsat,double earthRad,String timeOrdering){
	double srAndIA=0;
	//convert slant range into grnd range 
	double gndRangeAtNearRange=earthRad*FastMath.acos(1-(slntRangeInNearRange*slntRangeInNearRange-hsat*hsat)/(2*earthRad*(earthRad+hsat))  );
	double gndRangePixel=0;
	
	double gndRangeAtFarRange=gndRangeAtNearRange+sizeXPixel*samplePixelSpacing;
	
	if(timeOrdering.equalsIgnoreCase("Increasing")){		
		//calculate the gnd range for the gpc
		gndRangePixel=gndRangeAtNearRange+xPix*samplePixelSpacing;
	}else{
		gndRangePixel=gndRangeAtFarRange-xPix*samplePixelSpacing;
	}
	//slant range
	double finalSlantRange=FastMath.sqrt(hsat*hsat + (2*earthRad*(earthRad+hsat))*(1-FastMath.cos(gndRangePixel/earthRad)));

	//incidence angle
	srAndIA=FastMath.acos((hsat*(1+hsat/(2*earthRad))/finalSlantRange) - (finalSlantRange/(2*earthRad)));			
	
	//double conv=srAndIA*180/Math.PI;
	//System.out.println(conv);
	return srAndIA;
	
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:36,代碼來源:GeoUtils.java

示例4: getIncidence

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/**
 * Calculate the incidence angle
 */
public double getIncidence(int position) {
	double incidenceangle = 0.0;
	try{

     // estimation of incidence angle based on near and range distance values
     double nearincidence = FastMath.toRadians(getIncidenceNear().doubleValue());
     double sataltitude=getSatelliteAltitude();

     double distancerange = sataltitude * FastMath.tan(nearincidence) + position * this.getPixelsize()[0];
     incidenceangle = FastMath.atan(distancerange / sataltitude);
	}catch(Exception e){
		logger.warn("Error calculatiing incidence angle:"+e.getMessage());
	}
    return incidenceangle;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:19,代碼來源:SarImageReader.java

示例5: updateP

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
private double updateP (double duration, double[] p, double[] pDot, double[] pDotDot, double[] pDotDotDot){
	double max_dotdotdot = 0.0;
	for (int i = 0; i < (p.length-1); i++){
		if (FastMath.abs(pDotDotDot[i]) > max_dotdotdot)
			max_dotdotdot = FastMath.abs(pDotDotDot[i]);
	}
			
	double timeStep = FastMath.min(FastMath.pow((epsilon*6/max_dotdotdot), 1.0/3), FastMath.min(duration, max_step));

	double timeStepSquare = timeStep*timeStep*0.5;
	for (int i = 0; i < (p.length-1); i++){
		double new_val = p[i] + pDot[i]*timeStep + pDotDot[i]*timeStepSquare;
		double diff = FastMath.abs(new_val - p[i]);
		while (new_val > 1 || new_val < 0 || diff>0.2){
			timeStep *= 0.9;
			timeStepSquare = timeStep*timeStep*0.5;
			new_val = p[i] + pDot[i]*timeStep + pDotDot[i]*timeStepSquare;
			diff = FastMath.abs(new_val - p[i]);
		}			
	}
	doUpdating(timeStep, timeStepSquare, p, pDot, pDotDot);
	duration -= timeStep;
	return duration;
	
	
}
 
開發者ID:nicfel,項目名稱:Mascot,代碼行數:27,代碼來源:Euler2ndOrder.java

示例6: getBackwardsMigration

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
@Override    
  public double[][] getBackwardsMigration(int i){
int intervalNr;
  	if (i >= rateShiftsInput.get().getDimension())
  		intervalNr = rateShiftsInput.get().getDimension()-1;
  	else
  		intervalNr = i;

  	double[][] m = new double[dimensionInput.get()][dimensionInput.get()];
double[] mig = migrationGLMInput.get().getRates(intervalNr);
double[] Ne = NeGLMInput.get().getRates(intervalNr);

int c = 0;
for (int a = 0; a < dimensionInput.get(); a++){
	for (int b = 0; b < dimensionInput.get(); b++){
		if (a!=b){
			m[b][a] = FastMath.min( 
					Ne[a]*mig[c]/Ne[b],
					maxRateInput.get());
			c++;
		}
	}
}
return m;
  }
 
開發者ID:nicfel,項目名稱:Mascot,代碼行數:26,代碼來源:GLM.java

示例7: nthRoot

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
public ValueType nthRoot(CalculatedValue g, int n)
{
    try
    {
        final List<Complex> roots = g.getComplex().nthRoot(n);
        for (Complex root : roots)
        {
            if (FastMath.abs(root.getImaginary()) < 1E-15)
            {
                return setValue(root.getReal());
            }
        }
        if (!roots.isEmpty())
        {
            return setComplexValue(roots.get(0));
        }
    }
    catch (Exception ex)
    {
        // nothing to do
    }
    return invalidate(ErrorType.NOT_A_NUMBER);
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:24,代碼來源:CalculatedValue.java

示例8: integrate

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/**
 * Calculate defined integral
 */
public ValueType integrate(int significantDigits, CalculatedValue outValue) throws CancelException
{
    final double absoluteAccuracy = FastMath.pow(10, -1.0 * significantDigits);
    final IntermediateValue re = integrateSimpsons(CalculatedValue.PartType.RE, minValue.getReal(),
            maxValue.getReal(), absoluteAccuracy);
    if (Double.isNaN(re.value))
    {
        return outValue.invalidate(CalculatedValue.ErrorType.NOT_A_NUMBER);
    }
    if (re.complexDetected)
    {
        final IntermediateValue im = integrateSimpsons(CalculatedValue.PartType.IM, minValue.getReal(),
                maxValue.getReal(), absoluteAccuracy);
        return outValue.setComplexValue(re.value, im.value);
    }
    else
    {
        return outValue.setValue(re.value);
    }
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:24,代碼來源:FormulaTermLoop.java

示例9: calculateShape

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
public static double calculateShape(double percentile, List<Double> scores) {
	int pos = (int)(scores.size() * percentile);
	double loc = scores.get(pos);

	// calculate Pareto shape
	double shape = 0;
	for (int i = pos; i < scores.size() ; i++) {
		double d = scores.get(i) - loc + 1;
		shape += FastMath.log(d);
	}
	
	shape /= (scores.size() - pos);
	shape = 1/shape;
	
	return shape;
}
 
開發者ID:Auraya,項目名稱:armorvox-client,代碼行數:17,代碼來源:DistUtils.java

示例10: vector

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/** Build the normalized vector corresponding to spherical coordinates.
 * @param theta azimuthal angle \( \theta \) in the x-y plane
 * @param phi polar angle \( \varphi \)
 * @return normalized vector
 * @exception OutOfRangeException if \( \varphi \) is not in the [\( 0; \pi \)] range
 */
private static Vector3D vector(final double theta, final double phi)
   throws OutOfRangeException {

    if (phi < 0 || phi > FastMath.PI) {
        throw new OutOfRangeException(phi, 0, FastMath.PI);
    }

    final double cosTheta = FastMath.cos(theta);
    final double sinTheta = FastMath.sin(theta);
    final double cosPhi   = FastMath.cos(phi);
    final double sinPhi   = FastMath.sin(phi);

    return new Vector3D(cosTheta * sinPhi, sinTheta * sinPhi, cosPhi);

}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:22,代碼來源:S2Point.java

示例11: Rotation

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/** Build a rotation from the quaternion coordinates.
 * <p>A rotation can be built from a <em>normalized</em> quaternion,
 * i.e. a quaternion for which q<sub>0</sub><sup>2</sup> +
 * q<sub>1</sub><sup>2</sup> + q<sub>2</sub><sup>2</sup> +
 * q<sub>3</sub><sup>2</sup> = 1. If the quaternion is not normalized,
 * the constructor can normalize it in a preprocessing step.</p>
 * <p>Note that some conventions put the scalar part of the quaternion
 * as the 4<sup>th</sup> component and the vector part as the first three
 * components. This is <em>not</em> our convention. We put the scalar part
 * as the first component.</p>
 * @param q0 scalar part of the quaternion
 * @param q1 first coordinate of the vectorial part of the quaternion
 * @param q2 second coordinate of the vectorial part of the quaternion
 * @param q3 third coordinate of the vectorial part of the quaternion
 * @param needsNormalization if true, the coordinates are considered
 * not to be normalized, a normalization preprocessing step is performed
 * before using them
 */
public Rotation(double q0, double q1, double q2, double q3,
                boolean needsNormalization) {

  if (needsNormalization) {
    // normalization preprocessing
    double inv = 1.0 / FastMath.sqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3);
    q0 *= inv;
    q1 *= inv;
    q2 *= inv;
    q3 *= inv;
  }

  this.q0 = q0;
  this.q1 = q1;
  this.q2 = q2;
  this.q3 = q3;

}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:37,代碼來源:Rotation.java

示例12: converged

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/**
 * Check if the optimization algorithm has converged considering the
 * last two points.
 * This method may be called several times from the same algorithm
 * iteration with different points. This can be detected by checking the
 * iteration number at each call if needed. Each time this method is
 * called, the previous and current point correspond to points with the
 * same role at each iteration, so they can be compared. As an example,
 * simplex-based algorithms call this method for all points of the simplex,
 * not only for the best or worst ones.
 *
 * @param iteration Index of current iteration
 * @param previous Best point in the previous iteration.
 * @param current Best point in the current iteration.
 * @return {@code true} if the arguments satify the convergence criterion.
 */
@Override
public boolean converged(final int iteration,
                         final PointVectorValuePair previous,
                         final PointVectorValuePair current) {
    if (maxIterationCount != ITERATION_CHECK_DISABLED && iteration >= maxIterationCount) {
        return true;
    }

    final double[] p = previous.getValueRef();
    final double[] c = current.getValueRef();
    for (int i = 0; i < p.length; ++i) {
        final double pi         = p[i];
        final double ci         = c[i];
        final double difference = FastMath.abs(pi - ci);
        final double size       = FastMath.max(FastMath.abs(pi), FastMath.abs(ci));
        if (difference > size * getRelativeThreshold() &&
            difference > getAbsoluteThreshold()) {
            return false;
        }
    }
    return true;
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:39,代碼來源:SimpleVectorValueChecker.java

示例13: guessPhi

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/**
 * Estimate a first guess of the phase.
 *
 * @param observations Observations, sorted w.r.t. abscissa.
 * @return the guessed phase.
 */
private double guessPhi(WeightedObservedPoint[] observations) {
    // initialize the means
    double fcMean = 0;
    double fsMean = 0;

    double currentX = observations[0].getX();
    double currentY = observations[0].getY();
    for (int i = 1; i < observations.length; ++i) {
        // one step forward
        final double previousX = currentX;
        final double previousY = currentY;
        currentX = observations[i].getX();
        currentY = observations[i].getY();
        final double currentYPrime = (currentY - previousY) / (currentX - previousX);

        double omegaX = omega * currentX;
        double cosine = FastMath.cos(omegaX);
        double sine = FastMath.sin(omegaX);
        fcMean += omega * currentY * cosine - currentYPrime * sine;
        fsMean += omega * currentY * sine + currentYPrime * cosine;
    }

    return FastMath.atan2(-fsMean, fcMean);
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:31,代碼來源:HarmonicFitter.java

示例14: transform

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException if the length of the data array is
 * not a power of two plus one
 */
public double[] transform(final double[] f, final TransformType type)
  throws MathIllegalArgumentException {
    if (type == TransformType.FORWARD) {
        if (normalization == DctNormalization.ORTHOGONAL_DCT_I) {
            final double s = FastMath.sqrt(2.0 / (f.length - 1));
            return TransformUtils.scaleArray(fct(f), s);
        }
        return fct(f);
    }
    final double s2 = 2.0 / (f.length - 1);
    final double s1;
    if (normalization == DctNormalization.ORTHOGONAL_DCT_I) {
        s1 = FastMath.sqrt(s2);
    } else {
        s1 = s2;
    }
    return TransformUtils.scaleArray(fct(f), s1);
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:25,代碼來源:FastCosineTransformer.java

示例15: walkInRowOrder

import org.apache.commons.math3.util.FastMath; //導入依賴的package包/類
/** {@inheritDoc} */
@Override
public T walkInRowOrder(final FieldMatrixChangingVisitor<T> visitor) {
    visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
    for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
        final int pStart = iBlock * BLOCK_SIZE;
        final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
        for (int p = pStart; p < pEnd; ++p) {
            for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                final int jWidth = blockWidth(jBlock);
                final int qStart = jBlock * BLOCK_SIZE;
                final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                final T[] block = blocks[iBlock * blockColumns + jBlock];
                int k = (p - pStart) * jWidth;
                for (int q = qStart; q < qEnd; ++q) {
                    block[k] = visitor.visit(p, q, block[k]);
                    ++k;
                }
            }
         }
    }
    return visitor.end();
}
 
開發者ID:jiaminghan,項目名稱:droidplanner-master,代碼行數:24,代碼來源:BlockFieldMatrix.java


注:本文中的org.apache.commons.math3.util.FastMath類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。