//
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
namespace IStation.Numerics.LinearAlgebra
{
public abstract partial class Vector
{
///
/// Returns a Vector containing the same values of .
///
/// This method is included for completeness.
/// The vector to get the values from.
/// A vector containing the same values as .
/// If is .
public static Vector operator +(Vector rightSide)
{
return rightSide.Clone();
}
///
/// Returns a Vector containing the negated values of .
///
/// The vector to get the values from.
/// A vector containing the negated values as .
/// If is .
public static Vector operator -(Vector rightSide)
{
return rightSide.Negate();
}
///
/// Adds two Vectors together and returns the results.
///
/// One of the vectors to add.
/// The other vector to add.
/// The result of the addition.
/// If and are not the same size.
/// If or is .
public static Vector operator +(Vector leftSide, Vector rightSide)
{
return leftSide.Add(rightSide);
}
///
/// Adds a scalar to each element of a vector.
///
/// The vector to add to.
/// The scalar value to add.
/// The result of the addition.
/// If is .
public static Vector operator +(Vector leftSide, T rightSide)
{
return leftSide.Add(rightSide);
}
///
/// Adds a scalar to each element of a vector.
///
/// The scalar value to add.
/// The vector to add to.
/// The result of the addition.
/// If is .
public static Vector operator +(T leftSide, Vector rightSide)
{
return rightSide.Add(leftSide);
}
///
/// Subtracts two Vectors and returns the results.
///
/// The vector to subtract from.
/// The vector to subtract.
/// The result of the subtraction.
/// If and are not the same size.
/// If or is .
public static Vector operator -(Vector leftSide, Vector rightSide)
{
return leftSide.Subtract(rightSide);
}
///
/// Subtracts a scalar from each element of a vector.
///
/// The vector to subtract from.
/// The scalar value to subtract.
/// The result of the subtraction.
/// If is .
public static Vector operator -(Vector leftSide, T rightSide)
{
return leftSide.Subtract(rightSide);
}
///
/// Subtracts each element of a vector from a scalar.
///
/// The scalar value to subtract from.
/// The vector to subtract.
/// The result of the subtraction.
/// If is .
public static Vector operator -(T leftSide, Vector rightSide)
{
return rightSide.SubtractFrom(leftSide);
}
///
/// Multiplies a vector with a scalar.
///
/// The vector to scale.
/// The scalar value.
/// The result of the multiplication.
/// If is .
public static Vector operator *(Vector leftSide, T rightSide)
{
return leftSide.Multiply(rightSide);
}
///
/// Multiplies a vector with a scalar.
///
/// The scalar value.
/// The vector to scale.
/// The result of the multiplication.
/// If is .
public static Vector operator *(T leftSide, Vector rightSide)
{
return rightSide.Multiply(leftSide);
}
///
/// Computes the dot product between two Vectors.
///
/// The left row vector.
/// The right column vector.
/// The dot product between the two vectors.
/// If and are not the same size.
/// If or is .
public static T operator *(Vector leftSide, Vector rightSide)
{
return leftSide.DotProduct(rightSide);
}
///
/// Divides a scalar with a vector.
///
/// The scalar to divide.
/// The vector.
/// The result of the division.
/// If is .
public static Vector operator /(T dividend, Vector divisor)
{
return divisor.DivideByThis(dividend);
}
///
/// Divides a vector with a scalar.
///
/// The vector to divide.
/// The scalar value.
/// The result of the division.
/// If is .
public static Vector operator /(Vector dividend, T divisor)
{
return dividend.Divide(divisor);
}
///
/// Pointwise divides two Vectors.
///
/// The vector to divide.
/// The other vector.
/// The result of the division.
/// If and are not the same size.
/// If is .
public static Vector operator /(Vector dividend, Vector divisor)
{
return dividend.PointwiseDivide(divisor);
}
///
/// Computes the remainder (% operator), where the result has the sign of the dividend,
/// of each element of the vector of the given divisor.
///
/// The vector whose elements we want to compute the remainder of.
/// The divisor to use.
/// If is .
public static Vector operator %(Vector dividend, T divisor)
{
return dividend.Remainder(divisor);
}
///
/// Computes the remainder (% operator), where the result has the sign of the dividend,
/// of the given dividend of each element of the vector.
///
/// The dividend we want to compute the remainder of.
/// The vector whose elements we want to use as divisor.
/// If is .
public static Vector operator %(T dividend, Vector divisor)
{
return divisor.RemainderByThis(dividend);
}
///
/// Computes the pointwise remainder (% operator), where the result has the sign of the dividend,
/// of each element of two vectors.
///
/// The vector whose elements we want to compute the remainder of.
/// The divisor to use.
/// If and are not the same size.
/// If is .
public static Vector operator %(Vector dividend, Vector divisor)
{
return dividend.PointwiseRemainder(divisor);
}
[SpecialName]
public static Vector op_DotMultiply(Vector x, Vector y)
{
return x.PointwiseMultiply(y);
}
[SpecialName]
public static Vector op_DotDivide(Vector dividend, Vector divisor)
{
return dividend.PointwiseDivide(divisor);
}
[SpecialName]
public static Vector op_DotPercent(Vector dividend, Vector divisor)
{
return dividend.PointwiseRemainder(divisor);
}
[SpecialName]
public static Vector op_DotHat(Vector vector, Vector exponent)
{
return vector.PointwisePower(exponent);
}
[SpecialName]
public static Vector op_DotHat(Vector vector, T exponent)
{
return vector.PointwisePower(exponent);
}
///
/// Computes the sqrt of a vector pointwise
///
/// The input vector
///
public static Vector Sqrt(Vector x)
{
return x.PointwiseSqrt();
}
///
/// Computes the exponential of a vector pointwise
///
/// The input vector
///
public static Vector Exp(Vector x)
{
return x.PointwiseUnary(x.DoPointwiseExp);
}
///
/// Computes the log of a vector pointwise
///
/// The input vector
///
public static Vector Log(Vector x)
{
return x.PointwiseUnary(x.PointwiseLog);
}
///
/// Computes the log10 of a vector pointwise
///
/// The input vector
///
public static Vector Log10(Vector x)
{
return x.PointwiseLog10();
}
///
/// Computes the sin of a vector pointwise
///
/// The input vector
///
public static Vector Sin(Vector x)
{
return x.PointwiseSin();
}
///
/// Computes the cos of a vector pointwise
///
/// The input vector
///
public static Vector Cos(Vector x)
{
return x.PointwiseCos();
}
///
/// Computes the tan of a vector pointwise
///
/// The input vector
///
public static Vector Tan(Vector x)
{
return x.PointwiseTan();
}
///
/// Computes the asin of a vector pointwise
///
/// The input vector
///
public static Vector Asin(Vector x)
{
return x.PointwiseAsin();
}
///
/// Computes the acos of a vector pointwise
///
/// The input vector
///
public static Vector Acos(Vector x)
{
return x.PointwiseAcos();
}
///
/// Computes the atan of a vector pointwise
///
/// The input vector
///
public static Vector Atan(Vector x)
{
return x.PointwiseAtan();
}
///
/// Computes the sinh of a vector pointwise
///
/// The input vector
///
public static Vector Sinh(Vector x)
{
return x.PointwiseSinh();
}
///
/// Computes the cosh of a vector pointwise
///
/// The input vector
///
public static Vector Cosh(Vector x)
{
return x.PointwiseCosh();
}
///
/// Computes the tanh of a vector pointwise
///
/// The input vector
///
public static Vector Tanh(Vector x)
{
return x.PointwiseTanh();
}
///
/// Computes the absolute value of a vector pointwise
///
/// The input vector
///
public static Vector Abs(Vector x)
{
return x.PointwiseAbs();
}
///
/// Computes the floor of a vector pointwise
///
/// The input vector
///
public static Vector Floor(Vector x)
{
return x.PointwiseFloor();
}
///
/// Computes the ceiling of a vector pointwise
///
/// The input vector
///
public static Vector Ceiling(Vector x)
{
return x.PointwiseCeiling();
}
///
/// Computes the rounded value of a vector pointwise
///
/// The input vector
///
public static Vector Round(Vector x)
{
return x.PointwiseRound();
}
}
}