Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 5
0
        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("检查矩阵形状");
            }
        }
Esempio n. 6
0
        /// <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);
            }
        }
Esempio n. 7
0
 public void init(int columns, int rows)
 {
     tempmap          = new map(columns, rows);
     sess.maps[index] = tempmap;
 }