コード例 #1
0
ファイル: LinearOperatorsTest.cs プロジェクト: sharpyr/Veho
        public static T[,] Cross <T>(this T[,] aX, T[,] bX, Func <T, T, T> zipper, Func <T, T, T> reducer)
        {
            int height = aX.Height(), width = bX.Width();
            var matrix  = new T[height, width];
            var rows    = matrix.RowsIter();
            var columns = matrix.ColumnsIter();

            rows.Iterate((i, row) => {
                columns.Iterate((j, column) => {
                    var zipped   = VecZippers.Zip(row, column, zipper);
                    var reduced  = VecReducers.Reduce(zipped, reducer);
                    matrix[i, j] = reduced;
                });
            });
            return(matrix);
        }
コード例 #2
0
ファイル: LinearOperatorsTest.cs プロジェクト: sharpyr/Veho
        public static T[,] Cross <T>(T[,] aX, T[,] bX, Func <T, T, T> zipper, Func <T, T, T> reducer)
        {
            int height = aX.Height(), width = bX.Width();
            var matrix = new T[height, width];

            for (var i = 0; i < height; i++)
            {
                var row = aX.Row(i);
                for (var j = 0; j < width; j++)
                {
                    var column  = bX.Column(j);
                    var zipped  = VecZippers.Zip(row, column, zipper);
                    var reduced = VecReducers.Reduce(zipped, reducer);
                    matrix[i, j] = reduced;
                }
            }
            return(matrix);
        }