当前位置: 首页>>代码示例>>C#>>正文


C# SparseCompressedRowMatrixStorage类代码示例

本文整理汇总了C#中SparseCompressedRowMatrixStorage的典型用法代码示例。如果您正苦于以下问题:C# SparseCompressedRowMatrixStorage类的具体用法?C# SparseCompressedRowMatrixStorage怎么用?C# SparseCompressedRowMatrixStorage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SparseCompressedRowMatrixStorage类属于命名空间,在下文中一共展示了SparseCompressedRowMatrixStorage类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SparseMatrix

 /// <summary>
 /// Create a new sparse matrix straight from an initialized matrix storage instance.
 /// The storage is used directly without copying.
 /// Intended for advanced scenarios where you're working directly with
 /// storage for performance or interop reasons.
 /// </summary>
 public SparseMatrix(SparseCompressedRowMatrixStorage<float> storage)
     : base(storage)
 {
     _storage = storage;
 }
开发者ID:jhashemi,项目名称:mathnet-numerics,代码行数:11,代码来源:SparseMatrix.cs

示例2: Transpose

        /// <summary>
        /// Returns the transpose of this matrix.
        /// </summary>
        /// <returns>The transpose of this matrix.</returns>
        public override Matrix<float> Transpose()
        {
            var rowPointers = _storage.RowPointers;
            var columnIndices = _storage.ColumnIndices;
            var values = _storage.Values;

            var ret = new SparseCompressedRowMatrixStorage<float>(ColumnCount, RowCount)
                {
                    ColumnIndices = new int[_storage.ValueCount],
                    Values = new float[_storage.ValueCount]
                };

            // Do an 'inverse' CopyTo iterate over the rows
            for (var i = 0; i < RowCount; i++)
            {
                // Get the begin / end index for the current row
                var startIndex = rowPointers[i];
                var endIndex = rowPointers[i + 1];

                // Get the values for the current row
                if (startIndex == endIndex)
                {
                    // Begin and end are equal. There are no values in the row, Move to the next row
                    continue;
                }

                for (var j = startIndex; j < endIndex; j++)
                {
                    ret.At(columnIndices[j], i, values[j]);
                }
            }

            return new SparseMatrix(ret);
        }
开发者ID:jhashemi,项目名称:mathnet-numerics,代码行数:38,代码来源:SparseMatrix.cs

示例3: SparseMatrix

 /// <summary>
 /// Create a new sparse matrix straight from an initialized matrix storage instance.
 /// The storage is used directly without copying.
 /// Intended for advanced scenarios where you're working directly with
 /// storage for performance or interop reasons.
 /// </summary>
 public SparseMatrix(SparseCompressedRowMatrixStorage<Complex32> storage)
     : base(storage)
 {
     _storage = storage;
 }
开发者ID:smoothdeveloper,项目名称:mathnet-numerics,代码行数:11,代码来源:SparseMatrix.cs

示例4: Transpose

        /// <summary>
        /// Returns the transpose of this matrix.
        /// </summary>
        /// <returns>The transpose of this matrix.</returns>
        public override Matrix<Complex32> Transpose()
        {
            var rowPointers = _storage.RowPointers;
            var columnIndices = _storage.ColumnIndices;
            var values = _storage.Values;

            var ret = new SparseCompressedRowMatrixStorage<Complex32>(ColumnCount, RowCount)
                {
                    ColumnIndices = new int[_storage.ValueCount],
                    Values = new Complex32[_storage.ValueCount]
                };

            // Do an 'inverse' CopyTo iterate over the rows
            for (var i = 0; i < RowCount; i++)
            {
                var startIndex = rowPointers[i];
                var endIndex = rowPointers[i + 1];

                if (startIndex == endIndex)
                {
                    continue;
                }

                for (var j = startIndex; j < endIndex; j++)
                {
                    ret.At(columnIndices[j], i, values[j]);
                }
            }

            return new SparseMatrix(ret);
        }
开发者ID:smoothdeveloper,项目名称:mathnet-numerics,代码行数:35,代码来源:SparseMatrix.cs

示例5: Identity

        /// <summary>
        /// Initializes a square <see cref="SparseMatrix"/> with all zero's except for ones on the diagonal.
        /// </summary>
        /// <param name="order">the size of the square matrix.</param>
        /// <returns>Identity <c>SparseMatrix</c></returns>
        /// <exception cref="ArgumentException">
        /// If <paramref name="order"/> is less than one.
        /// </exception>
        public static SparseMatrix Identity(int order)
        {
            var mStorage = new SparseCompressedRowMatrixStorage<float>(order, order, 0f)
                {
                    ValueCount = order,
                    Values = new float[order],
                    ColumnIndices = new int[order]
                };

            for (var i = 0; i < order; i++)
            {
                mStorage.Values[i] = 1f;
                mStorage.ColumnIndices[i] = i;
                mStorage.RowPointers[i] = i;
            }

            return new SparseMatrix(mStorage);
        }
