| 86 | |
| 87 | template<typename T, af_op_t op> |
| 88 | SparseArray<T> arithOp(const SparseArray<T> &lhs, const Array<T> &rhs, |
| 89 | const bool reverse) { |
| 90 | SparseArray<T> out = createArrayDataSparseArray<T>( |
| 91 | lhs.dims(), lhs.getValues(), lhs.getRowIdx(), lhs.getColIdx(), |
| 92 | lhs.getStorage(), true); |
| 93 | switch (out.getStorage()) { |
| 94 | case AF_STORAGE_CSR: |
| 95 | getQueue().enqueue(kernel::sparseArithOpS<T, op, AF_STORAGE_CSR>, |
| 96 | out.getValues(), out.getRowIdx(), |
| 97 | out.getColIdx(), rhs, reverse); |
| 98 | break; |
| 99 | case AF_STORAGE_COO: |
| 100 | getQueue().enqueue(kernel::sparseArithOpS<T, op, AF_STORAGE_COO>, |
| 101 | out.getValues(), out.getRowIdx(), |
| 102 | out.getColIdx(), rhs, reverse); |
| 103 | break; |
| 104 | default: |
| 105 | AF_ERROR("Sparse Arithmetic only supported for CSR or COO", |
| 106 | AF_ERR_NOT_SUPPORTED); |
| 107 | } |
| 108 | |
| 109 | return out; |
| 110 | } |
| 111 | |
| 112 | template<typename T, af_op_t op> |
| 113 | SparseArray<T> arithOp(const SparseArray<T> &lhs, const SparseArray<T> &rhs) { |