public static void CreateIntegerVector(REngine engine, int n, Stopwatch s)
        {
            int[] d = createIntegerArray(n);
            s.Start();
            var nvec = engine.CreateIntegerVector(d);

            s.Stop();
        }
        public NumericVector[] CreateNumericVectors(int n, int sizeEach)
        {
            var res    = new NumericVector[n];
            var f      = engine.Evaluate("function(vecLen) {rnorm(vecLen)}").AsFunction();
            var vecLen = engine.CreateIntegerVector(sizeEach);

            for (int i = 0; i < n; i++)
            {
                res[i] = f.Invoke(vecLen).AsNumeric();
            }
            return(res);
        }
Exemple #3
0
        internal static SymbolicExpression ToVector(REngine engine, IEnumerable values)
        {
            if (values == null)
            {
                throw new ArgumentNullException("values", "values to transform to an R vector must not be null");
            }
            var ints     = values as IEnumerable <int>;
            var chars    = values as IEnumerable <string>;
            var cplxs    = values as IEnumerable <Complex>;
            var logicals = values as IEnumerable <bool>;
            var nums     = values as IEnumerable <double>;
            var raws     = values as IEnumerable <byte>;
            var sexpVec  = values as SymbolicExpression;

            if (sexpVec != null && sexpVec.IsVector())
            {
                return(sexpVec);
            }
            if (ints != null)
            {
                return(engine.CreateIntegerVector(ints));
            }
            if (chars != null)
            {
                return(engine.CreateCharacterVector(chars));
            }
            if (cplxs != null)
            {
                return(engine.CreateComplexVector(cplxs));
            }
            if (logicals != null)
            {
                return(engine.CreateLogicalVector(logicals));
            }
            if (nums != null)
            {
                return(engine.CreateNumericVector(nums));
            }
            if (raws != null)
            {
                return(engine.CreateRawVector(raws));
            }
            throw new NotSupportedException(string.Format("Cannot convert type {0} to an R vector", values.GetType()));
        }
 public static void CreateIntegerVector(REngine engine, int n, Stopwatch s)
 {
     int[] d = createIntegerArray(n);
     s.Start();
     var nvec = engine.CreateIntegerVector(d);
     s.Stop();
 }
Exemple #5
0
        internal static SymbolicExpression ToVector(REngine engine, IEnumerable values)
        {
            if (values == null) throw new ArgumentNullException("values", "values to transform to an R vector must not be null");
            var ints = values as IEnumerable<int>;
            var chars = values as IEnumerable<string>;
            var cplxs = values as IEnumerable<Complex>;
            var logicals = values as IEnumerable<bool>;
            var nums = values as IEnumerable<double>;
            var raws = values as IEnumerable<byte>;
            var sexpVec = values as SymbolicExpression;

            if (sexpVec != null && sexpVec.IsVector())
                return sexpVec;
            if (ints != null)
                return engine.CreateIntegerVector(ints);
            if (chars != null)
                return engine.CreateCharacterVector(chars);
            if (cplxs != null)
                return engine.CreateComplexVector(cplxs);
            if (logicals != null)
                return engine.CreateLogicalVector(logicals);
            if (nums != null)
                return engine.CreateNumericVector(nums);
            if (raws != null)
                return engine.CreateRawVector(raws);
            throw new NotSupportedException(string.Format("Cannot convert type {0} to an R vector", values.GetType()));
        }