public PartialMatrix <double> ReadDouble(StreamReader reader) { double[][] elements = PartialMatrix <double> .CreateElements(_rowCount, _colCount); int row = 0; // Read the Body while (reader.EndOfStream == false) { string[] fields = reader.ReadLine().Split(new[] { _delimiter }); if (fields.Length != _colCount) { throw new InvalidDataException("Unexpected number of columns on line " + row); } for (int col = 0; col < fields.Length; col++) { elements[row][col] = Convert.ToDouble(fields[col].Trim()); } row++; } if (row != _rowCount) { throw new InvalidDataException("Unexpected number of rows in file"); } return(new PartialMatrix <double>(_globalRowStartIndex, _globalRowStartIndex + _rowCount - 1, _globalColStartIndex, _globalColStartIndex + _colCount - 1, elements)); }
public PartialMatrix <double> ReadDouble(BinaryReader reader) { double[][] elements = PartialMatrix <double> .CreateElements(_rowCount, _colCount); for (int i = 0; i < _rowCount; i++) { for (int j = 0; j < _colCount; j++) { elements[i][j] = reader.ReadDouble(); } } return(new PartialMatrix <double>(_globalRowStartIndex, _globalRowStartIndex + _rowCount - 1, _globalColStartIndex, _globalColStartIndex + _colCount - 1, elements)); }