Fix: Unitary Decomposition -> Conj inplace not handled correct

This commit is contained in:
h z
2024-12-15 01:21:59 +00:00
parent 1f46ce1cf0
commit dc10d86866
9 changed files with 135 additions and 23 deletions

View File

@@ -110,10 +110,31 @@ public static partial class CategoryOf<TDimension>
return new(U, logd);
}
/*/// <inheritdoc />
public override JDPair<OnField<Complex>.FMatrix> EigenDecomposition() => this.UnitaryDecomposition();*/
/*
* /// <inheritdoc />
* public override JDPair<OnField<Complex>.FMatrix> EigenDecomposition() => this.UnitaryDecomposition();
* */
internal override void UnitaryFix(OnField<Complex>.FMatrix a) => a.UnitaryFix();
protected override bool NeedPreNormalFix() => !Property.IsUnitary;
protected override void PreNormalConstructionFix()
{
if (Property.IsDiagonal)
{
for (int i = 1; i <= Dim; i++)
this[i, i] /= (this[i, i] * Complex.Conjugate(this[i, i]));
}
else
{
this[1] = this[1].Normalize;
for (int i = 2; i <= Dim; i++)
{
for (int j = 1; j < i; j++)
this[i] -= this[i].ProjectionOn(this[j]);
this[i] = this[i].Normalize;
}
}
}
}
}