/// <summary> /// See <see cref="IMatrixView.MultiplyIntoResult(IVectorView, IVector, bool)"/>. /// </summary> public void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, bool transposeThis = false) { if ((lhsVector is Vector lhsDense) && (rhsVector is Vector rhsDense)) { MultiplyIntoResult(lhsDense, rhsDense, transposeThis); } if (transposeThis) { Preconditions.CheckMultiplicationDimensions(NumRows, lhsVector.Length); Preconditions.CheckSystemSolutionDimensions(NumColumns, rhsVector.Length); CsrMultiplications.CsrTimesVector(NumColumns, values, colOffsets, rowIndices, lhsVector, rhsVector); } else { Preconditions.CheckMultiplicationDimensions(NumColumns, lhsVector.Length); Preconditions.CheckSystemSolutionDimensions(NumRows, rhsVector.Length); CsrMultiplications.CsrTransTimesVector(NumColumns, values, colOffsets, rowIndices, lhsVector, rhsVector); } }
/// <summary> /// See <see cref="IMatrixView.Multiply(IVectorView, bool)"/>. /// </summary> public IVector Multiply(IVectorView vector, bool transposeThis = false) { if (vector is Vector dense) { return(Multiply(dense, transposeThis)); } if (transposeThis) { var result = new double[NumColumns]; Preconditions.CheckMultiplicationDimensions(NumRows, vector.Length); CsrMultiplications.CsrTimesVector(NumColumns, values, colOffsets, rowIndices, vector, result); return(Vector.CreateFromArray(result, false)); } else { var result = new double[NumRows]; Preconditions.CheckMultiplicationDimensions(NumColumns, vector.Length); CsrMultiplications.CsrTransTimesVector(NumColumns, values, colOffsets, rowIndices, vector, result); return(Vector.CreateFromArray(result, false)); } }