@Test(expected=MatrixDimensionMismatchException.class) public void testTransitionMeasurementMatrixMismatch() { // A and H matrix do not match in dimensions // A = [ 1 ] RealMatrix A = new Array2DRowRealMatrix(new double[] { 1d }); // no control input RealMatrix B = null; // H = [ 1 1 ] RealMatrix H = new Array2DRowRealMatrix(new double[] { 1d, 1d }); // Q = [ 0 ] RealMatrix Q = new Array2DRowRealMatrix(new double[] { 0 }); // R = [ 0 ] RealMatrix R = new Array2DRowRealMatrix(new double[] { 0 }); ProcessModel pm = new DefaultProcessModel(A, B, Q, new ArrayRealVector(new double[] { 0 }), null); MeasurementModel mm = new DefaultMeasurementModel(H, R); new KalmanFilter(pm, mm); Assert.fail("transition and measurement matrix should not be compatible"); }
@Test(expected=MatrixDimensionMismatchException.class) public void testTransitionControlMatrixMismatch() { // A and B matrix do not match in dimensions // A = [ 1 ] RealMatrix A = new Array2DRowRealMatrix(new double[] { 1d }); // B = [ 1 1 ] RealMatrix B = new Array2DRowRealMatrix(new double[] { 1d, 1d }); // H = [ 1 ] RealMatrix H = new Array2DRowRealMatrix(new double[] { 1d }); // Q = [ 0 ] RealMatrix Q = new Array2DRowRealMatrix(new double[] { 0 }); // R = [ 0 ] RealMatrix R = new Array2DRowRealMatrix(new double[] { 0 }); ProcessModel pm = new DefaultProcessModel(A, B, Q, new ArrayRealVector(new double[] { 0 }), null); MeasurementModel mm = new DefaultMeasurementModel(H, R); new KalmanFilter(pm, mm); Assert.fail("transition and control matrix should not be compatible"); }
public void copySubMatrix( int arg0, int arg1, int arg2, int arg3, double[][] arg4 ) throws OutOfRangeException, NumberIsTooSmallException, MatrixDimensionMismatchException { matrix.copySubMatrix( arg0, arg1, arg2, arg3, arg4 ); }
@Override protected void setProperties(Properties data) throws IllegalArgumentException { // currently constant - write/read for future extension Utils.getDouble(data, KEY_MEASUREMENT_NOISE, DEFAULT_MEASUREMENT_NOISE); // ignore value RealMatrix mA = getMatrix(data, KEY_MATRIX_A, DEFAULT_A); RealMatrix mB = getMatrix(data, KEY_MATRIX_B, DEFAULT_B); RealMatrix mH = getMatrix(data, KEY_MATRIX_H, DEFAULT_H); RealMatrix mQ = getMatrix(data, KEY_MATRIX_Q, DEFAULT_Q); RealMatrix mR = getMatrix(data, KEY_MATRIX_R, DEFAULT_R); // variable RealMatrix mP = getMatrix(data, KEY_MATRIX_P, DEFAULT_P); RealVector xVector = getVector(data, KEY_VECTOR_X, DEFAULT_X_VECTOR); controlVector = getVector(data, KEY_VECTOR_CONTROL, controlVector); lastUpdated = Utils.getLong(data, KEY_LAST_UPDATED, lastUpdated); lastUpdate = Utils.getDouble(data, KEY_LAST_UPDATE, lastUpdate); allowedGap = Utils.getInt(data, KEY_ALLOWED_GAP, allowedGap); defaultMeasurement = Utils.getDouble(data, KEY_DEFAULT_MEASUREMENT, defaultMeasurement); try { ProcessModel pm = new DefaultProcessModel(mA, mB, mQ, xVector, mP); // xVector, mP MeasurementModel mm = new DefaultMeasurementModel(mH, mR); filter = new KalmanFilter(pm, mm); } catch (NullArgumentException | DimensionMismatchException | MatrixDimensionMismatchException e) { throw new IllegalArgumentException(e.getMessage()); } }
public void copySubMatrix( int[] arg0, int[] arg1, double[][] arg2 ) throws OutOfRangeException, NullArgumentException, NoDataException, MatrixDimensionMismatchException { matrix.copySubMatrix( arg0, arg1, arg2 ); }
public void setColumn( int arg0, double[] arg1 ) throws OutOfRangeException, MatrixDimensionMismatchException { matrix.setColumn( arg0, arg1 ); }
public void setColumnMatrix( int arg0, RealMatrix arg1 ) throws OutOfRangeException, MatrixDimensionMismatchException { matrix.setColumnMatrix( arg0, arg1 ); }
public void setColumnVector( int arg0, RealVector arg1 ) throws OutOfRangeException, MatrixDimensionMismatchException { matrix.setColumnVector( arg0, arg1 ); }
public void setRow( int arg0, double[] arg1 ) throws OutOfRangeException, MatrixDimensionMismatchException { matrix.setRow( arg0, arg1); }
public void setRowMatrix( int arg0, RealMatrix arg1 ) throws OutOfRangeException, MatrixDimensionMismatchException { matrix.setRowMatrix( arg0, arg1 ); }
public void setRowVector( int arg0, RealVector arg1 ) throws OutOfRangeException, MatrixDimensionMismatchException { matrix.setRowVector( arg0, arg1 ); }
public StateSpaceModel(DoubleMatrix state_transition_matrix, DoubleMatrix observation_matrix, DoubleMatrix transition_covariance_matrix, DoubleMatrix observation_covariance_matrix, DoubleMatrix initial_state_mean, DoubleMatrix initial_state_covariance, DoubleMatrix[] observations) { dimension_of_states_ = observation_matrix.getColumns(); dimension_of_observations_ = observation_matrix.getRows(); observation_matrix_ref_ = observation_matrix; if (!state_transition_matrix.isSquare() || state_transition_matrix.getRows() != dimension_of_states_) { throw new MatrixDimensionMismatchException(state_transition_matrix.getRows(), state_transition_matrix.getColumns(), dimension_of_states_, dimension_of_states_); } state_transition_matrix_ref_ = state_transition_matrix; if (!transition_covariance_matrix.isSquare() || transition_covariance_matrix.getRows() != dimension_of_states_) { throw new MatrixDimensionMismatchException(transition_covariance_matrix.getRows(), transition_covariance_matrix.getColumns(), dimension_of_states_, dimension_of_states_); } transition_covariance_matrix_ref_ = transition_covariance_matrix; if (!observation_covariance_matrix.isSquare() || observation_covariance_matrix.getRows() != dimension_of_observations_) { throw new MatrixDimensionMismatchException(observation_covariance_matrix.getRows(), observation_covariance_matrix.getColumns(), dimension_of_observations_, dimension_of_observations_); } observation_covariance_matrix_ref_ = observation_covariance_matrix; if (initial_state_mean.getRows() != dimension_of_states_ || initial_state_mean.getColumns() != 1) { throw new MatrixDimensionMismatchException(initial_state_mean.getRows(), initial_state_mean.getColumns(), dimension_of_states_, 1); } initial_state_mean_ref_ = initial_state_mean; if (!initial_state_covariance.isSquare() || initial_state_covariance.getRows() != dimension_of_states_) { throw new MatrixDimensionMismatchException(initial_state_covariance.getRows(), initial_state_covariance.getColumns(), dimension_of_states_, dimension_of_states_); } initial_state_covariance_ref_ = initial_state_covariance; number_of_observations_ = observations.length; observations_ref_ = observations; estimated_state_means_ = new DoubleMatrix[number_of_observations_]; estimated_state_covariances_ = new DoubleMatrix[number_of_observations_]; predicted_observation_means_ = new DoubleMatrix[number_of_observations_]; predicted_observation_covariances_ = new DoubleMatrix[number_of_observations_]; estimated_means_ = new DoubleMatrix[number_of_observations_]; estimated_covariances_ = new DoubleMatrix[number_of_observations_]; updateFilteredStates(); calculateLogLikelihood(); }
public RealMatrix add( RealMatrix arg0) throws MatrixDimensionMismatchException { return matrix.add(arg0); }
public RealMatrix subtract(RealMatrix arg0) throws MatrixDimensionMismatchException { return matrix.subtract(arg0); }