Пример #1
0
        public static Matrix Transpose(Matrix sourceMatrix)
        {
            Int32[] shape = sourceMatrix.Shape;
            Array.Reverse(shape);
            Matrix resultMatrix = Matrix.CreateMatrix(shape);

            for (Int32 row = 0; row < shape[0]; ++row)
            {
                for (Int32 col = 0; col < shape[1]; ++col)
                {
                    resultMatrix[row, col] = sourceMatrix[col, row];
                }
            }
            return(resultMatrix);
        }
Пример #2
0
        public static Matrix InitializeMatrix(Int32[][] foodArr)
        {
            Int32 arrLength = foodArr[0].Length;

            for (Int32 i = 1; i < foodArr.GetLength(0); ++i)
            {
                if (foodArr[i].Length != arrLength)
                {
                    throw new ArgumentException("The array must be rectangular");
                }
            }

            Matrix resultMatrix = Matrix.CreateMatrix(foodArr.GetLength(0), foodArr[0].Length);

            FeedMatrix(resultMatrix, foodArr);
            return(resultMatrix);
        }