Fixed some blunders and finished #31.

This commit is contained in:
That-One-Nerd 2023-07-10 16:34:07 -04:00
parent 2c2e7e3a99
commit 97a0b2fee5
4 changed files with 20 additions and 3 deletions

View File

@ -6,10 +6,21 @@ Here's the full changelog:
``` ```
* Nerd_STF * Nerd_STF
* Mathematics * Mathematics
* Abstract
* IMatrix
+ Cofactor()
* Algebra
* Matrix
= Fixed a blunder in `SignGrid(Int2)` with signs being incorrectly placed on matrixes with even column count.
* Matrix2x2
= Fixed a blunder in `Cofactor()` with the position of elements.
* NumberSystems * NumberSystems
* Complex * Complex
+ operator Complex(SystemComplex) + operator Complex(SystemComplex)
+ operator SystemComplex(Complex) + operator SystemComplex(Complex)
* Quaternion
+ operator Quaternion(SystemQuaternion)
+ operator SystemQuaternion(Quaternion)
* Float3 * Float3
= Added a setter to `XY` = Added a setter to `XY`
= Added a setter to `XZ` = Added a setter to `XZ`

View File

@ -6,6 +6,7 @@ public interface IMatrix<T> : IAbsolute<T>, ICeiling<T>, IClamp<T>, IDivide<T>,
where T : IMatrix<T> where T : IMatrix<T>
{ {
public T Adjugate(); public T Adjugate();
public T Cofactor();
public float Determinant(); public float Determinant();
public T? Inverse(); public T? Inverse();
public T Transpose(); public T Transpose();

View File

@ -20,7 +20,12 @@ public class Matrix : IMatrix<Matrix, Matrix>
return m; return m;
} }
public static Matrix One(Int2 size) => new(size, 1); public static Matrix One(Int2 size) => new(size, 1);
public static Matrix SignGrid(Int2 size) => new(size, Fills.SignFill); public static Matrix SignGrid(Int2 size) => new(size, delegate (int x)
{
float sgnValue = Fills.SignFill(x);
if (size.y % 2 == 0 && x / size.y % 2 == 1) sgnValue *= -1;
return sgnValue;
});
public static Matrix Zero(Int2 size) => new(size); public static Matrix Zero(Int2 size) => new(size);
public bool HasMinors => Size.x > 1 && Size.y > 1; public bool HasMinors => Size.x > 1 && Size.y > 1;

View File

@ -223,8 +223,8 @@ public record class Matrix2x2 : IStaticMatrix<Matrix2x2>
{ {
Matrix2x2 swapped = new(new[,] Matrix2x2 swapped = new(new[,]
{ {
{ r2c2, r1c2 }, { r2c2, r2c1 },
{ r2c1, r1c1 } { r1c2, r1c1 }
}); });
return swapped ^ SignGrid; return swapped ^ SignGrid;
} }