Show / Hide Table of Contents

Class Vector

A vector.

Inheritance
System.Object
Vector
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace:numl.Math.LinearAlgebra
Assembly:numl.dll
Syntax
public class Vector : IEnumerable<double>, IEnumerable

Constructors

View Source

Vector(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.

View Source

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.

View Source

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 Source

Empty

The empty.

Declaration
public static readonly Vector Empty
Field Value
Type Description
Vector

Properties

View Source

Item[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.

View Source

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.

View Source

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.

View Source

Length

Gets the length.

Declaration
public int Length { get; }
Property Value
Type Description
System.Int32

The length.

View Source

T

Gets the t.

Declaration
public Matrix T { get; }
Property Value
Type Description
Matrix

The t.

Methods

View Source

Calc(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.

View Source

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.

View Source

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.

View Source

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.

View Source

Copy()

Copies this object.

Declaration
public Vector Copy()
Returns
Type Description
Vector

A Vector.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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
System.Object.Equals(System.Object)
View Source

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.

View Source

GetEnumerator()

Gets the enumerator.

Declaration
public IEnumerator<double> GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<System.Double>

The enumerator.

Implements
System.Collections.Generic.IEnumerable<System.Double>.GetEnumerator()
View Source

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
System.Object.GetHashCode()
View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

Save(String)

Save vector to file

Declaration
public void Save(string file)
Parameters
Type Name Description
System.String file

file to save

View Source

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.

View Source

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.

View Source

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.

View Source

ToMatrix()

Converts a t to a matrix.

Declaration
public Matrix ToMatrix()
Returns
Type Description
Matrix

t as a Matrix.

View Source

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.

View Source

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
System.Object.ToString()
View Source

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 Source

Addition(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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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>
View Source

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[]
View Source

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
View Source

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
View Source

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
View Source

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.

View Source

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>
View Source

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
View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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 Source

IEnumerable.GetEnumerator()

Gets the enumerator.

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

The enumerator.

Implements
System.Collections.IEnumerable.GetEnumerator()

Extension Methods

EnumerableHelpers.Head<Double, R>(Func<Double, R>)
EnumerableHelpers.Tail<Double, R>(Func<Double, R>)
EnumerableHelpers.Tail<Double, R>(Int32, Func<Double, R>)
EnumerableHelpers.ForEach<Double, R>(Func<Double, R>)
EnumerableHelpers.Batch<Double>(Int32, Action<Int32, IEnumerable<Double>>, Boolean, Int32)
EnumerableHelpers.IndexOf<Double>(Double)
EnumerableHelpers.IndexOf<Double>(Func<Double, Boolean>)
EnumerableHelpers.Shuffle<Double>()
EnumerableHelpers.Random<Double>()
EnumerableHelpers.Slice<Double>(IEnumerable<Int32>)
EnumerableHelpers.IsAscending()
EnumerableHelpers.StandardDeviation<Double>(Func<Double, Double>, Boolean)
EnumerableHelpers.Variance<Double>(Func<Double, Double>, Boolean)
VectorExtensions.Calc(Func<Double, Double>)
VectorExtensions.Sum()
VectorExtensions.Log()
VectorExtensions.Prod()
VectorExtensions.Outer(Vector)
VectorExtensions.Each(Func<Double, Double>, Boolean)
VectorExtensions.Each(Func<Double, Int32, Double>, Boolean)
VectorExtensions.Reverse()
VectorExtensions.ToBinaryMatrix(Boolean)
VectorExtensions.Reshape(Int32, VectorType, VectorType)
VectorExtensions.Diag()
VectorExtensions.Diag(Int32, Int32)
VectorExtensions.Norm()
VectorExtensions.Norm(Double)
VectorExtensions.Mean()
VectorExtensions.Sqrt()
VectorExtensions.StdDev(Boolean)
VectorExtensions.Variance(Boolean)
VectorExtensions.Covariance(Vector)
VectorExtensions.Correlation(Vector)
VectorExtensions.Mode()
VectorExtensions.Median()
VectorExtensions.Stats()
VectorExtensions.Insert(Int32, Double, Boolean)
VectorExtensions.Combine(Vector[])
VectorExtensions.Expand(Int32)
VectorExtensions.Expand(Vector)
VectorExtensions.MinIndex()
VectorExtensions.MaxIndex()
VectorExtensions.Top(Int32)
VectorExtensions.TopReverse(Int32)
VectorExtensions.Indices(Func<Double, Boolean>)
VectorExtensions.Round(Int32)
VectorExtensions.Slice(IEnumerable<Int32>)
VectorExtensions.Slice(IEnumerable<Int32>, Boolean)
VectorExtensions.Slice(Int32, Int32)
VectorExtensions.Slice(Func<Double, Boolean>)
VectorExtensions.Sort(Boolean, Int32[])
VectorExtensions.Dot(Vector)
VectorExtensions.Segment(Int32)
VectorExtensions.Generate(Func<Double, Double>)
VectorExtensions.ToVector()
VectorExtensions.ToVector<Double>(Func<Double, Double>)
VectorExtensions.ToDouble()
VectorExtensions.First(Func<Int32, Double, Boolean>)
VectorExtensions.Last(Func<Int32, Double, Boolean>)
VectorExtensions.ContainsNaN()
VectorExtensions.IsNaN()
VectorExtensions.IsBinary()
VectorExtensions.ToBinary(Func<Double, Boolean>, Double, Double)
VectorExtensions.GetRandom()
  • View Source
©2017 — Seth Juarez
numl v0.9.20-beta
MIT License
docs by docfx