public static Complex Min(AFArray arr)
        {
            double r, i;

            Internal.VERIFY(AFAlgorithm.af_min_all(out r, out i, arr._ptr));
            return(new Complex(r, i));
        }
示例#2
0
        public static AFArray Upper(AFArray arr, bool unitDiagonal = false)
        {
            IntPtr ptr;

            Internal.VERIFY(AFData.af_upper(out ptr, arr._ptr, unitDiagonal));
            return(new AFArray(ptr));
        }
        public static (AFArray, AFArray) Grad(AFArray @in)
        {
            IntPtr dx, dy;

            Internal.VERIFY(AFAlgorithm.af_gradient(out dx, out dy, @in._ptr));
            return(new AFArray(dx), new AFArray(dy));
        }
        public static AFArray Var(AFArray arr, int dim, bool isbiased = false)
        {
            IntPtr ptr;

            Internal.VERIFY(AFStatistics.af_var(out ptr, arr._ptr, isbiased, dim));
            return(new AFArray(ptr));
        }
        public static AFArray StdDev(AFArray arr, int dim)
        {
            IntPtr ptr;

            Internal.VERIFY(AFStatistics.af_stdev(out ptr, arr._ptr, dim));
            return(new AFArray(ptr));
        }
        public static Complex Var(AFArray 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));
        }
示例#7
0
        public static AFArray Transpose(AFArray arr, bool conjugate)
        {
            IntPtr ptr;

            Internal.VERIFY(AFBlas.af_transpose(out ptr, arr._ptr, conjugate));
            return(new AFArray(ptr));
        }
        public static Complex StdDev(AFArray arr)
        {
            double r, i;

            Internal.VERIFY(AFStatistics.af_stdev_all(out r, out i, arr._ptr));
            return(new Complex(r, i));
        }
示例#9
0
        public static AFArray Wrap(AFArray 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 AFArray(ptr));
        }
示例#10
0
        public static AFArray Multiply(AFArray lhs, AFArray 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 AFArray(ptr));
        }
示例#11
0
        public static AFArray Dot(AFArray lhs, AFArray 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 AFArray(ptr));
        }
示例#12
0
        public static AFArray ExtractDiagonal(AFArray arr, int diagonalIndex = 0)
        {
            IntPtr ptr;

            Internal.VERIFY(AFData.af_diag_extract(out ptr, arr._ptr, diagonalIndex));
            return(new AFArray(ptr));
        }
示例#13
0
        public static AFArray Inverse(AFArray arr)
        {
            IntPtr ptr;

            Internal.VERIFY(AFLapack.af_inverse(out ptr, arr._ptr, af_mat_prop.AF_MAT_NONE));
            return(new AFArray(ptr));
        }
示例#14
0
        public static Complex Det(AFArray arr)
        {
            double r, i;

            Internal.VERIFY(AFLapack.af_det(out r, out i, arr._ptr));
            return(new Complex(r, i));
        }
示例#15
0
        public static AFArray Max(AFArray arr, int dim)
        {
            IntPtr ptr;

            Internal.VERIFY(AFAlgorithm.af_max(out ptr, arr._ptr, dim));
            return(new AFArray(ptr));
        }
示例#16
0
        public static AFArray TopK(AFArray 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 AFArray(idx));
        }
示例#17
0
        internal AFArray(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();
                }
            }
        }
示例#18
0
 public static void Print(AFArray arr, string name, int precision = 4)
 {
     Internal.VERIFY(AFUtil.af_print_array_gen(name, arr._ptr, precision));
 }
示例#19
0
 public static void Print(AFArray arr)
 {
     Internal.VERIFY(AFUtil.af_print_array(arr._ptr));
 }
示例#20
0
 public static void TransposeInPlace(AFArray arr, bool conjugate)
 {
     Internal.VERIFY(AFBlas.af_transpose_inplace(arr._ptr, conjugate));
 }