using Skeleton.Algebra.FixableObjects; using Skeleton.Algebra.ScalarFieldStructure; namespace Skeleton.Algebra; public partial class CategoryOf { public static partial class OnField { /// public class FDiagonalMatrix : FNormalMatrix { /// public FDiagonalMatrix() { U = One; D = AsMatrix; } /// public FDiagonalMatrix(IEnumerable es, bool row = true) : base(es, row) => this.PostConstructionFix(); /// public FDiagonalMatrix(params TScalar[] es) { U = One; if (es.Length == FDim) for (int i = 1; i <= FDim; i++) this[i, i] = es[i - 1]; else for (int i = 1; i <= FDim; i++) for (int j = 1; j <= FDim; j++) this[i, j] = es[i - 1 + (j - 1) * FDim]; this.PostConstructionFix(); } internal override bool NeedFix => base.NeedFix || !Property.IsDiagonal; internal override void Fix() { for (int i = 1; i <= Dim; i++) { for (int j = i + 1; j <= Dim; j++) { this[i, j] = StaticAccess.AdditionUnit; this[j, i] = StaticAccess.AdditionUnit; } } base.Fix(); } /// /// log of the normal matrix /// /// public FDiagonalMatrix Log() { FDiagonalMatrix res = new(); for (int i = 1; i <= Dim; i++) res[i, i] = FieldStructure.Log(this[i, i]); return res; } /// /// exp of the normal matrix /// /// public FDiagonalMatrix Exp() { FDiagonalMatrix res = new(); for (int i = 1; i <= Dim; i++) res[i, i] = FieldStructure.Exp(this[i, i]); return res; } internal override void UnitaryFix(FMatrix a) { } } } }