Пример #1
0
Файл: t_gemm.cs Проект: 0xCM/z0
        static float Dot <N>(Block256 <N, float> x, Block256 <N, float> y)
            where N : unmanaged, ITypeNat
        {
            var result = 0f;

            for (var i = 0; i < nat32i <N>(); i++)
            {
                result += x[i] * y[i];
            }
            return(result);
        }
Пример #2
0
Файл: gemv.cs Проект: 0xCM/z0
        /// <summary>
        /// Computes the matrix-vector product y = A*x;
        /// </summary>
        /// <param name="A">A source matrix of dimension MxN</param>
        /// <param name="x">A source vector of length N</param>
        /// <param name="y">A target vector of length M</param>
        /// <typeparam name="M">The row dimension type of A</typeparam>
        /// <typeparam name="N">The column dimension type of A</typeparam>
        public static ref Block256 <M, float> gemv <M, N>(Matrix256 <M, N, float> A, Block256 <N, float> x, ref Block256 <M, float> y)
            where M : unmanaged, ITypeNat
            where N : unmanaged, ITypeNat
        {
            var m   = nat32i <M>();
            var n   = nat32i <N>();
            var lda = n;

            CBLAS.cblas_sgemv(RowMajor, NoTranspose, m, n, alpha: 1f, ref head(A), lda, ref head(x), incX: 1, beta: 0, ref head(y), incY: 1);
            return(ref y);
        }
Пример #3
0
Файл: t_gemm.cs Проект: 0xCM/z0
        static double Dot <N>(Block256 <N, double> x, Block256 <N, double> y)
            where N : unmanaged, ITypeNat
        {
            var result = 0d;

            for (var i = 0; i < nat32i <N>(); i++)
            {
                result += x[i] * y[i];
            }
            return(result);
        }
Пример #4
0
Файл: t_gemm.cs Проект: 0xCM/z0
        internal static void refmul <M, N, T>(Matrix256 <M, N, T> A, Block256 <N, T> B, Block256 <M, T> X)
            where M : unmanaged, ITypeNat
            where N : unmanaged, ITypeNat
            where T : unmanaged
        {
            var m = nat32i <M>();

            for (var i = 0; i < m; i++)
            {
                X[i] = t_dot.dot(A.GetRow(i), B);
            }
        }
Пример #5
0
Файл: vml.cs Проект: 0xCM/z0
 public static ref Block256 <N, double> add <N>(Block256 <N, double> lhs, Block256 <N, double> rhs, ref Block256 <N, double> dst)
     where N : unmanaged, ITypeNat
 {
     VmlImport.vdAdd(nat32i <N>(), ref head(lhs), ref head(rhs), ref head(dst));
     return(ref dst);
 }
Пример #6
0
Файл: vml.cs Проект: 0xCM/z0
 public static ref Block256 <N, float> mul <N>(Block256 <N, float> lhs, Block256 <N, float> rhs, ref Block256 <N, float> dst)
     where N : unmanaged, ITypeNat
 {
     VmlImport.vsMul(nat32i <N>(), ref head(lhs), ref head(rhs), ref head(dst));
     return(ref dst);
 }
Пример #7
0
Файл: axpy.cs Проект: 0xCM/z0
 public static void axpy <N>(float a, Block256 <N, float> X, Block256 <N, float> Y, ref Block256 <N, float> Z)
     where N : unmanaged, ITypeNat
 {
     Y.CopyTo(ref Z);
     CBLAS.cblas_saxpy(nat32i <N>(), a, ref head(X), 1, ref head(Z), 1);
 }
Пример #8
0
Файл: dot.cs Проект: 0xCM/z0
 public static double dot <N>(Block256 <N, double> x, Block256 <N, double> y)
     where N : unmanaged, ITypeNat
 => dot(x.Unsized, y.Unsized);
Пример #9
0
Файл: dot.cs Проект: 0xCM/z0
 public static float dot <N>(Block256 <N, float> x, Block256 <N, float> y)
     where N : unmanaged, ITypeNat
 => dot(x.Unsized, y.Unsized);
Пример #10
0
 static ref T head <N, T>(Block256 <N, T> src)
     where N : unmanaged, ITypeNat
     where T : unmanaged
 => ref MemoryMarshal.GetReference <T>(src.Unsized);