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


C# Matrix.GetColumn方法代码示例

本文整理汇总了C#中System.Matrix.GetColumn方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.GetColumn方法的具体用法?C# Matrix.GetColumn怎么用?C# Matrix.GetColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Matrix的用法示例。


在下文中一共展示了Matrix.GetColumn方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestGetSetColumn

 public void TestGetSetColumn()
 {
     var matrix = new Matrix<int>(5, 5);
     int[] column = { 1, 2, 3, 4, 5 };
     matrix.SetColumn(3, column);
     Assert.AreEqual(column, matrix.GetColumn(3));
     Assert.AreEqual(0, matrix[0, 0]);
     Assert.AreEqual(1, matrix[0, 3]);
 }
开发者ID:pipifuyj,项目名称:MyMediaLite,代码行数:9,代码来源:MatrixTest.cs

示例2: TestSetColumnToOneValue

 public void TestSetColumnToOneValue()
 {
     var matrix = new Matrix<int>(5, 5);
     int[] row = { 1, 2, 3, 4, 5 };
     for (int i = 0; i < 5; i++)
         matrix.SetRow(i, row);
     matrix.SetColumnToOneValue(3, 10);
     int[] testcolumn = { 10, 10, 10, 10, 10 };
     Assert.AreEqual(testcolumn, matrix.GetColumn(3));
 }
开发者ID:zenogantner,项目名称:MML-KDD,代码行数:10,代码来源:MatrixTest.cs

示例3: canBeThere

        private bool canBeThere(Matrix m, int row, int column, int digit)
        {
            int[] temp = m.GetRow(row);
            foreach (int i in temp)
                if (i == digit)
                    return false;
            temp = m.GetColumn(column);
            foreach (int i in temp)
                if (i == digit)
                    return false;
            temp = m.GetRegion(row, column);
            foreach (int i in temp)
                if (i == digit)
                    return false;

            return true;
        }
开发者ID:bmwant,项目名称:SSO,代码行数:17,代码来源:BacktrackingEngine.cs

示例4: Hminired

        private Matrix Hminired(Matrix A)
        {
            //function A=hminired(A)
            //%HMINIRED Initial reduction of cost matrix for the Hungarian method.
            //%
            //%B=assredin(A)
            //%A - the unreduced cost matris.
            //%B - the reduced cost matrix with linked zeros in each row.

            //% v1.0  96-06-13. Niclas Borlin, [email protected]

            //[m,n]=size(A);
            int m = A.Rows, n = A.Columns;

            //% Subtract column-minimum values from each column.
            //colMin=min(A);
            var colMin = new DenseVector(A.GetColumns().Select(col => col.Min()).ToArray());
            //A=A-colMin(ones(n,1),:);
            for (int i = 0; i < A.Rows; ++i) {
                A.SetRow(i, A.GetRow(i) - colMin);
            }

            //% Subtract row-minimum values from each row.
            //rowMin=min(A')';
            var rowMin = new DenseVector(A.GetRows().Select(row => row.Min()).ToArray());
            //A=A-rowMin(:,ones(1,n));
            for (int j = 0; j < A.Rows; ++j) {
                A.SetColumn(j, A.GetColumn(j) - rowMin);
            }

            //% Get positions of all zeros.
            //[i,j]=find(A==0);
            List<int> ilist = new List<int>();
            List<int> jlist = new List<int>();
            A.EachT((v, i, j) => {
                if (v == 0) {
                    ilist.Add(i);
                    jlist.Add(j);
                }
            });

            //% Extend A to give room for row zero list header column.
            //A(1,n+1)=0;
            Matrix tmp = Zeros(n, n + 1);
            tmp.SetSubMatrix(0, n, 0, n, A);
            //for k=1:n
            for (int k = 0; k < n; ++k) {
                //    % Get all column in this row.
                //    cols=j(k==i)';
                var cols = new List<int>();
                cols.Add(n);
                for (int i = 0; i < ilist.Count; ++i) {
                    if (ilist[i] == k) {
                        cols.Add(jlist[i]);
                    }
                }
                cols.Add(-1);

                //    % Insert pointers in matrix.
                //    A(k,[n+1 cols])=[-cols 0];
                for (int i = 0; i < cols.Count - 1; ++i) {
                    tmp[k, cols[i]] = -(cols[i + 1]) - 1;
                } // TODO 不知道对不对了
                //result[k, cols[cols.Count - 1]] = 0;
                //end
            }
            var result = tmp.Each(v => {
                if (v < 0) return v + 1;
                else if (v == 0) return NoMatch;
                else return v;
            });

            return result;
        }
开发者ID:pakerliu,项目名称:sharp-context,代码行数:74,代码来源:Hungarian.cs

示例5: Variance

        internal static Vector Variance(Matrix value, double[] means)
        {
            Vector variance = new Vector(value.Columns);

            for (int i = 0; i < value.Columns; i++)
            {
                //TODO: Substitute this with the complete matrix variance algorithm
                variance[i] = Variance(value.GetColumn(i), means[i]);
            }

            return variance;
        }
开发者ID:pirzada,项目名称:sinapse,代码行数:12,代码来源:Tools.cs

示例6: Covariance

        internal static Matrix Covariance(Matrix matrix, double[] mean)
        {
            if (matrix.Rows == 1)
              {
                  throw new ArgumentException("Sample has only one observation.","matrix");
              }

              Matrix cov = new Matrix(matrix.Columns);

              for (int i = 0; i < cov.Columns; i++)
              {
                  Vector column = matrix.GetColumn(i);
                  cov[i, i] = Variance(column, mean[i]); // diagonal has the variances

                  for (int j = i + 1; j < cov.Columns; j++)
                  {
                      cov[i, j] = Covariance(column, matrix.GetColumn(j));
                      cov[j, i] = cov[i, j]; // Matrix is symmetric
                  }
              }
              return cov;
        }
开发者ID:pirzada,项目名称:sinapse,代码行数:22,代码来源:Tools.cs

示例7: Mode

        /// <summary>Calculates the matrix Modes vector.</summary>
        /// <param name="m">A matrix whose modes will be calculated.</param>
        /// <returns>Returns a vector containing the modes of the given matrix.</returns>
        public static Vector Mode(Matrix matrix)
        {
            Vector mode = new Vector(matrix.Columns);

            for (int i = 0; i < mode.Length; i++)
            {
                mode[i] = Mode(matrix.GetColumn(i));
            }

            return mode;
        }
开发者ID:pirzada,项目名称:sinapse,代码行数:14,代码来源:Tools.cs

示例8: Median

        /// <summary>Calculates the matrix Medians vector.</summary>
        /// <param name="m">A matrix whose deviations will be calculated.</param>
        /// <returns>Returns a vector containing the medians of the given matrix.</returns>
        public static Vector Median(Matrix value)
        {
            Vector medians = new Vector(value.Columns);

            for (int i = 0; i < value.Columns; i++)
            {
                medians[i] = Median(value.GetColumn(i));
            }

            return medians;
        }
开发者ID:pirzada,项目名称:sinapse,代码行数:14,代码来源:Tools.cs


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