001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.math3.filter;
018
019 import org.apache.commons.math3.exception.DimensionMismatchException;
020 import org.apache.commons.math3.exception.NoDataException;
021 import org.apache.commons.math3.exception.NullArgumentException;
022 import org.apache.commons.math3.linear.Array2DRowRealMatrix;
023 import org.apache.commons.math3.linear.RealMatrix;
024
025 /**
026 * Default implementation of a {@link MeasurementModel} for the use with a {@link KalmanFilter}.
027 *
028 * @since 3.0
029 * @version $Id: DefaultMeasurementModel.java 1416643 2012-12-03 19:37:14Z tn $
030 */
031 public class DefaultMeasurementModel implements MeasurementModel {
032
033 /**
034 * The measurement matrix, used to associate the measurement vector to the
035 * internal state estimation vector.
036 */
037 private RealMatrix measurementMatrix;
038
039 /**
040 * The measurement noise covariance matrix.
041 */
042 private RealMatrix measurementNoise;
043
044 /**
045 * Create a new {@link MeasurementModel}, taking double arrays as input parameters for the
046 * respective measurement matrix and noise.
047 *
048 * @param measMatrix
049 * the measurement matrix
050 * @param measNoise
051 * the measurement noise matrix
052 * @throws NullArgumentException
053 * if any of the input matrices is {@code null}
054 * @throws NoDataException
055 * if any row / column dimension of the input matrices is zero
056 * @throws DimensionMismatchException
057 * if any of the input matrices is non-rectangular
058 */
059 public DefaultMeasurementModel(final double[][] measMatrix, final double[][] measNoise)
060 throws NullArgumentException, NoDataException, DimensionMismatchException {
061 this(new Array2DRowRealMatrix(measMatrix), new Array2DRowRealMatrix(measNoise));
062 }
063
064 /**
065 * Create a new {@link MeasurementModel}, taking {@link RealMatrix} objects
066 * as input parameters for the respective measurement matrix and noise.
067 *
068 * @param measMatrix the measurement matrix
069 * @param measNoise the measurement noise matrix
070 */
071 public DefaultMeasurementModel(final RealMatrix measMatrix, final RealMatrix measNoise) {
072 this.measurementMatrix = measMatrix;
073 this.measurementNoise = measNoise;
074 }
075
076 /** {@inheritDoc} */
077 public RealMatrix getMeasurementMatrix() {
078 return measurementMatrix;
079 }
080
081 /** {@inheritDoc} */
082 public RealMatrix getMeasurementNoise() {
083 return measurementNoise;
084 }
085 }