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