コード例 #1
0
        public static ref BlockMatrix <M, N, T> Mul <M, K, N, T>(BlockMatrix <M, K, T> A, BlockMatrix <K, N, T> B, ref BlockMatrix <M, N, T> X)
            where M : ITypeNat, new()
            where K : ITypeNat, new()
            where N : ITypeNat, new()
            where T : unmanaged
        {
            var m = nati <M>();
            var n = nati <N>();

            for (var i = 0; i < m; i++)
            {
                for (var j = 0; j < n; j++)
                {
                    X[i, j] = dot(A.GetRow(i), B.GetCol(j));
                }
            }
            return(ref X);
        }
コード例 #2
0
ファイル: MatMulRef.cs プロジェクト: 0xCM/arrows
        public static ref BlockMatrix <M, N, T> Mul <M, K, N, T>(BlockMatrix <M, K, T> A, BlockMatrix <K, N, T> B, ref BlockMatrix <M, N, T> X)
            where M : ITypeNat, new()
            where K : ITypeNat, new()
            where N : ITypeNat, new()
            where T : struct
        {
            var m  = nati <M>();
            var n  = nati <N>();
            var tB = B.Transpose();

            for (var i = 0; i < m; i++)
            {
                var r = A.GetRow(i);
                for (var j = 0; j < n; j++)
                {
                    var c = tB.GetRow(j);
                    X[i, j] = r * c;
                }
            }
            return(ref X);
        }