public IVarianceI Calculate(
     IVarianceIResultElementFactory varianceIResultElementFactory,
     IVarianceIFactory varianceIFactory,
     IVarianceIResultElementCalculation varianceIResultElementCalculation,
     Il l,
     It t,
     Ist st,
     ItΛ tΛ,
     IVarianceΦ varianceΦ,
     Iz z)
 {
     return(varianceIFactory.Create(
                tΛ.Value
                .Select(i => varianceIResultElementCalculation.Calculate(
                            varianceIResultElementFactory,
                            i.tIndexElement,
                            i.ΛIndexElement,
                            l,
                            t,
                            st,
                            varianceΦ,
                            z))
                .ToImmutableList()));
 }
Ejemplo n.º 2
0
        public void StoreObject(Type type)
        {
            if (Index == null)
            {
                return;
            }
            if (type.IsValueType)
            {
                throw new InvalidOperationException("A reference type expected");
            }
            // Store in array of all references
            LoadContext();                        // stack: [context]
            Il.Ldfld(ReaderContext.ObjectsField); // stack: [context.objects]
            var doneLabel = Il.DefineLabel("done");

            Il.Brfalse(doneLabel);                                                                           // if(context.objects == null) goto done; stack: []

            LoadContext();                                                                                   // stack: [context]
            Il.Ldfld(ReaderContext.ObjectsField);                                                            // stack: [context.objects]
            Il.Ldloc(Index);                                                                                 // stack: [context.objects, index]
            LoadResult(type);                                                                                // stack: [context.objects, index, result]
            Il.Call(HackHelpers.GetMethodDefinition <Dictionary <int, object> >(dict => dict.Add(0, null))); // context.objects.Add(index, result)
            Il.MarkLabel(doneLabel);
        }
Ejemplo n.º 3
0
        private static Bitmap DDSDataToBMP(byte[] ddsData)
        {
            // Create a DevIL image "name" (which is actually a number)
            int imageName;

            Il.ilGenImages(1, out imageName);
            Il.ilBindImage(imageName);

            // Load the DDS file into the bound DevIL image
            Il.ilLoadL(Il.IL_DDS, ddsData, ddsData.Length);

            // Set a few size variables that will simplify later code
            int       imageWidth  = Il.ilGetInteger(Il.IL_IMAGE_WIDTH);
            int       imageHeight = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT);
            Rectangle rect        = new Rectangle(0, 0, imageWidth, imageHeight);

            // Convert the DevIL image to a pixel byte array to copy into Bitmap
            Il.ilConvertImage(Il.IL_BGRA, Il.IL_UNSIGNED_BYTE);

            // Create a Bitmap to copy the image into, and prepare it to get data
            Bitmap     bitmap     = new Bitmap(imageWidth, imageHeight);
            BitmapData bitmapData = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);

            // Copy the pixel byte array from the DevIL image to the Bitmap
            int result = Il.ilCopyPixels(0, 0, 0, Il.ilGetInteger(Il.IL_IMAGE_WIDTH), Il.ilGetInteger(Il.IL_IMAGE_HEIGHT), 1, Il.IL_BGRA, Il.IL_UNSIGNED_BYTE, bitmapData.Scan0);

            if (result == Il.IL_INVALID_CONVERSION || result == Il.IL_ILLEGAL_OPERATION)
            {
                throw new InvalidDataException("Cannot Convert Bitmap.");
            }

            // Clean up and return Bitmap
            Il.ilDeleteImages(1, ref imageName);
            bitmap.UnlockBits(bitmapData);
            return(bitmap);
        }
Ejemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult ds = openFileDialog1.ShowDialog();

            if (ds == DialogResult.OK)
            {
                Il.ilGenImages(1, out index);
                Il.ilBindImage(index);
                url = openFileDialog1.FileName;
                if (Il.ilLoadImage(url))
                {
                    int width  = Il.ilGetInteger(Il.IL_IMAGE_WIDTH);
                    int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT);


                    int bitsPP = Il.ilGetInteger(Il.IL_IMAGE_BITS_PER_PIXEL);

                    switch (bitsPP)
                    {
                    case 24:
                        indexObject = MakeGlTexture(Gl.GL_RGB, Il.ilGetData(), width, height);
                        break;

                    case 32:
                        indexObject = MakeGlTexture(Gl.GL_RGBA, Il.ilGetData(), width, height);
                        break;
                    }

                    isLoaded = true;
                    Il.ilDeleteImages(1, ref index);

                    timer2.Enabled = true;
                    timer1.Enabled = false;
                }
            }
        }
Ejemplo n.º 5
0
        public void LoadTexture(string textureId, string path)
        {
            int devilId = 0;

            Il.ilGenImages(1, out devilId);
            Il.ilBindImage(devilId);//set as the active texture

            if (!Il.ilLoadImage(path))
            {
                System.Diagnostics.Debug.Assert(false,
                                                "Could not open file, [" + path + "].");
            }

            //flip images for this one project
            Ilu.iluFlipImage();
            int width    = Il.ilGetInteger(Il.IL_IMAGE_WIDTH);
            int height   = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT);
            int openGLId = Ilut.ilutGLBindTexImage();

            System.Diagnostics.Debug.Assert(openGLId != 0);
            Il.ilDeleteImages(1, ref devilId);

            _textureDatabase.Add(textureId, new Texture(openGLId, width, height));
        }
