本文整理汇总了C#中VectorType类的典型用法代码示例。如果您正苦于以下问题:C# VectorType类的具体用法?C# VectorType怎么用?C# VectorType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VectorType类属于命名空间,在下文中一共展示了VectorType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrayExpression
internal ArrayExpression(
VectorType vectorType,
EnumerableArrayWrapper<ExpressionBase, IMetadataExpression> elements
) {
this.VectorType = vectorType;
this.Elements = elements;
}
示例2: Indices
public static IEnumerable<int> Indices(this Matrix source, Func<Vector, bool> f, VectorType t)
{
int max = t == VectorType.Row ? source.Rows : source.Cols;
for (int i = 0; i < max; i++)
if (f(source[i, t]))
yield return i;
}
示例3: CovarianceDiag
public static Vector CovarianceDiag(Matrix source, VectorType t = VectorType.Col)
{
int length = t == VectorType.Row ? source.Rows : source.Cols;
Vector vector = new Vector(length);
for (int i = 0; i < length; i++)
vector[i] = source[i, t].Variance();
return vector;
}
示例4: Correlation
public static Matrix Correlation(Matrix source, VectorType t = VectorType.Col)
{
int length = t == VectorType.Row ? source.Rows : source.Cols;
Matrix m = new Matrix(length);
for (int i = 0; i < length; i++)
for (int j = i; j < length; j++) // symmetric matrix
m[i, j] = m[j, i] = source[i, t].Correlation(source[j, t]);
return m;
}
示例5: MatrixHelper
public MatrixHelper(string vector, VectorType type, int columns, int rows, bool isLinearMatrix)
{
this.type = type;
vectorString = vector;
this.columns = columns;
this.rows = rows;
matrix = !isLinearMatrix ? SplitVector() : SplitLinerMatrix();
this.isLinearMatrix = isLinearMatrix;
}
示例6: Mean
public static Vector Mean(this Matrix source, VectorType t)
{
int count = t == VectorType.Row ? source.Cols : source.Rows;
VectorType type = t == VectorType.Row ? VectorType.Column : VectorType.Row;
Vector v = new Vector(count);
for (int i = 0; i < count; i++)
v[i] = source[i, type].Mean();
return v;
}
示例7: Summarize
/// <summary>
/// Summarizes a given Matrix.
/// </summary>
/// <param name="matrix">Matrix to summarize.</param>
/// <param name="byVector">Indicates which direction to summarize, default is <see cref="VectorType.Row"/> indicating top-down.</param>
/// <returns></returns>
public static Summary Summarize(Matrix matrix, VectorType byVector = VectorType.Row)
{
return new Summary()
{
Average = matrix.Mean(byVector),
StandardDeviation = matrix.StdDev(byVector),
Minimum = matrix.Min(byVector),
Maximum = matrix.Max(byVector),
Median = matrix.Median(byVector)
};
}
示例8: Covariance
public static Matrix Covariance(Matrix source, VectorType t = VectorType.Col)
{
int length = t == VectorType.Row ? source.Rows : source.Cols;
Matrix m = new Matrix(length);
//for (int i = 0; i < length; i++)
Parallel.For(0, length, i =>
//for (int j = i; j < length; j++) // symmetric matrix
Parallel.For(i, length, j =>
m[i, j] = m[j, i] = source[i, t].Covariance(source[j, t])));
return m;
}
示例9: Vector
//Spezielle Vektoren erzeugen.
public Vector(int _n, VectorType type)
: base(_n, 1)
{
switch (type)
{
case VectorType.ONES:
for (int i = 0; i < base.NoRows; i++)
{
this[i] = 1.0;
}
break;
}
}
示例10: Vector
/// <summary>
/// Initializes a new instance of the Vector class that contains elements
/// copied from the specified array.
/// </summary>
/// <param name="type">The vector type</param>
/// <param name="data">The array whose elements are copied to the vector.</param>
public Vector(VectorType type, double[] data)
{
if (data.Length < 1) throw new System.ArgumentException("data.Length < 1");
this._Type = type;
this._Data = new double[data.Length];
data.CopyTo(this._Data, 0);
//for (int i = 0; i < data.Length; i++)
//{
// this.MeData[i] = data[i];
//}
}
示例11: Covariance
/// <summary>Covariances.</summary>
/// <param name="source">Source for the.</param>
/// <param name="t">(Optional) Row or Column sum.</param>
/// <returns>A Matrix.</returns>
public static Matrix Covariance(Matrix source, VectorType t = VectorType.Col)
{
int length = t == VectorType.Row ? source.Rows : source.Cols;
Matrix m = new Matrix(length);
//for (int i = 0; i < length; i++)
for (int i = 0; i < length; i++)
{
//for (int j = i; j < length; j++) // symmetric matrix
for (int j = i; j < length; j++)
m[i, j] = m[j, i] = source[i, t].Covariance(source[j, t]);
}
return m;
}
示例12: Estimate
/// <summary>Estimates.</summary>
/// <param name="X">The Matrix to process.</param>
/// <param name="type">(Optional) the type.</param>
public void Estimate(Matrix X, VectorType type = VectorType.Row)
{
var n = type == VectorType.Row ? X.Rows : X.Cols;
var s = type == VectorType.Row ? X.Cols : X.Rows;
this.Mu = X.Sum(type) / n;
this.Sigma = Matrix.Zeros(s);
for (var i = 0; i < n; i++)
{
var x = X[i, type] - this.Mu;
this.Sigma += x.Outer(x);
}
this.Sigma *= 1d / (n - 1d);
}
示例13: Estimate
/// <summary>Estimates.</summary>
/// <param name="X">The Matrix to process.</param>
/// <param name="type">(Optional) the type.</param>
public void Estimate(Matrix X, VectorType type = VectorType.Row)
{
int n = type == VectorType.Row ? X.Rows : X.Cols;
int s = type == VectorType.Row ? X.Cols : X.Rows;
Mu = X.Sum(type) / n;
Sigma = Matrix.Zeros(s);
for (int i = 0; i < n; i++)
{
var x = X[i, type] - Mu;
Sigma += x.Outer(x);
}
Sigma *= (1d / (n - 1d));
}
示例14: Sum
/// <summary>
/// Computes the sum of either the rows or columns of a matrix and returns a vector.
/// </summary>
/// <param name="m">Input Matrix.</param>
/// <param name="t">Row or Column sum.</param>
/// <returns>Vector Sum.</returns>
public static Vector Sum(Matrix m, VectorType t)
{
if (t == VectorType.Row)
{
Vector result = new Vector(m.Cols);
for (int i = 0; i < m.Cols; i++)
for (int j = 0; j < m.Rows; j++)
result[i] += m[j, i];
return result;
}
else
{
Vector result = new Vector(m.Rows);
for (int i = 0; i < m.Rows; i++)
for (int j = 0; j < m.Cols; j++)
result[i] += m[i, j];
return result;
}
}
示例15: VectorData
public VectorData(string name, uint offset, uint address, VectorType type, float x, float y, float z, float a, string labels, bool degrees, uint pluginLine)
: base(name, offset, address, pluginLine)
{
// Vector Components
_x = x;
_y = y;
_z = z;
_a = a;
// Visibility for last 2 Components
_zVis = _aVis = false;
_labels = labels;
_degrees = degrees;
// Optional custom label letters for components
if (_labels.Length < (int)type)
{
_xLabel = "x";
_yLabel = "y";
_zLabel = "z";
_aLabel = "a";
}
else
{
switch (type)
{
case VectorType.Vector4:
_aLabel = _labels[3].ToString();
goto case VectorType.Vector3;
case VectorType.Vector3:
_zLabel = _labels[2].ToString();
goto case VectorType.Vector2;
case VectorType.Vector2:
_yLabel = _labels[1].ToString();
goto default;
default:
_xLabel = _labels[0].ToString();
break;
}
}
// Make last 2 Components visible if we need either
switch (type)
{
case VectorType.Vector4:
_aVis = true;
goto case VectorType.Vector3;
case VectorType.Vector3:
_zVis = true;
break;
}
// Create our Vector type name
_typeLabel = "vector";
switch (type)
{
case VectorType.Vector4:
_typeLabel += "4";
break;
case VectorType.Vector3:
_typeLabel += "3";
break;
case VectorType.Vector2:
_typeLabel += "2";
break;
}
if (_degrees)
_typeLabel += "D";
else
_typeLabel += "F";
}