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

Function arithOpD

src/backend/cpu/sparse_arith.cpp:56–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55template<typename T, af_op_t op>
56Array<T> arithOpD(const SparseArray<T> &lhs, const Array<T> &rhs,
57 const bool reverse) {
58 Array<T> out = createEmptyArray<T>(dim4(0));
59 Array<T> zero = createValueArray<T>(rhs.dims(), scalar<T>(0));
60 switch (op) {
61 case af_add_t: out = copyArray<T>(rhs); break;
62 case af_sub_t:
63 out = reverse ? copyArray<T>(rhs)
64 : arithOp<T, af_sub_t>(zero, rhs, rhs.dims());
65 break;
66 default: out = copyArray<T>(rhs);
67 }
68 switch (lhs.getStorage()) {
69 case AF_STORAGE_CSR:
70 getQueue().enqueue(kernel::sparseArithOpD<T, op, AF_STORAGE_CSR>,
71 out, lhs.getValues(), lhs.getRowIdx(),
72 lhs.getColIdx(), rhs, reverse);
73 break;
74 case AF_STORAGE_COO:
75 getQueue().enqueue(kernel::sparseArithOpD<T, op, AF_STORAGE_COO>,
76 out, lhs.getValues(), lhs.getRowIdx(),
77 lhs.getColIdx(), rhs, reverse);
78 break;
79 default:
80 AF_ERROR("Sparse Arithmetic only supported for CSR or COO",
81 AF_ERR_NOT_SUPPORTED);
82 }
83
84 return out;
85}
86
87template<typename T, af_op_t op>
88SparseArray<T> arithOp(const SparseArray<T> &lhs, const Array<T> &rhs,

Callers

nothing calls this directly

Calls 5

getStorageMethod · 0.80
dim4Class · 0.70
getQueueFunction · 0.50
dimsMethod · 0.45
enqueueMethod · 0.45

Tested by

no test coverage detected