static void Main(string[] args) { long start = DateTime.Now.Ticks; long result = 0; result = new Program().sumSolve(39); long end = DateTime.Now.Ticks; Console.WriteLine(result + " " + (end - start)/10000); Console.ReadLine(); }
public void Dispose() { _map = null; foreach (var cycle in _cycles.Values) { cycle.OnForcedPositionChange -= updateHeadLocation; } _cycles = null; Utilities.Dispose(); }
public void init() { initialised=false; reductionFactor_x=1; reductionFactor_y=1; image=null; width=0; height=0; rotationLookup=null; OptimalNoOfFeatures=0; topFeature=null; currPolarRadius=0; polarLookup=null; }
public long sumSolve(int u) { long result = 0; setup(); for (int a = 0; a < u; ++a) { A = multiply(A, A); long[,] sumRes = multiply(A, B); result += sumRes[0, 0]; result %= MOD; Console.WriteLine(result); } return result; }
public long solve(long n) { setup(); while(n != 0) { if(n%2 == 1) { result = multiply(result, A); } n /= 2; A = multiply(A, A); } result = multiply(result, B); return result[0,0]; }
public void Floyd(int max) { int[,] p; bool closeWay = true; long[,] a = graph.Floyd(out p); //запускаем алгоритм Флойда int i, j; int countWay = 0; int count = 0; //анализируем полученные данные и выводим их на экран for (i = 0; i < graph.Size; i++) { for (j = 0; j < graph.Size; j++) { if (i != j) { if (a[i, j] != int.MaxValue && a[i, j] > 0) { ++countWay; if (a[i, j] > max) { ++count; } } } } } if (countWay == count) { Console.WriteLine($"Кратчайшие пути больше {max}, поэтому дорогу нельзя перекрыть"); } else { countWay = 0; count = 0; int countRealWays = 0; Node graph1; int wayi = -1; int wayj = -1; closeWay = false; for (i = 0; i < Size; ++i) { { for (j = 0; j < Size; ++j) { if (graph[i, j] != 0) { if (wayi < 0 && wayj < 0) { wayi = i; wayj = j; } ++countRealWays; } } } } int C = -1; while (!closeWay && C < Size * Size) { ++C; countWay = 0; count = 0; int[,] arraynew = new int[Size, Size]; bool change = false; bool change1 = false; int wi = -1; int wj = -1; for (i = 0; i < Size; ++i) { for (j = 0; j < Size; ++j) { if (graph[i, j] != 0 && wayi == i && wayj == j) { arraynew[i, j] = 0; wi = i; wj = j; change = true; } else { arraynew[i, j] = graph[i, j]; } } } arraynew[wj, wi] = 0; graph1 = new Node(arraynew); a = graph1.Floyd(out p); //запускаем алгоритм Флойда for (i = 0; i < graph1.Size; i++) { for (j = 0; j < graph1.Size; j++) { if (i != j) { if (a[i, j] != int.MaxValue && a[i, j] > 0) { ++countWay; if (a[i, j] <= max) { ++count; } } } } } if (countWay == count) { closeWay = true; foreach (string name in names) { Console.Write($"{name} "); } Console.WriteLine(); for (int ii = 0; ii < graph1.Size; ii++) { for (int jj = 0; jj < graph1.Size; jj++) { if (ii != jj) { if (a[ii, jj] == int.MaxValue) { Console.WriteLine($"Пути из вершины {ii} в вершину {jj} не существует"); } else { Console.Write($"Кратчайший путь от вершины {ii} до вершины {jj} равен {a[ii, jj]} "); Console.WriteLine(); } } } } for (int ii = 0; ii < graph1.Size; ii++) { for (int jj = 0; jj < graph1.Size; jj++) { Console.Write($"{arraynew[ii, jj]} "); } Console.WriteLine(); } } else if (countWay != count) { for (i = 0; i < Size; ++i) { for (j = 0; j < Size; ++j) { if (arraynew[i, j] != 0 && !change1) { wayi = i; wayj = j; change1 = true; } } } } } if (closeWay == true) { Console.WriteLine($" Можно закрыть дорогу {names[wayi]} - {names[wayj]}"); } else { Console.WriteLine("Нельзя перекрыть ни одну дорогу"); } } }
public void Run() { G = MinCostArr(); }
public PascalCombination(int N) { this.N = N; Comb = new long[N + 1, N + 1]; }
private static long getMatrixScore(long[,] matrix) { int dimension = matrix.GetLength(0); int[] left = new int[dimension]; int[] right = new int[dimension]; for (int i = 0; i < dimension; i++) { left[i] = right[i] = -1; } long sum = 0; for (int i = 1; i <= dimension; i++) { long best = 0; int bestP1 = -1; int bestP2 = -1; for (int p1 = 0; p1 < dimension; p1++) { if (right[p1] != -1) { continue; } bool[] inP1LeftCycle = new bool[dimension]; if (i != dimension) { int curr = p1; while (left[curr] != -1) { curr = left[curr]; inP1LeftCycle[curr] = true; } } for (int p2 = 0; p2 < dimension; p2++) { if (left[p2] != -1) { continue; } if (inP1LeftCycle[p2]) { continue; } if (p1 == p2) { continue; } if (best < matrix[p1, p2]) { best = matrix[p1, p2]; bestP1 = p1; bestP2 = p2; } } } sum += best; if (bestP1 == -1) { Console.Write("-1\n"); } else { left[bestP2] = bestP1; right[bestP1] = bestP2; } } return(sum / (long)dimension); }
public static extern af_err af_get_data_ptr([Out] long[,] data, IntPtr array_arr);
public static extern af_err af_create_array(out IntPtr array_arr, [In] long[,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
static bool M13(sbyte[] arg0, long[, ] arg1, uint[] arg2) { arg0 = arg0; arg0[0] = s_2; return(true); }
public FiniteRing(long[,] aAddOpp, long[,] aMultOpp, long aSimpleSubfieldSize) : this(aAddOpp, aMultOpp) { this.FSimpleSubfieldSize = aSimpleSubfieldSize; }
public byte released; //当前版本是否开放 0 : No,1:Yes public override void parseJson(object jd) { Dictionary <string, object> item = jd as Dictionary <string, object>; props_id = long.Parse(item["props_id"].ToString()); name = item["name"].ToString(); types = byte.Parse(item["types"].ToString()); describe = item["describe"].ToString(); grade = short.Parse(item["grade"].ToString()); next_grade = long.Parse(item["next_grade"].ToString()); // int[] nodeIntarr = item["cprice"] as int[]; //cprice = new int[nodeIntarr.Length]; //for (int m = 0; m < nodeIntarr.Length; m++) //{ // cprice[m] = nodeIntarr[m]; //} // sprice = int.Parse(item["sprice"].ToString()); power = short.Parse(item["power"].ToString()); intelligence = short.Parse(item["intelligence"].ToString()); agility = short.Parse(item["agility"].ToString()); hp = short.Parse(item["hp"].ToString()); attack = short.Parse(item["attack"].ToString()); armor = short.Parse(item["armor"].ToString()); magic_resist = short.Parse(item["magic_resist"].ToString()); critical = short.Parse(item["critical"].ToString()); dodge = short.Parse(item["dodge"].ToString()); hit_ratio = short.Parse(item["hit_ratio"].ToString()); armor_penetration = short.Parse(item["armor_penetration"].ToString()); magic_penetration = short.Parse(item["magic_penetration"].ToString()); suck_blood = short.Parse(item["suck_blood"].ToString()); tenacity = short.Parse(item["tenacity"].ToString()); movement_speed = short.Parse(item["movement_speed"].ToString()); attack_speed = short.Parse(item["attack_speed"].ToString()); striking_distance = short.Parse(item["striking_distance"].ToString()); hp_regain = short.Parse(item["hp_regain"].ToString()); //int[] nodeEquip = item["be_equip"] as int[]; //be_equip = new long[nodeEquip.Length]; //for (int m = 0; m < nodeEquip.Length; m++) //{ // be_equip[m] = nodeEquip[m]; //} object[] nodeCond = (object[])item["syn_condition"]; syn_condition = new long[nodeCond.Length, 2]; if (nodeCond.Length > 0) { for (int i = 0; i < nodeCond.Length; i++) { int[] node = nodeCond[i] as int[]; if (node != null) { for (int j = 0; j < node.Length; j++) { syn_condition[i, j] = node[j]; } } } } syn_cost = short.Parse(item["syn_cost"].ToString()); icon_name = item["icon_name"].ToString(); released = byte.Parse(item["released"].ToString()); propertylist[0] = power; propertylist[1] = intelligence; propertylist[2] = agility; propertylist[3] = hp; propertylist[4] = attack; propertylist[5] = armor; propertylist[6] = magic_resist; propertylist[7] = critical; propertylist[8] = dodge; propertylist[9] = hit_ratio; propertylist[10] = armor_penetration; propertylist[11] = magic_penetration; propertylist[12] = suck_blood; propertylist[13] = tenacity; propertylist[14] = movement_speed; propertylist[15] = attack_speed; propertylist[16] = striking_distance; propertylist[17] = hp_regain; }
public Constraint AddAutomaton(IEnumerable <IntVar> vars, long starting_state, long[,] transitions, IEnumerable <long> final_states) { Constraint ct = new Constraint(model_); AutomatonConstraintProto aut = new AutomatonConstraintProto(); foreach (IntVar var in vars) { aut.Vars.Add(var.Index); } aut.StartingState = starting_state; foreach (long f in final_states) { aut.FinalStates.Add(f); } for (int i = 0; i < transitions.GetLength(0); ++i) { aut.TransitionTail.Add(transitions[i, 0]); aut.TransitionLabel.Add(transitions[i, 1]); aut.TransitionHead.Add(transitions[i, 2]); } ct.Proto.Automaton = aut; return(ct); }
public Two_D(int H, int W) { this.H = H; this.W = W; D = new long[H, W]; }
public SpendingOptimizer(long[,] owes, int usercount) { _owes = owes; _usercount = usercount; }
public static void Main(string[] args) { long[,] A = ReadLongTable(3, 3); long N = rl; long[] B; ReadCol(out B, N); HashSet <long> hs = new HashSet <long>(); foreach (var b in B) { hs.Add(b); } // yoko for (int h = 0; h < 3; h++) { bool ok = true; for (int w = 0; w < 3; w++) { if (!hs.Contains(A[h, w])) { ok = false; } } if (ok) { Console.WriteLine("Yes"); return; } } // tate for (int w = 0; w < 3; w++) { bool ok = true; for (int h = 0; h < 3; h++) { if (!hs.Contains(A[h, w])) { ok = false; } } if (ok) { Console.WriteLine("Yes"); return; } } // naname if ((hs.Contains(A[0, 0]) && hs.Contains(A[1, 1]) && hs.Contains(A[2, 2])) || (hs.Contains(A[2, 0]) && hs.Contains(A[1, 1]) && hs.Contains(A[0, 2]))) { Console.WriteLine("Yes"); return; } Console.WriteLine("No"); }
public Spectr_full_fast(long[,] osob, int b1, int Reg, int nudft) : base(osob, b1, nudft) { this.reg1 = Reg; }
} // end class omegaCouple /// <summary> /// No instance underneath. This core loop is static. /// Synchronous action. No thread forked. /// Omega_small and Omega_capital are two fundamental arithmetical indicators. /// Omega_small is the number of primes that factor the argument. /// Omega_capital is the sum of multiplicities of the primes that factor the argument. /// </summary> /// <param name="theIsolatedNatural"></param> public static long[,] OmegaData(Int64 theIsolatedNatural) { if (+1L > theIsolatedNatural) { throw new System.Exception("Omega functions are defined for n in N, n>=+1."); }// else can continue. // long[,] omegaData = null;// this will be imported from an ArrayList, since we don't know yet how many factors we have. Int64 LastCandidateDivider = default(Int64); Int64 DiophantineQuotient = 2L; // init to >1. bool res = true; Int64 loop_theIsolatedNatural = theIsolatedNatural; // init. System.Collections.ArrayList factors = new System.Collections.ArrayList(); // while ( 1 < DiophantineQuotient ) { res = PrimesFinder.ElementFullCalculation.ElementFullEvaluation( loop_theIsolatedNatural, out LastCandidateDivider, out DiophantineQuotient ); if (1 < DiophantineQuotient) { factors.Add(LastCandidateDivider); } else {//NB. when the isolatedNatural leads to a quotient==-1, it means it must be divided for itsself and give quotient==1. factors.Add(loop_theIsolatedNatural); } // after usage, refresh loop engine. loop_theIsolatedNatural = DiophantineQuotient;// refresh loop engine. } // build the response. // long currentPrime = (long)(factors[0]); // I need it already initialized. long factorAccumulator = 1; // I need it already initialized. long currentMultiplicity = 0; // I need it already initialized. System.Collections.ArrayList factorLager = new System.Collections.ArrayList(); factorLager.Add(new omegaCouple(currentPrime, +1));// init // for (int c = 0; c < factors.Count; c++) { if (currentPrime == (long)(factors[c])) { // currentPrime stays the same. // factorAccumulator stays the same. currentMultiplicity++; ((omegaCouple)(factorLager[(int)(factorAccumulator - 1)])).setMultiplicity(currentMultiplicity); } else { currentPrime = (long)(factors[c]); // update the current prime. factorAccumulator++; // a new prime facor. currentMultiplicity = 1; factorLager.Add(new omegaCouple(currentPrime, currentMultiplicity)); } }// end for (int c = 0; c < factors.Count; c++) // omegaData = new long[factorAccumulator, 2]; for (int c = 0; c < factorAccumulator; c++) { omegaData[c, 0] = ((omegaCouple)(factorLager[c])).get_primeFactor(); omegaData[c, 1] = ((omegaCouple)(factorLager[c])).get_factorMultiplicity(); }// end for (int c = 0; c < factors.Count; c++) // // ready. return(omegaData); }// end public static int[,] OmegaData( Int64 theIsolatedNatural )
public static extern af_err af_write_array(IntPtr array_arr, [In] long[,] data, UIntPtr size_bytes, af_source src);
}// end RationalReductionOnOmegaData /// <summary> /// TODO : documentare abbondantemente ! /// </summary> /// <param name="NumeratorOmegaData"></param> /// <param name="DenominatorOmegaData"></param> /// <returns></returns> public static long[, ,] RationalReductionOnOmegaData(long[,] NumeratorOmegaData, long[,] DenominatorOmegaData) { int matrici = 2; int righe = NumeratorOmegaData.Length / 2 + DenominatorOmegaData.Length / 2; int colonne = 2; long[, ,] reducedFractionOmegaData = new long[matrici, righe, colonne]; // pre-init the response-tensor with product invariant +1. for (int mat = 0; mat < matrici; mat++) { for (int row = 0; row < righe; row++) { for (int col = 0; col < colonne; col++) { reducedFractionOmegaData[mat, row, col] = +1; } // ed for col } //end for row } //end for mat // long[,] signedExponentResult = new long[NumeratorOmegaData.Length / 2 + DenominatorOmegaData.Length / 2, 2]; int accResultInsertion = 0; for (int element_num = 0; element_num < NumeratorOmegaData.Length / 2; element_num++) { // pre-init with numerator's factors. signedExponentResult[accResultInsertion, 0] = NumeratorOmegaData[element_num, 0]; // base i.e. factor signedExponentResult[accResultInsertion, 1] = NumeratorOmegaData[element_num, 1]; // exponent i.e. multiplicity accResultInsertion++; // one factor^multiplicity inserted. }// end for : pre-init with numerator's factors. // DON'T re-init accResultInsertion. for (int element_num = 0; element_num < NumeratorOmegaData.Length / 2; element_num++) { // with these nested loops compare each denominator's factor with a numerator's factor. Numerator's factors are already inserted. for (int element_den = 0; element_den < DenominatorOmegaData.Length / 2; element_den++) { // with these nested loops compare each denominator's factor with a numerator's factor. Numerator's factors are already inserted. if (NumeratorOmegaData[element_num, 0] == DenominatorOmegaData[element_den, 0]) { // in case a denominator's factor matches with a numerator's factor : simplify the exponents (i.e. the multiplicity). bool isAlreadyTreatedFacor = false; // check if such factor is already present in the treatd ones' list. int readOnes = 0; // a counter to step in the already treated factors. for ( ; readOnes < accResultInsertion; readOnes++) { // is a factor has already been treated : if (DenominatorOmegaData[element_den, 0] == signedExponentResult[readOnes, 0]) { // then stop searching : it will be overwritten with the updated exponent. isAlreadyTreatedFacor = true; break; // the current factor has been already treated. }// else continue searching. }// end search in already treated factors. if (!isAlreadyTreatedFacor) // if the current factor was never treated before insert it as a brand new one. { // if the current factor was never treated before insert it as a brand new one. long esponente_final = NumeratorOmegaData[element_num, 1] - DenominatorOmegaData[element_den, 1]; // calculate the right moltiplicity. signedExponentResult[accResultInsertion, 0] = NumeratorOmegaData[element_num, 0]; // base signedExponentResult[accResultInsertion, 1] = esponente_final; // exponent accResultInsertion++; //one factor ahead, after having inserted both base and exponent. }// else don't repeat an already treated factor. else// i.e. if the current factor is already present between the treated ones { // sostituzione del fattore inserito senza match, con quello matchato( i.e. update its exponent). long esponente_final = NumeratorOmegaData[element_num, 1] - DenominatorOmegaData[element_den, 1]; // calculate the right moltiplicity. signedExponentResult[readOnes, 0] = NumeratorOmegaData[element_num, 0]; // base signedExponentResult[readOnes, 1] = esponente_final; // exponent // DON'T go ahead : the place was already existing. accResultInsertion++;//one factor ahead, after having inserted both base and exponent. }// end else : sostituzione del fattore inserito senza match, con quello matchato.( i.e. update its exponent). } // end if(base_num==base_den) else continue searching else // no match in current factor { bool isAlreadyTreatedFacor = false; for (int readOnes = 0; readOnes < accResultInsertion; readOnes++) { if (DenominatorOmegaData[element_den, 0] == signedExponentResult[readOnes, 0]) { isAlreadyTreatedFacor = true; break;// the current facto has been already treated. }// else continue searching. }// end search in already treated factors. if (!isAlreadyTreatedFacor) { long esponente_final = (-1) * DenominatorOmegaData[element_den, 1];// mul_(-1) because are exponents at denominator. signedExponentResult[accResultInsertion, 0] = DenominatorOmegaData[element_den, 0]; signedExponentResult[accResultInsertion, 1] = esponente_final; accResultInsertion++;//one factor ahead, after having inserted both base and exponent. }// else don't repeat an already treated factor. }// end else // no match in current factor } // end for element_den } // end for element_num //the simplified matrix, which collects together factors with positive and with negative exponents, is now ready. // this method returns a tensor of two matrices mx2 long[2, m,2]; i must fill it up, with the data of the simplified matrix. // the following loop is devoted to that: int accNumInsertion = 0; int accDenInsertion = 0; for (int row = 0; row < righe; row++) { // in the tensor, matrix[0,n,m] is the one with positive exponents (i.e. the numerator). if (signedExponentResult[row, 1] > 0) // num== matrice[0,n,m] { // num== matrice[0,n,m] reducedFractionOmegaData[0, accNumInsertion, 0] = signedExponentResult[row, 0]; // base reducedFractionOmegaData[0, accNumInsertion, 1] = signedExponentResult[row, 1]; // exp accNumInsertion++; // NB. separate counters for numerator's insertions and denominator's ones. }// end insertion in numerator. else if (signedExponentResult[row, 1] < 0) // den== matrice[1,n,m]// in the tensor, matrix[1,n,m] is the one with negative exponents (i.e. the denominator). { // den== matrice[1,n,m]// in the tensor, matrix[1,n,m] is the one with negative exponents (i.e. the denominator). reducedFractionOmegaData[1, accDenInsertion, 0] = signedExponentResult[row, 0]; // base reducedFractionOmegaData[1, accDenInsertion, 1] = signedExponentResult[row, 1]; // exp accDenInsertion++; // NB. separate counters for numerator's insertions and denominator's ones. }// end insertion in denominator. else // exp==multiplicity==0 -> write +1. { // exp==multiplicity==0 -> write +1. reducedFractionOmegaData[0, accNumInsertion, 0] = +1; // base reducedFractionOmegaData[0, accNumInsertion, 1] = +1; // exp accNumInsertion++; // NB. separate counters for numerator's insertions and denominator's ones. // exp==multiplicity==0 -> write +1. reducedFractionOmegaData[1, accDenInsertion, 0] = +1; // base reducedFractionOmegaData[1, accDenInsertion, 1] = +1; // exp accDenInsertion++; // NB. separate counters for numerator's insertions and denominator's ones. }// end // exp==multiplicity==0 -> don't write anywhere. }// end for : insertion in final tensor, from simplified matrix. //ready. return(reducedFractionOmegaData);// return the tensor. }// end RationalReductionOnOmegaData
public static extern af_err af_get_scalar([Out] long[,] output_value, IntPtr array_arr);
public virtual Tuple <long, long[]> Solve(long nodeCount, long[][] edges) { long[,] graph = CreateGraph(nodeCount, edges); throw new NotImplementedException(); }
public VelocityTracker() { x = new double[10, maxSize]; y = new double[10, maxSize]; time = new long[10, maxSize]; }
public void setTimeMatrix(long[,] newTimeMatrix) { TimeMatrix = newTimeMatrix; }
public string[] Solve(int V, int E, long[,] matrix) { int variableCount = V * V; List <string> result = new List <string>(); result.Add("first line"); string temp = ""; // 1v2v3v...vV satri for (int i = 0; i < V; i++) { temp = ""; for (int j = 0; j < V; j++) { temp += $"{i * V + j + 1} "; } temp += "0"; result.Add(temp); } // satri 2 taii for (int i = 0; i < V; i++) { for (int j = i * V + 1; j <= (i + 1) * V; j++) { for (int k = j + 1; k <= (i + 1) * V; k++) { temp = $"-{j} -{k} 0"; result.Add(temp); } } } // sotooni for (int i = 0; i < V; i++) { temp = ""; for (int j = 0; j < V; j++) { temp += $"{j * V + 1 + i} "; } temp += "0"; result.Add(temp); } // sotooni 2 taii for (int i = 0; i < V; i++) { for (int j = i + 1; j < V * V; j += V) { for (int k = j + V; k <= V * V; k += V) { temp = $"-{j} -{k} 0"; result.Add(temp); } } } // build reverse adjacency graph int[,] revAdjMatrix = new int[V + 1, V + 1]; for (int i = 1; i <= V; i++) { for (int j = 1; j <= V; j++) { revAdjMatrix[i, j] = 1; } } for (int i = 0; i < E; i++) { revAdjMatrix[matrix[i, 0], matrix[i, 1]] = 0; revAdjMatrix[matrix[i, 1], matrix[i, 0]] = 0; } for (int i = 0; i < V + 1; i++) { revAdjMatrix[i, i] = 0; } // check adjacency for (int i = 1; i <= V; i++) { for (int j = 1; j <= V; j++) { if (revAdjMatrix[i, j] == 1) { temp = ""; for (int k = 1; k < V; k++) { temp = $"-{V * i - k} -{V * j - k + 1} 0"; result.Add(temp); temp = $"-{V * i - k + 1} -{V * j - k} 0"; result.Add(temp); } } } } result[0] = $"{result.Count - 1} {V * V}"; return(result.ToArray()); }
public void Calculate_Time_Special_Point() { long[][] periods = Period_job.get_period(); long periods_full_length = Period_job.Find_Length_Period_In_Data(); int ew = periods.Length; //счетчик найденных максимумов long[,] osob_x = new long[14, ew]; // список особых точек для вывода на график long[,] osob_y = new long[14, ew]; long[,] schet = new long[15, ew]; // список особых точек для расчета (должны отличаться!!!!!) long[] schet_sum = new long[15]; // список особых точек long[,] row1 = initial_data.get_row1(); long[] row3 = initial_data.get_row3(); int reg = initial_data.REG; max_Amplitude_position = Spirogramm_Additional_Function.Calculate_Max_Amplitude_Position(periods); end_Amplitude_position = Spirogramm_Additional_Function.Calculate_End_Amplitude_Position(periods, max_Amplitude_position); max_Derivative_Amplitude = Spirogramm_Additional_Function.Calculate_Max_Derivative_Position(periods); full_Square = Spirogramm_Additional_Function.Calculate_Square(periods, end_Amplitude_position); B1_4_Square_position = Spirogramm_Additional_Function.Calculate_Chosen_Part_Time_Amplitude(periods, 250); B2_4_Square_position = Spirogramm_Additional_Function.Calculate_Chosen_Part_Time_Amplitude(periods, 500); B3_4_Square_position = Spirogramm_Additional_Function.Calculate_Chosen_Part_Time_Amplitude(periods, 750); B4_4_Square_position = Spirogramm_Additional_Function.Calculate_Chosen_Part_Time_Amplitude(periods, 1000); B1_4_Square = Spirogramm_Additional_Function.Calculate_Square(periods, B1_4_Square_position); B2_4_Square = Spirogramm_Additional_Function.Calculate_Square(periods, B2_4_Square_position); B3_4_Square = Spirogramm_Additional_Function.Calculate_Square(periods, B3_4_Square_position); B4_4_Square = Spirogramm_Additional_Function.Calculate_Square(periods, B4_4_Square_position); for (int i = 0; i < ew; i++) { if (periods[i].Length < 700) { schet[1, i] = 0; //Положение максимума производной schet[2, i] = 0; // минимум В1 schet[3, i] = 0; // положение минимума В1 - начала отсчета schet[4, i] = 0; // максимум В2 - max schet[5, i] = 0; // положение максимума В2 schet[6, i] = 0; // В1_4 - первая четверть schet[7, i] = 0; // положение первой четверти В1_4 schet[8, i] = 0; // В2_4 - вторая четверть schet[9, i] = 0; // положение второй четверти В2_4 schet[10, i] = 0; //В3_4 - третья четверть schet[11, i] = 0; // положение третьей четверти В3_4 schet[12, i] = 0; //В4_4 - четвертая четверть - или конец отсчета schet[13, i] = 0; //положение четвертой четверти В4_4 schet[14, i] = 0; // основание - положение В1 } else { schet[0, i] = row3[Period_job.Return_Length_X_Zero(i, max_Derivative_Amplitude[i])]; schet[1, i] = row1[Period_job.Return_Length_X_Zero(i, max_Derivative_Amplitude[i]), 0]; // положение максимума В2 - начала отсчета - EKG_max_x[w] schet[2, i] = periods[i][0 + shift_B1]; // минимум В1 schet[3, i] = row1[Period_job.Return_Length_X_Zero(i, 0 + shift_B1), 0]; // положение минимума В1 - начала отсчета schet[14, i] = periods[i][0 + shift_B1]; schet[4, i] = periods[i][max_Amplitude_position[i]] - periods[i][0 + shift_B1]; // максимум В2 schet[5, i] = row1[Period_job.Return_Length_X_Zero(i, max_Amplitude_position[i]), 0]; // положение максимума В2 schet[6, i] = periods[i][B1_4_Square_position[i]] - periods[i][0 + shift_B1]; // первоя четверть В1-4 schet[7, i] = row1[Period_job.Return_Length_X_Zero(i, B1_4_Square_position[i]), 0]; // положение первой четверти В1-4 schet[8, i] = periods[i][B2_4_Square_position[i]] - periods[i][0 + shift_B1]; // максимум В2-4 schet[9, i] = row1[Period_job.Return_Length_X_Zero(i, B2_4_Square_position[i]), 0]; // положение второй четверти В2-4 schet[10, i] = periods[i][B3_4_Square_position[i]] - periods[i][0 + shift_B1]; // максимум В3-4 schet[11, i] = row1[Period_job.Return_Length_X_Zero(i, B3_4_Square_position[i]), 0]; // положение третьей четверти В3-4 schet[12, i] = periods[i][end_Amplitude_position[i]] - periods[i][0 + shift_B1]; // максимум В4-4 schet[13, i] = row1[Period_job.Return_Length_X_Zero(i, end_Amplitude_position[i]), 0]; // положение четвертой четверти В4-4 } } spec_point = schet; }
public void Init(int n) { E = n + 1; G = new long[E, E]; G.Set(INF); E.REP(i => G[i, i] = 0); }
private void set_spec_point(long[,] value) { spec_point = value; }
} /// <summary> /// update the integral image /// </summary> private void UpdateIntegralImage() {
public static int Main() { bool passed = true; //initialize class CL cl1 = new CL(); //initialize struct VT vt1; vt1.i_vt_op1 = 16; vt1.ui_vt_op1 = 16; vt1.l_vt_op1 = 16; vt1.ul_vt_op1 = 16; vt1.f_vt_op1 = 16; vt1.d_vt_op1 = 16; vt1.m_vt_op1 = 16; vt1.i_vt_op2 = 15; vt1.ui_vt_op2 = 15; vt1.l_vt_op2 = 15; vt1.ul_vt_op2 = 15; vt1.f_vt_op2 = 15; vt1.d_vt_op2 = 15; vt1.m_vt_op2 = 15; vt1.nHldr_vt_op2 = new numHolder(15); int[] i_arr1d_op1 = { 0, 16 }; int[,] i_arr2d_op1 = { { 0, 16 }, { 1, 1 } }; int[,,] i_arr3d_op1 = { { { 0, 16 }, { 1, 1 } } }; uint[] ui_arr1d_op1 = { 0, 16 }; uint[,] ui_arr2d_op1 = { { 0, 16 }, { 1, 1 } }; uint[,,] ui_arr3d_op1 = { { { 0, 16 }, { 1, 1 } } }; long[] l_arr1d_op1 = { 0, 16 }; long[,] l_arr2d_op1 = { { 0, 16 }, { 1, 1 } }; long[,,] l_arr3d_op1 = { { { 0, 16 }, { 1, 1 } } }; ulong[] ul_arr1d_op1 = { 0, 16 }; ulong[,] ul_arr2d_op1 = { { 0, 16 }, { 1, 1 } }; ulong[,,] ul_arr3d_op1 = { { { 0, 16 }, { 1, 1 } } }; float[] f_arr1d_op1 = { 0, 16 }; float[,] f_arr2d_op1 = { { 0, 16 }, { 1, 1 } }; float[,,] f_arr3d_op1 = { { { 0, 16 }, { 1, 1 } } }; double[] d_arr1d_op1 = { 0, 16 }; double[,] d_arr2d_op1 = { { 0, 16 }, { 1, 1 } }; double[,,] d_arr3d_op1 = { { { 0, 16 }, { 1, 1 } } }; decimal[] m_arr1d_op1 = { 0, 16 }; decimal[,] m_arr2d_op1 = { { 0, 16 }, { 1, 1 } }; decimal[,,] m_arr3d_op1 = { { { 0, 16 }, { 1, 1 } } }; int[] i_arr1d_op2 = { 15, 0, 1 }; int[,] i_arr2d_op2 = { { 0, 15 }, { 1, 1 } }; int[,,] i_arr3d_op2 = { { { 0, 15 }, { 1, 1 } } }; uint[] ui_arr1d_op2 = { 15, 0, 1 }; uint[,] ui_arr2d_op2 = { { 0, 15 }, { 1, 1 } }; uint[,,] ui_arr3d_op2 = { { { 0, 15 }, { 1, 1 } } }; long[] l_arr1d_op2 = { 15, 0, 1 }; long[,] l_arr2d_op2 = { { 0, 15 }, { 1, 1 } }; long[,,] l_arr3d_op2 = { { { 0, 15 }, { 1, 1 } } }; ulong[] ul_arr1d_op2 = { 15, 0, 1 }; ulong[,] ul_arr2d_op2 = { { 0, 15 }, { 1, 1 } }; ulong[,,] ul_arr3d_op2 = { { { 0, 15 }, { 1, 1 } } }; float[] f_arr1d_op2 = { 15, 0, 1 }; float[,] f_arr2d_op2 = { { 0, 15 }, { 1, 1 } }; float[,,] f_arr3d_op2 = { { { 0, 15 }, { 1, 1 } } }; double[] d_arr1d_op2 = { 15, 0, 1 }; double[,] d_arr2d_op2 = { { 0, 15 }, { 1, 1 } }; double[,,] d_arr3d_op2 = { { { 0, 15 }, { 1, 1 } } }; decimal[] m_arr1d_op2 = { 15, 0, 1 }; decimal[,] m_arr2d_op2 = { { 0, 15 }, { 1, 1 } }; decimal[,,] m_arr3d_op2 = { { { 0, 15 }, { 1, 1 } } }; numHolder[] nHldr_arr1d_op2 = { new numHolder(15), new numHolder(0), new numHolder(1) }; numHolder[,] nHldr_arr2d_op2 = { { new numHolder(0), new numHolder(15) }, { new numHolder(1), new numHolder(1) } }; numHolder[,,] nHldr_arr3d_op2 = { { { new numHolder(0), new numHolder(15) }, { new numHolder(1), new numHolder(1) } } }; int[,] index = { { 0, 0 }, { 1, 1 } }; { int i_l_op1 = 16; int i_l_op2 = 15; uint ui_l_op2 = 15; long l_l_op2 = 15; ulong ul_l_op2 = 15; float f_l_op2 = 15; double d_l_op2 = 15; decimal m_l_op2 = 15; numHolder nHldr_l_op2 = new numHolder(15); if ((i_l_op1 - i_l_op2 != i_l_op1 - ui_l_op2) || (i_l_op1 - ui_l_op2 != i_l_op1 - l_l_op2) || (i_l_op1 - l_l_op2 != i_l_op1 - (int)ul_l_op2) || (i_l_op1 - (int)ul_l_op2 != i_l_op1 - f_l_op2) || (i_l_op1 - f_l_op2 != i_l_op1 - d_l_op2) || ((decimal)(i_l_op1 - d_l_op2) != i_l_op1 - m_l_op2) || (i_l_op1 - m_l_op2 != i_l_op1 - i_l_op2) || (i_l_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 1 failed"); passed = false; } if ((i_l_op1 - s_i_s_op2 != i_l_op1 - s_ui_s_op2) || (i_l_op1 - s_ui_s_op2 != i_l_op1 - s_l_s_op2) || (i_l_op1 - s_l_s_op2 != i_l_op1 - (int)s_ul_s_op2) || (i_l_op1 - (int)s_ul_s_op2 != i_l_op1 - s_f_s_op2) || (i_l_op1 - s_f_s_op2 != i_l_op1 - s_d_s_op2) || ((decimal)(i_l_op1 - s_d_s_op2) != i_l_op1 - s_m_s_op2) || (i_l_op1 - s_m_s_op2 != i_l_op1 - s_i_s_op2) || (i_l_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 2 failed"); passed = false; } if ((s_i_s_op1 - i_l_op2 != s_i_s_op1 - ui_l_op2) || (s_i_s_op1 - ui_l_op2 != s_i_s_op1 - l_l_op2) || (s_i_s_op1 - l_l_op2 != s_i_s_op1 - (int)ul_l_op2) || (s_i_s_op1 - (int)ul_l_op2 != s_i_s_op1 - f_l_op2) || (s_i_s_op1 - f_l_op2 != s_i_s_op1 - d_l_op2) || ((decimal)(s_i_s_op1 - d_l_op2) != s_i_s_op1 - m_l_op2) || (s_i_s_op1 - m_l_op2 != s_i_s_op1 - i_l_op2) || (s_i_s_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 3 failed"); passed = false; } if ((s_i_s_op1 - s_i_s_op2 != s_i_s_op1 - s_ui_s_op2) || (s_i_s_op1 - s_ui_s_op2 != s_i_s_op1 - s_l_s_op2) || (s_i_s_op1 - s_l_s_op2 != s_i_s_op1 - (int)s_ul_s_op2) || (s_i_s_op1 - (int)s_ul_s_op2 != s_i_s_op1 - s_f_s_op2) || (s_i_s_op1 - s_f_s_op2 != s_i_s_op1 - s_d_s_op2) || ((decimal)(s_i_s_op1 - s_d_s_op2) != s_i_s_op1 - s_m_s_op2) || (s_i_s_op1 - s_m_s_op2 != s_i_s_op1 - s_i_s_op2) || (s_i_s_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 4 failed"); passed = false; } } { uint ui_l_op1 = 16; int i_l_op2 = 15; uint ui_l_op2 = 15; long l_l_op2 = 15; ulong ul_l_op2 = 15; float f_l_op2 = 15; double d_l_op2 = 15; decimal m_l_op2 = 15; numHolder nHldr_l_op2 = new numHolder(15); if ((ui_l_op1 - i_l_op2 != ui_l_op1 - ui_l_op2) || (ui_l_op1 - ui_l_op2 != ui_l_op1 - l_l_op2) || ((ulong)(ui_l_op1 - l_l_op2) != ui_l_op1 - ul_l_op2) || (ui_l_op1 - ul_l_op2 != ui_l_op1 - f_l_op2) || (ui_l_op1 - f_l_op2 != ui_l_op1 - d_l_op2) || ((decimal)(ui_l_op1 - d_l_op2) != ui_l_op1 - m_l_op2) || (ui_l_op1 - m_l_op2 != ui_l_op1 - i_l_op2) || (ui_l_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 5 failed"); passed = false; } if ((ui_l_op1 - s_i_s_op2 != ui_l_op1 - s_ui_s_op2) || (ui_l_op1 - s_ui_s_op2 != ui_l_op1 - s_l_s_op2) || ((ulong)(ui_l_op1 - s_l_s_op2) != ui_l_op1 - s_ul_s_op2) || (ui_l_op1 - s_ul_s_op2 != ui_l_op1 - s_f_s_op2) || (ui_l_op1 - s_f_s_op2 != ui_l_op1 - s_d_s_op2) || ((decimal)(ui_l_op1 - s_d_s_op2) != ui_l_op1 - s_m_s_op2) || (ui_l_op1 - s_m_s_op2 != ui_l_op1 - s_i_s_op2) || (ui_l_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 6 failed"); passed = false; } if ((s_ui_s_op1 - i_l_op2 != s_ui_s_op1 - ui_l_op2) || (s_ui_s_op1 - ui_l_op2 != s_ui_s_op1 - l_l_op2) || ((ulong)(s_ui_s_op1 - l_l_op2) != s_ui_s_op1 - ul_l_op2) || (s_ui_s_op1 - ul_l_op2 != s_ui_s_op1 - f_l_op2) || (s_ui_s_op1 - f_l_op2 != s_ui_s_op1 - d_l_op2) || ((decimal)(s_ui_s_op1 - d_l_op2) != s_ui_s_op1 - m_l_op2) || (s_ui_s_op1 - m_l_op2 != s_ui_s_op1 - i_l_op2) || (s_ui_s_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 7 failed"); passed = false; } if ((s_ui_s_op1 - s_i_s_op2 != s_ui_s_op1 - s_ui_s_op2) || (s_ui_s_op1 - s_ui_s_op2 != s_ui_s_op1 - s_l_s_op2) || ((ulong)(s_ui_s_op1 - s_l_s_op2) != s_ui_s_op1 - s_ul_s_op2) || (s_ui_s_op1 - s_ul_s_op2 != s_ui_s_op1 - s_f_s_op2) || (s_ui_s_op1 - s_f_s_op2 != s_ui_s_op1 - s_d_s_op2) || ((decimal)(s_ui_s_op1 - s_d_s_op2) != s_ui_s_op1 - s_m_s_op2) || (s_ui_s_op1 - s_m_s_op2 != s_ui_s_op1 - s_i_s_op2) || (s_ui_s_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 8 failed"); passed = false; } } { long l_l_op1 = 16; int i_l_op2 = 15; uint ui_l_op2 = 15; long l_l_op2 = 15; ulong ul_l_op2 = 15; float f_l_op2 = 15; double d_l_op2 = 15; decimal m_l_op2 = 15; numHolder nHldr_l_op2 = new numHolder(15); if ((l_l_op1 - i_l_op2 != l_l_op1 - ui_l_op2) || (l_l_op1 - ui_l_op2 != l_l_op1 - l_l_op2) || (l_l_op1 - l_l_op2 != l_l_op1 - (long)ul_l_op2) || (l_l_op1 - (long)ul_l_op2 != l_l_op1 - f_l_op2) || (l_l_op1 - f_l_op2 != l_l_op1 - d_l_op2) || ((decimal)(l_l_op1 - d_l_op2) != l_l_op1 - m_l_op2) || (l_l_op1 - m_l_op2 != l_l_op1 - i_l_op2) || (l_l_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 9 failed"); passed = false; } if ((l_l_op1 - s_i_s_op2 != l_l_op1 - s_ui_s_op2) || (l_l_op1 - s_ui_s_op2 != l_l_op1 - s_l_s_op2) || (l_l_op1 - s_l_s_op2 != l_l_op1 - (long)s_ul_s_op2) || (l_l_op1 - (long)s_ul_s_op2 != l_l_op1 - s_f_s_op2) || (l_l_op1 - s_f_s_op2 != l_l_op1 - s_d_s_op2) || ((decimal)(l_l_op1 - s_d_s_op2) != l_l_op1 - s_m_s_op2) || (l_l_op1 - s_m_s_op2 != l_l_op1 - s_i_s_op2) || (l_l_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 10 failed"); passed = false; } if ((s_l_s_op1 - i_l_op2 != s_l_s_op1 - ui_l_op2) || (s_l_s_op1 - ui_l_op2 != s_l_s_op1 - l_l_op2) || (s_l_s_op1 - l_l_op2 != s_l_s_op1 - (long)ul_l_op2) || (s_l_s_op1 - (long)ul_l_op2 != s_l_s_op1 - f_l_op2) || (s_l_s_op1 - f_l_op2 != s_l_s_op1 - d_l_op2) || ((decimal)(s_l_s_op1 - d_l_op2) != s_l_s_op1 - m_l_op2) || (s_l_s_op1 - m_l_op2 != s_l_s_op1 - i_l_op2) || (s_l_s_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 11 failed"); passed = false; } if ((s_l_s_op1 - s_i_s_op2 != s_l_s_op1 - s_ui_s_op2) || (s_l_s_op1 - s_ui_s_op2 != s_l_s_op1 - s_l_s_op2) || (s_l_s_op1 - s_l_s_op2 != s_l_s_op1 - (long)s_ul_s_op2) || (s_l_s_op1 - (long)s_ul_s_op2 != s_l_s_op1 - s_f_s_op2) || (s_l_s_op1 - s_f_s_op2 != s_l_s_op1 - s_d_s_op2) || ((decimal)(s_l_s_op1 - s_d_s_op2) != s_l_s_op1 - s_m_s_op2) || (s_l_s_op1 - s_m_s_op2 != s_l_s_op1 - s_i_s_op2) || (s_l_s_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 12 failed"); passed = false; } } { ulong ul_l_op1 = 16; int i_l_op2 = 15; uint ui_l_op2 = 15; long l_l_op2 = 15; ulong ul_l_op2 = 15; float f_l_op2 = 15; double d_l_op2 = 15; decimal m_l_op2 = 15; numHolder nHldr_l_op2 = new numHolder(15); if ((ul_l_op1 - (ulong)i_l_op2 != ul_l_op1 - ui_l_op2) || (ul_l_op1 - ui_l_op2 != ul_l_op1 - (ulong)l_l_op2) || (ul_l_op1 - (ulong)l_l_op2 != ul_l_op1 - ul_l_op2) || (ul_l_op1 - ul_l_op2 != ul_l_op1 - f_l_op2) || (ul_l_op1 - f_l_op2 != ul_l_op1 - d_l_op2) || ((decimal)(ul_l_op1 - d_l_op2) != ul_l_op1 - m_l_op2) || (ul_l_op1 - m_l_op2 != ul_l_op1 - (ulong)i_l_op2) || (ul_l_op1 - (ulong)i_l_op2 != 1)) { Console.WriteLine("testcase 13 failed"); passed = false; } if ((ul_l_op1 - (ulong)s_i_s_op2 != ul_l_op1 - s_ui_s_op2) || (ul_l_op1 - s_ui_s_op2 != ul_l_op1 - (ulong)s_l_s_op2) || (ul_l_op1 - (ulong)s_l_s_op2 != ul_l_op1 - s_ul_s_op2) || (ul_l_op1 - s_ul_s_op2 != ul_l_op1 - s_f_s_op2) || (ul_l_op1 - s_f_s_op2 != ul_l_op1 - s_d_s_op2) || ((decimal)(ul_l_op1 - s_d_s_op2) != ul_l_op1 - s_m_s_op2) || (ul_l_op1 - s_m_s_op2 != ul_l_op1 - (ulong)s_i_s_op2) || (ul_l_op1 - (ulong)s_i_s_op2 != 1)) { Console.WriteLine("testcase 14 failed"); passed = false; } if ((s_ul_s_op1 - (ulong)i_l_op2 != s_ul_s_op1 - ui_l_op2) || (s_ul_s_op1 - ui_l_op2 != s_ul_s_op1 - (ulong)l_l_op2) || (s_ul_s_op1 - (ulong)l_l_op2 != s_ul_s_op1 - ul_l_op2) || (s_ul_s_op1 - ul_l_op2 != s_ul_s_op1 - f_l_op2) || (s_ul_s_op1 - f_l_op2 != s_ul_s_op1 - d_l_op2) || ((decimal)(s_ul_s_op1 - d_l_op2) != s_ul_s_op1 - m_l_op2) || (s_ul_s_op1 - m_l_op2 != s_ul_s_op1 - (ulong)i_l_op2) || (s_ul_s_op1 - (ulong)i_l_op2 != 1)) { Console.WriteLine("testcase 15 failed"); passed = false; } if ((s_ul_s_op1 - (ulong)s_i_s_op2 != s_ul_s_op1 - s_ui_s_op2) || (s_ul_s_op1 - s_ui_s_op2 != s_ul_s_op1 - (ulong)s_l_s_op2) || (s_ul_s_op1 - (ulong)s_l_s_op2 != s_ul_s_op1 - s_ul_s_op2) || (s_ul_s_op1 - s_ul_s_op2 != s_ul_s_op1 - s_f_s_op2) || (s_ul_s_op1 - s_f_s_op2 != s_ul_s_op1 - s_d_s_op2) || ((decimal)(s_ul_s_op1 - s_d_s_op2) != s_ul_s_op1 - s_m_s_op2) || (s_ul_s_op1 - s_m_s_op2 != s_ul_s_op1 - (ulong)s_i_s_op2) || (s_ul_s_op1 - (ulong)s_i_s_op2 != 1)) { Console.WriteLine("testcase 16 failed"); passed = false; } } { float f_l_op1 = 16; int i_l_op2 = 15; uint ui_l_op2 = 15; long l_l_op2 = 15; ulong ul_l_op2 = 15; float f_l_op2 = 15; double d_l_op2 = 15; decimal m_l_op2 = 15; numHolder nHldr_l_op2 = new numHolder(15); if ((f_l_op1 - i_l_op2 != f_l_op1 - ui_l_op2) || (f_l_op1 - ui_l_op2 != f_l_op1 - l_l_op2) || (f_l_op1 - l_l_op2 != f_l_op1 - ul_l_op2) || (f_l_op1 - ul_l_op2 != f_l_op1 - f_l_op2) || (f_l_op1 - f_l_op2 != f_l_op1 - d_l_op2) || (f_l_op1 - d_l_op2 != f_l_op1 - (float)m_l_op2) || (f_l_op1 - (float)m_l_op2 != f_l_op1 - i_l_op2) || (f_l_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 17 failed"); passed = false; } if ((f_l_op1 - s_i_s_op2 != f_l_op1 - s_ui_s_op2) || (f_l_op1 - s_ui_s_op2 != f_l_op1 - s_l_s_op2) || (f_l_op1 - s_l_s_op2 != f_l_op1 - s_ul_s_op2) || (f_l_op1 - s_ul_s_op2 != f_l_op1 - s_f_s_op2) || (f_l_op1 - s_f_s_op2 != f_l_op1 - s_d_s_op2) || (f_l_op1 - s_d_s_op2 != f_l_op1 - (float)s_m_s_op2) || (f_l_op1 - (float)s_m_s_op2 != f_l_op1 - s_i_s_op2) || (f_l_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 18 failed"); passed = false; } if ((s_f_s_op1 - i_l_op2 != s_f_s_op1 - ui_l_op2) || (s_f_s_op1 - ui_l_op2 != s_f_s_op1 - l_l_op2) || (s_f_s_op1 - l_l_op2 != s_f_s_op1 - ul_l_op2) || (s_f_s_op1 - ul_l_op2 != s_f_s_op1 - f_l_op2) || (s_f_s_op1 - f_l_op2 != s_f_s_op1 - d_l_op2) || (s_f_s_op1 - d_l_op2 != s_f_s_op1 - (float)m_l_op2) || (s_f_s_op1 - (float)m_l_op2 != s_f_s_op1 - i_l_op2) || (s_f_s_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 19 failed"); passed = false; } if ((s_f_s_op1 - s_i_s_op2 != s_f_s_op1 - s_ui_s_op2) || (s_f_s_op1 - s_ui_s_op2 != s_f_s_op1 - s_l_s_op2) || (s_f_s_op1 - s_l_s_op2 != s_f_s_op1 - s_ul_s_op2) || (s_f_s_op1 - s_ul_s_op2 != s_f_s_op1 - s_f_s_op2) || (s_f_s_op1 - s_f_s_op2 != s_f_s_op1 - s_d_s_op2) || (s_f_s_op1 - s_d_s_op2 != s_f_s_op1 - (float)s_m_s_op2) || (s_f_s_op1 - (float)s_m_s_op2 != s_f_s_op1 - s_i_s_op2) || (s_f_s_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 20 failed"); passed = false; } } { double d_l_op1 = 16; int i_l_op2 = 15; uint ui_l_op2 = 15; long l_l_op2 = 15; ulong ul_l_op2 = 15; float f_l_op2 = 15; double d_l_op2 = 15; decimal m_l_op2 = 15; numHolder nHldr_l_op2 = new numHolder(15); if ((d_l_op1 - i_l_op2 != d_l_op1 - ui_l_op2) || (d_l_op1 - ui_l_op2 != d_l_op1 - l_l_op2) || (d_l_op1 - l_l_op2 != d_l_op1 - ul_l_op2) || (d_l_op1 - ul_l_op2 != d_l_op1 - f_l_op2) || (d_l_op1 - f_l_op2 != d_l_op1 - d_l_op2) || (d_l_op1 - d_l_op2 != d_l_op1 - (double)m_l_op2) || (d_l_op1 - (double)m_l_op2 != d_l_op1 - i_l_op2) || (d_l_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 21 failed"); passed = false; } if ((d_l_op1 - s_i_s_op2 != d_l_op1 - s_ui_s_op2) || (d_l_op1 - s_ui_s_op2 != d_l_op1 - s_l_s_op2) || (d_l_op1 - s_l_s_op2 != d_l_op1 - s_ul_s_op2) || (d_l_op1 - s_ul_s_op2 != d_l_op1 - s_f_s_op2) || (d_l_op1 - s_f_s_op2 != d_l_op1 - s_d_s_op2) || (d_l_op1 - s_d_s_op2 != d_l_op1 - (double)s_m_s_op2) || (d_l_op1 - (double)s_m_s_op2 != d_l_op1 - s_i_s_op2) || (d_l_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 22 failed"); passed = false; } if ((s_d_s_op1 - i_l_op2 != s_d_s_op1 - ui_l_op2) || (s_d_s_op1 - ui_l_op2 != s_d_s_op1 - l_l_op2) || (s_d_s_op1 - l_l_op2 != s_d_s_op1 - ul_l_op2) || (s_d_s_op1 - ul_l_op2 != s_d_s_op1 - f_l_op2) || (s_d_s_op1 - f_l_op2 != s_d_s_op1 - d_l_op2) || (s_d_s_op1 - d_l_op2 != s_d_s_op1 - (double)m_l_op2) || (s_d_s_op1 - (double)m_l_op2 != s_d_s_op1 - i_l_op2) || (s_d_s_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 23 failed"); passed = false; } if ((s_d_s_op1 - s_i_s_op2 != s_d_s_op1 - s_ui_s_op2) || (s_d_s_op1 - s_ui_s_op2 != s_d_s_op1 - s_l_s_op2) || (s_d_s_op1 - s_l_s_op2 != s_d_s_op1 - s_ul_s_op2) || (s_d_s_op1 - s_ul_s_op2 != s_d_s_op1 - s_f_s_op2) || (s_d_s_op1 - s_f_s_op2 != s_d_s_op1 - s_d_s_op2) || (s_d_s_op1 - s_d_s_op2 != s_d_s_op1 - (double)s_m_s_op2) || (s_d_s_op1 - (double)s_m_s_op2 != s_d_s_op1 - s_i_s_op2) || (s_d_s_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 24 failed"); passed = false; } } { decimal m_l_op1 = 16; int i_l_op2 = 15; uint ui_l_op2 = 15; long l_l_op2 = 15; ulong ul_l_op2 = 15; float f_l_op2 = 15; double d_l_op2 = 15; decimal m_l_op2 = 15; numHolder nHldr_l_op2 = new numHolder(15); if ((m_l_op1 - i_l_op2 != m_l_op1 - ui_l_op2) || (m_l_op1 - ui_l_op2 != m_l_op1 - l_l_op2) || (m_l_op1 - l_l_op2 != m_l_op1 - ul_l_op2) || (m_l_op1 - ul_l_op2 != m_l_op1 - (decimal)f_l_op2) || (m_l_op1 - (decimal)f_l_op2 != m_l_op1 - (decimal)d_l_op2) || (m_l_op1 - (decimal)d_l_op2 != m_l_op1 - m_l_op2) || (m_l_op1 - m_l_op2 != m_l_op1 - i_l_op2) || (m_l_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 25 failed"); passed = false; } if ((m_l_op1 - s_i_s_op2 != m_l_op1 - s_ui_s_op2) || (m_l_op1 - s_ui_s_op2 != m_l_op1 - s_l_s_op2) || (m_l_op1 - s_l_s_op2 != m_l_op1 - s_ul_s_op2) || (m_l_op1 - s_ul_s_op2 != m_l_op1 - (decimal)s_f_s_op2) || (m_l_op1 - (decimal)s_f_s_op2 != m_l_op1 - (decimal)s_d_s_op2) || (m_l_op1 - (decimal)s_d_s_op2 != m_l_op1 - s_m_s_op2) || (m_l_op1 - s_m_s_op2 != m_l_op1 - s_i_s_op2) || (m_l_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 26 failed"); passed = false; } if ((s_m_s_op1 - i_l_op2 != s_m_s_op1 - ui_l_op2) || (s_m_s_op1 - ui_l_op2 != s_m_s_op1 - l_l_op2) || (s_m_s_op1 - l_l_op2 != s_m_s_op1 - ul_l_op2) || (s_m_s_op1 - ul_l_op2 != s_m_s_op1 - (decimal)f_l_op2) || (s_m_s_op1 - (decimal)f_l_op2 != s_m_s_op1 - (decimal)d_l_op2) || (s_m_s_op1 - (decimal)d_l_op2 != s_m_s_op1 - m_l_op2) || (s_m_s_op1 - m_l_op2 != s_m_s_op1 - i_l_op2) || (s_m_s_op1 - i_l_op2 != 1)) { Console.WriteLine("testcase 27 failed"); passed = false; } if ((s_m_s_op1 - s_i_s_op2 != s_m_s_op1 - s_ui_s_op2) || (s_m_s_op1 - s_ui_s_op2 != s_m_s_op1 - s_l_s_op2) || (s_m_s_op1 - s_l_s_op2 != s_m_s_op1 - s_ul_s_op2) || (s_m_s_op1 - s_ul_s_op2 != s_m_s_op1 - (decimal)s_f_s_op2) || (s_m_s_op1 - (decimal)s_f_s_op2 != s_m_s_op1 - (decimal)s_d_s_op2) || (s_m_s_op1 - (decimal)s_d_s_op2 != s_m_s_op1 - s_m_s_op2) || (s_m_s_op1 - s_m_s_op2 != s_m_s_op1 - s_i_s_op2) || (s_m_s_op1 - s_i_s_op2 != 1)) { Console.WriteLine("testcase 28 failed"); passed = false; } } if (!passed) { Console.WriteLine("FAILED"); return(1); } else { Console.WriteLine("PASSED"); return(100); } }
public void setTimeWindows(long[,] newTimeWindows) { TimeWindows = newTimeWindows; }
private void writeRGBAHeader(int w, int h, int tileSize) { byte[] chanOut = { 0, channelType, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 }; file.Write(ByteUtil.get4Bytes(OE_MAGIC)); file.Write(ByteUtil.get4Bytes(OE_EXR_VERSION | OE_TILED_FLAG)); file.Write(Encoding.Default.GetBytes("channels")); file.Write(ZERO); file.Write(Encoding.Default.GetBytes("chlist")); file.Write(ZERO); file.Write(ByteUtil.get4Bytes(73)); file.Write(Encoding.Default.GetBytes("R")); file.Write(chanOut); file.Write(Encoding.Default.GetBytes("G")); file.Write(chanOut); file.Write(Encoding.Default.GetBytes("B")); file.Write(chanOut); file.Write(Encoding.Default.GetBytes("A")); file.Write(chanOut); file.Write(ZERO); // compression file.Write(Encoding.Default.GetBytes("compression")); file.Write(ZERO); file.Write(Encoding.Default.GetBytes("compression")); file.Write(ZERO); file.Write(ByteUtil.get4Bytes(1)); file.Write(compression); // file.Write(ByteUtil.get4BytesInv(compression)); // datawindow =~ image size file.Write(Encoding.Default.GetBytes("dataWindow")); file.Write(ZERO); file.Write(Encoding.Default.GetBytes("box2i")); file.Write(ZERO); file.Write(ByteUtil.get4Bytes(16)); file.Write(ByteUtil.get4Bytes(0)); file.Write(ByteUtil.get4Bytes(0)); file.Write(ByteUtil.get4Bytes(w - 1)); file.Write(ByteUtil.get4Bytes(h - 1)); // dispwindow -> look at openexr.com for more info file.Write(Encoding.Default.GetBytes("displayWindow")); file.Write(ZERO); file.Write(Encoding.Default.GetBytes("box2i")); file.Write(ZERO); file.Write(ByteUtil.get4Bytes(16)); file.Write(ByteUtil.get4Bytes(0)); file.Write(ByteUtil.get4Bytes(0)); file.Write(ByteUtil.get4Bytes(w - 1)); file.Write(ByteUtil.get4Bytes(h - 1)); /* * lines in increasing y order = 0 decreasing would be 1 */ file.Write(Encoding.Default.GetBytes("lineOrder")); file.Write(ZERO); file.Write(Encoding.Default.GetBytes("lineOrder")); file.Write(ZERO); file.Write(ByteUtil.get4Bytes(1)); file.Write((byte)2); file.Write(Encoding.Default.GetBytes("pixelAspectRatio")); file.Write(ZERO); file.Write(Encoding.Default.GetBytes("float")); file.Write(ZERO); file.Write(ByteUtil.get4Bytes(4)); file.Write(ByteUtil.get4Bytes(BitConverter.ToInt32(BitConverter.GetBytes(1.0f), 0))); // meaningless to a flat (2D) image file.Write(Encoding.Default.GetBytes("screenWindowCenter")); file.Write(ZERO); file.Write(Encoding.Default.GetBytes("v2f")); file.Write(ZERO); file.Write(ByteUtil.get4Bytes(8)); file.Write(ByteUtil.get4Bytes(BitConverter.ToInt32(BitConverter.GetBytes(0.0f), 0))); file.Write(ByteUtil.get4Bytes(BitConverter.ToInt32(BitConverter.GetBytes(0.0f), 0))); // meaningless to a flat (2D) image file.Write(Encoding.Default.GetBytes("screenWindowWidth")); file.Write(ZERO); file.Write(Encoding.Default.GetBytes("float")); file.Write(ZERO); file.Write(ByteUtil.get4Bytes(4)); file.Write(ByteUtil.get4Bytes(BitConverter.ToInt32(BitConverter.GetBytes(1.0f), 0))); this.tileSize = tileSize; tilesX = ((w + tileSize - 1) / tileSize); tilesY = ((h + tileSize - 1) / tileSize); /* * twice the space for the compressing buffer, as for ex. the compressor * can actually increase the size of the data :) If that happens though, * it is not saved into the file, but discarded */ tmpbuf = new byte[tileSize * tileSize * channelSize * 4]; comprbuf = new byte[tileSize * tileSize * channelSize * 4 * 2]; tileOffsets = new long[tilesX, tilesY]; file.Write(Encoding.Default.GetBytes("tiles")); file.Write(ZERO); file.Write(Encoding.Default.GetBytes("tiledesc")); file.Write(ZERO); file.Write(ByteUtil.get4Bytes(9)); file.Write(ByteUtil.get4Bytes(tileSize)); file.Write(ByteUtil.get4Bytes(tileSize)); // ONE_LEVEL tiles, ROUNDING_MODE = not important file.Write(ZERO); // an attribute with a name of 0 to end the list file.Write(ZERO); // save a pointer to where the tileOffsets are stored and write dummy // fillers for now tileOffsetsPosition = file.BaseStream.Position; writeTileOffsets(); }
void DetectYaw() { var currentPixelation = MonochromeColors(webcam.GetPixels32()); if (previusPixelation != null) { int outt = (int)(webcam.width / SensivitySensor); if (outt < 2) { outt = 2; } int[] xdm = new int[] { -4, -3, -2, -1, 0, 1, 2, 3, 4 }; int[] ydm = new int[] { -4, -3, -2, -1, 0, 1, 2, 3, 4 }; differ = new long[xdm.Length, ydm.Length]; for (int x = 0; x < xdm.Length; x++) { for (int y = 0; y < ydm.Length; y++) { differ[x, y] = PixelDifference(currentPixelation, previusPixelation, xdm[x] * outt, ydm[y] * outt, webcam.width, webcam.height); } } greatX = 0; greatY = 0; long less = long.MaxValue; for (int x = 0; x < xdm.Length; x++) { for (int y = 0; y < ydm.Length; y++) { if (differ[x, y] < less) { less = differ[x, y]; greatX = x; greatY = y; } } } float rotation = xdm[greatX]; #if UNITY_EDITOR rotation += Input.GetAxisRaw("Mouse X") * (Input.GetMouseButton(0) ? 10 : 0); rotation += Input.GetAxisRaw("Mouse Y") * (Input.GetMouseButton(0) ? 10 : 0); #endif if (less == 0) { rotation = 0; } Smooth(ref flatten, 10, ref rotation); ObjectRotation.transform.Rotate(Vector3.up, rotation * Time.deltaTime * MultipiqueYaw); } previusPixelation = currentPixelation; }
/// Uses the stored information to run the tensorflow graph and generate /// the actions. public void DecideAction(Dictionary <Agent, AgentInfo> agentInfo) { #if ENABLE_TENSORFLOW if (coord != null) { coord.GiveBrainInfo(brain, agentInfo); } int currentBatchSize = agentInfo.Count(); List <Agent> agentList = agentInfo.Keys.ToList(); if (currentBatchSize == 0) { return; } // Create the state tensor if (hasState) { int stateLength = 1; if (brain.brainParameters.vectorObservationSpaceType == SpaceType.continuous) { stateLength = brain.brainParameters.vectorObservationSize; } inputState = new float[currentBatchSize, stateLength *brain.brainParameters.numStackedVectorObservations]; var i = 0; foreach (Agent agent in agentList) { List <float> state_list = agentInfo[agent].stackedVectorObservation; for (int j = 0; j < brain.brainParameters.vectorObservationSize * brain.brainParameters.numStackedVectorObservations; j++) { inputState[i, j] = state_list[j]; } i++; } } // Create the state tensor if (hasPrevAction) { inputPrevAction = new int[currentBatchSize]; var i = 0; foreach (Agent agent in agentList) { float[] action_list = agentInfo[agent].storedVectorActions; inputPrevAction[i] = Mathf.FloorToInt(action_list[0]); i++; } } observationMatrixList.Clear(); for (int observationIndex = 0; observationIndex < brain.brainParameters.cameraResolutions.Count(); observationIndex++) { texturesHolder.Clear(); foreach (Agent agent in agentList) { texturesHolder.Add(agentInfo[agent].visualObservations[observationIndex]); } observationMatrixList.Add( BatchVisualObservations(texturesHolder, brain.brainParameters.cameraResolutions[observationIndex].blackAndWhite)); } // Create the recurrent tensor if (hasRecurrent) { // Need to have variable memory size inputOldMemories = new float[currentBatchSize, memorySize]; var i = 0; foreach (Agent agent in agentList) { float[] m = agentInfo[agent].memories.ToArray(); for (int j = 0; j < m.Count(); j++) { inputOldMemories[i, j] = m[j]; } i++; } } var runner = session.GetRunner(); try { runner.Fetch(graph[graphScope + ActionPlaceholderName][0]); } catch { throw new UnityAgentsException(string.Format(@"The node {0} could not be found. Please make sure the graphScope {1} is correct", graphScope + ActionPlaceholderName, graphScope)); } if (hasBatchSize) { runner.AddInput(graph[graphScope + BatchSizePlaceholderName][0], new int[] { currentBatchSize }); } foreach (TensorFlowAgentPlaceholder placeholder in graphPlaceholders) { try { if (placeholder.valueType == TensorFlowAgentPlaceholder.tensorType.FloatingPoint) { runner.AddInput(graph[graphScope + placeholder.name][0], new float[] { Random.Range(placeholder.minValue, placeholder.maxValue) }); } else if (placeholder.valueType == TensorFlowAgentPlaceholder.tensorType.Integer) { runner.AddInput(graph[graphScope + placeholder.name][0], new int[] { Random.Range((int)placeholder.minValue, (int)placeholder.maxValue + 1) }); } } catch { throw new UnityAgentsException(string.Format(@"One of the Tensorflow placeholder cound nout be found. In brain {0}, there are no {1} placeholder named {2}.", brain.gameObject.name, placeholder.valueType.ToString(), graphScope + placeholder.name)); } } // Create the state tensor if (hasState) { if (brain.brainParameters.vectorObservationSpaceType == SpaceType.discrete) { var discreteInputState = new int[currentBatchSize, 1]; for (int i = 0; i < currentBatchSize; i++) { discreteInputState[i, 0] = (int)inputState[i, 0]; } runner.AddInput(graph[graphScope + VectorObservationPlacholderName][0], discreteInputState); } else { runner.AddInput(graph[graphScope + VectorObservationPlacholderName][0], inputState); } } // Create the previous action tensor if (hasPrevAction) { runner.AddInput(graph[graphScope + PreviousActionPlaceholderName][0], inputPrevAction); } // Create the observation tensors for (int obs_number = 0; obs_number < brain.brainParameters.cameraResolutions.Length; obs_number++) { runner.AddInput(graph[graphScope + VisualObservationPlaceholderName[obs_number]][0], observationMatrixList[obs_number]); } if (hasRecurrent) { runner.AddInput(graph[graphScope + "sequence_length"][0], 1); runner.AddInput(graph[graphScope + RecurrentInPlaceholderName][0], inputOldMemories); runner.Fetch(graph[graphScope + RecurrentOutPlaceholderName][0]); } TFTensor[] networkOutput; try { networkOutput = runner.Run(); } catch (TFException e) { string errorMessage = e.Message; try { errorMessage = string.Format(@"The tensorflow graph needs an input for {0} of type {1}", e.Message.Split(new string[] { "Node: " }, 0)[1].Split('=')[0], e.Message.Split(new string[] { "dtype=" }, 0)[1].Split(',')[0]); } finally { throw new UnityAgentsException(errorMessage); } } // Create the recurrent tensor if (hasRecurrent) { float[,] recurrent_tensor = networkOutput[1].GetValue() as float[, ]; var i = 0; foreach (Agent agent in agentList) { var m = new float[memorySize]; for (int j = 0; j < memorySize; j++) { m[j] = recurrent_tensor[i, j]; } agent.UpdateMemoriesAction(m.ToList()); i++; } } if (brain.brainParameters.vectorActionSpaceType == SpaceType.continuous) { var output = networkOutput[0].GetValue() as float[, ]; var i = 0; foreach (Agent agent in agentList) { var a = new float[brain.brainParameters.vectorActionSize]; for (int j = 0; j < brain.brainParameters.vectorActionSize; j++) { a[j] = output[i, j]; } agent.UpdateVectorAction(a); i++; } } else if (brain.brainParameters.vectorActionSpaceType == SpaceType.discrete) { long[,] output = networkOutput[0].GetValue() as long[, ]; var i = 0; foreach (Agent agent in agentList) { var a = new float[1] { (float)(output[i, 0]) }; agent.UpdateVectorAction(a); i++; } } #else if (agentInfo.Count > 0) { throw new UnityAgentsException(string.Format(@"The brain {0} was set to Internal but the Tensorflow library is not present in the Unity project.", brain.gameObject.name)); } #endif }
private void FixupMeta() { if (blockMeta != null) { blockMetas.Clear(); for (int i = 0; i < WidthFull; i++) for (int j = 0; j < HeightFull; j++) if (blockMeta[i, j] != 0) blockMetas.Add(WorldPoint.PointToKey(i, j), blockMeta[i, j]); //blockMetas.Add(Tuple.Create(i, j), blockMeta[i, j]); blockMeta = null; } }
public async void Calculate() { var color = Color.FromRgb(ColorR, ColorG, ColorB); var p = new BuddhabrotPlotter(ImagePixelWidth, ImagePixelHeight, color); p.AlphaMagnification = ColorAlpha; if (DoAllPixel) { pixelMatrix = await p.Excute(Iteration); await Task.Factory.StartNew(() => MainImage = p.MatrixToImage(pixelMatrix).Result); } else { pixelMatrix = await p.ExcuteRandom(Iteration, PlotCount); await Task.Factory.StartNew(() => MainImage = p.MatrixToImage(pixelMatrix).Result); } IsRunning = false; Messenger.Raise(new InformationMessage("処理が終了しました。", "", "Info")); }