Пример #1
0
        public static JuliaArray <T> Create2D(int nr, int nc)
        {
            var type = typeof(T);

            if (!TypePair.ContainsKey(type.Name))
            {
                throw new ArgumentException("仅支持基本数据类型");
            }

            var arrartype = JuliaNative.ApplyArrayType(TypePair[type.Name], (size_t)2);
            var x         = JuliaNative.AllocArray2D(arrartype, (size_t)nr, (size_t)nc);

            return(new JuliaArray <T>(x));
        }
Пример #2
0
        public static JuliaArray <T> Create1D(int n)
        {
            var type = typeof(T);

            if (!TypePair.ContainsKey(type.Name))
            {
                throw new ArgumentException("仅支持基本数据类型");
            }

            var arrartype = JuliaNative.ApplyArrayType(TypePair[type.Name], (UIntPtr)1);
            var x         = JuliaNative.AllocArray1D(arrartype, (UIntPtr)n);

            return(new JuliaArray <T>(x));
        }
Пример #3
0
        private static JuliaValue <T> Box(double value)
        {
            var p = JuliaNative.BoxFloat64(value);

            return(new JuliaValue <T>(p));
        }
Пример #4
0
        private static JuliaValue <T> Box(long value)
        {
            var p = JuliaNative.BoxInt64(value);

            return(new JuliaValue <T>(p));
        }
Пример #5
0
 public double GetFloat64()
 {
     return(JuliaNative.UnboxFloat64(handle));
 }
Пример #6
0
 public long GetInt64()
 {
     return(JuliaNative.UnboxInt64(handle));
 }