Example #1
0
        public static NDArray ExtractDiagonal(NDArray arr, int diagonalIndex = 0)
        {
            IntPtr ptr;

            Internal.VERIFY(AFData.af_diag_extract(out ptr, arr._ptr, diagonalIndex));
            return(new NDArray(ptr));
        }
Example #2
0
        public static Complex Min(NDArray arr)
        {
            double r, i;

            Internal.VERIFY(AFAlgorithm.af_min_all(out r, out i, arr._ptr));
            return(new Complex(r, i));
        }
Example #3
0
        public static NDArray StdDev(NDArray arr, int dim)
        {
            IntPtr ptr;

            Internal.VERIFY(AFStatistics.af_stdev(out ptr, arr._ptr, dim));
            return(new NDArray(ptr));
        }
Example #4
0
        public static NDArray Dot(NDArray lhs, NDArray rhs, bool lconj = false, bool rconj = false)
        {
            IntPtr ptr;

            Internal.VERIFY(AFBlas.af_dot(out ptr, lhs._ptr, rhs._ptr, lconj ? af_mat_prop.AF_MAT_CONJ : af_mat_prop.AF_MAT_NONE, rconj ? af_mat_prop.AF_MAT_CONJ : af_mat_prop.AF_MAT_NONE));
            return(new NDArray(ptr));
        }
Example #5
0
        public static NDArray Wrap(NDArray arr, uint ox, uint oy, uint wx, uint wy, uint sx, uint sy, uint px, uint py, bool is_column)
        {
            IntPtr ptr;

            Internal.VERIFY(AFImgPro.af_wrap(out ptr, arr._ptr, ox, oy, wx, wy, sx, sy, px, py, is_column));
            return(new NDArray(ptr));
        }
Example #6
0
        public static Complex Var(NDArray arr, bool isbiased = false)
        {
            double r, i;

            Internal.VERIFY(AFStatistics.af_var_all(out r, out i, arr._ptr, isbiased));
            return(new Complex(r, i));
        }
Example #7
0
        public static NDArray Inverse(NDArray arr)
        {
            IntPtr ptr;

            Internal.VERIFY(AFLapack.af_inverse(out ptr, arr._ptr, af_mat_prop.AF_MAT_NONE));
            return(new NDArray(ptr));
        }
Example #8
0
        public static NDArray Max(NDArray arr, int dim)
        {
            IntPtr ptr;

            Internal.VERIFY(AFAlgorithm.af_max(out ptr, arr._ptr, dim));
            return(new NDArray(ptr));
        }
Example #9
0
        public static NDArray Transpose(NDArray arr, bool conjugate)
        {
            IntPtr ptr;

            Internal.VERIFY(AFBlas.af_transpose(out ptr, arr._ptr, conjugate));
            return(new NDArray(ptr));
        }
Example #10
0
        public static Complex Det(NDArray arr)
        {
            double r, i;

            Internal.VERIFY(AFLapack.af_det(out r, out i, arr._ptr));
            return(new Complex(r, i));
        }
Example #11
0
        public static NDArray Var(NDArray arr, int dim, bool isbiased = false)
        {
            IntPtr ptr;

            Internal.VERIFY(AFStatistics.af_var(out ptr, arr._ptr, isbiased, dim));
            return(new NDArray(ptr));
        }
Example #12
0
        public static NDArray Multiply(NDArray lhs, NDArray rhs, MatMulOp lop = MatMulOp.None, MatMulOp rop = MatMulOp.None)
        {
            IntPtr ptr;

            Internal.VERIFY(AFBlas.af_matmul(out ptr, lhs._ptr, rhs._ptr, (af_mat_prop)lop, (af_mat_prop)rop));
            return(new NDArray(ptr));
        }
Example #13
0
        public static NDArray Upper(NDArray arr, bool unitDiagonal = false)
        {
            IntPtr ptr;

            Internal.VERIFY(AFData.af_upper(out ptr, arr._ptr, unitDiagonal));
            return(new NDArray(ptr));
        }
Example #14
0
        public static Complex StdDev(NDArray arr)
        {
            double r, i;

            Internal.VERIFY(AFStatistics.af_stdev_all(out r, out i, arr._ptr));
            return(new Complex(r, i));
        }
Example #15
0
        public static NDArray TopK(NDArray arr, int k, int dim, int order)
        {
            IntPtr ptr;
            IntPtr idx;

            Internal.VERIFY(AFStatistics.af_topk(out ptr, out idx, arr._ptr, k, dim, order));
            return(new NDArray(idx));
        }
Example #16
0
        internal Tensor(IntPtr pointer)
        {
#if DEBUG
            if (pointer == IntPtr.Zero)
            {
                throw new ArgumentNullException("Invalid Array Pointer");
            }
#endif
            this._ptr = pointer;
            Interlocked.Increment(ref _instances);
            if (_instances % 50 == 0)             // only do it every time we allocated new 50 instances, we can tweak this
            {
                UIntPtr bytes, buffers, lockbytes, lockbuffers;
                Internal.VERIFY(AFDevice.af_device_mem_info(out bytes, out buffers, out lockbytes, out lockbuffers));
                // code borrowed from the R wrapper:
                if ((double)lockbytes > Math.Pow(1000, 3) || (double)lockbuffers > 50)
                {
                    GC.Collect();
                }
            }
        }
Example #17
0
 public static void Print(NDArray arr, string name, int precision = 4)
 {
     Internal.VERIFY(AFUtil.af_print_array_gen(name, arr._ptr, precision));
 }
Example #18
0
 public static void SetDevice(int device)
 {
     Internal.VERIFY(AFDevice.af_set_device(device));
 }
Example #19
0
 public static void TransposeInPlace(NDArray arr, bool conjugate)
 {
     Internal.VERIFY(AFBlas.af_transpose_inplace(arr._ptr, conjugate));
 }
Example #20
0
 public static void PrintInfo()
 {
     Internal.VERIFY(AFDevice.af_info());
 }
Example #21
0
 public static void SetBackend(Backend backend)
 {
     Internal.VERIFY(AFBackend.af_set_backend((af_backend)backend));
 }
Example #22
0
 public static void Print(NDArray arr)
 {
     Internal.VERIFY(AFUtil.af_print_array(arr._ptr));
 }