MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / sparseConvertStorage

Function sparseConvertStorage

src/api/c/sparse.cpp:116–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114
115template<typename T>
116af_array sparseConvertStorage(const af_array in_,
117 const af_storage destStorage) {
118 const SparseArray<T> in = getSparseArray<T>(in_);
119
120 if (destStorage == AF_STORAGE_DENSE) {
121 // Returns a regular af_array, not sparse
122 switch (in.getStorage()) {
123 case AF_STORAGE_CSR:
124 return getHandle(
125 detail::sparseConvertStorageToDense<T, AF_STORAGE_CSR>(in));
126 case AF_STORAGE_COO:
127 return getHandle(
128 detail::sparseConvertStorageToDense<T, AF_STORAGE_COO>(in));
129 default:
130 AF_ERROR("Invalid storage type of input array", AF_ERR_ARG);
131 }
132 } else if (destStorage == AF_STORAGE_CSR) {
133 // Returns a sparse af_array
134 switch (in.getStorage()) {
135 case AF_STORAGE_CSR: return retainSparseHandle<T>(in_);
136 case AF_STORAGE_COO:
137 return getHandle(
138 detail::sparseConvertStorageToStorage<T, AF_STORAGE_CSR,
139 AF_STORAGE_COO>(in));
140 default:
141 AF_ERROR("Invalid storage type of input array", AF_ERR_ARG);
142 }
143 } else if (destStorage == AF_STORAGE_COO) {
144 // Returns a sparse af_array
145 switch (in.getStorage()) {
146 case AF_STORAGE_CSR:
147 return getHandle(
148 detail::sparseConvertStorageToStorage<T, AF_STORAGE_COO,
149 AF_STORAGE_CSR>(in));
150 case AF_STORAGE_COO: return retainSparseHandle<T>(in_);
151 default:
152 AF_ERROR("Invalid storage type of input array", AF_ERR_ARG);
153 }
154 }
155
156 // Shoud never come here
157 return NULL;
158}
159
160////////////////////////////////////////////////////////////////////////////////
161// Get Functions

Callers

nothing calls this directly

Calls 2

getStorageMethod · 0.80
getHandleFunction · 0.70

Tested by

no test coverage detected