Ejemplo n.º 6
0
        private void LoadTexture()
        {
            // если файл выбран - и возвращен результат OK
            // создаем изображение с идентификатором
            Il.ilGenImages(1, out imageId);
            // делаем изображение текущим
            Il.ilBindImage(imageId);
            // адрес изображения полученный с помощью окна выбора файла
            string url = "zamok.jpg";

            // пробуем загрузить изображение
            if (Il.ilLoadImage(url))
            {
                // если загрузка прошла успешно
                // сохраняем размеры изображения
                int width  = Il.ilGetInteger(Il.IL_IMAGE_WIDTH);
                int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT);
                // определяем число бит на пиксель
                int bitspp = Il.ilGetInteger(Il.IL_IMAGE_BITS_PER_PIXEL);
                switch (bitspp)
                {
                // создаем текстуру, используя режим GL_RGB или GL_RGBA
                case 24:
                    mGlTextureObject = MakeGlTexture(Gl.GL_RGB, Il.ilGetData(), width, height);
                    break;

                case 32:
                    mGlTextureObject = MakeGlTexture(Gl.GL_RGBA, Il.ilGetData(), width, height);
                    break;
                }
                // активируем флаг, сигнализирующий загрузку текстуры
                textureIsLoad = true;
                // очищаем память
                Il.ilDeleteImages(1, ref imageId);
            }
        }
Ejemplo n.º 7
0
 public IExpectedValueI Calculate(
     IExpectedValueIResultElementFactory expectedValueIResultElementFactory,
     IExpectedValueIFactory expectedValueIFactory,
     IExpectedValueIResultElementCalculation expectedValueIResultElementCalculation,
     Il l,
     It t,
     Ist st,
     ItΛ tΛ,
     IExpectedValueΦ expectedValueΦ,
     Iz z)
 {
     return(expectedValueIFactory.Create(
                tΛ.Value
                .Select(i => expectedValueIResultElementCalculation.Calculate(
                            expectedValueIResultElementFactory,
                            i.tIndexElement,
                            i.ΛIndexElement,
                            l,
                            t,
                            st,
                            expectedValueΦ,
                            z))
                .ToImmutableList()));
 }