开发者ID:bstrausser,项目名称:mathnet-numerics,代码行数:26,代码来源:SparseMatrix.cs

示例6: Identity

        /// <summary>
        /// Initializes a square <see cref="SparseMatrix"/> with all zero's except for ones on the diagonal.
        /// </summary>
        /// <param name="order">the size of the square matrix.</param>
        /// <returns>Identity <c>SparseMatrix</c></returns>
        /// <exception cref="ArgumentException">
        /// If <paramref name="order"/> is less than one.
        /// </exception>
        public static SparseMatrix Identity(int order)
        {
            var m = new SparseCompressedRowMatrixStorage<double>(order, order, 0d)
                {
                    ValueCount = order,
                    Values = new double[order],
                    ColumnIndices = new int[order]
                };

            for (var i = 0; i < order; i++)
            {
                m.Values[i] = 1d;
                m.ColumnIndices[i] = i;
                m.RowPointers[i] = i;
            }

            return new SparseMatrix(m);
        }
开发者ID:hrapa,项目名称:mathnet-numerics,代码行数:26,代码来源:SparseMatrix.cs

示例7: SparseMatrix

 internal SparseMatrix(SparseCompressedRowMatrixStorage<double> storage)
     : base(storage)
 {
     _storage = storage;
 }
开发者ID:hrapa,项目名称:mathnet-numerics,代码行数:5,代码来源:SparseMatrix.cs

示例8: SubMatrix

        /// <summary>
        /// Creates a matrix that contains the values from the requested sub-matrix.
        /// </summary>
        /// <param name="rowIndex">The row to start copying from.</param>
        /// <param name="rowCount">The number of rows to copy. Must be positive.</param>
        /// <param name="columnIndex">The column to start copying from.</param>
        /// <param name="columnCount">The number of columns to copy. Must be positive.</param>
        /// <returns>The requested sub-matrix.</returns>
        /// <exception cref="ArgumentOutOfRangeException">If: <list><item><paramref name="rowIndex"/> is
        /// negative, or greater than or equal to the number of rows.</item>
        /// <item><paramref name="columnIndex"/> is negative, or greater than or equal to the number 
        /// of columns.</item>
        /// <item><c>(columnIndex + columnLength) &gt;= Columns</c></item>
        /// <item><c>(rowIndex + rowLength) &gt;= Rows</c></item></list></exception>        
        /// <exception cref="ArgumentException">If <paramref name="rowCount"/> or <paramref name="columnCount"/>
        /// is not positive.</exception>
        public override Matrix<float> SubMatrix(int rowIndex, int rowCount, int columnIndex, int columnCount)
        {
            // TODO: if rowIndex == columnIndex, use a diagonal matrix instead of a sparse one

            var storage = new SparseCompressedRowMatrixStorage<float>(rowCount, columnCount, 0f);
            _storage.CopySubMatrixTo(storage, rowIndex, 0, rowCount, columnIndex, 0, columnCount, true);
            return new SparseMatrix(storage);
        }
开发者ID:cesardv,项目名称:mathnet-numerics,代码行数:24,代码来源:DiagonalMatrix.cs

示例9: Identity

        /// <summary>
        /// Initializes a square <see cref="SparseMatrix"/> with all zero's except for ones on the diagonal.
        /// </summary>
        /// <param name="order">the size of the square matrix.</param>
        /// <returns>Identity <c>SparseMatrix</c></returns>
        /// <exception cref="ArgumentException">
        /// If <paramref name="order"/> is less than one.
        /// </exception>
        public static SparseMatrix Identity(int order)
        {
            var storage = new SparseCompressedRowMatrixStorage<Complex32>(order, order)
                {
                    Values = new Complex32[order],
                    ColumnIndices = new int[order]
                };

            for (var i = 0; i < order; i++)
            {
                storage.Values[i] = 1f;
                storage.ColumnIndices[i] = i;
                storage.RowPointers[i] = i;
            }

            storage.RowPointers[order] = order;

            return new SparseMatrix(storage);
        }
开发者ID:TransientResponse,项目名称:mathnet-numerics,代码行数:27,代码来源:SparseMatrix.cs


注:本文中的SparseCompressedRowMatrixStorage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。