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


Java RealVector.getDimension方法代碼示例

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


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

示例1: sim

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
@Override
public double sim(RealVector r1, RealVector r2, boolean sparse) {
    if (r1.getDimension() != r2.getDimension()) {
        return 0;
    }

    double min = 0.0;
    double sum = 0.0;

    for (int i = 0; i < r1.getDimension(); ++i) {
        if (r1.getEntry(i) > r2.getEntry(i)) {
            min += r2.getEntry(i);
        } else {
            min += r1.getEntry(i);
        }
        sum += r1.getEntry(i) + r2.getEntry(i);
    }

    if (sum == 0) {
        return 0;
    }

    double result = 2 * min / sum;
    return Math.abs(result);
}
 
開發者ID:Lambda-3,項目名稱:Indra,代碼行數:26,代碼來源:DiceRelatednessFunction.java

示例2: sim

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
@Override
public double sim(RealVector r1, RealVector r2, boolean sparse) {
    if (r1.getDimension() != r2.getDimension()) {
        return 0;
    }

    double max = 0;
    double tmp;

    for (int i = 0; i < r1.getDimension(); ++i) {
        tmp = Math.abs((r1.getEntry(i) - r2.getEntry(i)));
        max = (tmp > max ? tmp : max);
    }

    double result = 1 / (1 + (max == Double.NaN ? 0 : max));
    return Math.abs(result);
}
 
開發者ID:Lambda-3,項目名稱:Indra,代碼行數:18,代碼來源:ChebyshevRelatednessFunction.java

示例3: sim

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
@Override
public double sim(RealVector r1, RealVector r2, boolean sparse) {
    if (r1.getDimension() != r2.getDimension()) {
        return 0;
    }

    double alpha = 0.99;
    double divergence = 0.0;

    for (int i = 0; i < r1.getDimension(); ++i) {
        if (r1.getEntry(i) > 0.0 && r2.getEntry(i) > 0.0) {
            divergence += r1.getEntry(i) * Math.log(r1.getEntry(i) / ((1 - alpha) * r1.getEntry(i) + alpha * r2.getEntry(i)));
        }
    }

    double result = (1 - (divergence / Math.sqrt(2 * Math.log(2))));
    return Math.abs(result);
}
 
開發者ID:Lambda-3,項目名稱:Indra,代碼行數:19,代碼來源:AlphaSkewRelatednessFunction.java

示例4: sim

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
@Override
public double sim(RealVector r1, RealVector r2, boolean sparse) {
    if (r1.getDimension() != r2.getDimension()) {
        return 0;
    }

    double min = 0.0;
    double max = 0.0;

    for (int i = 0; i <r1.getDimension(); ++i) {
        if (r1.getEntry(i) > r2.getEntry(i)) {
            min +=r2.getEntry(i);
            max += r1.getEntry(i);
        } else {
            min += r1.getEntry(i);
            max += r2.getEntry(i);
        }
    }

    if (max == 0) {
        return 0;
    }

    return Math.abs(min / max);
}
 
開發者ID:Lambda-3,項目名稱:Indra,代碼行數:26,代碼來源:Jaccard2RelatednessFunction.java

示例5: predict

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
/**
 * Predict the internal state estimation one time step ahead.
 *
 * @param u
 *            the control vector
 * @throws DimensionMismatchException
 *             if the dimension of the control vector does not match
 */
public void predict(final RealVector u) throws DimensionMismatchException
{
	// sanity checks
	if (u != null && u.getDimension() != controlMatrix.getColumnDimension())
	{
		throw new DimensionMismatchException(u.getDimension(),
				controlMatrix.getColumnDimension());
	}

	// project the state estimation ahead (a priori state)
	// xHat(k)- = A * xHat(k-1) + B * u(k-1)
	// stateEstimation = transitionMatrix.operate(stateEstimation);

	// add control input if it is available
	// if (u != null)
	// {
	// stateEstimation = stateEstimation.add(controlMatrix.operate(u));
	// }

	// We don't need to use the transition matrix or control matrix, since
	// we have already done all the work... we can just set the state
	// estimation to u.
	if (u != null)
	{
		stateEstimation = u;
	}

	// project the error covariance ahead
	// P(k)- = A * P(k-1) * A' + Q
	errorCovariance = transitionMatrix.multiply(errorCovariance)
			.multiply(transitionMatrixT)
			.add(processModel.getProcessNoise());
}
 
開發者ID:KalebKE,項目名稱:FSensor,代碼行數:42,代碼來源:RotationKalmanFilter.java

示例6: testSqrtVector

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
@Test
public void testSqrtVector() {
    final RealVector result = MatrixFunctions.sqrt(vector);
    for (int i = 0; i < result.getDimension(); i++) {
        assertEquals(Math.sqrt(vector.getEntry(i)), result.getEntry(i), 0);
    }
}
 
開發者ID:knime,項目名稱:knime-activelearning,代碼行數:8,代碼來源:MatrixFunctionsTest.java

示例7: sqrt

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
public static RealVector sqrt(final RealVector vector) {
    final RealVector result = vector.copy();
    for (int e = 0; e < result.getDimension(); e++) {
        result.setEntry(e, Math.sqrt(result.getEntry(e)));
    }
    return result;
}
 
開發者ID:knime,項目名稱:knime-activelearning,代碼行數:8,代碼來源:MatrixFunctions.java