Ejemplo n.º 8
0
 public bool EmitNullChecking(Type type, GroboIL.Label objIsNullLabel)
 {
     if (!type.IsValueType)
     {
         Il.Dup();                   // stack: [obj, obj]
         Il.Brfalse(objIsNullLabel); // if(obj == null) goto returnDefaultValue; stack: [obj]
         return(true);
     }
     if (type.IsNullable())
     {
         using (var temp = DeclareLocal(type.MakeByRefType()))
         {
             Il.Stloc(temp);
             Il.Ldnull();
             Il.Ldloc(temp);
             EmitHasValueAccess(type);
             Il.Brfalse(objIsNullLabel);
             Il.Pop();
             Il.Ldloc(temp);
         }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 9
0
 /// <summary>
 ///     Loads <c>index</c> onto the evaluation stack
 /// </summary>
 public void LoadIndex()
 {
     Il.Ldarg(1);
     Il.Ldind(typeof(int));
 }
Ejemplo n.º 10
0
 /// <summary>
 ///     Loads <c>ref index</c> onto the evaluation stack
 /// </summary>
 public void LoadIndexByRef()
 {
     Il.Ldarg(1);
 }
Ejemplo n.º 11
0
 /// <summary>
 ///     Loads <c>pinnedData</c> onto the evaluation stack
 /// </summary>
 public void LoadData()
 {
     Il.Ldarg(0);
 }
Ejemplo n.º 12
0
 /// <summary>
 ///     Loads &amp;<c>data</c>[<c>index</c>] onto the evaluation stack
 /// </summary>
 public void GoToCurrentLocation()
 {
     LoadData();  // stack: [pinnedData]
     LoadIndex(); // stack: [pinnedData, index]
     Il.Add();    // stack: [pinnedData + index]
 }
Ejemplo n.º 13
0
        public void EmitArithmeticOperation(ExpressionType nodeType, Type resultType, Type leftType, Type rightType, MethodInfo method)
        {
            if (!leftType.IsNullable() && !rightType.IsNullable())
            {
                if (method != null)
                {
                    Il.Call(method);
                }
                else
                {
                    if (leftType.IsStruct())
                    {
                        throw new InvalidOperationException("Unable to perfrom operation '" + nodeType + "' to a struct of type '" + leftType + "'");
                    }
                    if (rightType.IsStruct())
                    {
                        throw new InvalidOperationException("Unable to perfrom operation '" + nodeType + "' to a struct of type '" + rightType + "'");
                    }
                    EmitOp(Il, nodeType, resultType);
                }
            }
            else
            {
                using (var localLeft = DeclareLocal(leftType))
                    using (var localRight = DeclareLocal(rightType))
                    {
                        Il.Stloc(localRight);
                        Il.Stloc(localLeft);
                        var returnNullLabel = Il.DefineLabel("returnNull");
                        if (leftType.IsNullable())
                        {
                            Il.Ldloca(localLeft);
                            EmitHasValueAccess(leftType);
                            Il.Brfalse(returnNullLabel);
                        }
                        if (rightType.IsNullable())
                        {
                            Il.Ldloca(localRight);
                            EmitHasValueAccess(rightType);
                            Il.Brfalse(returnNullLabel);
                        }
                        if (!leftType.IsNullable())
                        {
                            Il.Ldloc(localLeft);
                        }
                        else
                        {
                            Il.Ldloca(localLeft);
                            EmitValueAccess(leftType);
                        }
                        if (!rightType.IsNullable())
                        {
                            Il.Ldloc(localRight);
                        }
                        else
                        {
                            Il.Ldloca(localRight);
                            EmitValueAccess(rightType);
                        }
                        Type argumentType = resultType.GetGenericArguments()[0];
                        if (method != null)
                        {
                            Il.Call(method);
                        }
                        else
                        {
                            EmitOp(Il, nodeType, argumentType);
                        }
                        Il.Newobj(resultType.GetConstructor(new[] { argumentType }));

                        var doneLabel = Il.DefineLabel("done");
                        Il.Br(doneLabel);
                        MarkLabelAndSurroundWithSP(returnNullLabel);
                        EmitLoadDefaultValue(resultType);
                        MarkLabelAndSurroundWithSP(doneLabel);
                    }
            }
        }
Ejemplo n.º 14
0
 public void MarkLabelAndSurroundWithSP(GroboIL.Label label)
 {
     MarkHiddenSP();
     Il.MarkLabel(label);
     MarkHiddenSP();
 }
Ejemplo n.º 15
0
 /// <summary>
 ///     Loads <c>context.serializerId</c> onto the evaluation stack
 /// </summary>
 public void LoadSerializerId()
 {
     LoadContext();
     Il.Ldfld(ReaderContext.SerializerIdField);
 }
Ejemplo n.º 16
0
        protected void btnSube_Click(object sender, EventArgs e)
        {
            Sube  sube;
            Adres adres;
            Il    il;
            Ilce  ilce;
            int   selectedRowIndex = gvSube.SelectedIndex;

            try
            {
                if (selectedRowIndex < 0)
                {
                    sube  = new Sube();
                    adres = new Adres();
                    il    = new Il();
                    ilce  = new Ilce();

                    var i  = ddlSubeIl.SelectedIndex;
                    var ie = ddlSubeIlce.SelectedItem.Text.ToString();
                    il   = db.Iller.Find(i);
                    ilce = (from ii in db.Iller
                            join iiee in db.Ilceler on ii.Id equals iiee.IlId
                            where iiee.IlId == i && iiee.Ad == ie
                            select iiee).SingleOrDefault();
                    adres.IlId   = i;
                    adres.IlceId = ilce.Id;

                    adres.Mahalle = tbSubeMahalle.Text;
                    adres.Sokak   = tbSubeSokak.Text;
                    db.Adresler.Add(adres);
                    db.SaveChanges();

                    sube.Ad      = tbSubeAd.Text;
                    sube.Tel     = tbSubeTel.Text;
                    sube.AdresId = adres.Id;
                    db.Subeler.Add(sube);

                    lblSubeSonuc.Text = "Şube başarıyla eklenmiştir.";
                }
                else
                {
                    int subeId = Convert.ToInt32(tbSubeId.Text);
                    sube = db.Subeler.Find(subeId);

                    int adresId = Convert.ToInt32(sube.AdresId);
                    adres = db.Adresler.Find(adresId);

                    var i  = ddlSubeIl.SelectedIndex;
                    var ie = ddlSubeIlce.SelectedItem.Text.ToString();
                    il   = db.Iller.Find(i);
                    ilce = (from ii in db.Iller
                            join iiee in db.Ilceler on ii.Id equals iiee.IlId
                            where iiee.IlId == i && iiee.Ad == ie
                            select iiee).SingleOrDefault();
                    adres.IlId   = i;
                    adres.IlceId = ilce.Id;

                    adres.Mahalle = tbSubeMahalle.Text;
                    adres.Sokak   = tbSubeSokak.Text;

                    sube.Ad           = tbSubeAd.Text;
                    sube.Tel          = tbSubeTel.Text;
                    lblSubeSonuc.Text = "Sube başarıyla güncellenmiştir.";
                }
                db.SaveChanges();
            }
            catch (Exception)
            {
                lblSubeSonuc.Text = "İşlem başarısız olmuştur.";
            }
            gvSubeDataBind();
            clearSube();
        }
Ejemplo n.º 17
0
        public static void Main(string[] args)
        {
            int    imageId;
            string inputFile  = "Data" + Path.DirectorySeparatorChar + "yinyangblue.gif";
            string outputFile = "Data" + Path.DirectorySeparatorChar + "yinyangblue.jpg";

            Console.WriteLine("DevIlExamples.SimpleExample - DevIL simple command line application.");

            if (args.Length == 2)
            {
                inputFile  = args[0];
                outputFile = args[1];
                Console.WriteLine("Converting - {0} -> {1}", inputFile, outputFile);
            }
            else
            {
                Console.WriteLine("Usage - DevIlExamples.SimpleExample <inputfile> <outputfile>");
                Console.WriteLine("Converting example files - {0} -> {1}", inputFile, outputFile);
            }

            if (Il.ilGetInteger(Il.IL_VERSION_NUM) < Il.IL_VERSION ||
                Il.ilGetInteger(Ilu.ILU_VERSION_NUM) < Ilu.ILU_VERSION ||
                Il.ilGetInteger(Ilut.ILUT_VERSION_NUM) < Ilut.ILUT_VERSION)
            {
                Console.WriteLine("*** Your DevIL native libraries are older than what Tao.DevIl supports, get the latest DevIL native libraries. ***");
                Console.WriteLine("Your DevIL native IL version: {0}.  Tao.DevIl's IL version: {1}.",
                                  Il.ilGetInteger(Il.IL_VERSION_NUM), Il.IL_VERSION);
                Console.WriteLine("Your DevIL native ILU version: {0}.  Tao.DevIl's ILU version: {1}.",
                                  Il.ilGetInteger(Ilu.ILU_VERSION_NUM), Ilu.ILU_VERSION_NUM);
                Console.WriteLine("Your DevIL native ILUT version: {0}.  Tao.DevIl's ILUT version: {1}.",
                                  Il.ilGetInteger(Ilut.ILUT_VERSION_NUM), Ilut.ILUT_VERSION_NUM);
            }

            // Initialize DevIL
            Il.ilInit();

            // Generate the main image name to use
            Il.ilGenImages(1, out imageId);

            // Bind this image name
            Il.ilBindImage(imageId);

            // Loads the image into the imageId
            if (!Il.ilLoadImage(inputFile))
            {
                Console.WriteLine("Could not open file, {0}, exiting.", inputFile);
                Exit();
            }

            // Display the image's dimensions
            Console.WriteLine("Width: {0} Height: {1}, Depth: {2}, Bpp: {3}",
                              Il.ilGetInteger(Il.IL_IMAGE_WIDTH), Il.ilGetInteger(Il.IL_IMAGE_HEIGHT),
                              Il.ilGetInteger(Il.IL_IMAGE_DEPTH),
                              Il.ilGetInteger(Il.IL_IMAGE_BITS_PER_PIXEL));

            // Enable overwriting destination file
            Il.ilEnable(Il.IL_FILE_OVERWRITE);

            // Save the image
            Il.ilSaveImage(outputFile);

            // Done with the imageId, so let's delete it
            Il.ilDeleteImages(1, ref imageId);

            Exit();
        }
Ejemplo n.º 18
0
        public IΦHat Calculate(
            IExpectedValueIResultElementCalculationFactory expectedValueIResultElementCalculationFactory,
            IExpectedValueΦResultElementCalculationFactory expectedValueΦResultElementCalculationFactory,
            IVarianceIResultElementCalculationFactory varianceIResultElementCalculationFactory,
            IVarianceΦResultElementCalculationFactory varianceΦResultElementCalculationFactory,
            IVHatResultElementCalculationFactory VHatResultElementCalculationFactory,
            Iυ2ResultElementCalculationFactory υ2ResultElementCalculationFactory,
            IΦHatResultElementCalculationFactory ΦHatResultElementCalculationFactory,
            IExpectedValueICalculationFactory expectedValueICalculationFactory,
            IExpectedValueΦCalculationFactory expectedValueΦCalculationFactory,
            IMRNBCalculationFactory MRNBCalculationFactory,
            IRNBCalculationFactory RNBCalculationFactory,
            ItStarCalculationFactory tStarCalculationFactory,
            IVarianceICalculationFactory varianceICalculationFactory,
            IVarianceΦCalculationFactory varianceΦCalculationFactory,
            IVHatCalculationFactory VHatCalculationFactory,
            Iυ2CalculationFactory υ2CalculationFactory,
            INormalFactory normalFactory,
            IExpectedValueIResultElementFactory expectedValueIResultElementFactory,
            IExpectedValueΦResultElementFactory expectedValueΦResultElementFactory,
            IVarianceIResultElementFactory varianceIResultElementFactory,
            IVarianceΦResultElementFactory varianceΦResultElementFactory,
            IVHatResultElementFactory VHatResultElementFactory,
            Iυ2ResultElementFactory υ2ResultElementFactory,
            IΦHatResultElementFactory ΦHatResultElementFactory,
            IExpectedValueIFactory expectedValueIFactory,
            IExpectedValueΦFactory expectedValueΦFactory,
            IVarianceIFactory varianceIFactory,
            IVarianceΦFactory varianceΦFactory,
            IVHatFactory VHatFactory,
            Iυ2Factory υ2Factory,
            IΦHatFactory ΦHatFactory,
            Il l,
            It t,
            IΛ Λ,
            IslΛ slΛ,
            Ist st,
            ItΛ tΛ,
            IL L,
            Ip p,
            Iμ μ,
            Iσ σ,
            IΩ Ω,
            Iz z)
        {
            // ExpectedValueΦ
            IExpectedValueΦ expectedValueΦ = expectedValueΦCalculationFactory.Create()
                                             .Calculate(
                expectedValueΦResultElementFactory,
                expectedValueΦFactory,
                expectedValueΦResultElementCalculationFactory.Create(),
                l,
                t,
                slΛ,
                L,
                p,
                μ);

            // VarianceΦ
            IVarianceΦ varianceΦ = varianceΦCalculationFactory.Create()
                                   .Calculate(
                varianceΦResultElementFactory,
                varianceΦFactory,
                varianceΦResultElementCalculationFactory.Create(),
                l,
                t,
                slΛ,
                L,
                p,
                μ,
                σ);

            // ExpectedValueI
            IExpectedValueI expectedValueI = expectedValueICalculationFactory.Create()
                                             .Calculate(
                expectedValueIResultElementFactory,
                expectedValueIFactory,
                expectedValueIResultElementCalculationFactory.Create(),
                l,
                t,
                st,
                tΛ,
                expectedValueΦ,
                z);

            // VarianceI
            IVarianceI varianceI = varianceICalculationFactory.Create()
                                   .Calculate(
                varianceIResultElementFactory,
                varianceIFactory,
                varianceIResultElementCalculationFactory.Create(),
                l,
                t,
                st,
                tΛ,
                varianceΦ,
                z);

            // υ2
            Iυ2 υ2 = υ2CalculationFactory.Create()
                     .Calculate(
                normalFactory,
                υ2ResultElementFactory,
                υ2Factory,
                MRNBCalculationFactory.Create(),
                RNBCalculationFactory.Create(),
                υ2ResultElementCalculationFactory.Create(),
                t,
                Λ,
                Ω,
                expectedValueI,
                varianceI);

            // VHat
            IVHat VHat = VHatCalculationFactory.Create()
                         .Calculate(
                normalFactory,
                VHatResultElementFactory,
                VHatFactory,
                RNBCalculationFactory.Create(),
                tStarCalculationFactory.Create(),
                VHatResultElementCalculationFactory.Create(),
                t,
                Λ,
                expectedValueI,
                varianceI,
                υ2);

            return(this.Calculate(
                       normalFactory,
                       ΦHatResultElementFactory,
                       ΦHatFactory,
                       ΦHatResultElementCalculationFactory.Create(),
                       slΛ,
                       expectedValueΦ,
                       varianceΦ,
                       VHat,
                       υ2));
        }
Ejemplo n.º 19
0
 /// <summary>
 ///     Loads <c>context</c> onto the evaluation stack
 /// </summary>
 public void LoadContext()
 {
     Il.Ldarg(3);
 }
Ejemplo n.º 20
0
 /// <summary>
 ///     Loads <c>result</c> onto the evaluation stack
 /// </summary>
 public void LoadResult(Type resultType)
 {
     Il.Ldarg(2);
     Il.Ldind(resultType);
 }
Ejemplo n.º 21
0
 /// <summary>
 ///     Loads <c>dataLength</c> onto the evaluation stack
 /// </summary>
 public void LoadDataLength()
 {
     LoadContext();
     Il.Ldfld(ReaderContext.LengthField);
 }
        public IVarianceΦResultElement Calculate(
            IVarianceΦResultElementFactory varianceΦResultElementFactory,
            IlIndexElement lIndexElement,
            IsIndexElement sIndexElement,
            IΛIndexElement ΛIndexElement,
            Il l,
            It t,
            IL L,
            Ip p,
            Iμ μ,
            Iσ σ)
        {
            int Ls = L.GetElementAtAsint(
                sIndexElement);

            int τLowerBound = 0;

            int τUpperBound = (int)Math.Floor(
                (decimal)
                (Ls - lIndexElement.Value.Value.Value)
                /
                t.GetT());

            // Mean
            decimal meanSum = 0;

            for (int τ = τLowerBound; τ <= τUpperBound; τ = τ + 1)
            {
                int lPrimeLowerBound = lIndexElement.Value.Value.Value + τ * t.GetT() + 1;

                int lPrimeVarianceUpperBound = Math.Min(
                    lIndexElement.Value.Value.Value + τ * t.GetT() + t.GetT(),
                    Ls);

                int lPrimeCovarianceUpperBound = Math.Min(
                    lIndexElement.Value.Value.Value + τ * t.GetT() + t.GetT(),
                    Ls - 1);

                // Mean: Variance
                for (int lPrime = lPrimeLowerBound; lPrime <= lPrimeVarianceUpperBound; lPrime = lPrime + 1)
                {
                    meanSum +=
                        (τ + 1)
                        *
                        p.GetElementAtAsdecimal(
                            sIndexElement,
                            l.GetElementAt(
                                lPrime),
                            ΛIndexElement)
                        *
                        (1 - p.GetElementAtAsdecimal(
                             sIndexElement,
                             l.GetElementAt(
                                 lPrime),
                             ΛIndexElement));
                }

                // Mean: Covariance
                for (int lPrime = lPrimeLowerBound; lPrime <= lPrimeCovarianceUpperBound; lPrime = lPrime + 1)
                {
                    int lHatLowerBound = lPrime + 1;

                    int lHatUpperBound = Ls;

                    for (int lHat = lHatLowerBound; lHat <= lHatUpperBound; lHat = lHat + 1)
                    {
                        meanSum -=
                            (τ + 1)
                            *
                            2
                            *
                            p.GetElementAtAsdecimal(
                                sIndexElement,
                                l.GetElementAt(
                                    lPrime),
                                ΛIndexElement)
                            *
                            p.GetElementAtAsdecimal(
                                sIndexElement,
                                l.GetElementAt(
                                    lHat),
                                ΛIndexElement);
                    }
                }
            }

            // Variance
            decimal varianceSum = 0;

            for (int τ = τLowerBound; τ <= τUpperBound; τ = τ + 1)
            {
                int lPrimeLowerBound = lIndexElement.Value.Value.Value + τ * t.GetT() + 1;

                int lPrimeUpperBound = Ls;

                for (int lPrime = lPrimeLowerBound; lPrime <= lPrimeUpperBound; lPrime = lPrime + 1)
                {
                    varianceSum +=
                        p.GetElementAtAsdecimal(
                            sIndexElement,
                            l.GetElementAt(
                                lPrime),
                            ΛIndexElement);
                }
            }

            return(varianceΦResultElementFactory.Create(
                       sIndexElement,
                       lIndexElement,
                       ΛIndexElement,
                       μ.GetElementAtAsdecimal(
                           sIndexElement,
                           ΛIndexElement)
                       *
                       meanSum
                       +
                       σ.GetElementAtAsdecimal(
                           sIndexElement,
                           ΛIndexElement)
                       *
                       σ.GetElementAtAsdecimal(
                           sIndexElement,
                           ΛIndexElement)
                       *
                       varianceSum
                       *
                       varianceSum));
        }
Ejemplo n.º 23
0
 /// <summary>
 ///     Loads <c>ref result</c> onto the evaluation stack
 /// </summary>
 public void LoadResultByRef()
 {
     Il.Ldarg(2);
 }
Ejemplo n.º 24
0
 public void EmitConvert(Type from, Type to, bool check = false)
 {
     if (from == to)
     {
         return;
     }
     if (!from.IsValueType)
     {
         if (!to.IsValueType)
         {
             Il.Castclass(to);
         }
         else
         {
             if (from != typeof(object) && !(from == typeof(Enum) && to.IsEnum))
             {
                 throw new InvalidCastException("Cannot cast an object of type '" + from + "' to type '" + to + "'");
             }
             Il.Unbox_Any(to);
         }
     }
     else
     {
         if (!to.IsValueType)
         {
             if (to != typeof(object) && !(to == typeof(Enum) && from.IsEnum))
             {
                 throw new InvalidCastException("Cannot cast an object of type '" + from + "' to type '" + to + "'");
             }
             Il.Box(from);
         }
         else
         {
             if (to.IsNullable())
             {
                 var toArgument = to.GetGenericArguments()[0];
                 if (from.IsNullable())
                 {
                     var fromArgument = from.GetGenericArguments()[0];
                     using (var temp = DeclareLocal(from))
                     {
                         Il.Stloc(temp);
                         Il.Ldloca(temp);
                         EmitHasValueAccess(from);
                         var valueIsNullLabel = Il.DefineLabel("valueIsNull");
                         Il.Brfalse(valueIsNullLabel);
                         Il.Ldloca(temp);
                         EmitValueAccess(from);
                         if (toArgument != fromArgument)
                         {
                             EmitConvert(fromArgument, toArgument, check);
                         }
                         Il.Newobj(to.GetConstructor(new[] { toArgument }));
                         var doneLabel = Il.DefineLabel("done");
                         Il.Br(doneLabel);
                         MarkLabelAndSurroundWithSP(valueIsNullLabel);
                         EmitLoadDefaultValue(to);
                         MarkLabelAndSurroundWithSP(doneLabel);
                     }
                 }
                 else
                 {
                     if (toArgument != from)
                     {
                         EmitConvert(from, toArgument, check);
                     }
                     Il.Newobj(to.GetConstructor(new[] { toArgument }));
                 }
             }
             else if (from.IsNullable())
             {
                 var fromArgument = from.GetGenericArguments()[0];
                 using (var temp = DeclareLocal(from))
                 {
                     Il.Stloc(temp);
                     Il.Ldloca(temp);
                     var valueIsNullLabel = Il.DefineLabel("valueIsNull");
                     Il.Brfalse(valueIsNullLabel);
                     Il.Ldloca(temp);
                     EmitValueAccess(from);
                     if (to != fromArgument)
                     {
                         EmitConvert(fromArgument, to, check);
                     }
                     var doneLabel = Il.DefineLabel("done");
                     Il.Br(doneLabel);
                     MarkLabelAndSurroundWithSP(valueIsNullLabel);
                     EmitLoadDefaultValue(to);
                     MarkLabelAndSurroundWithSP(doneLabel);
                 }
             }
             else if (to.IsEnum || to == typeof(Enum))
             {
                 EmitConvert(from, typeof(int), check);
             }
             else if (from.IsEnum || from == typeof(Enum))
             {
                 EmitConvert(typeof(int), to, check);
             }
             else
             {
                 if (!check)
                 {
                     EmitConvertValue(Il, from, to);
                 }
                 else
                 {
                     EmitConvertValueChecked(Il, from, to);
                 }
             }
         }
     }
 }
Ejemplo n.º 25
0
 /// <summary>
 ///     Loads the specified field onto the evaluation stack
 /// </summary>
 /// <param name="field">Field to load</param>
 public void LoadField(FieldInfo field)
 {
     Il.Ldfld(field);
 }
Ejemplo n.º 26
0
 private void LoadTexture(string filename, uint texture)
 {
     if (Il.ilLoadImage(filename))                                       //載入影像檔
     {
         int BitsPerPixel = Il.ilGetInteger(Il.IL_IMAGE_BITS_PER_PIXEL); //取得儲存每個像素的位元數
         int Depth        = Il.ilGetInteger(Il.IL_IMAGE_DEPTH);          //取得影像的深度值
         Ilu.iluScale(512, 512, Depth);                                  //將影像大小縮放為2的指數次方
         Ilu.iluFlipImage();                                             //顛倒影像
         Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);                    //連結紋理物件
         //設定紋理參數
         Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT);
         Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT);
         Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
         Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
         //建立紋理物件
         if (BitsPerPixel == 24)
         {
             Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, 512, 512, 0,
                             Il.ilGetInteger(Il.IL_IMAGE_FORMAT), Il.ilGetInteger(Il.IL_IMAGE_TYPE), Il.ilGetData());
         }
         if (BitsPerPixel == 32)
         {
             Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, 512, 512, 0,
                             Il.ilGetInteger(Il.IL_IMAGE_FORMAT), Il.ilGetInteger(Il.IL_IMAGE_TYPE), Il.ilGetData());
         }
     }
     else
     {   // 若檔案無法開啟,顯示錯誤訊息
         string message = "Cannot open file " + filename + ".";
         MessageBox.Show(message, "Image file open error!!!", MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation);
     }
 }
