Ejemplo n.º 1
0
        /// <summary>
        /// Returns the transpose of this matrix.
        /// </summary>
        /// <param name="storage">A value indicating, whether the transpose should be done on storage level (without complex conjugation).</param>
        public CompressedColumnStorage <T> Transpose(bool storage)
        {
            var result = CompressedColumnStorage <T> .Create(columnCount, rowCount, this.NonZerosCount);

            this.Transpose(result, storage);
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sparse matrix multiplication, C = A*B
        /// </summary>
        /// <param name="other">The sparse matrix multiplied to this instance.</param>
        /// <returns>C = A*B</returns>
        public CompressedColumnStorage <T> Multiply(CompressedColumnStorage <T> other)
        {
            int m = this.rows;
            int n = other.ColumnCount;

            var result = CompressedColumnStorage <T> .Create(m, n, this.NonZerosCount + other.NonZerosCount);

            Multiply(other, result);

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds two matrices in CSC format, C = A + B, where A is current instance.
        /// </summary>
        public CompressedColumnStorage <T> Add(CompressedColumnStorage <T> other)
        {
            int m = this.rowCount;
            int n = this.columnCount;

            // check inputs
            if (m != other.RowCount || n != other.ColumnCount)
            {
                throw new ArgumentException(Resources.MatrixDimensions);
            }

            var result = CompressedColumnStorage <T> .Create(m, n, this.NonZerosCount + other.NonZerosCount);

            var one = Helper.OneOf <T>();

            Add(one, one, other, result);

            return(result);
        }