コード例 #1
0
        private static int getWidth(DerivativeType type)
        {
            switch (type)
            {
            case DerivativeType.x:
                //return 5;
                return(3);

            case DerivativeType.y:
                return(1);

            case DerivativeType.xy:
                return(3);
            }
            return(-1); // It should never come to this!
        }
コード例 #2
0
ファイル: DerivativeKernel.cs プロジェクト: aelex13/RugbyIBV
        private static int getHeight(DerivativeType type)
        {
            switch (type)
            {
                case DerivativeType.x:
                    return 1;

                case DerivativeType.y:
                    //return 5;
                    return 3;

                case DerivativeType.xy:
                    return 3;
            }
            return -1; // It should never come to this!
        }
コード例 #3
0
ファイル: DerivativeKernel.cs プロジェクト: aelex13/RugbyIBV
        private static float[,] constructWeights(DerivativeType type)
        {
            switch (type)
            {
                case DerivativeType.x:
                    //return new float[5, 1] { { 1f / 12f }, { -8f / 12f }, { 0f }, { 8f / 12f }, { -1f / 12f } };
                    return new float[3, 1] { { 1f },{ 0f },{ -1f } };

                case DerivativeType.y:
                    //return new float[1, 5] { { 1f / 12f, -8f / 12f, 0f, 8f / 12f, -1f / 12f } };
                    return new float[1, 3] { { 1f, 0f, -1f } };

                case DerivativeType.xy:
                    return new float[3, 3] { { 1f / 4f, 0f, -1f / 4f }, { 0f, 0f, 0f }, { -1f / 4f, 0f, 1f / 4f } };
            }
            return null; // It should never come to this!
        }
コード例 #4
0
        private static float[,] constructWeights(DerivativeType type)
        {
            switch (type)
            {
            case DerivativeType.x:
                //return new float[5, 1] { { 1f / 12f }, { -8f / 12f }, { 0f }, { 8f / 12f }, { -1f / 12f } };
                return(new float[3, 1] {
                    { 1f }, { 0f }, { -1f }
                });

            case DerivativeType.y:
                //return new float[1, 5] { { 1f / 12f, -8f / 12f, 0f, 8f / 12f, -1f / 12f } };
                return(new float[1, 3] {
                    { 1f, 0f, -1f }
                });

            case DerivativeType.xy:
                return(new float[3, 3] {
                    { 1f / 4f, 0f, -1f / 4f }, { 0f, 0f, 0f }, { -1f / 4f, 0f, 1f / 4f }
                });
            }
            return(null); // It should never come to this!
        }
コード例 #5
0
ファイル: FieldValue.cs プロジェクト: lulzzz/IvyFEM
 protected void AllocValues(uint pointCnt)
 {
     if (Type == FieldValueType.ZScalar ||
         Type == FieldValueType.ZVector2 ||
         Type == FieldValueType.ZVector3)
     {
         // complex
         if (DerivativeType.HasFlag(FieldDerivativeType.Value))
         {
             ComplexValues = new System.Numerics.Complex[pointCnt * Dof];
         }
         if (DerivativeType.HasFlag(FieldDerivativeType.Velocity))
         {
             ComplexVelocityValues = new System.Numerics.Complex[pointCnt * Dof];
         }
         if (DerivativeType.HasFlag(FieldDerivativeType.Acceleration))
         {
             ComplexAccelerationValues = new System.Numerics.Complex[pointCnt * Dof];
         }
     }
     else
     {
         // double
         if (DerivativeType.HasFlag(FieldDerivativeType.Value))
         {
             DoubleValues = new double[pointCnt * Dof];
         }
         if (DerivativeType.HasFlag(FieldDerivativeType.Velocity))
         {
             DoubleVelocityValues = new double[pointCnt * Dof];
         }
         if (DerivativeType.HasFlag(FieldDerivativeType.Acceleration))
         {
             DoubleAccelerationValues = new double[pointCnt * Dof];
         }
     }
 }
コード例 #6
0
 public DerivativeKernel(IApplicableFilter decoratingFilter, DerivativeType type)
     : base(decoratingFilter, DerivativeKernel.getWidth(type), DerivativeKernel.getHeight(type), constructWeights(type))
 {
     this.type = type;
 }
コード例 #7
0
ファイル: DerivativeKernel.cs プロジェクト: aelex13/RugbyIBV
 public DerivativeKernel(IApplicableFilter decoratingFilter, DerivativeType type)
     : base(decoratingFilter, DerivativeKernel.getWidth(type), DerivativeKernel.getHeight(type), constructWeights(type))
 {
     this.type = type;
 }
コード例 #8
0
        public double CalculateDerivative(Func <double, double, double> function, double x, double y, DerivativeType type)
        {
            var xStep = 0.0;
            var yStep = 0.0;

            if (type == DerivativeType.X)
            {
                xStep = Epsilon;
            }
            else
            {
                yStep = Epsilon;
            }

            var derivative = (function(x + xStep, y + yStep) - function(x - xStep, y - yStep)) / (2 * (xStep + yStep));

            return(derivative);
        }