C#,数值计算——完全VEGAS编码的蒙特·卡洛计算方法与源程序

1 文本格式

using System;

namespace Legalsoft.Truffer
{
    /// <summary>
    /// Complete VEGAS Code
    /// adaptive/recursive Monte Carlo
    /// </summary>
    public abstract class VEGAS
    {
        const int NDMX = 50;
        const int MXDIM = 10;
        const int RANSEED = 5330;
        const double ALPH = 1.5;
        const double TINY = 1.0e-30;
        private Ran ran_vegas = new Ran(RANSEED);

        //public static delegateFuncVectorDouble func_v_d { get; set; } = null;
        public VEGAS()
        {
        }

        public abstract double fxn(double[] x, double wgt);

        public static void rebin(double rc, int nd, double[] r, double[] xin, double[,] xi, int j)
        {
            //int i;
            int k = 0;
            double dr = 0.0;
            //double xn = 0.0;
            double xo = 0.0;

            for (int i = 0; i < nd - 1; i++)
            {
                while (rc > dr)
                {
                    dr += r[(++k) - 1];
                }
                if (k > 1)
                {
                    xo = xi[j, k - 2];
                }
                double xn = xi[j, k - 1];
                dr -= rc;
                xin[i] = xn - (xn - xo) * dr / r[k - 1];
            }
            for (int i = 0; i < nd - 1; i++)
            {
                xi[j, i] = xin[i];
            }
            xi[j, nd - 1] = 1.0;
        }

