1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.math3.filter;
18
19 import org.apache.commons.math3.exception.DimensionMismatchException;
20 import org.apache.commons.math3.exception.NoDataException;
21 import org.apache.commons.math3.exception.NullArgumentException;
22 import org.apache.commons.math3.linear.Array2DRowRealMatrix;
23 import org.apache.commons.math3.linear.RealMatrix;
24
25 /**
26 * Default implementation of a {@link MeasurementModel} for the use with a {@link KalmanFilter}.
27 *
28 * @since 3.0
29 * @version $Id: DefaultMeasurementModel.java 1416643 2012-12-03 19:37:14Z tn $
30 */
31 public class DefaultMeasurementModel implements MeasurementModel {
32
33 /**
34 * The measurement matrix, used to associate the measurement vector to the
35 * internal state estimation vector.
36 */
37 private RealMatrix measurementMatrix;
38
39 /**
40 * The measurement noise covariance matrix.
41 */
42 private RealMatrix measurementNoise;
43
44 /**
45 * Create a new {@link MeasurementModel}, taking double arrays as input parameters for the
46 * respective measurement matrix and noise.
47 *
48 * @param measMatrix
49 * the measurement matrix
50 * @param measNoise
51 * the measurement noise matrix
52 * @throws NullArgumentException
53 * if any of the input matrices is {@code null}
54 * @throws NoDataException
55 * if any row / column dimension of the input matrices is zero
56 * @throws DimensionMismatchException
57 * if any of the input matrices is non-rectangular
58 */
59 public DefaultMeasurementModel(final double[][] measMatrix, final double[][] measNoise)
60 throws NullArgumentException, NoDataException, DimensionMismatchException {
61 this(new Array2DRowRealMatrix(measMatrix), new Array2DRowRealMatrix(measNoise));
62 }
63
64 /**
65 * Create a new {@link MeasurementModel}, taking {@link RealMatrix} objects
66 * as input parameters for the respective measurement matrix and noise.
67 *
68 * @param measMatrix the measurement matrix
69 * @param measNoise the measurement noise matrix
70 */
71 public DefaultMeasurementModel(final RealMatrix measMatrix, final RealMatrix measNoise) {
72 this.measurementMatrix = measMatrix;
73 this.measurementNoise = measNoise;
74 }
75
76 /** {@inheritDoc} */
77 public RealMatrix getMeasurementMatrix() {
78 return measurementMatrix;
79 }
80
81 /** {@inheritDoc} */
82 public RealMatrix getMeasurementNoise() {
83 return measurementNoise;
84 }
85 }