示例#1
0
 /// <inheritdoc/>
 public void RegisterState(IIntegrationState state)
 {
     RegisteredStates.Add(state);
     if (state is ITruncatable truncatable)
     {
         TruncatableStates.Add(truncatable);
     }
 }
示例#2
0
            /// <summary>
            /// Creates a derivative.
            /// </summary>
            /// <param name="track">If set to <c>true</c>, the integration method will use this state to limit truncation errors.</param>
            /// <returns>
            /// The derivative.
            /// </returns>
            public override IDerivative CreateDerivative(bool track)
            {
                var derivative = new DerivativeInstance(this, _stateValues + 1);

                _stateValues += 2;
                if (track)
                {
                    TruncatableStates.Add(derivative);
                }
                return(derivative);
            }
示例#3
0
            /// <inheritdoc/>
            public override IIntegral CreateIntegral(bool track = true)
            {
                var integral = new IntegralInstance(this, _stateValues + 1);

                _stateValues += 2;
                if (track)
                {
                    TruncatableStates.Add(integral);
                }
                return(integral);
            }
示例#4
0
            /// <summary>
            /// Initializes the integration method using the allocated biasing state.
            /// At this point, all entities should have received the chance to allocate and register integration states.
            /// </summary>
            public override void Initialize()
            {
                // Create all the states
                States.Set(i => new SpiceIntegrationState(0.0,
                                                          new DenseVector <double>(State.Solver.Size),
                                                          _stateValues));

                // Reset all integration coefficients
                for (var i = 0; i < Coefficients.Length; i++)
                {
                    Coefficients[i] = 0.0;
                }

                base.Initialize();

                // Add our own truncatable states
                if (Parameters.TruncateNodes)
                {
                    TruncatableStates.Add(new NodeTruncation(this));
                }
            }