Пример #1
0
 /// <summary>
 /// Performs the following operation for 0 &lt;= j &lt; <see cref="Order"/>, 0 &lt;= i &lt;= j:
 /// result[i, j] = <paramref name="otherCoefficient"/> * <paramref name="otherMatrix"/>[i, j] + this[i, j].
 /// The resulting matrix is written to a new <see cref="TriangularUpper"/> and then returned.
 /// </summary>
 /// <param name="otherMatrix">A matrix with the same <see cref="Order"/> as this <see cref="TriangularUpper"/>
 ///     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 TriangularUpper Axpy(TriangularUpper 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 TriangularUpper(result, NumColumns));
 }
Пример #2
0
 /// <summary>
 /// Performs the following operation for 0 &lt;= j &lt; <see cref="Order"/>, 0 &lt;= i &lt;= j:
 /// 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="TriangularUpper"/> instance.
 /// </summary>
 /// <param name="thisCoefficient">A scalar that multiplies each entry of this <see cref="TriangularUpper"/>.</param>
 /// <param name="otherMatrix">A matrix with the same <see cref="Order"/> as this <see cref="TriangularUpper"/>
 ///     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, TriangularUpper 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;= j &lt; <see cref="Order"/>, 0 &lt;= i &lt;= j:
 /// 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="TriangularUpper"/> and then returned.
 /// </summary>
 /// <param name="thisCoefficient">A scalar that multiplies each entry of this <see cref="TriangularUpper"/>.</param>
 /// <param name="otherMatrix">A matrix with the same <see cref="Order"/> as this <see cref="TriangularUpper"/>
 ///     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 TriangularUpper LinearCombination(double thisCoefficient, TriangularUpper 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 TriangularUpper(result, NumColumns));
 }
Пример #4
0
 /// <summary>
 /// Performs the following operation for 0 &lt;= j &lt; <see cref="Order"/>, 0 &lt;= i &lt;= j:
 /// this[i, j] = <paramref name="otherCoefficient"/> * <paramref name="otherMatrix"/>[i, j] + this[i, j].
 /// The resulting matrix overwrites the entries of this <see cref="TriangularUpper"/> instance.
 /// </summary>
 /// <param name="otherMatrix">A matrix with the same <see cref="Order"/> as this <see cref="TriangularUpper"/>
 ///     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(TriangularUpper otherMatrix, double otherCoefficient)
 {
     Preconditions.CheckSameMatrixDimensions(this, otherMatrix);
     Blas.Daxpy(data.Length, otherCoefficient, otherMatrix.data, 0, 1, this.data, 0, 1);
 }