SynchronizedMultivariateSummaryStatistics.java

  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.math4.legacy.stat.descriptive;

  18. import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
  19. import org.apache.commons.math4.legacy.exception.MathIllegalStateException;
  20. import org.apache.commons.math4.legacy.linear.RealMatrix;

  21. /**
  22.  * Implementation of
  23.  * {@link org.apache.commons.math4.legacy.stat.descriptive.MultivariateSummaryStatistics} that
  24.  * is safe to use in a multithreaded environment.  Multiple threads can safely
  25.  * operate on a single instance without causing runtime exceptions due to race
  26.  * conditions.  In effect, this implementation makes modification and access
  27.  * methods atomic operations for a single instance.  That is to say, as one
  28.  * thread is computing a statistic from the instance, no other thread can modify
  29.  * the instance nor compute another statistic.
  30.  * @since 1.2
  31.  */
  32. public class SynchronizedMultivariateSummaryStatistics
  33.     extends MultivariateSummaryStatistics {
  34.     /**
  35.      * Construct a SynchronizedMultivariateSummaryStatistics instance.
  36.      * @param k dimension of the data
  37.      * @param isCovarianceBiasCorrected if true, the unbiased sample
  38.      * covariance is computed, otherwise the biased population covariance
  39.      * is computed
  40.      */
  41.     public SynchronizedMultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) {
  42.         super(k, isCovarianceBiasCorrected);
  43.     }

  44.     /**
  45.      * {@inheritDoc}
  46.      */
  47.     @Override
  48.     public synchronized void addValue(double[] value) throws DimensionMismatchException {
  49.       super.addValue(value);
  50.     }

  51.     /**
  52.      * {@inheritDoc}
  53.      */
  54.     @Override
  55.     public synchronized int getDimension() {
  56.         return super.getDimension();
  57.     }

  58.     /**
  59.      * {@inheritDoc}
  60.      */
  61.     @Override
  62.     public synchronized long getN() {
  63.         return super.getN();
  64.     }

  65.     /**
  66.      * {@inheritDoc}
  67.      */
  68.     @Override
  69.     public synchronized double[] getSum() {
  70.         return super.getSum();
  71.     }

  72.     /**
  73.      * {@inheritDoc}
  74.      */
  75.     @Override
  76.     public synchronized double[] getSumSq() {
  77.         return super.getSumSq();
  78.     }

  79.     /**
  80.      * {@inheritDoc}
  81.      */
  82.     @Override
  83.     public synchronized double[] getSumLog() {
  84.         return super.getSumLog();
  85.     }

  86.     /**
  87.      * {@inheritDoc}
  88.      */
  89.     @Override
  90.     public synchronized double[] getMean() {
  91.         return super.getMean();
  92.     }

  93.     /**
  94.      * {@inheritDoc}
  95.      */
  96.     @Override
  97.     public synchronized double[] getStandardDeviation() {
  98.         return super.getStandardDeviation();
  99.     }

  100.     /**
  101.      * {@inheritDoc}
  102.      */
  103.     @Override
  104.     public synchronized RealMatrix getCovariance() {
  105.         return super.getCovariance();
  106.     }

  107.     /**
  108.      * {@inheritDoc}
  109.      */
  110.     @Override
  111.     public synchronized double[] getMax() {
  112.         return super.getMax();
  113.     }

  114.     /**
  115.      * {@inheritDoc}
  116.      */
  117.     @Override
  118.     public synchronized double[] getMin() {
  119.         return super.getMin();
  120.     }

  121.     /**
  122.      * {@inheritDoc}
  123.      */
  124.     @Override
  125.     public synchronized double[] getGeometricMean() {
  126.         return super.getGeometricMean();
  127.     }

  128.     /**
  129.      * {@inheritDoc}
  130.      */
  131.     @Override
  132.     public synchronized String toString() {
  133.         return super.toString();
  134.     }

  135.     /**
  136.      * {@inheritDoc}
  137.      */
  138.     @Override
  139.     public synchronized void clear() {
  140.         super.clear();
  141.     }

  142.     /**
  143.      * {@inheritDoc}
  144.      */
  145.     @Override
  146.     public synchronized boolean equals(Object object) {
  147.         return super.equals(object);
  148.     }

  149.     /**
  150.      * {@inheritDoc}
  151.      */
  152.     @Override
  153.     public synchronized int hashCode() {
  154.         return super.hashCode();
  155.     }

  156.     /**
  157.      * {@inheritDoc}
  158.      */
  159.     @Override
  160.     public synchronized StorelessUnivariateStatistic[] getSumImpl() {
  161.         return super.getSumImpl();
  162.     }

  163.     /**
  164.      * {@inheritDoc}
  165.      */
  166.     @Override
  167.     public synchronized void setSumImpl(StorelessUnivariateStatistic[] sumImpl)
  168.     throws DimensionMismatchException, MathIllegalStateException {
  169.         super.setSumImpl(sumImpl);
  170.     }

  171.     /**
  172.      * {@inheritDoc}
  173.      */
  174.     @Override
  175.     public synchronized StorelessUnivariateStatistic[] getSumsqImpl() {
  176.         return super.getSumsqImpl();
  177.     }

  178.     /**
  179.      * {@inheritDoc}
  180.      */
  181.     @Override
  182.     public synchronized void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl)
  183.     throws DimensionMismatchException, MathIllegalStateException {
  184.         super.setSumsqImpl(sumsqImpl);
  185.     }

  186.     /**
  187.      * {@inheritDoc}
  188.      */
  189.     @Override
  190.     public synchronized StorelessUnivariateStatistic[] getMinImpl() {
  191.         return super.getMinImpl();
  192.     }

  193.     /**
  194.      * {@inheritDoc}
  195.      */
  196.     @Override
  197.     public synchronized void setMinImpl(StorelessUnivariateStatistic[] minImpl)
  198.     throws DimensionMismatchException, MathIllegalStateException {
  199.         super.setMinImpl(minImpl);
  200.     }

  201.     /**
  202.      * {@inheritDoc}
  203.      */
  204.     @Override
  205.     public synchronized StorelessUnivariateStatistic[] getMaxImpl() {
  206.         return super.getMaxImpl();
  207.     }

  208.     /**
  209.      * {@inheritDoc}
  210.      */
  211.     @Override
  212.     public synchronized void setMaxImpl(StorelessUnivariateStatistic[] maxImpl)
  213.     throws DimensionMismatchException, MathIllegalStateException{
  214.         super.setMaxImpl(maxImpl);
  215.     }

  216.     /**
  217.      * {@inheritDoc}
  218.      */
  219.     @Override
  220.     public synchronized StorelessUnivariateStatistic[] getSumLogImpl() {
  221.         return super.getSumLogImpl();
  222.     }

  223.     /**
  224.      * {@inheritDoc}
  225.      */
  226.     @Override
  227.     public synchronized void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl)
  228.     throws DimensionMismatchException, MathIllegalStateException {
  229.         super.setSumLogImpl(sumLogImpl);
  230.     }

  231.     /**
  232.      * {@inheritDoc}
  233.      */
  234.     @Override
  235.     public synchronized StorelessUnivariateStatistic[] getGeoMeanImpl() {
  236.         return super.getGeoMeanImpl();
  237.     }

  238.     /**
  239.      * {@inheritDoc}
  240.      */
  241.     @Override
  242.     public synchronized void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl)
  243.     throws DimensionMismatchException, MathIllegalStateException {
  244.         super.setGeoMeanImpl(geoMeanImpl);
  245.     }

  246.     /**
  247.      * {@inheritDoc}
  248.      */
  249.     @Override
  250.     public synchronized StorelessUnivariateStatistic[] getMeanImpl() {
  251.         return super.getMeanImpl();
  252.     }

  253.     /**
  254.      * {@inheritDoc}
  255.      */
  256.     @Override
  257.     public synchronized void setMeanImpl(StorelessUnivariateStatistic[] meanImpl)
  258.     throws DimensionMismatchException, MathIllegalStateException {
  259.         super.setMeanImpl(meanImpl);
  260.     }
  261. }