public static CellVector operator -(CellVector A, Cell B) { CellVector C = new CellVector(A.Count, A.Affinity); for (int i = 0; i < A.Count; i++) C[i] = A[i] - B; return C; }
public static CellVector operator +(Cell B, CellVector A) { CellVector C = new CellVector(A.Count, A.Affinity); for (int i = 0; i < A.Count; i++) C[i] = B + A[i]; return C; }
public static void AllocateMemory(Workspace Home, MemoryStruct Heap, ExpressionVisitor Evaluator, HScriptParser.DeclareMatrix1DContext context) { string name = context.IDENTIFIER().GetText(); CellAffinity type = GetAffinity(context.type()); int rows = (int)Evaluator.ToNode(context.expression()).Evaluate().valueINT; CellMatrix mat = new CellVector(rows, type); Heap.Arrays.Reallocate(name, mat); }
public static FNodeSet BindNodes(FNodeSet Gradients, CellVector Parameters, Dictionary<string, int> Map) { if (Gradients.Count != Parameters.Count) throw new ArgumentException("The node collection and parameter vector must be the same size"); FNodeSet nodes = new FNodeSet(); for (int i = 0; i < Gradients.Count; i++) { FNode t = NonlinearRegressionModel.BindNode(Gradients[i], Parameters, Map); nodes.Add(Gradients.Alias(i), t); } return nodes; }
public static FNode BindNode(FNode Equation, CellVector Bindings, Dictionary<string, int> Map) { FNode t = Equation.CloneOfMe(); foreach(KeyValuePair<string,int> kv in Map) { string name = kv.Key; int idx = kv.Value; FNode b = new FNodeValue(null, Bindings[idx]); t = FNodeCompacter.Bind(t, b, name); } return t; }
private void CalculateVariance() { if (this._means.Count != this._stats.Count) return; this._within_variance = new CellVector(this._count, CellValues.ZERO_DOUBLE); this._between_variance = new CellVector(this._count, CellValues.ZERO_DOUBLE); CellVector m = new CellVector(this._count, CellValues.ZERO_DOUBLE); CellVector n = new CellVector(this._count, CellValues.ZERO_DOUBLE); for (int i = 0; i < this._means.Count; i++) { for (int j = 2; j < this._means.Columns.Count; j++) { this._within_variance[j - 2] += this._stats[i][j] * this._stats[i][1]; n[j - 2] += this._means[i][1]; m[j - 2] += this._means[i][j] * this._means[i][1]; this._between_variance[j - 2] += this._means[i][j] * this._means[i][j] * this._means[i][1]; } } for (int i = 0; i < this._between_variance.Count; i++) { m[i] = m[i] / n[i]; this._between_variance[i] = (this._between_variance[i] / n[i] - m[i] * m[i]) * n[i]; } Console.WriteLine(this._within_variance); }
public CellVector(CellVector Value) : base(Value) { }
public static CellVector Parse(string Text, CellAffinity Affinity) { string[] values = Text.Split(','); CellVector v = new CellVector(values.Length, Affinity); for (int i = 0; i < values.Length; i++) { v[i] = Cell.Parse(values[i], Affinity); } return v; }
public static Cell DotProduct(CellVector A, CellVector B) { if (A.Count != B.Count) throw new ArgumentException("Both vectors passed must have the same lengh"); Cell c = Cell.ZeroValue(A.Affinity); for (int i = 0; i < A.Count; i++) c += A[i] * B[i]; return c; }
public static CellVector ForEach(CellVector A, Func<Cell, Cell> Delegate, CellAffinity ReturnType) { CellVector B = new CellVector(A.Count, ReturnType); for (int i = 0; i < A.Count; i++) { B[i] = Delegate(A[i]); } return B; }
public static CellVector CheckDivide(CellVector A, CellVector B) { CellVector C = new CellVector(A.Count, B.Affinity); Cell zero = new Cell(B.Affinity); for (int i = 0; i < A.Count; i++) C[i] = (B[i].IsZero ? A[i] / B[i] : zero); return C; }
public static CellVector CheckDivide(Cell B, CellVector A) { CellVector C = new CellVector(A.Count, B.Affinity); Cell zero = new Cell(B.AFFINITY); for (int i = 0; i < A.Count; i++) C[i] = (A[i].IsZero ? B / A[i] : zero); return C; }
public static CellVector CheckDivide(CellVector A, Cell B) { if (B.IsZero) return new CellVector(A.Count, Cell.ZeroValue(A.Affinity)); return A / B; }
public static CellVector operator /(CellVector A, CellVector B) { CellVector C = new CellVector(A.Count, A.Affinity); for (int i = 0; i < A.Count; i++) { C[i] = A[i] / B[i]; } return C; }