当前位置: 首页>>代码示例>>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;未经允许,请勿转载。