本文整理汇总了C#中Matrix.GaussJordanEliminate方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.GaussJordanEliminate方法的具体用法?C# Matrix.GaussJordanEliminate怎么用?C# Matrix.GaussJordanEliminate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix.GaussJordanEliminate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LinearlyIndependent
public static bool LinearlyIndependent(params IVector[] vecs)
{
//reduce and see if there are zero rows
Matrix temp = new Matrix(vecs);
temp.GaussJordanEliminate();
return !temp[temp.Height - 1].IsZero();
}
示例2: Rank
public int Rank()
{
if (IsReducedRowEchelon())
{
int nonZeroRows = 0;
for (int i = 0; i < Height; i++)
{
if (!this[i].IsZero()) nonZeroRows++;
else break;
}
//should be the same as Image().Dimension and Kernel().Dimension - math!
return nonZeroRows;
}
else
{
Matrix temp = new Matrix(this);
temp.GaussJordanEliminate();
return temp.Rank();
}
}
示例3: LinearSystem
public LinearSystem(Matrix a, IVector b)
{
int w1 = a.Width;
IVector[] temp = new IVector[a.Height];
for (int i = 0; i < temp.Length; i++)
{
double[] vec = new double[w1 + 1];
for (int j = 0; j < w1; j++)
vec[j] = a[i][j];
vec[w1] = b[i];
temp[i] = new Vector(vec);
}
augmat = new Matrix(temp);
augmat.GaussJordanEliminate();
}
示例4: Kernel
//TODO: make class to represent bases
public SubSpace Kernel()
{
if (!IsReducedRowEchelon())
{
Matrix temp = new Matrix(this);
temp.GaussJordanEliminate();
return temp.Kernel();
}
//number of free vars = width - number of nonzero rows
//solution vector has width rows
//if column c of the matrix has no leading 1s, v[c] has free variables
//else v[c] is a bound variable
//basis will have 1 vector for each free variable
//for vector from free variable a:
// component a is a 1
// components corresponding to free variables are 0
// components corresponding to bound variables:
// iterate through rows, row[a] is next open component
bool[] hasLeading1 = new bool[Width];
int boundVars = 0;
for (int i = 0; i < Height; i++)
{
for (int j = 0; j < Width; j++)
{
if (this[i][j] != 0)
{
hasLeading1[j] = true;
boundVars++;
break;
}
}
}
IVector[] basis = new IVector[Width - boundVars];
int colOfCurrentFree = 0;
for (int i = 0; i < basis.Length; i++)
{
while (hasLeading1[colOfCurrentFree]) colOfCurrentFree++;
double[] temp = new double[Width];
int boundsSoFar = 0;
for (int j = 0; j < temp.Length; j++)
{
if (j == colOfCurrentFree)
temp[j] = 1; //j == the col this free var comes from
else if (!hasLeading1[j])
temp[j] = 0; //other free vars are being accounted for elsewhere
else
{
//we hafta get it from augmat
temp[j] = -this[boundsSoFar][colOfCurrentFree];
boundsSoFar++;
}
}
basis[i] = new Vector(temp);
colOfCurrentFree++;
}
return new SubSpace(basis);
}