Exemple #1
0
 protected abstract Vector Sub(Vector v);
        /// <summary>
        /// Δt 分更新。
        /// </summary>
        /// <param name="dt">Δt</param>
        public void Update(double dt)
        {
            if (this.f == null)
                return;

              /* ガウス法
            this.q += dt * this.f.GetValue(this.q);
              // */

            /* 中点法
            Vector k;
            k = dt * this.f.GetValue(this.q);
            k = dt * this.f.GetValue(this.q + k / 2);
            this.q += k;
            // */

            //* ルンゲクッタ法
            Vector k1, k2, k3, k4;
            k1 = dt * this.f.GetValue(this.q);
            k2 = dt * this.f.GetValue(this.q + k1 / 2);
            k3 = dt * this.f.GetValue(this.q + k2 / 2);
            k4 = dt * this.f.GetValue(this.q + k3);

            this.q += (k1 + 2 * (k2 + k3) + k4) / 6;
            // */
        }
Exemple #3
0
 protected abstract Vector Add(Vector v);
 public DynamicalSystem(VectorFunction f, Vector initQ)
 {
     this.q = initQ;
     this.f = f;
 }