コード例 #1
0
        /// <summary>
        /// Multiplies the transpose of this matrix with a vector and places the results into the result vector.
        /// </summary>
        /// <param name="rightSide">The vector to multiply with.</param>
        /// <param name="result">The result of the multiplication.</param>
        protected override void DoTransposeThisAndMultiply(Vector <double> rightSide, Vector <double> result)
        {
            var d = Math.Min(ColumnCount, RowCount);

            if (d < ColumnCount)
            {
                result.ClearSubVector(RowCount, ColumnCount - RowCount);
            }

            if (d == RowCount)
            {
                var denseOther  = rightSide.Storage as DenseVectorStorage <double>;
                var denseResult = result.Storage as DenseVectorStorage <double>;
                if (denseOther != null && denseResult != null)
                {
                    for (var j = 0; j < ColumnCount; j++)
                    {
                        var s = 0.0;
                        for (var i = 0; i < RowCount; i++)
                        {
                            s += At(i, j) * rightSide[i];
                        }
                        result[j] = s;
                    }
                    return;
                }
            }

            for (var i = 0; i < d; i++)
            {
                result.At(i, _data[i] * rightSide.At(i));
            }
        }
コード例 #2
0
        /// <summary>
        /// Multiplies the transpose of this matrix with a vector and places the results into the result vector.
        /// </summary>
        /// <param name="rightSide">The vector to multiply with.</param>
        /// <param name="result">The result of the multiplication.</param>
        protected override void DoTransposeThisAndMultiply(Vector <double> rightSide, Vector <double> result)
        {
            var d = Math.Min(ColumnCount, RowCount);

            if (d < ColumnCount)
            {
                result.ClearSubVector(RowCount, ColumnCount - RowCount);
            }

            if (d == RowCount)
            {
                var denseOther  = rightSide.Storage as DenseVectorStorage <double>;
                var denseResult = result.Storage as DenseVectorStorage <double>;
                if (denseOther != null && denseResult != null)
                {
                    Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
                    return;
                }
            }

            for (var i = 0; i < d; i++)
            {
                result.At(i, _data[i] * rightSide.At(i));
            }
        }
コード例 #3
0
        /// <summary>
        /// Multiplies this matrix with a vector and places the results into the result vector.
        /// </summary>
        /// <param name="rightSide">The vector to multiply with.</param>
        /// <param name="result">The result of the multiplication.</param>
        protected override void DoMultiply(Vector <double> rightSide, Vector <double> result)
        {
            var d = Math.Min(ColumnCount, RowCount);

            if (d < RowCount)
            {
                result.ClearSubVector(ColumnCount, RowCount - ColumnCount);
            }

            if (d == ColumnCount)
            {
                if (rightSide.Storage is DenseVectorStorage <double> denseOther && result.Storage is DenseVectorStorage <double> denseResult)
                {
                    LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
                    return;
                }
            }

            for (var i = 0; i < d; i++)
            {
                result.At(i, _data[i] * rightSide.At(i));
            }
        }