Ejemplo n.º 1
0
        private void DisplaySecondLevel()
        {
            B2.Clear();
            B8.Clear();
            B8.ReadOnly = false;
            B12.Clear();
            B13.Clear();
            B15.Clear();
            B16.Clear();
            B16.ReadOnly = false;

            B3.Text     = "3";
            B3.ReadOnly = true;
            B4.Clear();
            B4.ReadOnly = false;
            B5.Clear();
            B5.ReadOnly = false;
            B6.Text     = "2";
            B6.ReadOnly = true;
            B7.Clear();
            B7.ReadOnly = false;
            B9.Text     = "4";
            B9.ReadOnly = true;
            B10.Clear();
            B10.ReadOnly = false;
            B14.Text     = "1";
            B14.ReadOnly = true;
        }
Ejemplo n.º 2
0
        public static int[,] Multiply(this int[,] a, int[,] b)
        {
            // check if the task canceled from UI
            //if (pingpongalgorithmnew.current_token.iscancellationrequested)
            //{
            //    throw new taskcanceledexception("task canceled");
            //}
            //if (a.GetLength(0) == 2)
            //{
            //    int[,] data = new int[2, 2];
            //    data[0, 0] = a[0, 0] * b[0, 0] + a[0, 1] * b[1, 0];
            //    data[0, 1] = a[0, 0] * b[0, 1] + a[0, 1] * b[1, 1];
            //    data[1, 0] = a[1, 0] * b[0, 0] + a[1, 1] * b[1, 0];
            //    data[1, 1] = a[1, 0] * b[0, 1] + a[1, 1] * b[1, 1];
            //    return data;
            //}
            if (a.GetLength(0) < 64)
            {
                return(a.NaiveMultiplication(b));
            }

            (int[,] A11, int[,] A12, int[,] A21, int[,] A22) = a.divide();
            (int[,] B11, int[,] B12, int[,] B21, int[,] B22) = b.divide();
            //M1 = multiplication((A11 + A22), (B11 + B22))
            int[,] M1 = (A11.Add(A22)).Multiply(B11.Add(B22));
            //M2 = multiplication((A21 + A22), B11)
            int[,] M2 = (A21.Add(A22)).Multiply(B11);
            //M3 = multiplication(A11, (B12 - B22))
            int[,] M3 = A11.Multiply(B12.Subtrac(B22));
            //M4 = multiplication(A22, (B21 - B11))
            int[,] M4 = A22.Multiply(B21.Subtrac(B11));
            //M5 = multiplication((A11 + A12), B22)
            int[,] M5 = (A11.Add(A12)).Multiply(B22);
            //M6 = multiplication((A21 - A11), (B11 + B12))
            int[,] M6 = (A21.Subtrac(A11)).Multiply(B11.Add(B12));
            //M7 = multiplication((A12 - A22), (B21 + B22))
            int[,] M7 = (A12.Subtrac(A22)).Multiply(B21.Add(B22));

            //C11 = M1 + M4 - M5 + M7
            int[,] C11 = M1.Add(M4).Subtrac(M5).Add(M7);
            //C12 = M3 + M5
            int[,] C12 = M3.Add(M5);
            //C21 = M2 + M4
            int[,] C21 = M2.Add(M4);
            //C22 = M1 - M2 + M3 + M6
            int[,] C22 = M1.Subtrac(M2).Add(M3).Add(M6);
            return(combine(C11, C12, C21, C22, a.GetLength(0)));
        }
Ejemplo n.º 3
0
Archivo: arm.cs Proyecto: ShSaw/Bandage
 // Start is called before the first frame update
 void Start()
 {
     stopWatch = new Stopwatch();
     stopWatch.Start();
     scoreText.text = "Score: " + score.ToString();
     score          = 0;
     b2             = FindObjectOfType <Bullet2script>();
     b1             = FindObjectOfType <sc>();
     b3             = FindObjectOfType <B3>();
     b4             = FindObjectOfType <B4>();
     b5             = FindObjectOfType <B5>();
     b6             = FindObjectOfType <B6>();
     b7             = FindObjectOfType <B7>();
     b8             = FindObjectOfType <B8>();
     b9             = FindObjectOfType <B9>();
     b10            = FindObjectOfType <B10>();
     b11            = FindObjectOfType <B11>();
     b12            = FindObjectOfType <B12>();
     b13            = FindObjectOfType <B13>();
     b14            = FindObjectOfType <B14>();
     b15            = FindObjectOfType <B15>();
     b16            = FindObjectOfType <B16>();
     b17            = FindObjectOfType <B17>();
     b18            = FindObjectOfType <B18>();
     b19            = FindObjectOfType <B19>();
     b20            = FindObjectOfType <B20>();
     b21            = FindObjectOfType <B21>();
     b22            = FindObjectOfType <B22>();
     b23            = FindObjectOfType <B23>();
     b24            = FindObjectOfType <B24>();
     b25            = FindObjectOfType <B25>();
     b26            = FindObjectOfType <B26>();
     b27            = FindObjectOfType <B27>();
     b28            = FindObjectOfType <B28>();
     b29            = FindObjectOfType <B29>();
     b30            = FindObjectOfType <B30>();
     b31            = FindObjectOfType <B31>();
     b32            = FindObjectOfType <B32>();
     b33            = FindObjectOfType <B33>();
     b34            = FindObjectOfType <B34>();
     b35            = FindObjectOfType <B35>();
     b36            = FindObjectOfType <B36>();
     b37            = FindObjectOfType <B37>();
     b38            = FindObjectOfType <B38>();
     b39            = FindObjectOfType <B39>();
     b40            = FindObjectOfType <B40>();
     b41            = FindObjectOfType <B41>();
 }
