//
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// 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 MathNet.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);
}
///
/// Substracts 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.DevideByThis(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);
}
}
}