public void ReadMatrix(TextBlock inputBox, ObservableCollection <MatrixElement> list) { Matrix temp; try { temp = Matrix.FromString(inputBox.Text); } catch { InputErrorMessagebox.Visibility = Visibility.Visible; return; } MatrixInputButton.Flyout.Hide(); list.Add(new MatrixElement()); list[list.Count - 1].M = temp; list[list.Count - 1].S = $"{list[list.Count - 1].M.Height}x{list[list.Count - 1].M.Width}"; try { list[list.Count - 1].Det = list[list.Count - 1].M.Determinant.ToString(); } catch (InvalidOperationException) { list[list.Count - 1].Det = "Determinant does not exist"; } UpdateLetters(); }
private Matrix Evaluate(string input) { if (input.Length > 1) { Regex rx = new Regex(@"[\d,]+|[it]?\((?>\((?<DEPTH>)|\)(?<-DEPTH>)|[^()]+)*\)(?(DEPTH)(?!))|\w+|[+*]"); MatchCollection matches = rx.Matches(input); Matrix a; if (matches[0].Value[0] == 't') { return(Matrix.Transpose(Evaluate(matches[0].Value.Substring(2, matches[0].Value.Length - 3)))); } else if (matches[0].Value[0] == 'i') { return(Evaluate(matches[0].Value.Substring(2, matches[0].Value.Length - 3)).Inverse()); } else if (matches[0].Value[0] == '(') { a = Evaluate(matches[0].Value.Substring(1, matches[0].Value.Length - 2)); } else { a = Evaluate(matches[0].Value); } int pos = 1; while (pos < matches.Count) { if (matches[pos].Value == "+") { Matrix b = Evaluate(matches[pos + 1].Value); a = a + b; } else if (matches[pos].Value == "*") { if (matches[pos + 1].Value[0] >= '0' && matches[pos + 1].Value[0] <= '9') { a *= double.Parse(matches[pos + 1].Value); } else { Matrix b = Evaluate(matches[pos + 1].Value); a = a * b; } } pos += 2; } return(a); } else { if (input[0] >= 'A' && input[0] <= 'Z') { return(matrixList[input[0] - 'A'].M); } return(null); } }
public static void ToMatrixPreviewAddMainthread(this Matrices.Matrix matrix, string name = null) { Den.Tools.Tasks.CoroutineManager.Enqueue(() => onPreviewMatrixAdd?.Invoke(new Matrices.Matrix(matrix), name)); }
public static void ToMatrixPreviewCopyMainthread(this Matrices.Matrix matrix, string name = null) { Matrices.Matrix m2 = new Matrices.Matrix(matrix); Den.Tools.Tasks.CoroutineManager.Enqueue(() => onPreviewMatrix?.Invoke(m2, name)); }
public static void ToMatrixPreviewAdd(this Matrices.Matrix matrix, string name = null) { onPreviewMatrixAdd?.Invoke(new Matrices.Matrix(matrix), name); }
public static void ToMatrixPreview(this Matrices.Matrix matrix, string name = null) { onPreviewMatrix?.Invoke(matrix, name); }
internal static global::Network.Matrices.Matrix GenerateWeightedCOCMatrix(List<clique> cliques, global::Network.Matrices.Matrix matrix) { Matrices.Matrix result = new Matrices.Matrix(matrix); for (int c = 0; c < matrix.Cols; c++) { for (int r = 0; r < matrix.Rows; r++) { result[r, c] *= cliques[c].num_networks; } } return result; }