Ejemplo n.º 27
0
 public void Dispose()
 {
     // we won't be needing this anymore
     Il.ilDeleteImages(1, ref imageID);
 }
Ejemplo n.º 28
0
        public void EmitMemberAccess(Type type, MemberInfo member, ResultType whatReturn, out Type memberType)
        {
            switch (member.MemberType)
            {
            case MemberTypes.Property:
                var property = (PropertyInfo)member;
                var getter   = property.GetGetMethod(SkipVisibility);
                if (getter == null)
                {
                    throw new MissingMemberException(member.DeclaringType.Name, member.Name + "_get");
                }
                Il.Call(getter, type);
                Type propertyType = property.PropertyType;
                switch (whatReturn)
                {
                case ResultType.ByRefValueTypesOnly:
                    if (!propertyType.IsValueType)
                    {
                        memberType = propertyType;
                    }
                    else
                    {
                        using (var temp = DeclareLocal(propertyType))
                        {
                            Il.Stloc(temp);
                            Il.Ldloca(temp);
                            memberType = propertyType.MakeByRefType();
                        }
                    }
                    break;

                case ResultType.ByRefAll:
                    throw new InvalidOperationException("It's wierd to load a property by ref for a reference type");

                default:
                    memberType = propertyType;
                    break;
                }
                break;

            case MemberTypes.Field:
                var field = (FieldInfo)member;
                switch (whatReturn)
                {
                case ResultType.ByRefAll:
                    Il.Ldflda(field);
                    memberType = field.FieldType.MakeByRefType();
                    break;

                case ResultType.ByRefValueTypesOnly:
                    if (field.FieldType.IsValueType)
                    {
                        Il.Ldflda(field);
                        memberType = field.FieldType.MakeByRefType();
                    }
                    else
                    {
                        Il.Ldfld(field);
                        memberType = field.FieldType;
                    }
                    break;

                default:
                    Il.Ldfld(field);
                    memberType = field.FieldType;
                    break;
                }
                break;

            default:
                throw new NotSupportedException("Member type '" + member.MemberType + "' is not supported");
            }
        }