Ejemplo n.º 4
0
            public int CompareTo(object obj)
            {
                B12 that = (B12)obj;

                {
                    long diff = this.A - that.A;
                    if (diff > 0)
                    {
                        return(1);
                    }
                    else if (diff < 0)
                    {
                        return(-1);
                    }
                }
                {
                    int diff = this.B - that.B; if (0 != diff)
                    {
                        return(diff);
                    }
                }
                return(0);
            }
Ejemplo n.º 5
0
        protected override void ProcessCommand(NetworkStream nstm, char tag)
        {
            //string s;
            int len;

            switch (tag)
            {
            case 'e':     // Batch 'get next' enumeration.
            {
                try
                {
                    int ienumid = nstm.ReadByte();
                    if (ienumid >= 0)
                    {
                        byte enumid = (byte)ienumid;
                        if (enumid >= this.enums.Length)
                        {
                            nstm.WriteByte((byte)'-');
                        }
                        else
                        {
                            if (null == this.enums[enumid])
                            {
                                this.enums[enumid] = new LongIntComboListPartEnumerator(this);
                            }
                            int offset = 0;
                            if (null == buf || buf.Length < 60)
                            {
                                throw new Exception("Enumeration batch buffer too small!");
                            }
                            //if (uniquecompression) // Compressed...
                            {
                                for (; ;)
                                {
                                    if (!this.enums[enumid].MoveNext())
                                    {
                                        break;
                                    }
                                    B12 b12 = this.enums[enumid].Current;
                                    // Using Big Endian!
                                    b12.CopyToArray(buf, offset);
                                    offset += 12;
                                    if (offset + 12 > buf.Length)
                                    {
                                        break;
                                    }
                                }
                            }
                            if (offset > 0)
                            {
                                nstm.WriteByte((byte)'+');
                                XContent.SendXContent(nstm, buf, offset);
                            }
                            else
                            {
                                nstm.WriteByte((byte)'-');
                            }
                        }
                    }
                }
                catch
                {
                    nstm.WriteByte((byte)'-');
                    throw;
                }
            }
            break;

            case 'n':     // Reset next in enumeration..
            {
                int ienumid = nstm.ReadByte();
                if (ienumid >= 0)
                {
                    byte enumid = (byte)ienumid;
                    if (XLog.logging)
                    {
                        XLog.log("Starting enumeration (enumid:" + enumid.ToString() + ")");
                    }
                    if (enumid < this.enums.Length &&
                        null != this.enums[enumid])
                    {
                        //this.enums[enumid].Reset();
                        this.enums[enumid] = null;
                    }
                }
            }
            break;

            case 's':
            {
                try
                {
#if ENABLE_TIMING
                    long start = 0;
                    if (XLog.logging)
                    {
                        QueryPerformanceCounter(out start);
                    }
#endif

                    int readbuflen = 1048576;
                    if (null != DistributedObjectsSlave.xslave)
                    {
                        System.Xml.XmlNode xzblocks = DistributedObjectsSlave.xslave["zblocks"];
                        if (null != xzblocks)
                        {
                            {
                                System.Xml.XmlAttribute xzbs = xzblocks.Attributes["readbuffersize"];
                                if (null != xzbs)
                                {
                                    readbuflen = DistributedObjectsSlave.ParseCapacity(xzbs.Value);
                                }
                            }
                        }
                    }

                    foreach (ZBlock zb in zblocks)
                    {
                        zb.LeaveAddMode(readbuflen);
                    }

                    foreach (ZBlock zb in zblocks)
                    {
                        zb.Sort(b12buffer, this.buf);
                    }

#if ENABLE_TIMING
                    if (XLog.logging)
                    {
                        long stop;
                        QueryPerformanceCounter(out stop);
                        long freq;
                        if (QueryPerformanceFrequency(out freq))
                        {
                            long secs = (stop - start) / freq;
                            if (secs > 10)
                            {
                                XLog.log("IntComboListPart sort seconds: " + secs.ToString());
                            }
                        }
                    }
#endif
                }
                finally
                {
                    nstm.WriteByte((byte)'+');
                }
            }
            break;

            case 'p':     // Batch push/publish...
            {
                buf = XContent.ReceiveXBytes(nstm, out len, buf);
                uint gbfree = (uint)(GetCurrentDiskFreeBytes() / 1073741824);
#if DEBUG
                {
                    string computer_name = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
                    if (computer_name == "MAPDDRULE" || computer_name == "MAPDCMILLER" || computer_name == "computer_name")
                    {
                        gbfree = uint.MaxValue;
                    }
                }
#endif
                if (gbfree > 20)
                {
                    int pcount = len / 12;         // size of B12
                    int y      = 0;
                    for (int i = 0; i != pcount; i++)
                    {
                        TimedAdd(buf, y);
                        y += 12;
                    }
                }
                else
                {
                    if (!nofreedisklog)
                    {
                        nofreedisklog = true;
                        XLog.errorlog("Low free disk space; now dropping entries.");
                    }
                }
            }
            break;

            default:
                base.ProcessCommand(nstm, tag);
                break;
            }
        }