예제 #1
0
        /// <summary>
        /// Calculates the partial derivatives of Z with respect to v.
        /// </summary>
        /// <param name="Z">Input: A 2-dimensional array of sDouble3 values.</param>
        /// <param name="dZdv">Input: Initialized array with same dimensions as Z. Output: Partial derivatives of Z.</param>
        /// <param name="dv">The step size of v.</param>
        /// <param name="p">Bool indicating the periodicity of the array in v. If true then Z[i,j+m] = Z[i,j].</param>
        public static Double3[,] Calc_dZdv(Double3[,] Z, double dv, bool p)
        {
            int uCount = Z.GetLength(0), vCount = Z.GetLength(1);

            Double3[,] dZdv = new Double3[uCount, vCount];
            if (p)
            {
                Calc_dZdv_p(Z, dZdv, dv);
            }
            else
            {
                Calc_dZdv_n(Z, dZdv, dv);
            }
            return(dZdv);
        }
예제 #2
0
        /// <summary>
        /// Calculates the partial derivatives of Z with respect to u.
        /// </summary>
        /// <param name="Z">Input: A 2-dimensional array of sDouble3 values.</param>
        /// <param name="dZdu">Input: Initialized array with same dimensions as Z. Output: Partial derivatives of Z.</param>
        /// <param name="stepSize">The step size of u.</param>
        /// <param name="periodic">Bool indicating the periodicity of the array in u. If true then Z[i+n,j] = Z[i,j].</param>
        public static Double3[,] Calc_dZdu(Double3[,] Z, double stepSize, bool periodic)
        {
            int uCount = Z.GetLength(0), vCount = Z.GetLength(1);

            Double3[,] dZdu = new Double3[uCount, vCount];
            if (periodic)
            {
                Calc_dZdu_p(Z, dZdu, stepSize);
            }
            else
            {
                Calc_dZdu_n(Z, dZdu, stepSize);
            }
            return(dZdu);
        }
예제 #3
0
파일: Double3.cs 프로젝트: widovd/NEUNET
        // ----------------------------------------------------------------------------------------
        #region Object

        public override bool Equals(object o)
        {
            Double3 value = (Double3)o;

            if (IsNaN(this) && IsNaN(value))
            {
                return(true);
            }
            if (X != value.X)
            {
                return(false);
            }
            if (Y != value.Y)
            {
                return(false);
            }
            if (Z != value.Z)
            {
                return(false);
            }
            return(true);
        }
예제 #4
0
        public Double3x3(Double3 rotationAxis, double rotationAngle)
        {
            double a  = rotationAngle.ToRadians();
            double cs = Cos(a);
            double sn = Sin(a);

            double ux = rotationAxis.X;
            double uy = rotationAxis.Y;
            double uz = rotationAxis.Z;

            XX = cs + ux * ux * (1 - cs);
            YX = uy * ux * (1 - cs) + uz * sn;
            ZX = uz * ux * (1 - cs) - uy * sn;

            XY = ux * uy * (1 - cs) - uz * sn;
            YY = cs + uy * uy * (1 - cs);
            ZY = uz * uy * (1 - cs) + ux * sn;

            XZ = ux * uz * (1 - cs) + uy * sn;
            YZ = uy * uz * (1 - cs) - ux * sn;
            ZZ = cs + uz * uz * (1 - cs);
        }
예제 #5
0
        public static void Calc_dZdu_p(Double3[,] Z, Double3[,] dZdu, double du)
        {
            int n = Z.GetLength(0), m = Z.GetLength(1);

            if ((n != dZdu.GetLength(0)) || (m != dZdu.GetLength(1)))
            {
                throw new ArgumentException("dZdu must have the same dimensions as Z.");
            }
            Parallel.For(0, n, (i) =>
            {
                for (int j = 0; j < m; j++)
                {
                    dZdu[i, j] = Double3.NaN; // default
                    Double3 Zm = Z[(i - 1).Trim(n), j];
                    Double3 Zp = Z[(i + 1).Trim(n), j];
                    if (Double3.IsNaN(Zm) || Double3.IsNaN(Zp))
                    {
                        continue;
                    }
                    dZdu[i, j] = 0.5d * (Zp - Zm) / du;
                }
            });
        }
예제 #6
0
        public static void Calc_dZdv_p(Double3[,] Z, Double3[,] dZdv, double dv)
        {
            int n = Z.GetLength(0);
            int m = Z.GetLength(1);

            if ((n != dZdv.GetLength(0)) || (m != dZdv.GetLength(1)))
            {
                throw new ArgumentException("dZdv must have the same dimensions as Z.");
            }
            Parallel.For(0, m, (j) =>
            {
                for (int i = 0; i < n; i++)
                {
                    dZdv[i, j] = Double3.NaN; // default
                    Double3 Zm = Z[i, (j - 1).Trim(m)];
                    Double3 Zp = Z[i, (j + 1).Trim(m)];
                    if (Double3.IsNaN(Zm) || Double3.IsNaN(Zp))
                    {
                        continue;
                    }
                    dZdv[i, j] = 0.5d * (Zp - Zm) / dv;
                }
            });
        }
예제 #7
0
파일: Double3.cs 프로젝트: widovd/NEUNET
        // ----------------------------------------------------------------------------------------
        #region Static

        public static bool IsNaN(Double3 value)
        {
            return(double.IsNaN(value.X) || double.IsNaN(value.Y) || double.IsNaN(value.Z));
        }