/* * Load dense matrix and transpose it. */ public static DenseMatrix DenseMatrixTransposeLoader(string DenseMatrixFileName) { StreamReader DenseMatrixFile = new StreamReader(DenseMatrixFileName); // Scan the data file to determine the dimension of the matrix int nCol = 0; int nRow = 0; string StrLine; while((StrLine = DenseMatrixFile.ReadLine()) != null) { if (nCol == 0) { string[] StrLineSplit = StrLine.Split('\t'); nRow = StrLineSplit.Length; } ++nCol; } DenseMatrixFile.Close(); // Load the data and store it into the matrix DenseMatrix Matrix = new DenseMatrix(nRow,nCol); DenseMatrixFile = new StreamReader(DenseMatrixFileName); int IdxCol = 0; while ((StrLine = DenseMatrixFile.ReadLine()) != null) { float[] LoadedColumn = new float[nRow]; string[] StrLineSplit = StrLine.Split('\t'); for (int IdxRow = 0; IdxRow < nRow; ++IdxRow) { LoadedColumn[IdxRow] = float.Parse(StrLineSplit[IdxRow]); } Matrix.FillColumn(LoadedColumn, IdxCol); ++IdxCol; } DenseMatrixFile.Close(); return Matrix; }