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


Java Math.log方法代碼示例

本文整理匯總了Java中java.lang.Math.log方法的典型用法代碼示例。如果您正苦於以下問題:Java Math.log方法的具體用法?Java Math.log怎麽用?Java Math.log使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.Math的用法示例。


在下文中一共展示了Math.log方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: k

import java.lang.Math; //導入方法依賴的package包/類
@Override
public double k(int[] x, int[] y) {
    double d = 0.0;

    int p1 = 0, p2 = 0;
    while (p1 < x.length && p2 < y.length) {
        int i1 = x[p1];
        int i2 = y[p2];
        if (i1 == i2) {
            p1++;
            p2++;
        } else if (i1 > i2) {
            d++;
            p2++;
        } else {
            d++;
            p1++;
        }
    }

    d += x.length - p1;
    d += y.length - p2;

    return d/(sigma*sigma) * Math.log(Math.sqrt(d)/sigma);
}
 
開發者ID:takun2s,項目名稱:smile_1.5.0_java7,代碼行數:26,代碼來源:BinarySparseThinPlateSplineKernel.java

示例2: k

import java.lang.Math; //導入方法依賴的package包/類
@Override
public double k(double[] x, double[] y) {
    if (x.length != y.length)
        throw new IllegalArgumentException(String.format("Arrays have different length: x[%d], y[%d]", x.length, y.length));
    
    double d = 0.0;

    for (int i = 0; i < x.length; i++) {
        double dxy = x[i] - y[i];
        d += dxy * dxy;
    }
        
    return d/(sigma*sigma) * Math.log(Math.sqrt(d)/sigma);
}
 
開發者ID:takun2s,項目名稱:smile_1.5.0_java7,代碼行數:15,代碼來源:ThinPlateSplineKernel.java

示例3: asinh

import java.lang.Math; //導入方法依賴的package包/類
/**
 * Asinh double.
 *
 * @param xx the xx
 * @return the hyperbolic arc sine of the argument
 * @throws ArithmeticException the arithmetic exception
 */
static public double asinh(double xx) throws ArithmeticException {
    double x;
    int sign;
    if(xx == 0.0) return xx;
    if( xx < 0.0 ) {
        sign = -1;
        x = -xx;
    } else {
        sign = 1;
        x = xx;
    }
    return sign*Math.log( x + Math.sqrt(x*x+1));
}
 
開發者ID:RudyB,項目名稱:Optics-Simulator,代碼行數:21,代碼來源:SpecialFunction.java

示例4: igam

import java.lang.Math; //導入方法依賴的package包/類
/**
 * Igam double.
 *
 * @param a double value
 * @param x double value
 * @return the Incomplete Gamma function.  Converted to Java from<BR> Cephes Math Library Release
 * 2.2:  July, 1992<BR> Copyright 1984, 1987, 1989, 1992 by Stephen L. Moshier<BR> Direct inquiries to 30 Frost
 * Street, Cambridge, MA 02140<BR>
 * @throws ArithmeticException the arithmetic exception
 */
static public double igam(double a, double x)
        throws ArithmeticException {


    double ans, ax, c, r;

    if( x <= 0 || a <= 0 ) return 0.0;

    if( x > 1.0 && x > a ) return 1.0 - igamc(a,x);

   /* Compute  x**a * exp(-x) / gamma(a)  */
    ax = a * Math.log(x) - x - lgamma(a);
    if( ax < -MAXLOG ) return( 0.0 );

    ax = Math.exp(ax);

    /* power series */
    r = a;
    c = 1.0;
    ans = 1.0;

    do {
        r += 1.0;
        c *= x/r;
        ans += c;
    }
    while( c/ans > MACHEP );

    return( ans * ax/a );

}
 
開發者ID:RudyB,項目名稱:Optics-Simulator,代碼行數:42,代碼來源:SpecialFunction.java

示例5: pseries

import java.lang.Math; //導入方法依賴的package包/類
/**
 * Pseries double.
 *
 * @param a the a
 * @param b the b
 * @param x the x
 * @return the double
 * @throws ArithmeticException the arithmetic exception
 */
static private  double pseries( double a, double b, double x )
        throws ArithmeticException {
    double s, t, u, v, n, t1, z, ai;

    ai = 1.0 / a;
    u = (1.0 - b) * x;
    v = u / (a + 1.0);
    t1 = v;
    t = u;
    n = 2.0;
    s = 0.0;
    z = MACHEP * ai;
    while( Math.abs(v) > z ) {
        u = (n - b) * x / n;
        t *= u;
        v = t / (a + n);
        s += v;
        n += 1.0;
    }
    s += t1;
    s += ai;

    u = a * Math.log(x);
    if( (a+b) < MAXGAM && Math.abs(u) < MAXLOG ) {
        t = gamma(a+b)/(gamma(a)*gamma(b));
        s = s * t * Math.pow(x,a);
    } else {
        t = lgamma(a+b) - lgamma(a) - lgamma(b) + u + Math.log(s);
        if( t < MINLOG ) 	s = 0.0;
        else  	            s = Math.exp(t);
    }
    return s;
}
 
