Exemplo n.º 1
0
        public myMatrix <TColumn, TRow, TValue> Transpose()
        {
            myMatrix <TColumn, TRow, TValue> trans = new myMatrix <TColumn, TRow, TValue>();

            foreach (TRow row in row_map.Keys)
            {
                foreach (TColumn col in col_map.Keys)
                {
                    //transpose the matrix O(n**2)
                    trans[col, row] = arr[row_map[row], col_map[col]];
                }
            }
            return(trans);
        }
Exemplo n.º 2
0
        //transpose matrix
        public myMatrix <TColumn, TRow, TValue> Transpose()
        {
            myMatrix <TColumn, TRow, TValue> result = new myMatrix <TColumn, TRow, TValue>();

            foreach (TRow row in row_map.Keys)
            {
                foreach (TColumn col in col_map.Keys)
                {
                    try
                    {
                        result[col, row] = arr[row_map[row]][col_map[col]];
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //testing
            myMatrix <string, string, string> myIndexer = new myMatrix <string, string, string>();

            myIndexer["1", "1"] = "22";
            myIndexer["1", "2"] = "23";
            myIndexer["2", "1"] = "44";
            myIndexer["2", "2"] = "46";
            myIndexer["3", "2"] = "55";
            myIndexer.Print();
            //Console.WriteLine(myIndexer["1", "2"]);
            myMatrix <string, string, string> trans = myIndexer.Transpose();

            trans.Print();
            myIndexer.RemoveRow("1");
            myIndexer.Print();
            myIndexer.RemoveCol("1");
            myIndexer.Print();
        }