Exemplo n.º 1
0
        public static NDArray <T> sin <T>(this NumPy <T> np, NDArray <T> nd)
        {
            NDArray <T> sinArray = new NDArray <T>();

            sinArray.Data  = new T[nd.Size];
            sinArray.Shape = new Shape(nd.Shape.Shapes);

            for (int idx = 0; idx < nd.Size; idx++)
            {
                switch (nd[idx])
                {
                case double d:
                    sinArray[idx] = (T)(object)Math.Sin(d);
                    break;

                case float d:
                    sinArray[idx] = (T)(object)Math.Sin(d);
                    break;

                case Complex d:
                    sinArray[idx] = (T)(object)Complex.Sin(d);
                    break;
                }
            }

            return(sinArray);
        }
Exemplo n.º 2
0
        public static NDArray <T> array <T>(this NumPy <T> np, IEnumerable <T> array, int ndim = 1)
        {
            var nd = new NDArray <T>();

            nd.Data  = array.ToArray();
            nd.Shape = new Shape(new int[] { nd.Data.Length });

            return(nd);
        }
Exemplo n.º 3
0
        public static NDArray <NDArray <T> > sin <T>(this NumPy <T> np, NDArray <NDArray <T> > nd)
        {
            var sinArray = new NDArray <NDArray <T> >();

            sinArray.Data  = new NDArray <T> [nd.Size];
            sinArray.Shape = new Shape(nd.Shape.Shapes);

            for (int idx = 0; idx < nd.Size; idx++)
            {
                switch (default(T))
                {
                case double d:
                    sinArray[idx] = new NDArray <T>
                    {
                        Data  = new T[] { (T)(object)Math.Sin(d) },
                        Shape = new Shape(1)
                    };
                    break;
                }
            }

            return(sinArray);
        }
Exemplo n.º 4
0
 public static NDArray <T> asarray <T>(this NumPy <T> np, IEnumerable <T> array, int ndim = 1)
 {
     return(np.array(array));
 }
Exemplo n.º 5
0
 public static NDArray <T> ones_like <T>(this NumPy <T> np, NDArray <T> nd, string order = "C")
 {
     return(np.ones(new Shape(nd.Shape.Shapes)));
 }