    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.math.stat.descriptive;
    018
    019    import org.apache.commons.math.DimensionMismatchException;
    020    import org.apache.commons.math.linear.RealMatrix;
    021
    022    /**
    023     * Implementation of
    024     * {@link org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics} that
    025     * is safe to use in a multithreaded environment.  Multiple threads can safely
    026     * operate on a single instance without causing runtime exceptions due to race
    027     * conditions.  In effect, this implementation makes modification and access
    028     * methods atomic operations for a single instance.  That is to say, as one
    029     * thread is computing a statistic from the instance, no other thread can modify
    030     * the instance nor compute another statistic.
    031     * @since 1.2
    032     * @version $Revision: 811685 $ $Date: 2009-09-05 19:36:48 +0200 (sam. 05 sept. 2009) $
    033     */
    034    public class SynchronizedMultivariateSummaryStatistics
    035      extends MultivariateSummaryStatistics {
    036
    037        /** Serialization UID */
    038        private static final long serialVersionUID = 7099834153347155363L;
    039
    040        /**
    041         * Construct a SynchronizedMultivariateSummaryStatistics instance
    042         * @param k dimension of the data
    043         * @param isCovarianceBiasCorrected if true, the unbiased sample
    044         * covariance is computed, otherwise the biased population covariance
    045         * is computed
    046         */
    047        public SynchronizedMultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) {
    048            super(k, isCovarianceBiasCorrected);
    049        }
    050
    051        /**
    052         * {@inheritDoc}
    053         */
    054        @Override
    055        public synchronized void addValue(double[] value)
    056          throws DimensionMismatchException {
    057          super.addValue(value);
    058        }
    059
    060        /**
    061         * {@inheritDoc}
    062         */
    063        @Override
    064        public synchronized int getDimension() {
    065            return super.getDimension();
    066        }
    067
    068        /**
    069         * {@inheritDoc}
    070         */
    071        @Override
    072        public synchronized long getN() {
    073            return super.getN();
    074        }
    075
    076        /**
    077         * {@inheritDoc}
    078         */
    079        @Override
    080        public synchronized double[] getSum() {
    081            return super.getSum();
    082        }
    083
    084        /**
    085         * {@inheritDoc}
    086         */
    087        @Override
    088        public synchronized double[] getSumSq() {
    089            return super.getSumSq();
    090        }
    091
    092        /**
    093         * {@inheritDoc}
    094         */
    095        @Override
    096        public synchronized double[] getSumLog() {
    097            return super.getSumLog();
    098        }
    099
    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    }