        /// <summary>
        /// Performs Monte Carlo integration of a user-supplied ndim-dimensional
        /// function fxn over a rectangular volume specified by regn[0..2 * ndim - 1], a
        /// vector consisting of ndim "lower left" coordinates of the region followed
        /// by ndim "upper right" coordinates.The integration consists of itmx
        /// iterations, each with approximately ncall calls to the function.After each
        /// iteration the grid is refined; more than 5 or 10 iterations are rarely
        /// useful.The input flag init signals whether this call is a new start or a
        /// subsequent call for additional iterations(see comments in the code). The
        /// input flag nprn(normally 0) controls the amount of diagnostic output.
        /// Returned answers are tgral (the best estimate of the integral), sd(its
        /// standard deviation), and chi2a(X^2 per degree of freedom, an indicator of
        /// whether consistent results are being obtained).
        /// </summary>
        /// <param name="regn"></param>
        /// <param name="init"></param>
        /// <param name="ncall"></param>
        /// <param name="itmx"></param>
        /// <param name="nprn"></param>
        /// <param name="tgral"></param>
        /// <param name="sd"></param>
        /// <param name="chi2a"></param>
        public void vegas(double[] regn, int init, int ncall, int itmx, int nprn, ref double tgral, ref double sd, ref double chi2a)
        {
            int mds = 0;
            int ndo = 0;
            double schi = 0.0;
            double si = 0.0;
            double swgt = 0.0;
            int[] ia = new int[MXDIM];
            int[] kg = new int[MXDIM];
            double[] dt = new double[MXDIM];
            double[] dx = new double[MXDIM];
            double[] r = new double[NDMX];
            double[] x = new double[MXDIM];
            double[] xin = new double[NDMX];
            double[,] d = new double[NDMX, MXDIM];
            double[,] di = new double[NDMX, MXDIM];
            double[,] xi = new double[MXDIM, NDMX];

            //Ran ran_vegas = new Ran(RANSEED);

            int ndim = regn.Length / 2;
            if (init <= 0)
            {
                mds = ndo = 1;
                for (int j = 0; j < ndim; j++)
                {
                    xi[j, 0] = 1.0;
                }
            }
            if (init <= 1)
            {
                si = swgt = schi = 0.0;
            }
            if (init <= 2)
            {
                int nd = NDMX;
                int ng = 1;
                if (mds != 0)
                {
                    ng = (int)Math.Pow(ncall / 2.0 + 0.25, 1.0 / ndim);
                    mds = 1;
                    if ((2 * ng - NDMX) >= 0)
                    {
                        mds = -1;
                        int n1pg = ng / NDMX + 1;
                        nd = ng / n1pg;
                        ng = n1pg * nd;
                    }
                }
                int k = 1;
                for (int i = 0; i < ndim; i++)
                {
                    k *= ng;
                }
                int npg = Math.Max((int)(ncall / k), 2);
                double calls = (double)npg * (double)k;
                double dxg = 1.0 / ng;
                double dv2g = 1.0;
                for (int i = 0; i < ndim; i++)
                {
                    dv2g *= dxg;
                }
                dv2g = Globals.SQR(calls * dv2g) / npg / npg / (npg - 1.0);
                int xnd = nd;
                dxg *= xnd;
                double xjac = 1.0 / calls;
                for (int j = 0; j < ndim; j++)
                {
                    dx[j] = regn[j + ndim] - regn[j];
                    xjac *= dx[j];
                }
                if (nd != ndo)
                {
                    for (int i = 0; i < Math.Max(nd, ndo); i++)
                    {
                        r[i] = 1.0;
                    }
                    for (int j = 0; j < ndim; j++)
                    {
                        rebin(ndo / xnd, nd, r, xin, xi, j);
                    }
                    ndo = nd;
                }
                if (nprn >= 0)
                {
                    /*
                    Console.Write(" Input parameters for vegas");
                    Console.Write("  ndim= ");
                    Console.Write("{0,4}", ndim);
                    Console.Write("{0,4}", "  ncall= ");
                    Console.Write("{0,8}", calls);
                    Console.Write("{0}", "\n");
                    Console.Write("{0,34}", "  it=");
                    Console.Write("{0,5}", it);
                    Console.Write("{0,5}", "  itmx=");
                    Console.Write("{0,5}", itmx);
                    Console.Write("{0}", "\n");
                    Console.Write("{0,34}", "  nprn=");
                    Console.Write("{0,5}", nprn);
                    Console.Write("{0,5}", "  ALPH=");
                    Console.Write("{0,9}", ALPH);
                    Console.Write("{0}", "\n");
                    Console.Write("{0,34}", "  mds=");
                    Console.Write("{0,5}", mds);
                    Console.Write("{0,5}", "  nd=");
                    Console.Write("{0,5}", nd);
                    Console.Write("{0}", "\n");
                    for (j = 0; j < ndim; j++)
                    {
                        Console.Write("{0,30}", " x1[");
                        Console.Write("{0,2}", j);
                        Console.Write("{0,2}", "]= ");
                        Console.Write("{0,11}", regn[j]);
                        Console.Write("{0}", " xu[");
                        Console.Write("{0,2}", j);
                        Console.Write("{0}", "]= ");
                        Console.Write("{0,11}", regn[j + ndim]);
                        Console.Write("{0}", "\n");
                    }
                    */
                    for (int it = 0; it < itmx; it++)
                    {
                        double ti = 0.0;
                        double tsi = 0.0;
                        for (int j = 0; j < ndim; j++)
                        {
                            kg[j] = 1;
                            for (int i = 0; i < nd; i++)
                            {
                                d[i, j] = di[i, j] = 0.0;
                            }
                        }
                        for (; ; )
                        {
                            double fb = 0.0;
                            double f2b = 0.0;
                            for (k = 0; k < npg; k++)
                            {
                                double w1gt = xjac;
                                for (int j = 0; j < ndim; j++)
                                {
                                    double xn = (kg[j] - ran_vegas.doub()) * dxg + 1.0;
                                    ia[j] = Math.Max(Math.Min((int)xn, NDMX), 1);
                                    double xo;
                                    double rc;
                                    if (ia[j] > 1)
                                    {
                                        xo = xi[j, ia[j] - 1] - xi[j, ia[j] - 2];
                                        rc = xi[j, ia[j] - 2] + (xn - ia[j]) * xo;
                                    }
                                    else
                                    {
                                        xo = xi[j, ia[j] - 1];
                                        rc = (xn - ia[j]) * xo;
                                    }
                                    x[j] = regn[j] + rc * dx[j];
                                    w1gt *= xo * xnd;
                                }
                                double f = w1gt * fxn(x, w1gt);
                                double f2 = f * f;
                                fb += f;
                                f2b += f2;
                                for (int j = 0; j < ndim; j++)
                                {
                                    di[ia[j] - 1, j] += f;
                                    if (mds >= 0)
                                    {
                                        d[ia[j] - 1, j] += f2;
                                    }
                                }
                            }
                            f2b = Math.Sqrt(f2b * npg);
                            f2b = (f2b - fb) * (f2b + fb);
                            if (f2b <= 0.0)
                            {
                                f2b = TINY;
                            }
                            ti += fb;
                            tsi += f2b;
                            if (mds < 0)
                            {
                                for (int j = 0; j < ndim; j++)
                                {
                                    d[ia[j] - 1, j] += f2b;
                                }
                            }
                            for (k = ndim - 1; k >= 0; k--)
                            {
                                kg[k] %= ng;
                                if (++kg[k] != 1)
                                {
                                    break;
                                }
                            }
                            if (k < 0)
                            {
                                break;
                            }
                        }
                        tsi *= dv2g;
                        double wgt = 1.0 / tsi;
                        si += wgt * ti;
                        schi += wgt * ti * ti;
                        swgt += wgt;
                        tgral = si / swgt;
                        chi2a = (schi - si * tgral) / (it + 0.0001);
                        if (chi2a < 0.0)
                        {
                            chi2a = 0.0;
                        }
                        sd = Math.Sqrt(1.0 / swgt);
                        tsi = Math.Sqrt(tsi);
                    }

                    if (nprn >= 0)
                    {
                        /*
                        Console.Write(" iteration no. ");
                        Console.Write("{0,3}", (it + 1));
                        Console.Write("{0,3}", " : integral = ");
                        Console.Write("{0,14}", ti);
                        Console.Write("{0,14}", " +/- ");
                        Console.Write("{0,9}", tsi);
                        Console.Write("{0}", "\n");
                        Console.Write("{0}", " all iterations:  ");
                        Console.Write("{0}", " integral =");
                        Console.Write("{0,14}", tgral);
                        Console.Write("{0}", "+-");
                        Console.Write("{0,9}", sd);
                        Console.Write("{0,9}", " chi**2/IT n =");
                        Console.Write("{0,9}", chi2a);
                        Console.Write("{0}", "\n");
                        if (nprn != 0)
                        {
                            for (j = 0; j < ndim; j++)
                            {
                                Console.Write("{0}", " DATA FOR axis  ");
                                Console.Write("{0,2}", j);
                                Console.Write("{0}", "\n");
                                Console.Write("{0}", "     X      delta i          X      delta i");
                                Console.Write("{0}", "          X       deltai");
                                Console.Write("{0}", "\n");
                                for (i = nprn / 2; i < nd - 2; i += nprn + 2)
                                {
                                    Console.Write("{0,8}", xi[j, i]);
                                    Console.Write("{0,12}", di[i, j]);
                                    Console.Write("{0,12}", xi[j, i + 1]);
                                    Console.Write("{0,12}", di[i + 1, j]);
                                    Console.Write("{0,12}", xi[j, i + 2]);
                                    Console.Write("{0,12}", di[i + 2, j]);
                                    Console.Write("{0,12}", "\n");
                                }
                            }
                        }
                        */
                    }
                    for (int j = 0; j < ndim; j++)
                    {
                        double xo = d[0, j];
                        double xn = d[1, j];
                        d[0, j] = (xo + xn) / 2.0;
                        dt[j] = d[0, j];
                        for (int i = 2; i < nd; i++)
                        {
                            double rc = xo + xn;
                            xo = xn;
                            xn = d[i, j];
                            d[i - 1, j] = (rc + xn) / 3.0;
                            dt[j] += d[i - 1, j];
                        }
                        d[nd - 1, j] = (xo + xn) / 2.0;
                        dt[j] += d[nd - 1, j];
                    }
                    for (int j = 0; j < ndim; j++)
                    {
                        double rc = 0.0;
                        for (int i = 0; i < nd; i++)
                        {
                            if (d[i, j] < TINY)
                            {
                                d[i, j] = TINY;
                            }
                            r[i] = Math.Pow((1.0 - d[i, j] / dt[j]) / (Math.Log(dt[j]) - Math.Log(d[i, j])), ALPH);
                            rc += r[i];
                        }
                        rebin(rc / xnd, nd, r, xin, xi, j);
                    }
                }
            }
        }
    }
}
 

