예제 #1
0
파일: map.cs 프로젝트: grdaimap/hello-world
        public map rev()
        {
            map c;

            c = new map(shape[0], shape[1]);
            for (int cl = 0; cl < c.shape[0]; cl++)
            {
                for (int r = 0; r < c.shape[1]; r++)
                {
                    c.data[cl, r] = -c.data[cl, r];
                }
            }
            return(c);
        }
예제 #2
0
파일: map.cs 프로젝트: grdaimap/hello-world
        public map change(double a)
        {
            map c;

            c = new map(shape[0], shape[1]);
            for (int cl = 0; cl < c.shape[0]; cl++)
            {
                for (int r = 0; r < c.shape[1]; r++)
                {
                    c.data[cl, r] += a;
                }
            }
            return(c);
        }
예제 #3
0
파일: map.cs 프로젝트: grdaimap/hello-world
        public static map log(map a)
        {
            map c;

            c = new map(a.shape[0], a.shape[1]);
            for (int cl = 0; cl < c.shape[0]; cl++)
            {
                for (int r = 0; r < c.shape[1]; r++)
                {
                    c.data[cl, r] = Math.Log(a.data[cl, r]);
                }
            }
            return(c);
        }
예제 #4
0
파일: map.cs 프로젝트: grdaimap/hello-world
        /// <summary>
        /// 改变形状
        /// </summary>
        public map Reshape()
        {
            map c = new map(shape[0] * shape[1], 1);

            double[,] new_data = new double[shape[0] * shape[1], 1];
            for (int cl = 0; cl < shape[0]; cl++)
            {
                for (int r = 0; r < shape[1]; r++)
                {
                    new_data[cl * shape[1] + r, 0] = data[cl, r];
                }
            }
            c.data = new_data;
            return(c);
        }
예제 #5
0
파일: map.cs 프로젝트: grdaimap/hello-world
        public static map mul(map a, map b)
        {
            map c;

            if (a.shape[0] == b.shape[0] && a.shape[1] == b.shape[1])
            {
                c = new map(a.shape[0], b.shape[1]);
                for (int cl = 0; cl < c.shape[0]; cl++)
                {
                    for (int r = 0; r < c.shape[1]; r++)
                    {
                        c.data[cl, r] = a.data[cl, r] * b.data[cl, r];
                    }
                }
                return(c);
            }
            else
            {
                throw new Exception("检查矩阵形状");
            }
        }
예제 #6
0
파일: map.cs 프로젝트: grdaimap/hello-world
        /// <summary>
        /// 重载*运算,矩阵乘法
        /// </summary>
        /// <param name="a">图类型</param>
        /// <param name="b">图类型</param>
        /// <returns>一个矩阵乘法的结果图</returns>
        public static map operator *(map a, map b)
        {
            map c;

            if (a.shape[1] != b.shape[0])
            {
                throw new Exception("检查矩阵形状");
            }
            else
            {
                c = new map(a.shape[0], b.shape[1]);
                for (int cl = 0; cl < c.shape[0]; cl++)
                {
                    for (int r = 0; r < c.shape[1]; r++)
                    {
                        for (int co = 0; co < a.shape[1]; co++)
                        {
                            c.data[cl, r] += a.data[cl, co] * b.data[co, r];
                        }
                    }
                }
                return(c);
            }
        }
예제 #7
0
 public void init(int columns, int rows)
 {
     tempmap          = new map(columns, rows);
     sess.maps[index] = tempmap;
 }