コード例 #1
0
 /// <summary>
 /// </summary>
 public SparseVector(long aSize, long aNnz, CudaDeviceVariable <indexT> indices, CudaDeviceVariable <dataT> values, IndexBase aIdxBase)
 {
     size        = aSize;
     nnz         = aNnz;
     idxBase     = aIdxBase;
     descr       = new cusparseSpVecDescr();
     typeIndices = IndexTypeTranslator.GetType(typeof(indexT));
     typeData    = CudaDataTypeTranslator.GetType(typeof(dataT));
     res         = CudaSparseNativeMethods.cusparseCreateSpVec(ref descr, size, nnz, indices.DevicePointer, values.DevicePointer, typeIndices, idxBase, typeData);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cusparseCreateSpVec", res));
     if (res != cusparseStatus.Success)
     {
         throw new CudaSparseException(res);
     }
 }
コード例 #2
0
        public static SparseMatrix <indexT1, dataT1> CreateCooAoS <indexT1, dataT1>(
            long rows,
            long cols,
            long nnz,
            CudaDeviceVariable <indexT1> cooInd,
            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.cusparseCreateCooAoS(ref descr, rows, cols, nnz, cooInd.DevicePointer,
                                                                                          cooValues.DevicePointer, typeIndices, idxBase, typeData);

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

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