public IEnumerable <SparseVector <T> > ReadRows()
        {
            if (this.streamReader == null)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            // seek to matrix start position
            this.streamReader.BaseStream.Seek(0L, SeekOrigin.Begin);
            this.streamReader.DiscardBufferedData();

            // skip header
            var header = this.streamReader.ReadLine();

            // skip stats
            var parsedMatrixElements = (from line in SkippedEmptyAndCommentsLines(this.streamReader).Skip(1) // skip stats line
                                        let trimmedLine = line.Trim()
                                                          where trimmedLine != string.Empty && !trimmedLine.StartsWith("%")
                                                          select lineParser.ParseLine(trimmedLine));

            return(MatrixElement <T> .ToSparceVectorsFromOrderedMatrixElements(this.RowsCount,
                                                                               this.ColumnsCount,
                                                                               this.ElementsCount,
                                                                               parsedMatrixElements,
                                                                               1, 1));
        }
Пример #2
0
        public IEnumerable <SparseVector <T> > ReadRows()
        {
            if (fullyCached)
            {
                if (this.ElementsCount <= 0)
                {
                    return(Enumerable.Empty <SparseVector <T> >());
                }

                return(MatrixElement <T> .ToSparceVectorsFromOrderedMatrixElements(
                           this.RowsCount,
                           this.ColumnsCount,
                           this.ElementsCount,
                           CachedMatrixElements(),
                           0, 0));
            }

            return(CacheAndYield());
        }