Exemple #1
0
        //CSR
        public static SparseMatrix <indexT1, dataT1> CreateCOO <indexT1, dataT1>(
            long rows,
            long cols,
            long nnz,
            CudaDeviceVariable <indexT1> cooRowInd,
            CudaDeviceVariable <indexT1> cooColInd,
            CudaDeviceVariable <dataT1> cooValues,
            IndexBase idxBase) where indexT1 : struct where dataT1 : struct
        {
            cusparseSpMatDescr descr       = new cusparseSpMatDescr();
            IndexType          typeIndices = IndexTypeTranslator.GetType(typeof(indexT1));
            cudaDataType       typeData    = CudaDataTypeTranslator.GetType(typeof(dataT1));
            cusparseStatus     res         = CudaSparseNativeMethods.cusparseCreateCoo(ref descr, rows, cols, nnz, cooRowInd.DevicePointer,
                                                                                       cooColInd.DevicePointer, cooValues.DevicePointer, typeIndices, idxBase, typeData);

            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cusparseCreateCoo", res));
            if (res != cusparseStatus.Success)
            {
                throw new CudaSparseException(res);
            }

            return(new SparseMatrix <indexT1, dataT1>(descr, rows, cols, nnz, idxBase, typeIndices, typeData));
        }