Ejemplo n.º 29
0
 // Инициализация OpenGl
 void DevIlInit()
 {
     Il.ilInit();
     Il.ilEnable(Il.IL_ORIGIN_SET);
 }
Ejemplo n.º 30
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_RGB | Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);

            Gl.glClearColor(255, 255, 255, 1);

            Gl.glViewport(0, 0, OpenGlControl.Width, OpenGlControl.Height);

            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();

            Il.ilInit();
            Il.ilEnable(Il.IL_ORIGIN_SET);

            Glu.gluOrtho2D(0, width, 0, height);
            Gl.glFlush();
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glLoadIdentity();

            objects_menu = Doodle_Jump.Menu.ObjectMenu.ListObjectMenu();

            mGlTextureObject[0]  = Texture.Texture.LoadImage(@"..\..\..\images\doodle-left.png");
            mGlTextureObject[1]  = Texture.Texture.LoadImage(@"..\..\..\images\doodle-right.png");
            mGlTextureObject[2]  = Texture.Texture.LoadImage(@"..\..\..\images\static_panel.png");
            mGlTextureObject[3]  = Texture.Texture.LoadImage(@"..\..\..\images\move_panel.png");
            mGlTextureObject[4]  = Texture.Texture.LoadImage(@"..\..\..\images\doodle-jump-left.png");
            mGlTextureObject[5]  = Texture.Texture.LoadImage(@"..\..\..\images\doodle-jump-right.png");
            mGlTextureObject[6]  = Texture.Texture.LoadImage(@"..\..\..\images\bad_panel1.png");
            mGlTextureObject[7]  = Texture.Texture.LoadImage(@"..\..\..\images\bad_panel2.png");
            mGlTextureObject[8]  = Texture.Texture.LoadImage(@"..\..\..\images\bg.png");
            mGlTextureObject[9]  = Texture.Texture.LoadImage(@"..\..\..\images\monster_1.png");
            mGlTextureObject[10] = Texture.Texture.LoadImage(@"..\..\..\images\doodle-pow.png");
            mGlTextureObject[11] = Texture.Texture.LoadImage(@"..\..\..\images\shot.png");
            mGlTextureObject[12] = Texture.Texture.LoadImage(@"..\..\..\images\pruz1.png");
            mGlTextureObject[13] = Texture.Texture.LoadImage(@"..\..\..\images\pruz2.png");
            mGlTextureObject[14] = Texture.Texture.LoadImage(@"..\..\..\images\monster_2.png");
            mGlTextureObject[15] = Texture.Texture.LoadImage(@"..\..\..\images\batut1.png");
            mGlTextureObject[16] = Texture.Texture.LoadImage(@"..\..\..\images\monster_1a.png");
            mGlTextureObject[17] = Texture.Texture.LoadImage(@"..\..\..\images\monster_3left.png");
            mGlTextureObject[18] = Texture.Texture.LoadImage(@"..\..\..\images\monster_3right.png");
            mGlTextureObject[19] = Texture.Texture.LoadImage(@"..\..\..\images\gyro_on_panel.png");
            mGlTextureObject[20] = Texture.Texture.LoadImage(@"..\..\..\images\gyro1.png");
            mGlTextureObject[21] = Texture.Texture.LoadImage(@"..\..\..\images\batut2.png");
            mGlTextureObject[22] = Texture.Texture.LoadImage(@"..\..\..\images\durka.png");
            mGlTextureObject[23] = Texture.Texture.LoadImage(@"..\..\..\images\menu\main_menu_bg.png");
            mGlTextureObject[24] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_newgame.png");
            mGlTextureObject[25] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_newgame_active.png");
            mGlTextureObject[26] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_exit.png");
            mGlTextureObject[27] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_exit_active.png");
            mGlTextureObject[28] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_restart.png");
            mGlTextureObject[29] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_restart_active.png");
            mGlTextureObject[30] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_top10.png");
            mGlTextureObject[31] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_top10_active.png");
            mGlTextureObject[32] = Texture.Texture.LoadImage(@"..\..\..\images\menu\top10.png");
            mGlTextureObject[33] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_return.png");
            mGlTextureObject[34] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_return_active.png");
            mGlTextureObject[35] = Texture.Texture.LoadImage(@"..\..\..\images\bg_gameover.png");
            mGlTextureObject[36] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_ok.png");
            mGlTextureObject[37] = Texture.Texture.LoadImage(@"..\..\..\images\menu\button_ok_active.png");
            mGlTextureObject[38] = Texture.Texture.LoadImage(@"..\..\..\images\menu\enter_name.png");
            mGlTextureObject[39] = Texture.Texture.LoadImage(@"..\..\..\images\pause.png");
            mGlTextureObject[40] = Texture.Texture.LoadImage(@"..\..\..\images\menu\help1.png");
            mGlTextureObject[41] = Texture.Texture.LoadImage(@"..\..\..\images\menu\sound.png");
            mGlTextureObject[42] = Texture.Texture.LoadImage(@"..\..\..\images\menu\sound_active.png");
            mGlTextureObject[43] = Texture.Texture.LoadImage(@"..\..\..\images\menu\soundoff.png");
            mGlTextureObject[44] = Texture.Texture.LoadImage(@"..\..\..\images\menu\soundoff_active.png");
            timer1.Start();
        }