Exemplo n.º 1
0
        public static Matrix2DFloat operator +(float value1, Matrix2DFloat value2)
        {
            var result = new Matrix2DFloat(value2.Width, value2.Height);

            result.ForEach((x, y) => {
                result[x, y] = value1 + value2[x, y];
            });
            return(result);
        }
Exemplo n.º 2
0
        public static float Sum(Matrix2DFloat matrix)
        {
            float result = 0;

            matrix.ForEach((x, y) => {
                result = result + matrix[x, y];
            });
            return(result);
        }
Exemplo n.º 3
0
        public static Matrix2DFloat operator -(Matrix2DFloat value)
        {
            var result = new Matrix2DFloat(value.Width, value.Height);

            result.ForEach((x, y) => {
                result[x, y] = -value[x, y];
            });
            return(result);
        }
Exemplo n.º 4
0
        public static Matrix2DFloat operator /(Matrix2DFloat value1, float value2)
        {
            var result = new Matrix2DFloat(value1.Width, value1.Height);

            result.ForEach((x, y) => {
                result[x, y] = value1[x, y] / value2;
            });
            return(result);
        }
Exemplo n.º 5
0
        public static Matrix2DFloat operator *(Matrix2DFloat value1, Matrix2DFloat value2)
        {
            var width  = Math.Max(value1.Width, value2.Width);
            var height = Math.Max(value1.Height, value2.Height);
            var result = new Matrix2DFloat(width, height);

            result.ForEach((x, y) => {
                result[x, y] = value1[x, y] * value2[x, y];
            });
            return(result);
        }
Exemplo n.º 6
0
        public Matrix2DFloat Equals(Matrix2DFloat value)
        {
            if (value == null)
            {
                return(null);
            }
            var result = new Matrix2DFloat(Width, Height);

            result.ForEach((x, y) => {
                result[x, y] = this[x, y] == value[x, y] ? 1 : 0;
            });
            return(result);
        }
Exemplo n.º 7
0
        public static Matrix2DFloat operator >=(Matrix2DFloat value1, float value2)
        {
            if (value1 == null)
            {
                return(null);
            }
            var result = new Matrix2DFloat(value1.Width, value1.Height);

            result.ForEach((x, y) => {
                result[x, y] = value1[x, y] >= value2 ? 1 : 0;
            });
            return(result);
        }
Exemplo n.º 8
0
        public static Matrix2DFloat operator -(Matrix2DFloat value1, Matrix2DFloat value2)
        {
            if (value1 == null || value2 == null)
            {
                return(null);
            }
            var width  = Math.Max(value1.Width, value2.Width);
            var height = Math.Max(value1.Height, value2.Height);
            var result = new Matrix2DFloat(width, height);

            result.ForEach((x, y) => {
                result[x, y] = value1[x, y] - value2[x, y];
            });
            return(result);
        }
Exemplo n.º 9
0
        public Matrix2DFloat Dot(Matrix2DFloat value)
        {
            if (Width != value.Height)
            {
                throw new ArgumentException(string.Format(
                                                "ValueError: shapes ({0}, {1}) and ({2}, {3}) not aligned",
                                                Width, Height,
                                                value.Width, value.Height
                                                ));
            }
            var result = new Matrix2DFloat(value.Width, Height);

            result.ForEach((x, y) => {
                float total = 0;
                int count   = Width;
                for (int i = 0; i < count; i++)
                {
                    var r  = this[i, y] * value[x, i];
                    total += r;
                }
                result[x, y] = total;
            });
            return(result);
        }