Class Vector
A vector.
Inheritance
Inherited Members
Namespace:numl.Math.LinearAlgebra
Assembly:numl.dll
Syntax
public class Vector : IEnumerable<double>, IEnumerable
Constructors
View SourceVector(IEnumerable<Double>)
this is when the values are actually referencing a vector in an existing matrix.
Declaration
public Vector(IEnumerable<double> contents)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Double> | contents | The contents. |
Vector(Double[])
this is when the values are actually referencing a vector in an existing matrix.
Declaration
public Vector(double[] contents)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | contents | The contents. |
Vector(Int32)
this is when the values are actually referencing a vector in an existing matrix.
Declaration
public Vector(int n)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | The int to process. |
Fields
View SourceEmpty
The empty.
Declaration
public static readonly Vector Empty
Field Value
Type | Description |
---|---|
Vector |
Properties
View SourceItem[IEnumerable<Int32>]
Indexer to set items within this collection using array index syntax.
Declaration
public double this[IEnumerable<int> slice] { set; }
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Int32> | slice | The slice. |
Property Value
Type | Description |
---|---|
System.Double | The indexed item. |
Item[Int32]
Indexer to get or set items within this collection using array index syntax.
Declaration
public double this[int i] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | i | Zero-based index of the entry to access. |
Property Value
Type | Description |
---|---|
System.Double | The indexed item. |
Item[Predicate<Double>]
Indexer to set items within this collection using array index syntax.
Declaration
public double this[Predicate<double> f] { set; }
Parameters
Type | Name | Description |
---|---|---|
System.Predicate<System.Double> | f | The Predicate<double> to process. |
Property Value
Type | Description |
---|---|
System.Double | The indexed item. |
Length
Gets the length.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The length. |
T
Gets the t.
Declaration
public Matrix T { get; }
Property Value
Type | Description |
---|---|
Matrix | The t. |
Methods
View SourceCalc(Vector, Func<Double, Double>)
Calcs.
Declaration
public static Vector Calc(Vector v, Func<double, double> f)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | A variable-length parameters list containing v. |
System.Func<System.Double, System.Double> | f | The Func<int,double,double> to process. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Calc(Vector, Func<Int32, Double, Double>)
Calcs.
Declaration
public static Vector Calc(Vector v, Func<int, double, double> f)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | A variable-length parameters list containing v. |
System.Func<System.Int32, System.Double, System.Double> | f | The Func<int,double,double> to process. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Combine(Vector[])
Combines the given v.
Declaration
public static Vector Combine(params Vector[] v)
Parameters
Type | Name | Description |
---|---|---|
Vector[] | v | A variable-length parameters list containing v. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the requested operation is invalid. |
ContainsNaN(Vector)
Query if 'vector' contains NaN.
Declaration
public static bool ContainsNaN(Vector vector)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | The vector. |
Returns
Type | Description |
---|---|
System.Boolean | true if it succeeds, false if it fails. |
Copy()
Copies this object.
Declaration
public Vector Copy()
Returns
Type | Description |
---|---|
Vector | A Vector. |
Create(Int32, Func<Double>)
Creates a new Vector.
Declaration
public static Vector Create(int length, Func<double> f)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | The length. |
System.Func<System.Double> | f | The Func<int,double> to process. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Create(Int32, Func<Int32, Double>)
Creates a new Vector.
Declaration
public static Vector Create(int length, Func<int, double> f)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | The length. |
System.Func<System.Int32, System.Double> | f | The Func<int,double> to process. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Diag(Vector)
Diags.
Declaration
public static Matrix Diag(Vector v)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | A variable-length parameters list containing v. |
Returns
Type | Description |
---|---|
Matrix | A Matrix. |
Diag(Vector, Int32, Int32)
Diags.
Declaration
public static Matrix Diag(Vector v, int n, int d)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | A variable-length parameters list containing v. |
System.Int32 | n | The int to process. |
System.Int32 | d | The int to process. |
Returns
Type | Description |
---|---|
Matrix | A Matrix. |
Dot(Vector, Vector)
Dots.
Declaration
public static double Dot(Vector one, Vector two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
Vector | two | The two. |
Returns
Type | Description |
---|---|
System.Double | A double. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the requested operation is invalid. |
Equals(Object)
Determines whether the specified System.Object is equal to the current System.Object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified System.Object is equal to the current System.Object; otherwise, false. |
Overrides
Exp(Vector)
Exponents the given v.
Declaration
public static Vector Exp(Vector v)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | A variable-length parameters list containing v. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
GetEnumerator()
Gets the enumerator.
Declaration
public IEnumerator<double> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Double> | The enumerator. |
Implements
GetHashCode()
Serves as a hash function for a particular type.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the current System.Object. |
Overrides
IsNaN(Vector)
Query if 'vector' is NaN.
Declaration
public static bool IsNaN(Vector vector)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | The vector. |
Returns
Type | Description |
---|---|
System.Boolean | true if NaN, false if not. |
Load(String)
Loads the given vector file.
Declaration
public static Vector Load(string file)
Parameters
Type | Name | Description |
---|---|---|
System.String | file | The file to load. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the requested file is not present. |
Log(Vector)
Logs the given v.
Declaration
public static Vector Log(Vector v)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | A variable-length parameters list containing v. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Norm(Vector)
Normals.
Declaration
public static double Norm(Vector x)
Parameters
Type | Name | Description |
---|---|---|
Vector | x | The Vector to process. |
Returns
Type | Description |
---|---|
System.Double | A double. |
Norm(Vector, Double)
Normals.
Declaration
public static double Norm(Vector x, double p)
Parameters
Type | Name | Description |
---|---|---|
Vector | x | The Vector to process. |
System.Double | p | The double to process. |
Returns
Type | Description |
---|---|
System.Double | A double. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the requested operation is invalid. |
NormRand(Int32, Double, Double, Int32)
Normalise random.
Declaration
public static Vector NormRand(int n, double mean = 0, double stdDev = 1, int precision = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | The int to process. |
System.Double | mean | (Optional) the mean. |
System.Double | stdDev | (Optional) the standard development. |
System.Int32 | precision | (Optional) the precision. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Ones(Int32)
Ones.
Declaration
public static Vector Ones(int n)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | The int to process. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Outer(Vector, Vector)
Outers.
Declaration
public static Matrix Outer(Vector x, Vector y)
Parameters
Type | Name | Description |
---|---|---|
Vector | x | The Vector to process. |
Vector | y | The Vector to process. |
Returns
Type | Description |
---|---|
Matrix | A Matrix. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the requested operation is invalid. |
Parse(String)
Parses a string containing MATLAB style Vector syntax, i.e. "[1, 2, 3];"
Declaration
public static Vector Parse(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Input string to parse. |
Returns
Type | Description |
---|---|
Vector | Matrix. |
Prod(Vector)
Products the given v.
Declaration
public static double Prod(Vector v)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | A variable-length parameters list containing v. |
Returns
Type | Description |
---|---|
System.Double | A double. |
Rand(Int32)
Rands.
Declaration
public static Vector Rand(int n)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | The int to process. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Range(Int32, Int32)
Ranges.
Declaration
public static Vector Range(int s, int e = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | s | The int to process. |
System.Int32 | e | (Optional) the int to process. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Round(Vector, Int32)
Rounds.
Declaration
public static Vector Round(Vector v, int decimals = 0)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | A variable-length parameters list containing v. |
System.Int32 | decimals | (Optional) the decimals. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Save(String)
Save vector to file
Declaration
public void Save(string file)
Parameters
Type | Name | Description |
---|---|---|
System.String | file | file to save |
SortOrder(Vector)
Sort order.
Declaration
public static Vector SortOrder(Vector vector)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | The vector. |
Returns
Type | Description |
---|---|
Vector | The sorted order. |
Sum(Vector)
Sums the given v.
Declaration
public static double Sum(Vector v)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | A variable-length parameters list containing v. |
Returns
Type | Description |
---|---|
System.Double | A double. |
ToArray()
Convert this object into an array representation.
Declaration
public double[] ToArray()
Returns
Type | Description |
---|---|
System.Double[] | An array that represents the data in this object. |
ToMatrix()
Converts a t to a matrix.
Declaration
public Matrix ToMatrix()
Returns
Type | Description |
---|---|
Matrix | t as a Matrix. |
ToMatrix(VectorType)
Converts a t to a matrix.
Declaration
public Matrix ToMatrix(VectorType t)
Parameters
Type | Name | Description |
---|---|---|
VectorType | t | The VectorType to process. |
Returns
Type | Description |
---|---|
Matrix | t as a Matrix. |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string that represents the current object. |
Overrides
Zeros(Int32)
Zeros.
Declaration
public static Vector Zeros(int n)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | The int to process. |
Returns
Type | Description |
---|---|
Vector | A Vector. |
Operators
View SourceAddition(Vector, Vector)
Addition operator.
Declaration
public static Vector operator +(Vector one, Vector two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
Vector | two | The two. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the requested operation is invalid. |
Addition(Vector, Double)
Addition operator.
Declaration
public static Vector operator +(Vector v, double s)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | The Vector to process. |
System.Double | s | The double to process. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Addition(Double, Vector)
Addition operator.
Declaration
public static Vector operator +(double s, Vector v)
Parameters
Type | Name | Description |
---|---|---|
System.Double | s | The double to process. |
Vector | v | The Vector to process. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Division(Vector, Double)
Division operator.
Declaration
public static Vector operator /(Vector one, double two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
System.Double | two | The two. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Division(Vector, Int32)
Division operator.
Declaration
public static Vector operator /(Vector one, int two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
System.Int32 | two | The two. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Equality(Vector, Vector)
Equality operator.
Declaration
public static bool operator ==(Vector one, Vector two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
Vector | two | The two. |
Returns
Type | Description |
---|---|
System.Boolean | The result of the operation. |
ExclusiveOr(Vector, Double)
Raises each value to the specified power.
Declaration
public static Vector operator ^(Vector one, double power)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
System.Double | power | The power. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
GreaterThan(Vector, Double)
Returns an array of matching indices where each value is greater than the supplied value.
Declaration
public static IEnumerable<int> operator>(Vector one, double val)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | |
System.Double | val |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Int32> |
Implicit(Vector to Double[])
double[] casting operator.
Declaration
public static implicit operator double[](Vector v)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | The Vector to process. |
Returns
Type | Description |
---|---|
System.Double[] |
Implicit(Double[] to Vector)
Vector casting operator.
Declaration
public static implicit operator Vector(double[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | array | The array. |
Returns
Type | Description |
---|---|
Vector |
Implicit(Int32[] to Vector)
Vector casting operator.
Declaration
public static implicit operator Vector(int[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | array | The array. |
Returns
Type | Description |
---|---|
Vector |
Implicit(Single[] to Vector)
Vector casting operator.
Declaration
public static implicit operator Vector(float[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Single[] | array | The array. |
Returns
Type | Description |
---|---|
Vector |
Inequality(Vector, Vector)
Inequality operator.
Declaration
public static bool operator !=(Vector one, Vector two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
Vector | two | The two. |
Returns
Type | Description |
---|---|
System.Boolean | The result of the operation. |
LessThan(Vector, Double)
Returns an array of matching indices where each value is less than the supplied value.
Declaration
public static IEnumerable<int> operator <(Vector one, double val)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | |
System.Double | val |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Int32> |
Modulus(Vector, Double)
Mod operator.
Declaration
public static Vector operator %(Vector one, double two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
System.Double | two | The mod. |
Returns
Type | Description |
---|---|
Vector |
Multiply(Vector, Vector)
Multiplication operator.
Declaration
public static Vector operator *(Vector one, Vector two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
Vector | two | The two. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the requested operation is invalid. |
Multiply(Vector, Double)
Multiplication operator.
Declaration
public static Vector operator *(Vector one, double two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
System.Double | two | The two. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Multiply(Vector, Int32)
Multiplication operator.
Declaration
public static Vector operator *(Vector one, int two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
System.Int32 | two | The two. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Multiply(Double, Vector)
Multiplication operator.
Declaration
public static Vector operator *(double one, Vector two)
Parameters
Type | Name | Description |
---|---|---|
System.Double | one | The one. |
Vector | two | The two. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Subtraction(Vector, Vector)
Subtraction operator.
Declaration
public static Vector operator -(Vector one, Vector two)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
Vector | two | The two. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the requested operation is invalid. |
Subtraction(Vector, Double)
Subtraction operator.
Declaration
public static Vector operator -(Vector v, double s)
Parameters
Type | Name | Description |
---|---|---|
Vector | v | The Vector to process. |
System.Double | s | The double to process. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Subtraction(Double, Vector)
Subtraction operator.
Declaration
public static Vector operator -(double s, Vector v)
Parameters
Type | Name | Description |
---|---|---|
System.Double | s | The double to process. |
Vector | v | The Vector to process. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
UnaryNegation(Vector)
Negation operator.
Declaration
public static Vector operator -(Vector one)
Parameters
Type | Name | Description |
---|---|---|
Vector | one | The one. |
Returns
Type | Description |
---|---|
Vector | The result of the operation. |
Explicit Interface Implementations
View SourceIEnumerable.GetEnumerator()
Gets the enumerator.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | The enumerator. |