Browse Source

LA: pointwise trigonometric functions, static functions (F#, usability)

* Added abstract functions for a bunch of pointwise functions (mainly those defined as operators in F#) in Matrix and Vector and also added implementations for all the subtypes

* Exposed some of the pointwise functions as static members in the Matrix and Vector generic types, so that these can be called from F# as if they are normal mathematical operators

* Removing Sign from static member as it won't work for F# which expects it to return an integer and is different from the pointwise definition.

* Exposed PointwiseLog() and PointwiseExp() as static members Log() and Exp() respectively so that they work with F# mathematical operator syntax

* Looks like op_DotHat is already in.  Reverting to original so as not to overwrite other people's work

* Changing all the newly added pointwise functions with f(0)=0 to use the AllowSkip option in Map so that its more efficient for sparse matrices.

* Fixed one of the PointwiseBinary helpers so that it has protected access

* Filled in comments for all public functions.  Fixed PointwiseBinary to consider both matrices when replicating so that a dense or sparse matrix is created accordingly
v3
Albert Pang 10 years ago
committed by Christoph Ruegg
parent
commit
8d36fb4ce6
  1. 69
      src/Numerics/LinearAlgebra/Complex/Matrix.cs
  2. 73
      src/Numerics/LinearAlgebra/Complex/Vector.cs
  3. 69
      src/Numerics/LinearAlgebra/Complex32/Matrix.cs
  4. 73
      src/Numerics/LinearAlgebra/Complex32/Vector.cs
  5. 69
      src/Numerics/LinearAlgebra/Double/Matrix.cs
  6. 73
      src/Numerics/LinearAlgebra/Double/Vector.cs
  7. 402
      src/Numerics/LinearAlgebra/Matrix.Arithmetic.cs
  8. 170
      src/Numerics/LinearAlgebra/Matrix.Operators.cs
  9. 70
      src/Numerics/LinearAlgebra/Single/Matrix.cs
  10. 73
      src/Numerics/LinearAlgebra/Single/Vector.cs
  11. 436
      src/Numerics/LinearAlgebra/Vector.Arithmetic.cs
  12. 170
      src/Numerics/LinearAlgebra/Vector.Operators.cs

69
src/Numerics/LinearAlgebra/Complex/Matrix.cs

@ -459,6 +459,75 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
Map(Complex.Log, result, Zeros.Include);
}
protected override void DoPointwiseAbs(Matrix<Complex> result)
{
Map(x => (Complex)Complex.Abs(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseAcos(Matrix<Complex> result)
{
Map(Complex.Acos, result, Zeros.Include);
}
protected override void DoPointwiseAsin(Matrix<Complex> result)
{
Map(Complex.Asin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan(Matrix<Complex> result)
{
Map(Complex.Atan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan2(Matrix<Complex> other, Matrix<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseCeiling(Matrix<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseCos(Matrix<Complex> result)
{
Map(Complex.Cos, result, Zeros.Include);
}
protected override void DoPointwiseCosh(Matrix<Complex> result)
{
Map(Complex.Cosh, result, Zeros.Include);
}
protected override void DoPointwiseFloor(Matrix<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseLog10(Matrix<Complex> result)
{
Map(Complex.Log10, result, Zeros.Include);
}
protected override void DoPointwiseRound(Matrix<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseSign(Matrix<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseSin(Matrix<Complex> result)
{
Map(Complex.Sin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSinh(Matrix<Complex> result)
{
Map(Complex.Sinh, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSqrt(Matrix<Complex> result)
{
Map(Complex.Sqrt, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTan(Matrix<Complex> result)
{
Map(Complex.Tan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTanh(Matrix<Complex> result)
{
Map(Complex.Tanh, result, Zeros.AllowSkip);
}
/// <summary>
/// Computes the Moore-Penrose Pseudo-Inverse of this matrix.
/// </summary>

73
src/Numerics/LinearAlgebra/Complex/Vector.cs

@ -254,6 +254,79 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
Map(Complex.Log, result, Zeros.Include);
}
protected override void DoPointwiseAbs(Vector<Complex> result)
{
Map(x => (Complex)Complex.Abs(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseAcos(Vector<Complex> result)
{
Map(Complex.Acos, result, Zeros.Include);
}
protected override void DoPointwiseAsin(Vector<Complex> result)
{
Map(Complex.Asin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan(Vector<Complex> result)
{
Map(Complex.Atan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan2(Vector<Complex> other, Vector<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseAtan2(Complex scalar, Vector<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseCeiling(Vector<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseCos(Vector<Complex> result)
{
Map(Complex.Cos, result, Zeros.Include);
}
protected override void DoPointwiseCosh(Vector<Complex> result)
{
Map(Complex.Cosh, result, Zeros.Include);
}
protected override void DoPointwiseFloor(Vector<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseLog10(Vector<Complex> result)
{
Map(Complex.Log10, result, Zeros.Include);
}
protected override void DoPointwiseRound(Vector<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseSign(Vector<Complex> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseSin(Vector<Complex> result)
{
Map(Complex.Sin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSinh(Vector<Complex> result)
{
Map(Complex.Sinh, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSqrt(Vector<Complex> result)
{
Map(Complex.Sqrt, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTan(Vector<Complex> result)
{
Map(Complex.Tan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTanh(Vector<Complex> result)
{
Map(Complex.Tanh, result, Zeros.AllowSkip);
}
/// <summary>
/// Computes the dot product between this vector and another vector.
/// </summary>

69
src/Numerics/LinearAlgebra/Complex32/Matrix.cs

@ -454,6 +454,75 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
Map(Complex32.Log, result, Zeros.Include);
}
protected override void DoPointwiseAbs(Matrix<Complex32> result)
{
Map(x => (Complex32)Complex32.Abs(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseAcos(Matrix<Complex32> result)
{
Map(Complex32.Acos, result, Zeros.Include);
}
protected override void DoPointwiseAsin(Matrix<Complex32> result)
{
Map(Complex32.Asin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan(Matrix<Complex32> result)
{
Map(Complex32.Atan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan2(Matrix<Complex32> other, Matrix<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseCeiling(Matrix<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseCos(Matrix<Complex32> result)
{
Map(Complex32.Cos, result, Zeros.Include);
}
protected override void DoPointwiseCosh(Matrix<Complex32> result)
{
Map(Complex32.Cosh, result, Zeros.Include);
}
protected override void DoPointwiseFloor(Matrix<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseLog10(Matrix<Complex32> result)
{
Map(Complex32.Log10, result, Zeros.Include);
}
protected override void DoPointwiseRound(Matrix<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseSign(Matrix<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseSin(Matrix<Complex32> result)
{
Map(Complex32.Sin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSinh(Matrix<Complex32> result)
{
Map(Complex32.Sinh, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSqrt(Matrix<Complex32> result)
{
Map(Complex32.Sqrt, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTan(Matrix<Complex32> result)
{
Map(Complex32.Tan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTanh(Matrix<Complex32> result)
{
Map(Complex32.Tanh, result, Zeros.AllowSkip);
}
/// <summary>
/// Computes the Moore-Penrose Pseudo-Inverse of this matrix.
/// </summary>

73
src/Numerics/LinearAlgebra/Complex32/Vector.cs

@ -249,6 +249,79 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
Map(Complex32.Log, result, Zeros.Include);
}
protected override void DoPointwiseAbs(Vector<Complex32> result)
{
Map(x => (Complex32)Complex32.Abs(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseAcos(Vector<Complex32> result)
{
Map(Complex32.Acos, result, Zeros.Include);
}
protected override void DoPointwiseAsin(Vector<Complex32> result)
{
Map(Complex32.Asin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan(Vector<Complex32> result)
{
Map(Complex32.Atan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan2(Vector<Complex32> other, Vector<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseAtan2(Complex32 scalar, Vector<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseCeiling(Vector<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseCos(Vector<Complex32> result)
{
Map(Complex32.Cos, result, Zeros.Include);
}
protected override void DoPointwiseCosh(Vector<Complex32> result)
{
Map(Complex32.Cosh, result, Zeros.Include);
}
protected override void DoPointwiseFloor(Vector<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseLog10(Vector<Complex32> result)
{
Map(Complex32.Log10, result, Zeros.Include);
}
protected override void DoPointwiseRound(Vector<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseSign(Vector<Complex32> result)
{
throw new NotSupportedException();
}
protected override void DoPointwiseSin(Vector<Complex32> result)
{
Map(Complex32.Sin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSinh(Vector<Complex32> result)
{
Map(Complex32.Sinh, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSqrt(Vector<Complex32> result)
{
Map(Complex32.Sqrt, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTan(Vector<Complex32> result)
{
Map(Complex32.Tan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTanh(Vector<Complex32> result)
{
Map(Complex32.Tanh, result, Zeros.AllowSkip);
}
/// <summary>
/// Computes the dot product between this vector and another vector.
/// </summary>

69
src/Numerics/LinearAlgebra/Double/Matrix.cs

@ -424,6 +424,75 @@ namespace MathNet.Numerics.LinearAlgebra.Double
Map(Math.Log, result, Zeros.Include);
}
protected override void DoPointwiseAbs(Matrix<double> result)
{
Map(Math.Abs, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAcos(Matrix<double> result)
{
Map(Math.Acos, result, Zeros.Include);
}
protected override void DoPointwiseAsin(Matrix<double> result)
{
Map(Math.Asin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan(Matrix<double> result)
{
Map(Math.Atan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan2(Matrix<double> other, Matrix<double> result)
{
Map2(Math.Atan2, other, result, Zeros.Include);
}
protected override void DoPointwiseCeiling(Matrix<double> result)
{
Map(Math.Ceiling, result, Zeros.AllowSkip);
}
protected override void DoPointwiseCos(Matrix<double> result)
{
Map(Math.Cos, result, Zeros.Include);
}
protected override void DoPointwiseCosh(Matrix<double> result)
{
Map(Math.Cosh, result, Zeros.Include);
}
protected override void DoPointwiseFloor(Matrix<double> result)
{
Map(Math.Floor, result, Zeros.AllowSkip);
}
protected override void DoPointwiseLog10(Matrix<double> result)
{
Map(Math.Log10, result, Zeros.Include);
}
protected override void DoPointwiseRound(Matrix<double> result)
{
Map(Math.Round, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSign(Matrix<double> result)
{
Map(x => (double)Math.Sign(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseSin(Matrix<double> result)
{
Map(Math.Sin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSinh(Matrix<double> result)
{
Map(Math.Sinh, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSqrt(Matrix<double> result)
{
Map(Math.Sqrt, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTan(Matrix<double> result)
{
Map(Math.Tan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTanh(Matrix<double> result)
{
Map(Math.Tanh, result, Zeros.AllowSkip);
}
/// <summary>
/// Computes the Moore-Penrose Pseudo-Inverse of this matrix.
/// </summary>

73
src/Numerics/LinearAlgebra/Double/Vector.cs

@ -252,6 +252,79 @@ namespace MathNet.Numerics.LinearAlgebra.Double
Map(Math.Log, result, Zeros.Include);
}
protected override void DoPointwiseAbs(Vector<double> result)
{
Map(Math.Abs, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAcos(Vector<double> result)
{
Map(Math.Acos, result, Zeros.Include);
}
protected override void DoPointwiseAsin(Vector<double> result)
{
Map(Math.Asin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan(Vector<double> result)
{
Map(Math.Atan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan2(Vector<double> other, Vector<double> result)
{
Map2(Math.Atan2, other, result, Zeros.Include);
}
protected override void DoPointwiseAtan2(double scalar, Vector<double> result)
{
Map(x => Math.Atan2(x, scalar), result, Zeros.Include);
}
protected override void DoPointwiseCeiling(Vector<double> result)
{
Map(Math.Ceiling, result, Zeros.AllowSkip);
}
protected override void DoPointwiseCos(Vector<double> result)
{
Map(Math.Cos, result, Zeros.Include);
}
protected override void DoPointwiseCosh(Vector<double> result)
{
Map(Math.Cosh, result, Zeros.Include);
}
protected override void DoPointwiseFloor(Vector<double> result)
{
Map(Math.Floor, result, Zeros.AllowSkip);
}
protected override void DoPointwiseLog10(Vector<double> result)
{
Map(Math.Log10, result, Zeros.Include);
}
protected override void DoPointwiseRound(Vector<double> result)
{
Map(Math.Round, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSign(Vector<double> result)
{
Map(x => (double)Math.Sign(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseSin(Vector<double> result)
{
Map(Math.Sin, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSinh(Vector<double> result)
{
Map(Math.Sinh, result, Zeros.AllowSkip);
}
protected override void DoPointwiseSqrt(Vector<double> result)
{
Map(Math.Sqrt, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTan(Vector<double> result)
{
Map(Math.Tan, result, Zeros.AllowSkip);
}
protected override void DoPointwiseTanh(Vector<double> result)
{
Map(Math.Tanh, result, Zeros.AllowSkip);
}
/// <summary>
/// Computes the dot product between this vector and another vector.
/// </summary>

402
src/Numerics/LinearAlgebra/Matrix.Arithmetic.cs

@ -265,6 +265,23 @@ namespace MathNet.Numerics.LinearAlgebra
/// <param name="result">The matrix to store the result.</param>
protected abstract void DoPointwiseLog(Matrix<T> result);
protected abstract void DoPointwiseAbs(Matrix<T> result);
protected abstract void DoPointwiseAcos(Matrix<T> result);
protected abstract void DoPointwiseAsin(Matrix<T> result);
protected abstract void DoPointwiseAtan(Matrix<T> result);
protected abstract void DoPointwiseCeiling(Matrix<T> result);
protected abstract void DoPointwiseCos(Matrix<T> result);
protected abstract void DoPointwiseCosh(Matrix<T> result);
protected abstract void DoPointwiseFloor(Matrix<T> result);
protected abstract void DoPointwiseLog10(Matrix<T> result);
protected abstract void DoPointwiseRound(Matrix<T> result);
protected abstract void DoPointwiseSign(Matrix<T> result);
protected abstract void DoPointwiseSin(Matrix<T> result);
protected abstract void DoPointwiseSinh(Matrix<T> result);
protected abstract void DoPointwiseSqrt(Matrix<T> result);
protected abstract void DoPointwiseTan(Matrix<T> result);
protected abstract void DoPointwiseTanh(Matrix<T> result);
protected abstract void DoPointwiseAtan2(Matrix<T> other, Matrix<T> result);
protected abstract void DoPointwiseMinimum(T scalar, Matrix<T> result);
protected abstract void DoPointwiseMinimum(Matrix<T> other, Matrix<T> result);
protected abstract void DoPointwiseMaximum(T scalar, Matrix<T> result);
@ -1512,28 +1529,92 @@ namespace MathNet.Numerics.LinearAlgebra
}
/// <summary>
/// Pointwise applies the exponent function to each value.
/// Helper function to apply a unary function to a matrix. The function
/// f modifies the matrix given to it in place. Before its
/// called, a copy of the 'this' matrix is first created, then passed to
/// f. The copy is then returned as the result
/// </summary>
public Matrix<T> PointwiseExp()
/// <param name="f">Function which takes a matrix, modifies it in place and returns void</param>
/// <returns>New instance of matrix which is the result</returns>
protected Matrix<T> PointwiseUnary(Action<Matrix<T>> f)
{
var result = Build.SameAs(this);
DoPointwiseExp(result);
f(result);
return result;
}
/// <summary>
/// Pointwise applies the exponent function to each value.
/// Helper function to apply a unary function which modifies a matrix
/// in place.
/// </summary>
/// <param name="result">The matrix to store the result.</param>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void PointwiseExp(Matrix<T> result)
/// <param name="f">Function which takes a matrix, modifies it in place and returns void</param>
/// <param name="result">The matrix to be passed to f and where the result is to be stored</param>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
protected void PointwiseUnary(Action<Matrix<T>> f, Matrix<T> result)
{
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, result);
}
f(result);
}
/// <summary>
/// Helper function to apply a binary function which takes two matrices
/// and modifies the latter in place. A copy of the "this" matrix is
/// first made and then passed to f together with the other matrix. The
/// copy is then returned as the result
/// </summary>
/// <param name="f">Function which takes two matrices, modifies the second in place and returns void</param>
/// <param name="other">The other matrix to be passed to the function as argument. It is not modified</param>
/// <returns>The resulting matrix</returns>
/// <exception cref="ArgumentException">If this amtrix and <paramref name="result"/> are not the same dimension.</exception>
protected Matrix<T> PointwiseBinary(Action<Matrix<T>, Matrix<T>> f, Matrix<T> other)
{
if (ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var result = Build.SameAs(this, other);
f(other, result);
return result;
}
/// <summary>
/// Helper function to apply a binary function which takes two matrices
/// and modifies the second one in place
/// </summary>
/// <param name="f">Function which takes two matrices, modifies the second in place and returns void</param>
/// <param name="other">The other matrix to be passed to the function as argument. It is not modified</param>
/// <returns>The resulting matrix</returns>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same dimension.</exception>
protected void PointwiseBinary(Action<Matrix<T>,Matrix<T>> f, Matrix<T> other, Matrix<T> result)
{
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
DoPointwiseExp(result);
f(other, result);
}
/// <summary>
/// Pointwise applies the exponent function to each value.
/// </summary>
public Matrix<T> PointwiseExp()
{
return PointwiseUnary(DoPointwiseExp);
}
/// <summary>
/// Pointwise applies the exponent function to each value.
/// </summary>
/// <param name="result">The matrix to store the result.</param>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void PointwiseExp(Matrix<T> result)
{
PointwiseUnary(DoPointwiseExp, result);
}
/// <summary>
@ -1541,9 +1622,7 @@ namespace MathNet.Numerics.LinearAlgebra
/// </summary>
public Matrix<T> PointwiseLog()
{
var result = Build.SameAs(this);
DoPointwiseLog(result);
return result;
return PointwiseUnary(DoPointwiseLog);
}
/// <summary>
@ -1553,12 +1632,303 @@ namespace MathNet.Numerics.LinearAlgebra
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void PointwiseLog(Matrix<T> result)
{
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, result);
}
PointwiseUnary(DoPointwiseLog, result);
}
/// <summary>
/// Pointwise applies the abs function to each value
/// </summary>
public Matrix<T> PointwiseAbs()
{
return PointwiseUnary(DoPointwiseAbs);
}
/// <summary>
/// Pointwise applies the abs function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseAbs(Matrix<T> result)
{
PointwiseUnary(DoPointwiseAbs, result);
}
/// <summary>
/// Pointwise applies the acos function to each value
/// </summary>
public Matrix<T> PointwiseAcos()
{
return PointwiseUnary(DoPointwiseAcos);
}
/// <summary>
/// Pointwise applies the acos function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseAcos(Matrix<T> result)
{
PointwiseUnary(DoPointwiseAcos, result);
}
/// <summary>
/// Pointwise applies the asin function to each value
/// </summary>
public Matrix<T> PointwiseAsin()
{
return PointwiseUnary(DoPointwiseAsin);
}
DoPointwiseLog(result);
/// <summary>
/// Pointwise applies the asin function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseAsin(Matrix<T> result)
{
PointwiseUnary(DoPointwiseAsin, result);
}
/// <summary>
/// Pointwise applies the atan function to each value
/// </summary>
public Matrix<T> PointwiseAtan()
{
return PointwiseUnary(DoPointwiseAtan);
}
/// <summary>
/// Pointwise applies the atan function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseAtan(Matrix<T> result)
{
PointwiseUnary(DoPointwiseAtan, result);
}
/// <summary>
/// Pointwise applies the atan2 function to each value of the current
/// matrix and a given other matrix being the 'x' of atan2 and the
/// 'this' matrix being the 'y'
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public Matrix<T> PointwiseAtan2(Matrix<T> other)
{
return PointwiseBinary(DoPointwiseAtan2, other);
}
/// <summary>
/// Pointwise applies the atan2 function to each value of the current
/// matrix and a given other matrix being the 'x' of atan2 and the
/// 'this' matrix being the 'y'
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public void PointwiseAtan2(Matrix<T> other, Matrix<T> result)
{
PointwiseBinary(DoPointwiseAtan2, other, result);
}
/// <summary>
/// Pointwise applies the ceiling function to each value
/// </summary>
public Matrix<T> PointwiseCeiling()
{
return PointwiseUnary(DoPointwiseCeiling);
}
/// <summary>
/// Pointwise applies the ceiling function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseCeiling(Matrix<T> result)
{
PointwiseUnary(DoPointwiseCeiling, result);
}
/// <summary>
/// Pointwise applies the cos function to each value
/// </summary>
public Matrix<T> PointwiseCos()
{
return PointwiseUnary(DoPointwiseCos);
}
/// <summary>
/// Pointwise applies the cos function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseCos(Matrix<T> result)
{
PointwiseUnary(DoPointwiseCos, result);
}
/// <summary>
/// Pointwise applies the cosh function to each value
/// </summary>
public Matrix<T> PointwiseCosh()
{
return PointwiseUnary(DoPointwiseCosh);
}
/// <summary>
/// Pointwise applies the cosh function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseCosh(Matrix<T> result)
{
PointwiseUnary(DoPointwiseCosh, result);
}
/// <summary>
/// Pointwise applies the floor function to each value
/// </summary>
public Matrix<T> PointwiseFloor()
{
return PointwiseUnary(DoPointwiseFloor);
}
/// <summary>
/// Pointwise applies the floor function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseFloor(Matrix<T> result)
{
PointwiseUnary(DoPointwiseFloor, result);
}
/// <summary>
/// Pointwise applies the log10 function to each value
/// </summary>
public Matrix<T> PointwiseLog10()
{
return PointwiseUnary(DoPointwiseLog10);
}
/// <summary>
/// Pointwise applies the log10 function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseLog10(Matrix<T> result)
{
PointwiseUnary(DoPointwiseLog10, result);
}
/// <summary>
/// Pointwise applies the round function to each value
/// </summary>
public Matrix<T> PointwiseRound()
{
return PointwiseUnary(DoPointwiseRound);
}
/// <summary>
/// Pointwise applies the round function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseRound(Matrix<T> result)
{
PointwiseUnary(DoPointwiseRound, result);
}
/// <summary>
/// Pointwise applies the sign function to each value
/// </summary>
public Matrix<T> PointwiseSign()
{
return PointwiseUnary(DoPointwiseSign);
}
/// <summary>
/// Pointwise applies the sign function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseSign(Matrix<T> result)
{
PointwiseUnary(DoPointwiseSign, result);
}
/// <summary>
/// Pointwise applies the sin function to each value
/// </summary>
public Matrix<T> PointwiseSin()
{
return PointwiseUnary(DoPointwiseSin);
}
/// <summary>
/// Pointwise applies the sin function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseSin(Matrix<T> result)
{
PointwiseUnary(DoPointwiseSin, result);
}
/// <summary>
/// Pointwise applies the sinh function to each value
/// </summary>
public Matrix<T> PointwiseSinh()
{
return PointwiseUnary(DoPointwiseSinh);
}
/// <summary>
/// Pointwise applies the sinh function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseSinh(Matrix<T> result)
{
PointwiseUnary(DoPointwiseSinh, result);
}
/// <summary>
/// Pointwise applies the sqrt function to each value
/// </summary>
public Matrix<T> PointwiseSqrt()
{
return PointwiseUnary(DoPointwiseSqrt);
}
/// <summary>
/// Pointwise applies the sqrt function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseSqrt(Matrix<T> result)
{
PointwiseUnary(DoPointwiseSqrt, result);
}
/// <summary>
/// Pointwise applies the tan function to each value
/// </summary>
public Matrix<T> PointwiseTan()
{
return PointwiseUnary(DoPointwiseTan);
}
/// <summary>
/// Pointwise applies the tan function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseTan(Matrix<T> result)
{
PointwiseUnary(DoPointwiseTan, result);
}
/// <summary>
/// Pointwise applies the tanh function to each value
/// </summary>
public Matrix<T> PointwiseTanh()
{
return PointwiseUnary(DoPointwiseTanh);
}
/// <summary>
/// Pointwise applies the tanh function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseTanh(Matrix<T> result)
{
PointwiseUnary(DoPointwiseTanh, result);
}
/// <summary>

170
src/Numerics/LinearAlgebra/Matrix.Operators.cs

@ -305,5 +305,175 @@ namespace MathNet.Numerics.LinearAlgebra
{
return matrix.PointwisePower(exponent);
}
/// <summary>
/// Computes the log of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Log(Matrix<T> x)
{
return x.PointwiseLog();
}
/// <summary>
/// Computes the exponential of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Exp(Matrix<T> x)
{
return x.PointwiseExp();
}
/// <summary>
/// Computes the absolute value of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Abs(Matrix<T> x)
{
return x.PointwiseAbs();
}
/// <summary>
/// Computes the acos of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Acos(Matrix<T> x)
{
return x.PointwiseAcos();
}
/// <summary>
/// Computes the asin of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Asin(Matrix<T> x)
{
return x.PointwiseAsin();
}
/// <summary>
/// Computes the atan of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Atan(Matrix<T> x)
{
return x.PointwiseAtan();
}
/// <summary>
/// Computes the ceiling of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Ceiling(Matrix<T> x)
{
return x.PointwiseCeiling();
}
/// <summary>
/// Computes the cos of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Cos(Matrix<T> x)
{
return x.PointwiseCos();
}
/// <summary>
/// Computes the cosh of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Cosh(Matrix<T> x)
{
return x.PointwiseCosh();
}
/// <summary>
/// Computes the floor of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Floor(Matrix<T> x)
{
return x.PointwiseFloor();
}
/// <summary>
/// Computes the log10 of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Log10(Matrix<T> x)
{
return x.PointwiseLog10();
}
/// <summary>
/// Computes the rounded value of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Round(Matrix<T> x)
{
return x.PointwiseRound();
}
/// <summary>
/// Computes the sin of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Sin(Matrix<T> x)
{
return x.PointwiseSin();
}
/// <summary>
/// Computes the sinh of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Sinh(Matrix<T> x)
{
return x.PointwiseSinh();
}
/// <summary>
/// Computes the sqrt of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Sqrt(Matrix<T> x)
{
return x.PointwiseSqrt();
}
/// <summary>
/// Computes the tan of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Tan(Matrix<T> x)
{
return x.PointwiseTan();
}
/// <summary>
/// Computes the tanh of a matrix pointwise
/// </summary>
/// <param name="x">The input matrix</param>
/// <returns></returns>
public static Matrix<T> Tanh(Matrix<T> x)
{
return x.PointwiseTanh();
}
}
}

70
src/Numerics/LinearAlgebra/Single/Matrix.cs

@ -424,6 +424,76 @@ namespace MathNet.Numerics.LinearAlgebra.Single
Map(x => (float)Math.Log(x), result, Zeros.Include);
}
protected override void DoPointwiseAbs(Matrix<float> result)
{
Map(x => (float)Math.Abs(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseAcos(Matrix<float> result)
{
Map(x => (float)Math.Acos(x), result, Zeros.Include);
}
protected override void DoPointwiseAsin(Matrix<float> result)
{
Map(x => (float)Math.Asin(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan(Matrix<float> result)
{
Map(x => (float)Math.Atan(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan2(Matrix<float> other, Matrix<float> result)
{
Map2((x, y) => (float)Math.Atan2((double)x, (double)y), other, result, Zeros.Include);
}
protected override void DoPointwiseCeiling(Matrix<float> result)
{
Map(x => (float)Math.Ceiling(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseCos(Matrix<float> result)
{
Map(x => (float)Math.Cos(x), result, Zeros.Include);
}
protected override void DoPointwiseCosh(Matrix<float> result)
{
Map(x => (float)Math.Cosh(x), result, Zeros.Include);
}
protected override void DoPointwiseFloor(Matrix<float> result)
{
Map(x => (float)Math.Floor(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseLog10(Matrix<float> result)
{
Map(x => (float)Math.Log10(x), result, Zeros.Include);
}
protected override void DoPointwiseRound(Matrix<float> result)
{
Map(x => (float)Math.Round(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseSign(Matrix<float> result)
{
Map(x => (float)Math.Sign(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseSin(Matrix<float> result)
{
Map(x => (float)Math.Sin(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseSinh(Matrix<float> result)
{
Map(x => (float)Math.Sinh(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseSqrt(Matrix<float> result)
{
Map(x => (float)Math.Sqrt(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseTan(Matrix<float> result)
{
Map(x => (float)Math.Tan(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseTanh(Matrix<float> result)
{
Map(x => (float)Math.Tanh(x), result, Zeros.AllowSkip);
}
/// <summary>
/// Computes the Moore-Penrose Pseudo-Inverse of this matrix.
/// </summary>

73
src/Numerics/LinearAlgebra/Single/Vector.cs

@ -252,6 +252,79 @@ namespace MathNet.Numerics.LinearAlgebra.Single
Map(x => (float)Math.Log(x), result, Zeros.Include);
}
protected override void DoPointwiseAbs(Vector<float> result)
{
Map(x => (float)Math.Abs(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseAcos(Vector<float> result)
{
Map(x => (float)Math.Acos(x), result, Zeros.Include);
}
protected override void DoPointwiseAsin(Vector<float> result)
{
Map(x => (float)Math.Asin(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan(Vector<float> result)
{
Map(x => (float)Math.Atan(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseAtan2(Vector<float> other, Vector<float> result)
{
Map2((x, y) => (float)Math.Atan2((double)x, (double)y), other, result, Zeros.Include);
}
protected override void DoPointwiseAtan2(float scalar, Vector<float> result)
{
Map(x => (float)Math.Atan2((double)x, (double)scalar), result, Zeros.Include);
}
protected override void DoPointwiseCeiling(Vector<float> result)
{
Map(x => (float)Math.Ceiling(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseCos(Vector<float> result)
{
Map(x => (float)Math.Cos(x), result, Zeros.Include);
}
protected override void DoPointwiseCosh(Vector<float> result)
{
Map(x => (float)Math.Cosh(x), result, Zeros.Include);
}
protected override void DoPointwiseFloor(Vector<float> result)
{
Map(x => (float)Math.Floor(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseLog10(Vector<float> result)
{
Map(x => (float)Math.Log10(x), result, Zeros.Include);
}
protected override void DoPointwiseRound(Vector<float> result)
{
Map(x => (float)Math.Round(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseSign(Vector<float> result)
{
Map(x => (float)Math.Sign(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseSin(Vector<float> result)
{
Map(x => (float)Math.Sin(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseSinh(Vector<float> result)
{
Map(x => (float)Math.Sinh(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseSqrt(Vector<float> result)
{
Map(x => (float)Math.Sqrt(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseTan(Vector<float> result)
{
Map(x => (float)Math.Tan(x), result, Zeros.AllowSkip);
}
protected override void DoPointwiseTanh(Vector<float> result)
{
Map(x => (float)Math.Tanh(x), result, Zeros.AllowSkip);
}
/// <summary>
/// Computes the dot product between this vector and another vector.
/// </summary>

436
src/Numerics/LinearAlgebra/Vector.Arithmetic.cs

@ -233,6 +233,24 @@ namespace MathNet.Numerics.LinearAlgebra
/// <param name="result">The vector to store the result.</param>
protected abstract void DoPointwiseLog(Vector<T> result);
protected abstract void DoPointwiseAbs(Vector<T> result);
protected abstract void DoPointwiseAcos(Vector<T> result);
protected abstract void DoPointwiseAsin(Vector<T> result);
protected abstract void DoPointwiseAtan(Vector<T> result);
protected abstract void DoPointwiseCeiling(Vector<T> result);
protected abstract void DoPointwiseCos(Vector<T> result);
protected abstract void DoPointwiseCosh(Vector<T> result);
protected abstract void DoPointwiseFloor(Vector<T> result);
protected abstract void DoPointwiseLog10(Vector<T> result);
protected abstract void DoPointwiseRound(Vector<T> result);
protected abstract void DoPointwiseSign(Vector<T> result);
protected abstract void DoPointwiseSin(Vector<T> result);
protected abstract void DoPointwiseSinh(Vector<T> result);
protected abstract void DoPointwiseSqrt(Vector<T> result);
protected abstract void DoPointwiseTan(Vector<T> result);
protected abstract void DoPointwiseTanh(Vector<T> result);
protected abstract void DoPointwiseAtan2(Vector<T> other, Vector<T> result);
protected abstract void DoPointwiseAtan2(T scalar, Vector<T> result);
protected abstract void DoPointwiseMinimum(T scalar, Vector<T> result);
protected abstract void DoPointwiseMinimum(Vector<T> other, Vector<T> result);
protected abstract void DoPointwiseMaximum(T scalar, Vector<T> result);
@ -957,53 +975,443 @@ namespace MathNet.Numerics.LinearAlgebra
}
/// <summary>
/// Pointwise applies the exponent function to each value.
/// Helper function to apply a unary function to a vector. The function
/// f modifies the vector given to it in place. Before its
/// called, a copy of the 'this' vector with the same dimension is
/// first created, then passed to f. The copy is returned as the result
/// </summary>
public Vector<T> PointwiseExp()
/// <param name="f">Function which takes a vector, modifies it in place and returns void</param>
/// <returns>New instance of vector which is the result</returns>
protected Vector<T> PointwiseUnary(Action<Vector<T>> f)
{
var result = Build.SameAs(this);
DoPointwiseExp(result);
f(result);
return result;
}
/// <summary>
/// Pointwise applies the exponent function to each value.
/// Helper function to apply a unary function which modifies a vector
/// in place.
/// </summary>
/// <param name="result">The vector to store the result.</param>
/// <param name="f">Function which takes a vector, modifies it in place and returns void</param>
/// <param name="result">The vector where the result is to be stored</param>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void PointwiseExp(Vector<T> result)
protected void PointwiseUnary(Action<Vector<T>> f, Vector<T> result)
{
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
}
DoPointwiseExp(result);
f(result);
}
/// <summary>
/// Pointwise applies the natural logarithm function to each value.
/// Helper function to apply a binary function which takes a scalar and
/// a vector and modifies the latter in place. A copy of the "this"
/// vector is therefore first made and then passed to f together with
/// the scalar argument. The copy is then returned as the result
/// </summary>
public Vector<T> PointwiseLog()
/// <param name="f">Function which takes a scalar and a vector, modifies the vector in place and returns void</param>
/// <param name="x">The scalar to be passed to the function</param>
/// <returns>The resulting vector</returns>
protected Vector<T> PointwiseBinary(Action<T, Vector<T>> f, T other)
{
var result = Build.SameAs(this);
DoPointwiseLog(result);
f(other, result);
return result;
}
/// <summary>
/// Pointwise applies the natural logarithm function to each value.
/// Helper function to apply a binary function which takes a scalar and
/// a vector, modifies the latter in place and returns void.
/// </summary>
/// <param name="result">The vector to store the result.</param>
/// <param name="f">Function which takes a scalar and a vector, modifies the vector in place and returns void</param>
/// <param name="x">The scalar to be passed to the function</param>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void PointwiseLog(Vector<T> result)
protected void PointwiseBinary(Action<T, Vector<T>> f, T x, Vector<T> result)
{
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
}
f(x, result);
}
/// <summary>
/// Helper function to apply a binary function which takes two vectors
/// and modifies the latter in place. A copy of the "this" vector is
/// first made and then passed to f together with the other vector. The
/// copy is then returned as the result
/// </summary>
/// <param name="f">Function which takes two vectors, modifies the second in place and returns void</param>
/// <param name="other">The other vector to be passed to the function as argument. It is not modified</param>
/// <returns>The resulting vector</returns>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
protected Vector<T> PointwiseBinary(Action<Vector<T>, Vector<T>> f, Vector<T> other)
{
if (Count != other.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other");
}
var result = Build.SameAs(this, other);
f(other, result);
return result;
}
/// <summary>
/// Helper function to apply a binary function which takes two vectors
/// and modifies the second one in place
/// </summary>
/// <param name="f">Function which takes two vectors, modifies the second in place and returns void</param>
/// <param name="other">The other vector to be passed to the function as argument. It is not modified</param>
/// <returns>The resulting vector</returns>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
protected void PointwiseBinary(Action<Vector<T>, Vector<T>> f, Vector<T> other, Vector<T> result)
{
if (Count != other.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
}
f(other, result);
}
/// <summary>
/// Pointwise applies the exponent function to each value.
/// </summary>
public Vector<T> PointwiseExp()
{
return PointwiseUnary(DoPointwiseExp);
}
/// <summary>
/// Pointwise applies the exponent function to each value.
/// </summary>
/// <param name="result">The vector to store the result.</param>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void PointwiseExp(Vector<T> result)
{
PointwiseUnary(DoPointwiseExp, result);
}
/// <summary>
/// Pointwise applies the natural logarithm function to each value.
/// </summary>
public Vector<T> PointwiseLog()
{
return PointwiseUnary(DoPointwiseLog);
}
/// <summary>
/// Pointwise applies the natural logarithm function to each value.
/// </summary>
/// <param name="result">The vector to store the result.</param>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void PointwiseLog(Vector<T> result)
{
PointwiseUnary(DoPointwiseLog, result);
}
/// <summary>
/// Pointwise applies the abs function to each value
/// </summary>
public Vector<T> PointwiseAbs()
{
return PointwiseUnary(DoPointwiseAbs);
}
/// <summary>
/// Pointwise applies the abs function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseAbs(Vector<T> result)
{
PointwiseUnary(DoPointwiseAbs, result);
}
/// <summary>
/// Pointwise applies the acos function to each value
/// </summary>
public Vector<T> PointwiseAcos()
{
return PointwiseUnary(DoPointwiseAcos);
}
/// <summary>
/// Pointwise applies the acos function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseAcos(Vector<T> result)
{
PointwiseUnary(DoPointwiseAcos, result);
}
/// <summary>
/// Pointwise applies the asin function to each value
/// </summary>
public Vector<T> PointwiseAsin()
{
return PointwiseUnary(DoPointwiseAsin);
}
/// <summary>
/// Pointwise applies the asin function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseAsin(Vector<T> result)
{
PointwiseUnary(DoPointwiseAsin, result);
}
/// <summary>
/// Pointwise applies the atan function to each value
/// </summary>
public Vector<T> PointwiseAtan()
{
return PointwiseUnary(DoPointwiseAtan);
}
/// <summary>
/// Pointwise applies the atan function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseAtan(Vector<T> result)
{
PointwiseUnary(DoPointwiseAtan, result);
}
DoPointwiseLog(result);
/// <summary>
/// Pointwise applies the atan2 function to each value of the current
/// vector and a given other vector being the 'x' of atan2 and the
/// 'this' vector being the 'y'
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public Vector<T> PointwiseAtan2(Vector<T> other)
{
return PointwiseBinary(DoPointwiseAtan2, other);
}
/// <summary>
/// Pointwise applies the atan2 function to each value of the current
/// vector and a given other vector being the 'x' of atan2 and the
/// 'this' vector being the 'y'
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public void PointwiseAtan2(Vector<T> other, Vector<T> result)
{
PointwiseBinary(DoPointwiseAtan2, other, result);
}
/// <summary>
/// Pointwise applies the ceiling function to each value
/// </summary>
public Vector<T> PointwiseCeiling()
{
return PointwiseUnary(DoPointwiseCeiling);
}
/// <summary>
/// Pointwise applies the ceiling function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseCeiling(Vector<T> result)
{
PointwiseUnary(DoPointwiseCeiling, result);
}
/// <summary>
/// Pointwise applies the cos function to each value
/// </summary>
public Vector<T> PointwiseCos()
{
return PointwiseUnary(DoPointwiseCos);
}
/// <summary>
/// Pointwise applies the cos function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseCos(Vector<T> result)
{
PointwiseUnary(DoPointwiseCos, result);
}
/// <summary>
/// Pointwise applies the cosh function to each value
/// </summary>
public Vector<T> PointwiseCosh()
{
return PointwiseUnary(DoPointwiseCosh);
}
/// <summary>
/// Pointwise applies the cosh function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseCosh(Vector<T> result)
{
PointwiseUnary(DoPointwiseCosh, result);
}
/// <summary>
/// Pointwise applies the floor function to each value
/// </summary>
public Vector<T> PointwiseFloor()
{
return PointwiseUnary(DoPointwiseFloor);
}
/// <summary>
/// Pointwise applies the floor function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseFloor(Vector<T> result)
{
PointwiseUnary(DoPointwiseFloor, result);
}
/// <summary>
/// Pointwise applies the log10 function to each value
/// </summary>
public Vector<T> PointwiseLog10()
{
return PointwiseUnary(DoPointwiseLog10);
}
/// <summary>
/// Pointwise applies the log10 function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseLog10(Vector<T> result)
{
PointwiseUnary(DoPointwiseLog10, result);
}
/// <summary>
/// Pointwise applies the round function to each value
/// </summary>
public Vector<T> PointwiseRound()
{
return PointwiseUnary(DoPointwiseRound);
}
/// <summary>
/// Pointwise applies the round function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseRound(Vector<T> result)
{
PointwiseUnary(DoPointwiseRound, result);
}
/// <summary>
/// Pointwise applies the sign function to each value
/// </summary>
public Vector<T> PointwiseSign()
{
return PointwiseUnary(DoPointwiseSign);
}
/// <summary>
/// Pointwise applies the sign function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseSign(Vector<T> result)
{
PointwiseUnary(DoPointwiseSign, result);
}
/// <summary>
/// Pointwise applies the sin function to each value
/// </summary>
public Vector<T> PointwiseSin()
{
return PointwiseUnary(DoPointwiseSin);
}
/// <summary>
/// Pointwise applies the sin function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseSin(Vector<T> result)
{
PointwiseUnary(DoPointwiseSin, result);
}
/// <summary>
/// Pointwise applies the sinh function to each value
/// </summary>
public Vector<T> PointwiseSinh()
{
return PointwiseUnary(DoPointwiseSinh);
}
/// <summary>
/// Pointwise applies the sinh function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseSinh(Vector<T> result)
{
PointwiseUnary(DoPointwiseSinh, result);
}
/// <summary>
/// Pointwise applies the sqrt function to each value
/// </summary>
public Vector<T> PointwiseSqrt()
{
return PointwiseUnary(DoPointwiseSqrt);
}
/// <summary>
/// Pointwise applies the sqrt function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseSqrt(Vector<T> result)
{
PointwiseUnary(DoPointwiseSqrt, result);
}
/// <summary>
/// Pointwise applies the tan function to each value
/// </summary>
public Vector<T> PointwiseTan()
{
return PointwiseUnary(DoPointwiseTan);
}
/// <summary>
/// Pointwise applies the tan function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseTan(Vector<T> result)
{
PointwiseUnary(DoPointwiseTan, result);
}
/// <summary>
/// Pointwise applies the tanh function to each value
/// </summary>
public Vector<T> PointwiseTanh()
{
return PointwiseUnary(DoPointwiseTanh);
}
/// <summary>
/// Pointwise applies the tanh function to each value
/// </summary>
/// <param name="result">The vector to store the result</param>
public void PointwiseTanh(Vector<T> result)
{
PointwiseUnary(DoPointwiseTanh, result);
}
/// <summary>

170
src/Numerics/LinearAlgebra/Vector.Operators.cs

@ -271,5 +271,175 @@ namespace MathNet.Numerics.LinearAlgebra
{
return vector.PointwisePower(exponent);
}
/// <summary>
/// Computes the log of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Log(Vector<T> x)
{
return x.PointwiseUnary(x.PointwiseLog);
}
/// <summary>
/// Computes the exponential of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Exp(Vector<T> x)
{
return x.PointwiseUnary(x.DoPointwiseExp);
}
/// <summary>
/// Computes the absolute value of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Abs(Vector<T> x)
{
return x.PointwiseAbs();
}
/// <summary>
/// Computes the acos of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Acos(Vector<T> x)
{
return x.PointwiseAcos();
}
/// <summary>
/// Computes the asin of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Asin(Vector<T> x)
{
return x.PointwiseAsin();
}
/// <summary>
/// Computes the atan of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Atan(Vector<T> x)
{
return x.PointwiseAtan();
}
/// <summary>
/// Computes the ceiling of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Ceiling(Vector<T> x)
{
return x.PointwiseCeiling();
}
/// <summary>
/// Computes the cos of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Cos(Vector<T> x)
{
return x.PointwiseCos();
}
/// <summary>
/// Computes the cosh of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Cosh(Vector<T> x)
{
return x.PointwiseCosh();
}
/// <summary>
/// Computes the floor of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Floor(Vector<T> x)
{
return x.PointwiseFloor();
}
/// <summary>
/// Computes the log10 of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Log10(Vector<T> x)
{
return x.PointwiseLog10();
}
/// <summary>
/// Computes the rounded value of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Round(Vector<T> x)
{
return x.PointwiseRound();
}
/// <summary>
/// Computes the sin of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Sin(Vector<T> x)
{
return x.PointwiseSin();
}
/// <summary>
/// Computes the sinh of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Sinh(Vector<T> x)
{
return x.PointwiseSinh();
}
/// <summary>
/// Computes the sqrt of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Sqrt(Vector<T> x)
{
return x.PointwiseSqrt();
}
/// <summary>
/// Computes the tan of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Tan(Vector<T> x)
{
return x.PointwiseTan();
}
/// <summary>
/// Computes the tanh of a vector pointwise
/// </summary>
/// <param name="x">The input vector</param>
/// <returns></returns>
public static Vector<T> Tanh(Vector<T> x)
{
return x.PointwiseTanh();
}
}
}

Loading…
Cancel
Save