/// <summary> /// Creates a new matrix with the specified values. /// </summary> /// <param name="engine">The <see cref="REngine"/> handling this instance.</param> /// <param name="type">The element type.</param> /// <param name="matrix">The values.</param> public Matrix(REngine engine, SymbolicExpressionType type, T[,] matrix) : base(engine, engine.GetFunction <Rf_allocMatrix>()(type, matrix.GetLength(0), matrix.GetLength(1))) { int rowCount = RowCount; int columnCount = ColumnCount; //InitMatrixWithIndexers(matrix, rowCount, columnCount); InitMatrixFast(matrix); }
/// <summary> /// Creates a new vector with the specified size. /// </summary> /// <param name="engine">The <see cref="REngine"/> handling this instance.</param> /// <param name="type">The element type.</param> /// <param name="length">The length of vector.</param> protected Vector(REngine engine, SymbolicExpressionType type, int length) : base(engine, engine.GetFunction <Rf_allocVector>()(type, length)) { if (length <= 0) { throw new ArgumentOutOfRangeException("length"); } var empty = new byte[length * DataSize]; Marshal.Copy(empty, 0, DataPointer, empty.Length); }
/// <summary> /// Creates a new isolated environment. /// </summary> /// <param name="engine">The engine.</param> /// <returns>The newly created isolated environment.</returns> public static REnvironment CreateIsolatedEnvironment(this REngine engine) { if (engine == null) { throw new ArgumentNullException("engine"); } if (!engine.IsRunning) { throw new ArgumentException(); } var pointer = engine.GetFunction <Rf_allocSExp>()(SymbolicExpressionType.Environment); return(new REnvironment(engine, pointer)); }
/// <summary> /// Creates a new matrix with the specified size. /// </summary> /// <param name="engine">The engine.</param> /// <param name="type">The element type.</param> /// <param name="rowCount">The size of row.</param> /// <param name="columnCount">The size of column.</param> protected Matrix(REngine engine, SymbolicExpressionType type, int rowCount, int columnCount) : base(engine, engine.GetFunction <Rf_allocMatrix>()(type, rowCount, columnCount)) { if (rowCount <= 0) { throw new ArgumentOutOfRangeException("rowCount"); } if (columnCount <= 0) { throw new ArgumentOutOfRangeException("columnCount"); } var empty = new byte[rowCount * columnCount * DataSize]; Marshal.Copy(empty, 0, DataPointer, empty.Length); }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="engine">The <see cref="REngine"/> handling this instance.</param> /// <param name="s">The string</param> public InternalString(REngine engine, string s) : base(engine, engine.GetFunction <Rf_mkChar>()(s)) { }
/// <summary> /// Creates a new vector with the specified values. /// </summary> /// <param name="engine">The <see cref="REngine"/> handling this instance.</param> /// <param name="type">The element type.</param> /// <param name="vector">The elements of vector.</param> protected Vector(REngine engine, SymbolicExpressionType type, IEnumerable <T> vector) : base(engine, engine.GetFunction <Rf_allocVector>()(type, vector.Count())) { SetVector(vector.ToArray()); }
/// <summary> /// Creates a new environment object. /// </summary> /// <param name="engine">The engine.</param> /// <param name="parent">The parent environment.</param> public REnvironment(REngine engine, REnvironment parent) : base(engine, engine.GetFunction <Rf_NewEnvironment>()(engine.NilValue.DangerousGetHandle(), engine.NilValue.DangerousGetHandle(), parent.handle)) { }
/// <summary> /// Creates a new environment object. /// </summary> /// <param name="engine">The engine.</param> /// <param name="parent">The parent environment.</param> public REnvironment(REngine engine, REnvironment parent) : base(engine, engine.GetFunction<Rf_NewEnvironment>()(engine.NilValue.DangerousGetHandle(), engine.NilValue.DangerousGetHandle(), parent.handle)) { }
/// <summary> /// Creates a new empty GenericVector with the specified length. /// </summary> /// <param name="engine">The <see cref="REngine"/> handling this instance.</param> /// <param name="length">The length.</param> public GenericVector(REngine engine, int length) : base(engine, engine.GetFunction <Rf_allocVector>()(SymbolicExpressionType.List, length)) { }
protected TDelegate GetFunction <TDelegate>() where TDelegate : class { return(engine.GetFunction <TDelegate>()); }
/// <summary> /// Creates the delegate function for the specified function defined in the DLL. /// </summary> /// <typeparam name="TDelegate">The type of delegate.</typeparam> /// <returns>The delegate.</returns> protected internal TDelegate GetFunction <TDelegate>() where TDelegate : class { return(Engine.GetFunction <TDelegate>()); }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="engine">The <see cref="REngine"/> handling this instance.</param> /// <param name="s">The string</param> public InternalString(REngine engine, string s) : base(engine, engine.GetFunction<Rf_mkChar>()(s)) { }