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 */
17package org.apache.commons.math.stat.descriptive;
18
19import org.apache.commons.math.DimensionMismatchException;
20import org.apache.commons.math.linear.RealMatrix;
21
22/**
23 * Implementation of
24 * {@link org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics} that
25 * is safe to use in a multithreaded environment.  Multiple threads can safely
26 * operate on a single instance without causing runtime exceptions due to race
27 * conditions.  In effect, this implementation makes modification and access
28 * methods atomic operations for a single instance.  That is to say, as one
29 * thread is computing a statistic from the instance, no other thread can modify
30 * the instance nor compute another statistic.
31 * @since 1.2
32 * @version $Revision: 811685 $ $Date: 2009-09-05 19:36:48 +0200 (sam. 05 sept. 2009) $
33 */
34public class SynchronizedMultivariateSummaryStatistics
35  extends MultivariateSummaryStatistics {
36
37    /** Serialization UID */
38    private static final long serialVersionUID = 7099834153347155363L;
39
40    /**
41     * Construct a SynchronizedMultivariateSummaryStatistics instance
42     * @param k dimension of the data
43     * @param isCovarianceBiasCorrected if true, the unbiased sample
44     * covariance is computed, otherwise the biased population covariance
45     * is computed
46     */
47    public SynchronizedMultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) {
48        super(k, isCovarianceBiasCorrected);
49    }
50
51    /**
52     * {@inheritDoc}
53     */
54    @Override
55    public synchronized void addValue(double[] value)
56      throws DimensionMismatchException {
57      super.addValue(value);
58    }
59
60    /**
61     * {@inheritDoc}
62     */
63    @Override
64    public synchronized int getDimension() {
65        return super.getDimension();
66    }
67
68    /**
69     * {@inheritDoc}
70     */
71    @Override
72    public synchronized long getN() {
73        return super.getN();
74    }
75
76    /**
77     * {@inheritDoc}
78     */
79    @Override
80    public synchronized double[] getSum() {
81        return super.getSum();
82    }
83
84    /**
85     * {@inheritDoc}
86     */
87    @Override
88    public synchronized double[] getSumSq() {
89        return super.getSumSq();
90    }
91
92    /**
93     * {@inheritDoc}
94     */
95    @Override
96    public synchronized double[] getSumLog() {
97        return super.getSumLog();
98    }
99
100    /**
101     * {@inheritDoc}
102     */
103    @Override
104    public synchronized double[] getMean() {
105        return super.getMean();
106    }
107
108    /**
109     * {@inheritDoc}
110     */
111    @Override
112    public synchronized double[] getStandardDeviation() {
113        return super.getStandardDeviation();
114    }
115
116    /**
117     * {@inheritDoc}
118     */
119    @Override
120    public synchronized RealMatrix getCovariance() {
121        return super.getCovariance();
122    }
123
124    /**
125     * {@inheritDoc}
126     */
127    @Override
128    public synchronized double[] getMax() {
129        return super.getMax();
130    }
131
132    /**
133     * {@inheritDoc}
134     */
135    @Override
136    public synchronized double[] getMin() {
137        return super.getMin();
138    }
139
140    /**
141     * {@inheritDoc}
142     */
143    @Override
144    public synchronized double[] getGeometricMean() {
145        return super.getGeometricMean();
146    }
147
148    /**
149     * {@inheritDoc}
150     */
151    @Override
152    public synchronized String toString() {
153        return super.toString();
154    }
155
156    /**
157     * {@inheritDoc}
158     */
159    @Override
160    public synchronized void clear() {
161        super.clear();
162    }
163
164    /**
165     * {@inheritDoc}
166     */
167    @Override
168    public synchronized boolean equals(Object object) {
169        return super.equals(object);
170    }
171
172    /**
173     * {@inheritDoc}
174     */
175    @Override
176    public synchronized int hashCode() {
177        return super.hashCode();
178    }
179
180    /**
181     * {@inheritDoc}
182     */
183    @Override
184    public synchronized StorelessUnivariateStatistic[] getSumImpl() {
185        return super.getSumImpl();
186    }
187
188    /**
189     * {@inheritDoc}
190     */
191    @Override
192    public synchronized void setSumImpl(StorelessUnivariateStatistic[] sumImpl)
193      throws DimensionMismatchException {
194        super.setSumImpl(sumImpl);
195    }
196
197    /**
198     * {@inheritDoc}
199     */
200    @Override
201    public synchronized StorelessUnivariateStatistic[] getSumsqImpl() {
202        return super.getSumsqImpl();
203    }
204
205    /**
206     * {@inheritDoc}
207     */
208    @Override
209    public synchronized void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl)
210      throws DimensionMismatchException {
211        super.setSumsqImpl(sumsqImpl);
212    }
213
214    /**
215     * {@inheritDoc}
216     */
217    @Override
218    public synchronized StorelessUnivariateStatistic[] getMinImpl() {
219        return super.getMinImpl();
220    }
221
222    /**
223     * {@inheritDoc}
224     */
225    @Override
226    public synchronized void setMinImpl(StorelessUnivariateStatistic[] minImpl)
227      throws DimensionMismatchException {
228        super.setMinImpl(minImpl);
229    }
230
231    /**
232     * {@inheritDoc}
233     */
234    @Override
235    public synchronized StorelessUnivariateStatistic[] getMaxImpl() {
236        return super.getMaxImpl();
237    }
238
239    /**
240     * {@inheritDoc}
241     */
242    @Override
243    public synchronized void setMaxImpl(StorelessUnivariateStatistic[] maxImpl)
244      throws DimensionMismatchException {
245        super.setMaxImpl(maxImpl);
246    }
247
248    /**
249     * {@inheritDoc}
250     */
251    @Override
252    public synchronized StorelessUnivariateStatistic[] getSumLogImpl() {
253        return super.getSumLogImpl();
254    }
255
256    /**
257     * {@inheritDoc}
258     */
259    @Override
260    public synchronized void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl)
261      throws DimensionMismatchException {
262        super.setSumLogImpl(sumLogImpl);
263    }
264
265    /**
266     * {@inheritDoc}
267     */
268    @Override
269    public synchronized StorelessUnivariateStatistic[] getGeoMeanImpl() {
270        return super.getGeoMeanImpl();
271    }
272
273    /**
274     * {@inheritDoc}
275     */
276    @Override
277    public synchronized void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl)
278      throws DimensionMismatchException {
279        super.setGeoMeanImpl(geoMeanImpl);
280    }
281
282    /**
283     * {@inheritDoc}
284     */
285    @Override
286    public synchronized StorelessUnivariateStatistic[] getMeanImpl() {
287        return super.getMeanImpl();
288    }
289
290    /**
291     * {@inheritDoc}
292     */
293    @Override
294    public synchronized void setMeanImpl(StorelessUnivariateStatistic[] meanImpl)
295      throws DimensionMismatchException {
296        super.setMeanImpl(meanImpl);
297    }
298
299}
300