public SLAE(src.GUI.IGUI igui) { iGui = igui; MaxIter = DefaultMaxIter; MinResidual = DefaultMinResidual; MGMRES = DefaultMGMRES; Relaxation = DefaultRelaxation; }
public static List<Tuple<uint, uint>> getCover(src.Board board, src.Piece piece) { // Get cover List<Tuple<uint, uint>> cover = new List<Tuple<uint, uint>>(); int x = (int)piece.getX(); int y = (int)piece.getY(); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i == 0 && j == 0) { // Do not cover self continue; } int nx = x + i; int ny = y + j; if (board.withinBoard(nx, ny)) { Square s = board.getSquareAt((uint)nx, (uint)ny); if ((piece.getColour() == "white" && s.getBlackCover() == 0) || (piece.getColour() == "black" && s.getWhiteCover() == 0)) { Tuple<uint, uint> t = new Tuple<uint, uint>((uint)nx, (uint)ny); if (!getEnemyKingReach(board, piece).Contains(t)) { cover.Add(t); } } } } } return cover; }
=> ShiftRightLogicalVariable(src, control);
ref readonly var part = ref skip(src, i0);
src.Preconditioner.IPreconditioner GeneratePreconditioner(src.Preconditioner.Type type, Matrix.BaseMatrix matrix) { switch (type) { case src.Preconditioner.Type.NoPrecond: return src.Preconditioner.EmptyPreconditioner.Create(matrix); case src.Preconditioner.Type.Diagonal: return src.Preconditioner.DiagonalPreconditioner.Create(matrix); case src.Preconditioner.Type.LLT: return src.Preconditioner.LLTPreconditioner.Create(matrix); case src.Preconditioner.Type.LU: return src.Preconditioner.LUPreconditioner.Create(matrix); case src.Preconditioner.Type.LUsq: return src.Preconditioner.LUsqPreconditioner.Create(matrix); } return null; }
void capFile_onReadDataFrame(src.Packets.DataFrame dataFrame) { DataFrameCount++; RefreshValues(); }
=> Xor(src, CompareEqual(src, src));
=> ShuffleHigh(src, control);
ReadRaw(new BinaryReader(src, Encoding.UTF8));
private void updateDgvResult(src.Vector_.Vector vec) { tabControl1.SelectedIndex = 2; ClearDgv(dgvResult); if (vec == null) return; if (vec.Size > maxDrawSize) { dgvResult.Rows.Add("Vector is too big to draw"); return; } for (var i = 0; i < vec.Size; i++) dgvResult.Rows.Add(vec[i].ToString()); }
private void updateDgvRightPart(src.Vector_.Vector vec) { tabControl1.SelectedIndex = 0; ClearDgv(dgvRightPart); if (vec.Size > maxDrawSize) { dgvRightPart.Rows.Add("Vector is too big to draw"); return; } for (var i = 0; i < vec.Size; i++) { String[] strs = new String[1]; strs[0] = vec[i].ToString(); dgvRightPart.Rows.Add(strs); } }
private void updateDgvMatrix(src.Matrix.BaseMatrix matrix) { tabControl1.SelectedIndex = 0; dgvMatrix.Rows.Clear(); dgvMatrix.Columns.Clear(); if (matrix.Size > maxDrawSize) { dgvMatrix.Columns.Add("", ""); dgvMatrix.Rows.Add("Matrix is too big to draw"); return; } for(var i=0; i < matrix.Size; i++) dgvMatrix.Columns.Add("",""); string[][] strs = new string[matrix.Size][]; for(int i=0;i < matrix.Size;i++) strs[i] = new string[matrix.Size]; matrix.Run((i, j, u) => strs[i][j] = u.ToString()); for (int i = 0; i < matrix.Size; i++) dgvMatrix.Rows.Add(strs[i]); }
private void UpdateDgvResult(src.Vector_.Vector vec) { if (this.dgvRightPart.InvokeRequired) this.Invoke(new UpdateDgvResultCallback(UpdateDgvResult), new object[] { vec }); else updateDgvResult(vec); }
s.source.init(src, errh);
=> TestC(src, mask);
=> ShiftRightLogicalVariable(src, offset);
// Saves all moves done in a game public static void saveMove(src.Move m, string fileName) { // Create directory if not exists bool exists = System.IO.Directory.Exists(savePath); if (!exists) { System.IO.Directory.CreateDirectory(savePath); } // Append move to file using (StreamWriter sw = File.AppendText(savePath + fileName + "_" + MOVES + "." + fileEnding)) { sw.WriteLine(m.ToString()); } }
=> ShiftLeftLogical(src, offset);
// Loads current game at startup public static bool loadCurrent(ref src.Board board) { return SaveManager.loadState(ref board, CURRENT); }
=> Extract(src, pos);
=> Shuffle(src, mask);
=> ExtractVector128(src, pos);
=> ShiftLeftLogicalVariable(src, offset);
=> MaskMove(src, mask, refptr(ref dst));
=> shuffle(src, Vec128Pattern.Swap <byte>(swaps));
ref readonly var record = ref skip(src, i);
=> xor(src, sll(src, offset));
// --- Graphics interface --- // Functions for printing the text and image versions of the board. // Update the board and render the GUI. Also reset the selected move. public void updateBoard(src.Board board) { this.board = board; drawControl.setBoard(board); selectedMove = new src.Move(); renderGUI(); }
src.Solver.ISolverParametrs GenerateParameters(src.Solver.Type type, int maxIter, double eps, double relaxation = 1,int mGMRES = 5) { switch(type) { case src.Solver.Type.GMRES: return new Solver.GMRESParameters(eps, maxIter, mGMRES); case src.Solver.Type.Jacobi: return new Solver.JacobiParametrs(eps, maxIter, relaxation); case src.Solver.Type.GaussSeidel: return new Solver.GaussSeidelParametrs(eps, maxIter, relaxation); case src.Solver.Type.MSG: return new Solver.MSGParametrs(eps, maxIter); case src.Solver.Type.BCGStab: return new Solver.BCGStabParametrs(eps, MaxIter); case src.Solver.Type.LOS: return new Solver.LOSParametrs(eps, MaxIter); } return null; }
=> !TestZ(src, src);
ref readonly var path = ref skip(src, i);
src = rotr(src, offset);
src = rotl(src, offset);
public DLCommand(IList <byte> src, uint offset) => this.Update(src, offset);
// Savefile that is saved after every move and loaded at startup public static void saveCurrent(src.Board board) { SaveManager.saveState(board, CURRENT); }
private void fillTableResult(DataGridView dgv, Task task, src.SMethod.SimplexMethodSolver slv) { dgv.Rows.Clear(); dgv.Columns.Clear(); if (slv.errMsg != "OK") { return; } List<OrderPair> savedOrder = new List<OrderPair>(); foreach (OrderPair p in order) savedOrder.Add(new OrderPair(new Detail1D(pgrdOrderDetail, new double[]{p.Detail.Volume}),p.Num)); String[] strs = new String[3]; strs[0] = "Число заготовок:"; strs[1] = "Разрез:"; strs[2] = "Остатки:"; dgv.Columns.Add("", ""); dgv.Columns.Add("", ""); dgv.Columns.Add("", ""); dgv.Rows.Add(strs); dgv.Rows[0].DefaultCellStyle.BackColor = Color.LightGray; dgv.Columns[0].Width = 150;dgv.Columns[2].Width = 100; double allLeft = 0.0; for (int i = 0; i < slv.xsCol.Count - 1; i++) { if(slv.table[i, slv.table.GetLength(1) - 1] == 0.0) continue; int rounded = (int)slv.table[i, slv.table.GetLength(1) - 1]; strs[0] = rounded.ToString(); strs[1] = ""; foreach (OrderPair p in task.AllCuts[slv.xsCol[i] - 1].Pairs) { for (int j = 0; j < p.Num; j++) { strs[1] += (((Detail1D)p.Detail).Length).ToString().Replace(',','.'); foreach (OrderPair oP in order) { if (((Detail1D)oP.Detail).Length == ((Detail1D)p.Detail).Length) { oP.Num -= rounded; break; } } if (j == p.Num - 1) { if (p != task.AllCuts[slv.xsCol[i] - 1].Pairs.Last()) strs[1] += ","; } else strs[1] += ","; } } strs[2] = Math.Round(task.AllCuts[slv.xsCol[i] - 1].Left, 3).ToString().Replace(',', '.'); allLeft += task.AllCuts[slv.xsCol[i] - 1].Left * rounded; dgv.Rows.Add(strs); } // ЖАДНЫЙ List<src.Cut> leftCuts = greedyAlgorithm(); double greedyCutLeft = 0.0; foreach (Cut cut in leftCuts) { strs[0] = "1"; strs[1] = ""; foreach (OrderPair p in cut.Pairs) { for (int j = 0; j < p.Num; j++) { strs[1] += (((Detail1D)p.Detail).Length).ToString().Replace(',', '.'); foreach (OrderPair oP in order) { if (((Detail1D)oP.Detail).Length == ((Detail1D)p.Detail).Length) { oP.Num -= 1; break; } } if (j == p.Num - 1) { if (p != cut.Pairs.Last()) strs[1] += ","; } else strs[1] += ","; } } strs[2] = Math.Round(cut.Left, 3).ToString().Replace(',', '.'); greedyCutLeft += cut.Left; dgv.Rows.Add(strs); } strs[0] = strs[1] = strs[2] = ""; dgv.Rows.Add(strs); strs[0] = "Общие:"; strs[2] = Math.Round(allLeft, 3).ToString().Replace(',', '.') + " + " + Math.Round(greedyCutLeft, 3).ToString().Replace(',', '.'); dgv.Rows.Add(strs); dgv.Rows[dgv.Rows.Count-1].DefaultCellStyle.BackColor = Color.Gray; order = savedOrder; }
// Saves current save state. The filename is put in a textbox in the GUI public static void saveState(src.Board b, string fileName) { // Create directory if not exists bool exists = System.IO.Directory.Exists(savePath); if (!exists) { System.IO.Directory.CreateDirectory(savePath); } // Clear file, might be a better way string fullName = savePath + fileName + "_" + STATE + "." + fileEnding; File.WriteAllText(fullName, string.Empty); // Create Xml tree root XElement tree = new XElement("Board"); tree.Add(new XElement("Turn", b.getTurn())); // Get all squares with a piece var saveSquares = from s in b.getAllSquares() where s.getPiece() != null select s.getPiece(); // Create squares subtree tree foreach (src.Piece p in saveSquares) { XElement piece = new XElement("Piece", new XElement("X-coordinate", p.getX()), new XElement("Y-coordinate", p.getY()), new XElement("Type", p.GetType().Name), new XElement("Colour", p.getColour()), new XElement("Moved", p.movedFromInit())); if (p is src.Pawn) { piece.Add(new XElement("DoubleStepTurn", ((src.Pawn)p).getDoubleStepTurn())); } tree.Add(piece); } using (StreamWriter sw = File.AppendText(fullName)) { sw.WriteLine(tree); } }
private void fillTableSimplexMethod(DataGridView dgv, src.SMethod.SimplexMethodSolver slv) { dgv.Rows.Clear(); dgv.Columns.Clear(); if (slv.errMsg != "OK") { MessageBox.Show(slv.errMsg, "Симплекс-метод", MessageBoxButtons.OK); } String[] strs = new String[slv.xsStr.Count + 2]; strs[0] = ""; for (int i = 0; i < slv.xsStr.Count; i++) strs[i + 1] = "-x" + slv.xsStr[i].ToString(); strs[slv.xsStr.Count + 1] = "1"; for (int i = 0; i < slv.xsStr.Count + 2; i++) dgv.Columns.Add("", strs[i]); dgv.Columns[0].DefaultCellStyle.BackColor = Color.LightGray; dgv.Rows.Add(strs); dgv.Rows[0].DefaultCellStyle.BackColor = Color.LightGray; dgv.Columns[0].Width = 50; for (int i = 0; i < slv.xsCol.Count - 1; i++) { strs = new String[slv.xsStr.Count + 2]; int index = 0; if (slv.xsCol[i] != 0) strs[index] = "x" + slv.xsCol[i].ToString() + "="; else strs[index] = "0="; index++; for (int j = 0; j < slv.table.GetLength(1); j++) { strs[index] += slv.table[i, j].ToString().Replace(',', '.'); index++; } dgv.Rows.Add(strs); } strs = new String[slv.xsStr.Count + 2]; strs[0] = "Q"; for (int i = 0; i < slv.table.GetLength(1); i++) strs[i + 1] = Math.Abs(slv.table[slv.table.GetLength(0) - 1, i]).ToString().Replace(',', '.') + "\t"; dgv.Rows.Add(strs); }
//Loads the boardstate from the file written in the GUI textbox public static bool loadState(ref src.Board board, string fileName) { // Clear file, might be a better way string fullName = savePath + fileName + "_" + STATE + "." + fileEnding; // Check if file exists if (!File.Exists(fullName)) { return false; } // Clear the board board.clearBoard(); // Read the savefile var loadFile = XElement.Load(fullName); IEnumerable<XElement> elements = from el in loadFile.Elements() select el; // Insert in board foreach (XElement el in elements) { if (el.Name == "Turn") { board.setTurn(Convert.ToUInt32(el.Value)); } else if (el.Name == "Piece") { // The pieces values uint x = Convert.ToUInt32(el.Element("X-coordinate").Value); uint y = Convert.ToUInt32(el.Element("Y-coordinate").Value); string type = el.Element("Type").Value; string col = el.Element("Colour").Value; bool moved = Convert.ToBoolean(el.Element("Moved").Value); src.Piece piece; switch (type) { case "Pawn": piece = new src.Pawn(x, y, col); ((src.Pawn)piece).setDoubleStepTurn(Convert.ToUInt32(el.Element("DoubleStepTurn").Value)); break; case "Rook": piece = new src.Rook(x, y, col); break; case "Knight": piece = new src.Knight(x, y, col); break; case "Bishop": piece = new src.Bishop(x, y, col); break; case "Queen": piece = new src.Queen(x, y, col); break; case "King": piece = new src.King(x, y, col); break; default: //Should not happen return false; } // Update pieces piece.setHasMoved(moved); board.setPiece(x, y, piece); } } return true; }
=> xor(src, srl(src, offset));
=> ShuffleLow(src, control);
=> ShiftLeftLogical128BitLane(src, bytes);
=> Shuffle(src, control);
=> ShiftRightArithmetic(src, offset);
var(comp, _, exceptionDiagnostics) = await TestCaseCompilation.CreateCompilation(src, analyzerOptions, additionalReferences);
=> ShiftRightArithmeticVariable(src, control);
=> ShiftRightLogical128BitLane(src, bytes);
void capFile_onReadBeacon(src.Packets.BeaconFrame beacon) { RefreshValues(); }