Ejemplo n.º 1
0
        private static StatResult RunStatFunction(
            StatFunction statFunction,
            Type[] dataTypes,
            object[] valuesX,
            object[] valuesY)
        {
            statFunction.InitializeAccumulationTypes(dataTypes);
            statFunction.StartCalculation();
            statFunction.Reset();

            try
            {
                if (statFunction.PrerequisiteFunctions != null && statFunction.PrerequisiteFunctions.Length > 0)
                {
                    StatResult[] preValues = new StatResult[statFunction.PrerequisiteFunctions.Length];

                    for (int i = 0; i < statFunction.PrerequisiteFunctions.Length; i++)
                    {
                        preValues[i] = StatFunction.RunStatFunction(statFunction.PrerequisiteFunctions[i], dataTypes, valuesX, valuesY);

                        if (preValues[i].Value is Exception)
                        {
                            throw ( Exception )preValues[i].Value;
                        }
                    }

                    statFunction.InitializePrerequisites(preValues);
                }

                if (statFunction.RequiresAccumulation)
                {
                    for (int i = 0; i < valuesX.Length; i++)
                    {
                        if (valuesY == null)
                        {
                            statFunction.Accumulate(new object[] { valuesX[i] });
                        }
                        else
                        {
                            statFunction.Accumulate(new object[] { valuesX[i], valuesY[i] });
                        }
                    }
                }

                statFunction.EndCalculation();
                return(statFunction.GetResult());
            }
            catch (Exception ex)
            {
                return(new StatResult(ex));
            }
        }
Ejemplo n.º 2
0
 protected internal virtual void InitializePrerequisites( StatResult[] prerequisitesValues )
 {
   throw new NotImplementedException( "InitializePrerequisites must also be overridden when PrerequisiteFunctions has been overridden." ); 
 }
 private void CalculateStatFunctionValue( Stats.StatFunction statFunction, DataGridCollectionView view )
 {
   m_statFunctionValues[ statFunction ] = new Stats.StatResult(
     new InvalidOperationException( Log.NotToolkitStr( "Statistical functions" ) )
     );
 }
Ejemplo n.º 4
0
 private void CalculateStatFunctionValue(Stats.StatFunction statFunction, DataGridCollectionView view)
 {
     m_statFunctionValues[statFunction] = new Stats.StatResult(
         new InvalidOperationException(Log.NotToolkitStr("Statistical functions"))
         );
 }
    private static StatResult RunStatFunction( 
      StatFunction statFunction, 
      Type[] dataTypes, 
      object[] valuesX, 
      object[] valuesY )
    {
      statFunction.InitializeAccumulationTypes( dataTypes );
      statFunction.StartCalculation();
      statFunction.Reset();

      try
      {
        if( statFunction.PrerequisiteFunctions != null && statFunction.PrerequisiteFunctions.Length > 0 )
        {
          StatResult[] preValues = new StatResult[ statFunction.PrerequisiteFunctions.Length ];

          for( int i = 0; i < statFunction.PrerequisiteFunctions.Length; i++ )
          {
            preValues[ i ] = StatFunction.RunStatFunction( statFunction.PrerequisiteFunctions[ i ], dataTypes, valuesX, valuesY );

            if( preValues[ i ].Value is Exception )
              throw ( Exception )preValues[ i ].Value;
          }

          statFunction.InitializePrerequisites( preValues );
        }

        if( statFunction.RequiresAccumulation )
        {
          for( int i = 0; i < valuesX.Length; i++ )
          {
            if( valuesY == null )
            {
              statFunction.Accumulate( new object[] { valuesX[ i ] } );
            }
            else
            {
              statFunction.Accumulate( new object[] { valuesX[ i ], valuesY[ i ] } );
            }
          }
        }

        statFunction.EndCalculation();
        return statFunction.GetResult();
      }
      catch( Exception ex )
      {
        return new StatResult( ex );
      }
    }