Ejemplo n.º 1
0
        public static double GetLength(DoubleVec inVec)
        {
            double length = 0.0d;
            double sum    = 0.0d;

            double[] vec = inVec.GetVec();
            for (int i = 0; i < vec.Length; i++)
            {
                sum += (vec[i] * vec[i]);
            }
            if (sum > 0.0)
            {
                length = Math.Sqrt(sum);
            }
            return(length);
        }
Ejemplo n.º 2
0
        public static double GetInnerDot(DoubleVec vec1, DoubleVec vec2)
        {
            double innerDot = 0.0d;

            double[] vec1a = vec1.GetVec();
            double[] vec2a = vec2.GetVec();
            // proceed the calculation only if same size
            if (vec1.GetSize() == vec2.GetSize())
            {
                for (int i = 0; i < vec1.GetSize(); i++)
                {
                    innerDot += (vec1a[i] * vec2a[i]);
                }
            }
            return(innerDot);
        }