2 代码格式

using System;namespace Legalsoft.Truffer
{/// <summary>/// Complete VEGAS Code/// adaptive/recursive Monte Carlo/// </summary>public abstract class VEGAS{const int NDMX = 50;const int MXDIM = 10;const int RANSEED = 5330;const double ALPH = 1.5;const double TINY = 1.0e-30;private Ran ran_vegas = new Ran(RANSEED);//public static delegateFuncVectorDouble func_v_d { get; set; } = null;public VEGAS(){}public abstract double fxn(double[] x, double wgt);public static void rebin(double rc, int nd, double[] r, double[] xin, double[,] xi, int j){//int i;int k = 0;double dr = 0.0;//double xn = 0.0;double xo = 0.0;for (int i = 0; i < nd - 1; i++){while (rc > dr){dr += r[(++k) - 1];}if (k > 1){xo = xi[j, k - 2];}double xn = xi[j, k - 1];dr -= rc;xin[i] = xn - (xn - xo) * dr / r[k - 1];}for (int i = 0; i < nd - 1; i++){xi[j, i] = xin[i];}xi[j, nd - 1] = 1.0;}/// <summary>/// Performs Monte Carlo integration of a user-supplied ndim-dimensional/// function fxn over a rectangular volume specified by regn[0..2 * ndim - 1], a/// vector consisting of ndim "lower left" coordinates of the region followed/// by ndim "upper right" coordinates.The integration consists of itmx/// iterations, each with approximately ncall calls to the function.After each/// iteration the grid is refined; more than 5 or 10 iterations are rarely/// useful.The input flag init signals whether this call is a new start or a/// subsequent call for additional iterations(see comments in the code). The/// input flag nprn(normally 0) controls the amount of diagnostic output./// Returned answers are tgral (the best estimate of the integral), sd(its/// standard deviation), and chi2a(X^2 per degree of freedom, an indicator of/// whether consistent results are being obtained)./// </summary>/// <param name="regn"></param>/// <param name="init"></param>/// <param name="ncall"></param>/// <param name="itmx"></param>/// <param name="nprn"></param>/// <param name="tgral"></param>/// <param name="sd"></param>/// <param name="chi2a"></param>public void vegas(double[] regn, int init, int ncall, int itmx, int nprn, ref double tgral, ref double sd, ref double chi2a){int mds = 0;int ndo = 0;double schi = 0.0;double si = 0.0;double swgt = 0.0;int[] ia = new int[MXDIM];int[] kg = new int[MXDIM];double[] dt = new double[MXDIM];double[] dx = new double[MXDIM];double[] r = new double[NDMX];double[] x = new double[MXDIM];double[] xin = new double[NDMX];double[,] d = new double[NDMX, MXDIM];double[,] di = new double[NDMX, MXDIM];double[,] xi = new double[MXDIM, NDMX];//Ran ran_vegas = new Ran(RANSEED);int ndim = regn.Length / 2;if (init <= 0){mds = ndo = 1;for (int j = 0; j < ndim; j++){xi[j, 0] = 1.0;}}if (init <= 1){si = swgt = schi = 0.0;}if (init <= 2){int nd = NDMX;int ng = 1;if (mds != 0){ng = (int)Math.Pow(ncall / 2.0 + 0.25, 1.0 / ndim);mds = 1;if ((2 * ng - NDMX) >= 0){mds = -1;int n1pg = ng / NDMX + 1;nd = ng / n1pg;ng = n1pg * nd;}}int k = 1;for (int i = 0; i < ndim; i++){k *= ng;}int npg = Math.Max((int)(ncall / k), 2);double calls = (double)npg * (double)k;double dxg = 1.0 / ng;double dv2g = 1.0;for (int i = 0; i < ndim; i++){dv2g *= dxg;}dv2g = Globals.SQR(calls * dv2g) / npg / npg / (npg - 1.0);int xnd = nd;dxg *= xnd;double xjac = 1.0 / calls;for (int j = 0; j < ndim; j++){dx[j] = regn[j + ndim] - regn[j];xjac *= dx[j];}if (nd != ndo){for (int i = 0; i < Math.Max(nd, ndo); i++){r[i] = 1.0;}for (int j = 0; j < ndim; j++){rebin(ndo / xnd, nd, r, xin, xi, j);}ndo = nd;}if (nprn >= 0){/*Console.Write(" Input parameters for vegas");Console.Write("  ndim= ");Console.Write("{0,4}", ndim);Console.Write("{0,4}", "  ncall= ");Console.Write("{0,8}", calls);Console.Write("{0}", "\n");Console.Write("{0,34}", "  it=");Console.Write("{0,5}", it);Console.Write("{0,5}", "  itmx=");Console.Write("{0,5}", itmx);Console.Write("{0}", "\n");Console.Write("{0,34}", "  nprn=");Console.Write("{0,5}", nprn);Console.Write("{0,5}", "  ALPH=");Console.Write("{0,9}", ALPH);Console.Write("{0}", "\n");Console.Write("{0,34}", "  mds=");Console.Write("{0,5}", mds);Console.Write("{0,5}", "  nd=");Console.Write("{0,5}", nd);Console.Write("{0}", "\n");for (j = 0; j < ndim; j++){Console.Write("{0,30}", " x1[");Console.Write("{0,2}", j);Console.Write("{0,2}", "]= ");Console.Write("{0,11}", regn[j]);Console.Write("{0}", " xu[");Console.Write("{0,2}", j);Console.Write("{0}", "]= ");Console.Write("{0,11}", regn[j + ndim]);Console.Write("{0}", "\n");}*/for (int it = 0; it < itmx; it++){double ti = 0.0;double tsi = 0.0;for (int j = 0; j < ndim; j++){kg[j] = 1;for (int i = 0; i < nd; i++){d[i, j] = di[i, j] = 0.0;}}for (; ; ){double fb = 0.0;double f2b = 0.0;for (k = 0; k < npg; k++){double w1gt = xjac;for (int j = 0; j < ndim; j++){double xn = (kg[j] - ran_vegas.doub()) * dxg + 1.0;ia[j] = Math.Max(Math.Min((int)xn, NDMX), 1);double xo;double rc;if (ia[j] > 1){xo = xi[j, ia[j] - 1] - xi[j, ia[j] - 2];rc = xi[j, ia[j] - 2] + (xn - ia[j]) * xo;}else{xo = xi[j, ia[j] - 1];rc = (xn - ia[j]) * xo;}x[j] = regn[j] + rc * dx[j];w1gt *= xo * xnd;}double f = w1gt * fxn(x, w1gt);double f2 = f * f;fb += f;f2b += f2;for (int j = 0; j < ndim; j++){di[ia[j] - 1, j] += f;if (mds >= 0){d[ia[j] - 1, j] += f2;}}}f2b = Math.Sqrt(f2b * npg);f2b = (f2b - fb) * (f2b + fb);if (f2b <= 0.0){f2b = TINY;}ti += fb;tsi += f2b;if (mds < 0){for (int j = 0; j < ndim; j++){d[ia[j] - 1, j] += f2b;}}for (k = ndim - 1; k >= 0; k--){kg[k] %= ng;if (++kg[k] != 1){break;}}if (k < 0){break;}}tsi *= dv2g;double wgt = 1.0 / tsi;si += wgt * ti;schi += wgt * ti * ti;swgt += wgt;tgral = si / swgt;chi2a = (schi - si * tgral) / (it + 0.0001);if (chi2a < 0.0){chi2a = 0.0;}sd = Math.Sqrt(1.0 / swgt);tsi = Math.Sqrt(tsi);}if (nprn >= 0){/*Console.Write(" iteration no. ");Console.Write("{0,3}", (it + 1));Console.Write("{0,3}", " : integral = ");Console.Write("{0,14}", ti);Console.Write("{0,14}", " +/- ");Console.Write("{0,9}", tsi);Console.Write("{0}", "\n");Console.Write("{0}", " all iterations:  ");Console.Write("{0}", " integral =");Console.Write("{0,14}", tgral);Console.Write("{0}", "+-");Console.Write("{0,9}", sd);Console.Write("{0,9}", " chi**2/IT n =");Console.Write("{0,9}", chi2a);Console.Write("{0}", "\n");if (nprn != 0){for (j = 0; j < ndim; j++){Console.Write("{0}", " DATA FOR axis  ");Console.Write("{0,2}", j);Console.Write("{0}", "\n");Console.Write("{0}", "     X      delta i          X      delta i");Console.Write("{0}", "          X       deltai");Console.Write("{0}", "\n");for (i = nprn / 2; i < nd - 2; i += nprn + 2){Console.Write("{0,8}", xi[j, i]);Console.Write("{0,12}", di[i, j]);Console.Write("{0,12}", xi[j, i + 1]);Console.Write("{0,12}", di[i + 1, j]);Console.Write("{0,12}", xi[j, i + 2]);Console.Write("{0,12}", di[i + 2, j]);Console.Write("{0,12}", "\n");}}}*/}for (int j = 0; j < ndim; j++){double xo = d[0, j];double xn = d[1, j];d[0, j] = (xo + xn) / 2.0;dt[j] = d[0, j];for (int i = 2; i < nd; i++){double rc = xo + xn;xo = xn;xn = d[i, j];d[i - 1, j] = (rc + xn) / 3.0;dt[j] += d[i - 1, j];}d[nd - 1, j] = (xo + xn) / 2.0;dt[j] += d[nd - 1, j];}for (int j = 0; j < ndim; j++){double rc = 0.0;for (int i = 0; i < nd; i++){if (d[i, j] < TINY){d[i, j] = TINY;}r[i] = Math.Pow((1.0 - d[i, j] / dt[j]) / (Math.Log(dt[j]) - Math.Log(d[i, j])), ALPH);rc += r[i];}rebin(rc / xnd, nd, r, xin, xi, j);}}}}}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/125691.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

基于微信小程序的付费自习室

博主介绍&#xff1a;✌程序员徐师兄、7年大厂程序员经历。全网粉丝30W、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ 文章目录 1 简介2 技术栈3 需求分析3.1用户需求分析3.1.1 学生用户3.1.3 管理员用户 4 数据库设计4.4.1 E…

【C++】一文带你走入vector

文章目录 一、vector的介绍二、vector的常用接口说明2.1 vector的使用2.2 vector iterator的使用2.3 vector空间增长问题2.4 vector 增删查改 三、总结 ヾ(๑╹◡╹)&#xff89;" 人总要为过去的懒惰而付出代价ヾ(๑╹◡╹)&#xff89;" 一、vector的介绍 vector…

【MyBatis-Plus】快速精通Mybatis-plus框架—快速入门

大家在日常开发中应该能发现&#xff0c;单表的CRUD功能代码重复度很高&#xff0c;也没有什么难度。而这部分代码量往往比较大&#xff0c;开发起来比较费时。 因此&#xff0c;目前企业中都会使用一些组件来简化或省略单表的CRUD开发工作。目前在国内使用较多的一个组件就是…

【VUE·疑难问题】定义 table 中每行的高度(使用 element-UI)

一、如何定义 table 中每一行的 height &#xff1f; 1.table例子 <!-- 二、table --><div style"overflow: hidden;display: block;height: 68vh;width: 100%;"><el-table stripe show-header style"width: 100%" :data"tableData&q…

代码随想录Day12 二叉树 LeetCode T102二叉树的层序遍历 T226 翻转二叉树 T101 对称二叉树

本文思路和详细讲解来自于:代码随想录 (programmercarl.com) LeetCode T102 二叉树的层序遍历 题目链接:102. 二叉树的层序遍历 - 力扣&#xff08;LeetCode&#xff09; 题目思路: 本题使用队列辅助完成,讲解主要函数CheckOrder:首先判断root是否为空,是就直接返回,然后创建…

互联网Java工程师面试题·Elasticsearch 篇·第一弹

目录 1、elasticsearch 了解多少&#xff0c;说说你们公司 es 的集群架构&#xff0c;索引数据大小&#xff0c;分片有多少&#xff0c;以及一些调优手段 。 1.1 设计阶段调优 1.2 写入调优 1.3 查询调优 1.4 其他调优 2、elasticsearch 的倒排索引是什么 3、elastic…

安卓教材学习

文章目录 教材学习第一行代码 Android 第3版环境配置gradle配置下载包出现问题 教材学习 摘要&#xff1a;选了几本教材《第一行代码 Android 第3版》&#xff0c;记录一下跑案例遇到的问题&#xff0c;和总结一些内容。 第一行代码 Android 第3版 环境配置 gradle配置 gradl…

【Overload游戏引擎分析】画场景网格的Shader

Overload引擎地址&#xff1a; GitHub - adriengivry/Overload: 3D Game engine with editor 一、栅格绘制基本原理 Overload Editor启动之后&#xff0c;场景视图中有栅格线&#xff0c;这个在很多软件中都有。刚开始我猜测它应该是通过绘制线实现的。阅读代码发现&#xff0…

MySQL:数据库的物理备份和恢复-冷备份(3)

介绍 物理备份&#xff1a; 直接复制数据文件进行的备份 优点&#xff1a;不需要其他的工具&#xff0c;直接复制就好&#xff0c;恢复直接复制备份文件即可 缺点&#xff1a;与存储引擎有关&#xff0c;跨平台能力较弱 逻辑备份&#xff1a; 从数据库中导出数据另存而进行的备…

【BBC新闻文章分类】使用 TF 2.0和 LSTM 的文本分类

一、说明 NLP上的许多创新是如何将上下文添加到词向量中。常见的方法之一是使用递归神经网络

全志ARM926 Melis2.0系统的开发指引⑧

全志ARM926 Melis2.0系统的开发指引⑧ 编写目的12.5. 应用程序编写12.5.1. 简单应用编写12.5.1.1. 注册应用12.5.1.2. 创建管理窗口12.5.1.3. 实现管理窗口消息处理回调函数12.5.1.4. 创建图层12.5.1.5. 创建 framewin12.5.1.6. 实现 framewin 消息处理回调函数 -. 全志相关工具…

全志ARM926 Melis2.0系统的开发指引⑦

全志ARM926 Melis2.0系统的开发指引⑦ 编写目的11. 调屏11.1. 调屏步骤简介11.1.1. 判断屏接口。11.1.2. 确定硬件连接。11.1.3. 配置显示部分 sys_config.fex11.1.3.1. 配置屏相关 IO 11.1.4. Lcd_panel_cfg.c 初始化文件中配置屏参数11.1.4.1. LCD_cfg_panel_info11.1.4.2. L…