GetColumn() public method

Returns the specified column of the matrix
public GetColumn ( int passedColumnIndex ) : double[]
passedColumnIndex int
return double[]
コード例 #1
0
        /// <summary>
        /// Takes values from a matrix and determines a cofactor by removing a certain row and column from the matrix.
        /// Logic developed with help from Andrew Morton on stackoverflow:
        /// http://stackoverflow.com/questions/24416946/next-step-in-calculating-a-matrix-determinant
        /// </summary>
        public Matrix GetSubMatrix(int[] indicesOfRowsToKeep, int[] indicesOfColumnsToKeep)
        {

            Matrix subMatrix = new Matrix(indicesOfRowsToKeep.Length, indicesOfColumnsToKeep.Length);
            Matrix tempMatrix = new Matrix(indicesOfRowsToKeep.Length, this.NumberOfColumns);

            int insertRowAt = 0;
            foreach (int rowToKeep in indicesOfRowsToKeep)
            {
                tempMatrix.SetRow(insertRowAt, this.GetRow(rowToKeep));
                insertRowAt++;
            }

            int insertColumnAt = 0;
            foreach (int columnToKeep in indicesOfColumnsToKeep)
            {
                subMatrix.SetColumn(insertColumnAt, tempMatrix.GetColumn(columnToKeep));
                insertColumnAt++;
            }

            return subMatrix;
        }
コード例 #2
0
        public void Matrix_GetColumnStandardTest()
        {
            Matrix testMatrix = new Matrix(3, 2);
            double[] columnTwoOfTestMatrix = {7,8,9};

            testMatrix.SetColumn(1, columnTwoOfTestMatrix);

            testMatrix.GetColumn(1).ShouldBeEquivalentTo(columnTwoOfTestMatrix);            

        }
コード例 #3
0
 private static Point _pointFromProjectiveColumnVector(Matrix projectiveVector)
 {
     var col = projectiveVector.GetColumn(0);
     //smallest we're allowing is 1 millionth
     if (Math.Abs(col[3]) < 0.000001)
     {
         return Point.Origin;
     }
     else
     {
         var x = col[0]/col[3];
         var y = col[1]/col[3];
         var z = col[2]/col[3];
         return Point.MakePointWithInches(x, y, z);
     }
 }