Пример #1
0
        public static Matrix createTransposeMatrix(string filename, int netID) // working here - working for integers and random nodes
        {
            Dictionary <int, double> d = new Dictionary <int, double>();

            BufferedFileReader reader = BufferedFileTable.GetFile(filename);

            reader.GoToLine(0);

            while (!reader.EndOfStream) //reading file
            {
                string line = reader.ReadLine();

                if (line == null)
                {
                    break;
                }

                string[] line_parts = line.Split(',');

                if (Int64.Parse(line_parts[0]) == netID)
                {
                    d.Add(ExtractNode(line_parts[1]), ExtractDouble(line_parts[2])); // need to work here for string case
                }
            }

            Matrix m = new Matrix(d.Count, d.Count);  //transpose matrix


            //calculation
            for (int i = 0; i < d.Count; i++)
            {
                for (int j = 0; j < d.Count; j++)
                {
                    m[i, j] = d[i + 1] * d[j + 1];
                }
            }

            return(m);
        }