Update Cryville.Common.
This commit is contained in:
@@ -1,18 +1,41 @@
|
||||
namespace Cryville.Common.Math {
|
||||
/// <summary>
|
||||
/// Represents a square matrix.
|
||||
/// </summary>
|
||||
public class SquareMatrix {
|
||||
readonly float[,] content;
|
||||
/// <summary>
|
||||
/// The size of the matrix.
|
||||
/// </summary>
|
||||
public int Size {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a square matrix with the specified size.
|
||||
/// </summary>
|
||||
/// <param name="size">The size of the matrix.</param>
|
||||
public SquareMatrix(int size) {
|
||||
content = new float[size, size];
|
||||
Size = size;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the element at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="r">The zero-based row index.</param>
|
||||
/// <param name="c">The zero-based column index.</param>
|
||||
/// <returns>The element at the specified index.</returns>
|
||||
public float this[int r, int c] {
|
||||
get { return content[r, c]; }
|
||||
set { content[r, c] = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Eliminates the square matrix against a column vector.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The vector type.</typeparam>
|
||||
/// <param name="v">The column vector.</param>
|
||||
/// <param name="o">The column operator.</param>
|
||||
/// <returns>The column vector eliminated.</returns>
|
||||
public ColumnVector<T> Eliminate<T>(ColumnVector<T> v, IVectorOperator<T> o) {
|
||||
int s = Size;
|
||||
float[,] d = (float[,])content.Clone();
|
||||
@@ -48,6 +71,11 @@
|
||||
}
|
||||
return new ColumnVector<T>(res);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a square matrix and fills it with polynomial coefficients.
|
||||
/// </summary>
|
||||
/// <param name="size">The size of the square matrix.</param>
|
||||
/// <returns>A square matrix filled with polynomial coefficients.</returns>
|
||||
public static SquareMatrix WithPolynomialCoefficients(int size) {
|
||||
var m = new SquareMatrix(size);
|
||||
for (var r = 0; r < size; r++) {
|
||||
|
Reference in New Issue
Block a user