예제 #1
0
        /// <summary>
        /// Matrix product of two arrays.
        /// </summary>
        /// <param name="o1"></param>
        /// <param name="o2"></param>
        /// <returns></returns>
        public static ndarray MatrixProduct(object o1, object o2)
        {
            dtype d = FindArrayType(o1, null);

            d = FindArrayType(o2, d);

            ndarray a1 = np.FromAny(o1, d, flags: NPYARRAYFLAGS.NPY_ALIGNED);
            ndarray a2 = np.FromAny(o2, d, flags: NPYARRAYFLAGS.NPY_ALIGNED);

            if (a1.ndim == 0)
            {
                return(EnsureAnyArray((a1.item() as ndarray) * a2));
            }
            else if (a2.ndim == 0)
            {
                return(EnsureAnyArray(a1 * (a2.item() as ndarray)));
            }
            else
            {
                return(NpyCoreApi.MatrixProduct(a1, a2, d.TypeNum));
            }
        }