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

Function arithOpD

src/backend/opencl/sparse_arith.cpp:51–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

getStorageMethod · 0.80
dim4Class · 0.50
evalMethod · 0.45
dimsMethod · 0.45

Tested by

no test coverage detected