예제 #1
0
 /// <summary>
 /// Performs the following operation for 0 &lt;= i &lt; <see cref="Order"/>, 0 &lt;= j &lt;= i:
 /// result[i, j] = <paramref name="otherCoefficient"/> * <paramref name="otherMatrix"/>[i, j] + this[i, j].
 /// The resulting matrix is written to a new <see cref="TriangularLower"/> and then returned.
 /// </summary>
 /// <param name="otherMatrix">A matrix with the same <see cref="Order"/> as this <see cref="TriangularLower"/>
 ///     instance.</param>
 /// <param name="otherCoefficient">A scalar that multiplies each entry of <paramref name="otherMatrix"/>.</param>
 /// <exception cref="NonMatchingDimensionsException">Thrown if <paramref name="otherMatrix"/> has different
 ///     <see cref="Order"/> than this instance.</exception>
 public TriangularLower Axpy(TriangularLower otherMatrix, double otherCoefficient)
 {
     Preconditions.CheckSameMatrixDimensions(this, otherMatrix);
     //TODO: Perhaps this should be done using mkl_malloc and BLAS copy.
     double[] result = new double[data.Length];
     Array.Copy(this.data, result, data.Length);
     Blas.Daxpy(data.Length, otherCoefficient, otherMatrix.data, 0, 1, result, 0, 1);
     return(new TriangularLower(result, NumRows));
 }
예제 #2
0
 /// <summary>
 /// Performs the following operation for 0 &lt;= i &lt; <see cref="Order"/>, 0 &lt;= j &lt;= i:
 /// this[i, j] = <paramref name="thisCoefficient"/> * this[i, j]
 ///     + <paramref name="otherCoefficient"/> * <paramref name="otherMatrix"/>[i, j].
 /// The resulting matrix overwrites the entries of this <see cref="TriangularLower"/> instance.
 /// </summary>
 /// <param name="thisCoefficient">A scalar that multiplies each entry of this <see cref="TriangularLower"/>.</param>
 /// <param name="otherMatrix">A matrix with the same <see cref="Order"/> as this <see cref="TriangularLower"/>
 ///     instance.</param>
 /// <param name="otherCoefficient">A scalar that multiplies each entry of <paramref name="otherMatrix"/>.</param>
 /// <exception cref="NonMatchingDimensionsException">Thrown if <paramref name="otherMatrix"/> has different
 ///     <see cref="Order"/> than this instance.</exception>
 public void LinearCombinationIntoThis(double thisCoefficient, TriangularLower otherMatrix, double otherCoefficient)
 {
     Preconditions.CheckSameMatrixDimensions(this, otherMatrix);
     if (thisCoefficient == 1.0)
     {
         Blas.Daxpy(data.Length, otherCoefficient, otherMatrix.data, 0, 1, this.data, 0, 1);
     }
     else
     {
         BlasExtensions.Daxpby(data.Length, otherCoefficient, otherMatrix.data, 0, 1, thisCoefficient, this.data, 0, 1);
     }
 }
예제 #3
0
 /// <summary>
 /// Performs the following operation for 0 &lt;= i &lt; <see cref="Order"/>, 0 &lt;= j &lt;= i:
 /// result[i, j] = <paramref name="thisCoefficient"/> * this[i, j]
 ///     + <paramref name="otherCoefficient"/> * <paramref name="otherMatrix"/>[i, j].
 /// The resulting matrix is written to a new <see cref="TriangularLower"/> and then returned.
 /// </summary>
 /// <param name="thisCoefficient">A scalar that multiplies each entry of this <see cref="TriangularLower"/>.</param>
 /// <param name="otherMatrix">A matrix with the same <see cref="Order"/> as this <see cref="TriangularLower"/>
 ///     instance.</param>
 /// <param name="otherCoefficient">A scalar that multiplies each entry of <paramref name="otherMatrix"/>.</param>
 /// <exception cref="NonMatchingDimensionsException">Thrown if <paramref name="otherMatrix"/> has different
 ///     <see cref="Order"/> than this instance.</exception>
 public TriangularLower LinearCombination(double thisCoefficient, TriangularLower otherMatrix, double otherCoefficient)
 {
     Preconditions.CheckSameMatrixDimensions(this, otherMatrix);
     //TODO: Perhaps this should be done using mkl_malloc and BLAS copy.
     double[] result = new double[data.Length];
     if (thisCoefficient == 1.0)
     {
         Array.Copy(this.data, result, data.Length);
         Blas.Daxpy(data.Length, otherCoefficient, otherMatrix.data, 0, 1, result, 0, 1);
     }
     else if (otherCoefficient == 1.0)
     {
         Array.Copy(otherMatrix.data, result, data.Length);
         Blas.Daxpy(data.Length, thisCoefficient, this.data, 0, 1, result, 0, 1);
     }
     else
     {
         Array.Copy(this.data, result, data.Length);
         BlasExtensions.Daxpby(data.Length, otherCoefficient, otherMatrix.data, 0, 1, thisCoefficient, result, 0, 1);
     }
     return(new TriangularLower(result, NumRows));
 }
예제 #4
0
 /// <summary>
 /// Performs the following operation for 0 &lt;= i &lt; <see cref="Order"/>, 0 &lt;= j &lt;= i:
 /// this[i, j] = <paramref name="otherCoefficient"/> * <paramref name="otherMatrix"/>[i, j] + this[i, j].
 /// The resulting matrix overwrites the entries of this <see cref="TriangularLower"/> instance.
 /// </summary>
 /// <param name="otherMatrix">A matrix with the same <see cref="Order"/> as this <see cref="TriangularLower"/>
 ///     instance.</param>
 /// <param name="otherCoefficient">A scalar that multiplies each entry of <paramref name="otherMatrix"/>.</param>
 /// <exception cref="NonMatchingDimensionsException">Thrown if <paramref name="otherMatrix"/> has different
 ///     <see cref="Order"/> than this instance.</exception>
 public void AxpyIntoThis(TriangularLower otherMatrix, double otherCoefficient)
 {
     Preconditions.CheckSameMatrixDimensions(this, otherMatrix);
     Blas.Daxpy(data.Length, otherCoefficient, otherMatrix.data, 0, 1, this.data, 0, 1);
 }