開發者ID:RudyB,項目名稱:Optics-Simulator,代碼行數:43,代碼來源:SpecialFunction.java

示例6: igamc

import java.lang.Math; //導入方法依賴的package包/類
/**
 * Igamc double.
 *
 * @param a double value
 * @param x double value
 * @return the Complemented Incomplete Gamma function.Converted to Java from<BR> Cephes Math
 * Library Release 2.2:  July, 1992<BR> Copyright 1984, 1987, 1989, 1992 by Stephen L. Moshier<BR> Direct inquiries
 * to 30 Frost Street, Cambridge, MA 02140<BR>
 * @throws ArithmeticException the arithmetic exception
 */
static public double igamc( double a, double x )
        throws ArithmeticException {
    double big    = 4.503599627370496e15;
    double biginv =  2.22044604925031308085e-16;
    double ans, ax, c, yc, r, t, y, z;
    double pk, pkm1, pkm2, qk, qkm1, qkm2;

    if( x <= 0 || a <= 0 ) return 1.0;

    if( x < 1.0 || x < a ) return 1.0 - igam(a,x);

    ax = a * Math.log(x) - x - lgamma(a);
    if( ax < -MAXLOG ) return 0.0;

    ax = Math.exp(ax);

    /* continued fraction */
    y = 1.0 - a;
    z = x + y + 1.0;
    c = 0.0;
    pkm2 = 1.0;
    qkm2 = x;
    pkm1 = x + 1.0;
    qkm1 = z * x;
    ans = pkm1/qkm1;

    do {
        c += 1.0;
        y += 1.0;
        z += 2.0;
        yc = y * c;
        pk = pkm1 * z  -  pkm2 * yc;
        qk = qkm1 * z  -  qkm2 * yc;
        if( qk != 0 ) {
            r = pk/qk;
            t = Math.abs( (ans - r)/r );
            ans = r;
        } else
            t = 1.0;

        pkm2 = pkm1;
        pkm1 = pk;
        qkm2 = qkm1;
        qkm1 = qk;
        if( Math.abs(pk) > big ) {
            pkm2 *= biginv;
            pkm1 *= biginv;
            qkm2 *= biginv;
            qkm1 *= biginv;
        }
    } while( t > MACHEP );

    return ans * ax;
}
 
開發者ID:RudyB,項目名稱:Optics-Simulator,代碼行數:65,代碼來源:SpecialFunction.java

示例7: getRatioFromValue

import java.lang.Math; //導入方法依賴的package包/類
protected float getRatioFromValue(float value) {
    float ratio = (scale == Scale.LOG)
                ? (float) (Math.log(value/min) / Math.log(max/min))
                : (value - min) / (max - min);
    return Float.isNaN(ratio) ? 0f : ratio;
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:7,代碼來源:Slider.java

示例8: latToY

import java.lang.Math; //導入方法依賴的package包/類
public static double latToY(double aLat) {
	return Math.log(Math.tan(PI_DIV_4 + Math.toRadians(aLat) / 2)) * RADIUS;
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:4,代碼來源:SphericalMercator.java

示例9: log10

import java.lang.Math; //導入方法依賴的package包/類
/**
 * Log 10 double.
 *
 * @param x a double value
 * @return The log<sub>10</sub>
 * @throws ArithmeticException the arithmetic exception
 */
static public double log10(double x) throws ArithmeticException {
    if( x <= 0.0 ) throw new ArithmeticException("range exception");
    return Math.log(x)/2.30258509299404568401;
}
 
開發者ID:RudyB,項目名稱:Optics-Simulator,代碼行數:12,代碼來源:SpecialFunction.java

示例10: acosh

import java.lang.Math; //導入方法依賴的package包/類
/**
 * Acosh double.
 *
 * @param x a double value
 * @return the hyperbolic arc cosine of the argument
 * @throws ArithmeticException the arithmetic exception
 */
static public double acosh(double x) throws ArithmeticException {
    if( x < 1.0 ) throw new ArithmeticException("range exception");
    return Math.log( x + Math.sqrt(x*x-1));
}
 
開發者ID:RudyB,項目名稱:Optics-Simulator,代碼行數:12,代碼來源:SpecialFunction.java

示例11: atanh

import java.lang.Math; //導入方法依賴的package包/類
/**
 * Atanh double.
 *
 * @param x a double value
 * @return the hyperbolic arc tangent of the argument
 * @throws ArithmeticException the arithmetic exception
 */
static public double atanh(double x) throws ArithmeticException {
    if( x > 1.0 || x < -1.0 ) throw
            new ArithmeticException("range exception");
    return 0.5 * Math.log( (1.0+x)/(1.0-x) );
}
 
開發者ID:RudyB,項目名稱:Optics-Simulator,代碼行數:13,代碼來源:SpecialFunction.java


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