示例8: sim

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
@Override
public double sim(RealVector r1, RealVector r2, boolean sparse) {
    if (r1.getDimension() != r2.getDimension()) {
        return 0;
    }

    double divergence = 0.0;
    double avr = 0.0;

    for (int i = 0; i < r1.getDimension(); ++i) {
        avr = (r1.getEntry(i) + r2.getEntry(i)) / 2;

        if (r1.getEntry(i) > 0.0 && avr > 0.0) {
            divergence += r1.getEntry(i) * Math.log(r1.getEntry(i) / avr);
        }
    }
    for (int i = 0; i < r2.getDimension(); ++i) {
        avr = (r1.getEntry(i) + r2.getEntry(i)) / 2;

        if (r2.getEntry(i) > 0.0 && avr > 0.0) {
            divergence += r1.getEntry(i) * Math.log(r2.getEntry(i) / avr);
        }
    }

    double result = 1 - (divergence / (2 * Math.sqrt(2 * Math.log(2))));
    return Math.abs(result);
}
 
開發者ID:Lambda-3,項目名稱:Indra,代碼行數:28,代碼來源:JensenShannonRelatednessFunction.java

示例9: sim

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
@Override
public double sim(RealVector r1, RealVector r2, boolean sparse) {
    if (r1.getDimension() != r2.getDimension()) {
        return 0;
    }

    double sum = 0.0;

    for (int i = 0; i < r1.getDimension(); ++i) {
        sum += Math.abs((r1.getEntry(i) - r2.getEntry(i)));
    }

    double result = 1 / (1 + (sum == Double.NaN ? 0 : sum));
    return Math.abs(result);
}
 
開發者ID:Lambda-3,項目名稱:Indra,代碼行數:16,代碼來源:CityBlockRelatednessFunction.java

示例10: CalMixDens

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
CalMixDens(BetaDistribution tumorDist, BetaDistribution normalDist, RealVector thetas, RealVector betas,
		   int nPoints, int featureIdx, RealMatrix[] mixDens) {
	this.tumorDist = tumorDist;
	this.normalDist = normalDist;
	this.thetas = thetas;
	this.nThetas = thetas.getDimension();
	this.betas = betas;
	this.nBetas = betas.getDimension();
	this.nPoints = nPoints;
	this.featureIdx = featureIdx;
	this.mixDens = mixDens;
}
 
開發者ID:jasminezhoulab,項目名稱:CancerLocator,代碼行數:13,代碼來源:MixModel.java

示例11: solveFToF

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
public float[] solveFToF(float[] b) {
  RealVector bVec = new ArrayRealVector(b.length);
  for (int i = 0; i < b.length; i++) {
    bVec.setEntry(i, b[i]);
  }
  RealVector resultVec = solver.solve(bVec);
  float[] result = new float[resultVec.getDimension()];
  for (int i = 0; i < result.length; i++) {
    result[i] = (float) resultVec.getEntry(i);
  }
  return result;
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:13,代碼來源:Solver.java

示例12: correct

import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
/**
 * Correct the current state estimate with an actual measurement.
 *
 * @param z
 *            the measurement vector
 * @throws NullArgumentException
 *             if the measurement vector is {@code null}
 * @throws DimensionMismatchException
 *             if the dimension of the measurement vector does not fit
 * @throws SingularMatrixException
 *             if the covariance matrix could not be inverted
 */
public void correct(final RealVector z) throws NullArgumentException,
           DimensionMismatchException, SingularMatrixException
{

	// sanity checks
	MathUtils.checkNotNull(z);
	if (z.getDimension() != measurementMatrix.getRowDimension())
	{
		throw new DimensionMismatchException(z.getDimension(),
				measurementMatrix.getRowDimension());
	}

	// S = H * P(k) * H' + R
	RealMatrix s = measurementMatrix.multiply(errorCovariance)
			.multiply(measurementMatrixT)
			.add(measurementModel.getMeasurementNoise());

	// Inn = z(k) - H * xHat(k)-
	RealVector innovation = z.subtract(measurementMatrix
			.operate(stateEstimation));

	// calculate gain matrix
	// K(k) = P(k)- * H' * (H * P(k)- * H' + R)^-1
	// K(k) = P(k)- * H' * S^-1

	// instead of calculating the inverse of S we can rearrange the formula,
	// and then solve the linear equation A x X = B with A = S', X = K' and
	// B = (H * P)'

	// K(k) * S = P(k)- * H'
	// S' * K(k)' = H * P(k)-'
	RealMatrix kalmanGain = new CholeskyDecomposition(s).getSolver()
			.solve(measurementMatrix.multiply(errorCovariance.transpose()))
			.transpose();

	// update estimate with measurement z(k)
	// xHat(k) = xHat(k)- + K * Inn
	stateEstimation = stateEstimation.add(kalmanGain.operate(innovation));

	// update covariance of prediction error
	// P(k) = (I - K * H) * P(k)-
	RealMatrix identity = MatrixUtils.createRealIdentityMatrix(kalmanGain
			.getRowDimension());
	errorCovariance = identity.subtract(
			kalmanGain.multiply(measurementMatrix)).multiply(
			errorCovariance);
}
 
開發者ID:KalebKE,項目名稱:FSensor,代碼行數:60,代碼來源:RotationKalmanFilter.java


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