Esempio n. 1
0
        /// <summary>
        /// Returns lowest grade basis blade in this MV.
        /// </summary>
        /// <returns>lowest grade basis blade in this MV.</returns>
        public int LowestGrade()
        {
            int lg = int.MaxValue;

            for (int g = 0; g < m_basisBlades.Length; g++)
            {
                for (int e = 0; e < m_basisBlades[g].Length; e++)
                {
                    RefGA.BasisBlade srcB = m_basisBlades[g][e];
                    if (srcB.Grade() < lg)
                    {
                        lg = srcB.Grade();
                    }
                }
            }
            return(lg);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns highest grade basis blade in this MV.
        /// </summary>
        /// <returns>highest grade basis blade in this MV.</returns>
        public int HighestGrade()
        {
            int hg = -1;

            for (int g = 0; g < m_basisBlades.Length; g++)
            {
                for (int e = 0; e < m_basisBlades[g].Length; e++)
                {
                    RefGA.BasisBlade srcB = m_basisBlades[g][e];
                    if (srcB.Grade() > hg)
                    {
                        hg = srcB.Grade();
                    }
                }
            }
            return(hg);
        }
Esempio n. 3
0
 /// <summary>
 /// Computes the inner product of two basis blades in arbitary non-Euclidean metric.
 /// </summary>
 /// <param name="A">input blade</param>
 /// <param name="B">input blade</param>
 /// <param name="M">The Metric to be used</param>
 /// <returns>Scalar product of <paramref name="A"/> and <paramref name="B"/>.</returns>
 public static ArrayList ScalarProduct(BasisBlade A, BasisBlade B, Metric M)
 {
     InnerProductType type = InnerProductType.SCALAR_PRODUCT;
     return InnerProductFilter(A.Grade(), B.Grade(), GeometricProduct(A, B, M), type);
 }
Esempio n. 4
0
 /// <summary>
 /// Computes the inner product of two basis blades in diagonal non-Euclidean metric.
 /// </summary>
 /// <param name="A">input blade</param>
 /// <param name="B">input blade</param>
 /// <param name="m">an array of doubles giving the metric for each basis vector</param>
 /// <returns>Scalar product of <paramref name="A"/> and <paramref name="B"/>.</returns>
 public static BasisBlade ScalarProduct(BasisBlade A, BasisBlade B, double[] m)
 {
     InnerProductType type = InnerProductType.SCALAR_PRODUCT;
     return InnerProductFilter(A.Grade(), B.Grade(), GeometricProduct(A, B, m), type);
 }
Esempio n. 5
0
 /// <summary>
 /// Computes the inner product of two basis blades in Euclidean metric.
 /// </summary>
 /// <param name="A">input blade</param>
 /// <param name="B">input blade</param>
 /// <param name="M">The Metric to be used.</param>
 /// <param name="type">inner product type to be used. Use one of the InnerProductType constants:
 /// LEFT_CONTRACTION, RIGHT_CONTRACTION, HESTENES_INNER_PRODUCT, MODIFIED_HESTENES_INNER_PRODUCT or SCALAR_PRODUCT.</param>
 /// <returns>Inner product of <paramref name="A"/> and <paramref name="B"/>.</returns>
 public static ArrayList InnerProduct(BasisBlade A, BasisBlade B, Metric M, InnerProductType type)
 {
     return InnerProductFilter(A.Grade(), B.Grade(), GeometricProduct(A, B, M), type);
 }
Esempio n. 6
0
 /// <summary>
 /// Computes the inner product of two basis blades in Euclidean metric.
 /// </summary>
 /// <param name="A">input blade</param>
 /// <param name="B">input blade</param>
 /// <param name="m">an array of doubles giving the metric for each basis vector.</param>
 /// <param name="type">inner product type to be used. Use one of the InnerProductType constants:
 /// LEFT_CONTRACTION, RIGHT_CONTRACTION, HESTENES_INNER_PRODUCT, MODIFIED_HESTENES_INNER_PRODUCT or SCALAR_PRODUCT.</param>
 /// <returns>Inner product of <paramref name="A"/> and <paramref name="B"/>.</returns>
 public static BasisBlade InnerProduct(BasisBlade A, BasisBlade B, double[] m, InnerProductType type)
 {
     return InnerProductFilter(A.Grade(), B.Grade(), GeometricProduct(A, B, m), type);
 }
Esempio n. 7
0
        /// <summary>
        ///   Applies the inner product 'filter' to a BasisBlade in order to turn a geometric product into an inner product
        /// </summary>
        /// <param name="ga">Grade of argument 'a'</param>
        /// <param name="gb">Grade of argument 'b'</param>
        /// <param name="r">the basis blade to be filtered</param>
        /// <param name="type">type the type of inner product required</param>
        /// <returns>Either <paramref name="r"/> or ZERO, or null when <paramref name="type"/> is invalid</returns>
        private static BasisBlade InnerProductFilter(int ga, int gb, BasisBlade r, InnerProductType type)
        {
            switch (type)
               {
               case InnerProductType.LEFT_CONTRACTION:
                   if ((ga > gb) || (r.Grade() != (gb - ga)))
                       return ZERO; // return zero
                   else return r; // return input blade

               case InnerProductType.RIGHT_CONTRACTION:
                   if ((ga < gb) || (r.Grade() != (ga - gb)))
                       return ZERO; // return zero
                   else return r; // return input blade

               case InnerProductType.HESTENES_INNER_PRODUCT:
                   if ((ga == 0) || (gb == 0)) return new BasisBlade();
                   if (Math.Abs(ga - gb) == r.Grade()) return r; // return input blade
                   else return ZERO; // return zero

               case InnerProductType.MODIFIED_HESTENES_INNER_PRODUCT:
                   if (Math.Abs(ga - gb) == r.Grade()) return r; // return input blade
                   else return ZERO; // return zero
               case InnerProductType.SCALAR_PRODUCT:
                   if (r.Grade() == 0) return r;
                   else return ZERO; // return zero
               default:
                   return null;
               }
        }