当前位置: 首页>>代码示例>>C#>>正文


C# Matrix.GaussJordanEliminate方法代码示例

本文整理汇总了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();
 }
开发者ID:SSheldon,项目名称:veccalc,代码行数:7,代码来源:VecOps.cs

示例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();
     }
 }
开发者ID:SSheldon,项目名称:veccalc,代码行数:20,代码来源:Matrix.cs

示例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();
    }
开发者ID:SSheldon,项目名称:veccalc,代码行数:16,代码来源:Matrix.cs

示例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);
    }
开发者ID:SSheldon,项目名称:veccalc,代码行数:61,代码来源:Matrix.cs


注:本文中的Matrix.GaussJordanEliminate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。