/// <summary>Shortcut to InnerProduct() </summary> public static ArrayList ip(BasisBlade A, BasisBlade B, Metric M, InnerProductType type) { return InnerProduct(A, B, M, type); }
/// <summary>Shortcut to InnerProduct() </summary> public static BasisBlade ip(BasisBlade A, BasisBlade B, double[] m, InnerProductType type) { return InnerProduct(A, B, m, type); }
/// <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); }
/// <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); }
/// <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; } }
/// <param name="ga">grade of left hand side argument of inner product.</param> /// <param name="gb">grade of right hand side argument of inner product.</param> /// <param name="R">Array of Basis Blades to which the filter should be applied.</param> /// <param name="type">InnerProductType (one of LEFT_CONTRACTION, RIGHT_CONTRACTION, HESTENES_INNER_PRODUCT, MODIFIED_HESTENES_INNER_PRODUCT or SCALAR_PRODUCT)</param> /// <summary> /// Applies the inner product 'filter' to an array of BasisBlades in order turn /// a geometric product into an inner product. /// </summary> private static ArrayList InnerProductFilter(int ga, int gb, ArrayList R, InnerProductType type) { ArrayList result = new ArrayList(); foreach (BasisBlade r in R) { BasisBlade B = InnerProductFilter(ga, gb, r, type); if (B.scale != 0.0) result.Add(B); } return result; }