Browse Source

Inline docs

optimization-3
Christoph Ruegg 13 years ago
parent
commit
26b30e590a
  1. 1
      src/Numerics/LinearAlgebra/Complex/Solvers/MILU0Preconditioner.cs
  2. 1
      src/Numerics/LinearAlgebra/Complex32/Solvers/MILU0Preconditioner.cs
  3. 1
      src/Numerics/LinearAlgebra/Double/Solvers/MILU0Preconditioner.cs
  4. 1
      src/Numerics/LinearAlgebra/Single/Solvers/MILU0Preconditioner.cs
  5. 6
      src/Numerics/LinearRegression/MultipleRegression.cs
  6. 19
      src/Numerics/LinearRegression/WeightedRegression.cs
  7. 1
      src/Numerics/Precision.Equality.cs

1
src/Numerics/LinearAlgebra/Complex/Solvers/MILU0Preconditioner.cs

@ -170,6 +170,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers
/// <param name="alu">Matrix values in MSR format (output).</param>
/// <param name="jlu">Row pointers and column indices (output).</param>
/// <param name="ju">Pointer to diagonal elements (output).</param>
/// <param name="modified">True if the modified/MILU algorithm should be used (recommended)</param>
/// <returns>Returns 0 on success or k > 0 if a zero pivot was encountered at step k.</returns>
private int Compute(int n, Complex[] a, int[] ja, int[] ia, Complex[] alu, int[] jlu, int[] ju, bool modified)
{

1
src/Numerics/LinearAlgebra/Complex32/Solvers/MILU0Preconditioner.cs

@ -165,6 +165,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
/// <param name="alu">Matrix values in MSR format (output).</param>
/// <param name="jlu">Row pointers and column indices (output).</param>
/// <param name="ju">Pointer to diagonal elements (output).</param>
/// <param name="modified">True if the modified/MILU algorithm should be used (recommended)</param>
/// <returns>Returns 0 on success or k > 0 if a zero pivot was encountered at step k.</returns>
private int Compute(int n, Complex32[] a, int[] ja, int[] ia, Complex32[] alu, int[] jlu, int[] ju, bool modified)
{

1
src/Numerics/LinearAlgebra/Double/Solvers/MILU0Preconditioner.cs

@ -163,6 +163,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
/// <param name="alu">Matrix values in MSR format (output).</param>
/// <param name="jlu">Row pointers and column indices (output).</param>
/// <param name="ju">Pointer to diagonal elements (output).</param>
/// <param name="modified">True if the modified/MILU algorithm should be used (recommended)</param>
/// <returns>Returns 0 on success or k > 0 if a zero pivot was encountered at step k.</returns>
private int Compute(int n, double[] a, int[] ja, int[] ia, double[] alu, int[] jlu, int[] ju, bool modified)
{

1
src/Numerics/LinearAlgebra/Single/Solvers/MILU0Preconditioner.cs

@ -163,6 +163,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
/// <param name="alu">Matrix values in MSR format (output).</param>
/// <param name="jlu">Row pointers and column indices (output).</param>
/// <param name="ju">Pointer to diagonal elements (output).</param>
/// <param name="modified">True if the modified/MILU algorithm should be used (recommended)</param>
/// <returns>Returns 0 on success or k > 0 if a zero pivot was encountered at step k.</returns>
private int Compute(int n, float[] a, int[] ja, int[] ia, float[] alu, int[] jlu, int[] ju, bool modified)
{

6
src/Numerics/LinearRegression/MultipleRegression.cs

@ -53,7 +53,7 @@ namespace MathNet.Numerics.LinearRegression
/// Uses the cholesky decomposition of the normal equations.
/// </summary>
/// <param name="x">Predictor matrix X</param>
/// <param name="y">Response vector Y</param>
/// <param name="y">Response matrix Y</param>
/// <returns>Best fitting vector for model parameters β</returns>
public static Matrix<T> NormalEquations<T>(Matrix<T> x, Matrix<T> y) where T : struct, IEquatable<T>, IFormattable
{
@ -109,7 +109,7 @@ namespace MathNet.Numerics.LinearRegression
/// Uses an orthogonal decomposition and is therefore more numerically stable than the normal equations but also slower.
/// </summary>
/// <param name="x">Predictor matrix X</param>
/// <param name="y">Response vector Y</param>
/// <param name="y">Response matrix Y</param>
/// <returns>Best fitting vector for model parameters β</returns>
public static Matrix<T> QR<T>(Matrix<T> x, Matrix<T> y) where T : struct, IEquatable<T>, IFormattable
{
@ -164,7 +164,7 @@ namespace MathNet.Numerics.LinearRegression
/// Uses a singular value decomposition and is therefore more numerically stable (especially if ill-conditioned) than the normal equations or QR but also slower.
/// </summary>
/// <param name="x">Predictor matrix X</param>
/// <param name="y">Response vector Y</param>
/// <param name="y">Response matrix Y</param>
/// <returns>Best fitting vector for model parameters β</returns>
public static Matrix<T> Svd<T>(Matrix<T> x, Matrix<T> y) where T : struct, IEquatable<T>, IFormattable
{

19
src/Numerics/LinearRegression/WeightedRegression.cs

@ -31,7 +31,6 @@
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.LinearRegression
{
@ -40,6 +39,9 @@ namespace MathNet.Numerics.LinearRegression
/// <summary>
/// Weighted Linear Regression using normal equations.
/// </summary>
/// <param name="x">Predictor matrix X</param>
/// <param name="y">Response vector Y</param>
/// <param name="w">Weight matrix W, usually diagonal with an entry for each predictor (row).</param>
public static Vector<T> Weighted<T>(Matrix<T> x, Vector<T> y, Matrix<T> w) where T : struct, IEquatable<T>, IFormattable
{
return x.TransposeThisAndMultiply(w*x).Cholesky().Solve(x.TransposeThisAndMultiply(w*y));
@ -48,6 +50,9 @@ namespace MathNet.Numerics.LinearRegression
/// <summary>
/// Weighted Linear Regression using normal equations.
/// </summary>
/// <param name="x">Predictor matrix X</param>
/// <param name="y">Response matrix Y</param>
/// <param name="w">Weight matrix W, usually diagonal with an entry for each predictor (row).</param>
public static Matrix<T> Weighted<T>(Matrix<T> x, Matrix<T> y, Matrix<T> w) where T : struct, IEquatable<T>, IFormattable
{
return x.TransposeThisAndMultiply(w*x).Cholesky().Solve(x.TransposeThisAndMultiply(w*y));
@ -56,6 +61,9 @@ namespace MathNet.Numerics.LinearRegression
/// <summary>
/// Weighted Linear Regression using normal equations.
/// </summary>
/// <param name="x">Predictor matrix X</param>
/// <param name="y">Response vector Y</param>
/// <param name="w">Weight matrix W, usually diagonal with an entry for each predictor (row).</param>
/// <param name="intercept">True if an intercept should be added as first artificial perdictor value. Default = false.</param>
public static T[] Weighted<T>(T[][] x, T[] y, T[] w, bool intercept = false) where T : struct, IEquatable<T>, IFormattable
{
@ -72,16 +80,19 @@ namespace MathNet.Numerics.LinearRegression
/// <summary>
/// Weighted Linear Regression using normal equations.
/// </summary>
/// <param name="samples">List of sample vectors (predictor) together with their response.</param>
/// <param name="weights">List of weights, one for each sample.</param>
/// <param name="intercept">True if an intercept should be added as first artificial perdictor value. Default = false.</param>
public static T[] Weighted<T>(IEnumerable<Tuple<T[], T>> samples, T[] w, bool intercept = false) where T : struct, IEquatable<T>, IFormattable
public static T[] Weighted<T>(IEnumerable<Tuple<T[], T>> samples, T[] weights, bool intercept = false) where T : struct, IEquatable<T>, IFormattable
{
var xy = samples.UnpackSinglePass();
return Weighted(xy.Item1, xy.Item2, w, intercept);
return Weighted(xy.Item1, xy.Item2, weights, intercept);
}
/// <summary>
/// Locally-Weighted Linear Regression using normal equations.
/// </summary>
[Obsolete("Warning: This function is here to stay but its signature will likely change.")]
public static Vector<T> Local<T>(Matrix<T> x, Vector<T> y, Vector<T> t, double radius, Func<double, T> kernel) where T : struct, IEquatable<T>, IFormattable
{
// TODO: Weird kernel definition
@ -96,6 +107,7 @@ namespace MathNet.Numerics.LinearRegression
/// <summary>
/// Locally-Weighted Linear Regression using normal equations.
/// </summary>
[Obsolete("Warning: This function is here to stay but its signature will likely change.")]
public static Matrix<T> Local<T>(Matrix<T> x, Matrix<T> y, Vector<T> t, double radius, Func<double, T> kernel) where T : struct, IEquatable<T>, IFormattable
{
// TODO: Weird kernel definition
@ -107,6 +119,7 @@ namespace MathNet.Numerics.LinearRegression
return Weighted(x, y, w);
}
[Obsolete("Warning: This function is here to stay but will likely be refactored and/or moved to another place.")]
public static double GaussianKernel(double normalizedDistance)
{
return Math.Exp(-0.5*normalizedDistance*normalizedDistance);

1
src/Numerics/Precision.Equality.cs

@ -397,6 +397,7 @@ namespace MathNet.Numerics
/// <param name="a">The norm of the first value (can be negative).</param>
/// <param name="b">The norm of the second value (can be negative).</param>
/// <param name="diff">The norm of the difference of the two values (can be negative).</param>
/// <param name="decimalPlaces">The number of decimal places.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="decimalPlaces"/> is smaller than zero.</exception>
public static bool AlmostEqualNormRelative(this double a, double b, double diff, int decimalPlaces)
{

Loading…
Cancel
Save