Esempio n. 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!
        }
Esempio n. 2
0
        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!
        }
Esempio n. 3
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!
        }
Esempio n. 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!
        }
Esempio n. 5
0
 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];
         }
     }
 }
Esempio n. 6
0
 public DerivativeKernel(IApplicableFilter decoratingFilter, DerivativeType type)
     : base(decoratingFilter, DerivativeKernel.getWidth(type), DerivativeKernel.getHeight(type), constructWeights(type))
 {
     this.type = type;
 }
Esempio n. 7
0
 public DerivativeKernel(IApplicableFilter decoratingFilter, DerivativeType type)
     : base(decoratingFilter, DerivativeKernel.getWidth(type), DerivativeKernel.getHeight(type), constructWeights(type))
 {
     this.type = type;
 }
        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);
        }