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

Function mtm

src/backend/cpu/sparse_blas.cpp:372–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370
371template<typename T, bool conjugate>
372void mtm(Param<T> output, CParam<T> values, CParam<int> rowIdx,
373 CParam<int> colIdx, CParam<T> right, int M, int N, int ldb, int ldc) {
374 const T *valPtr = values.get();
375 const int *rowPtr = rowIdx.get();
376 const int *colPtr = colIdx.get();
377 const T *rightPtr = right.get();
378 T *outPtr = output.get();
379
380 for (int o = 0; o < N; ++o) {
381 for (int i = 0; i < M; ++i) { outPtr[i] = scalar<T>(0); }
382
383 for (int i = 0; i < rowIdx.dims(0) - 1; ++i) {
384 for (int j = rowPtr[i]; j < rowPtr[i + 1]; ++j) {
385 // If stride[0] of right is not 1 then rightPtr[i*stride]
386 if (conjugate) {
387 outPtr[colPtr[j]] += getConjugate(valPtr[j]) * rightPtr[i];
388 } else {
389 outPtr[colPtr[j]] += valPtr[j] * rightPtr[i];
390 }
391 }
392 }
393 rightPtr += ldb;
394 outPtr += ldc;
395 }
396}
397
398template<typename T>
399Array<T> matmul(const common::SparseArray<T> &lhs, const Array<T> &rhs,

Callers

nothing calls this directly

Calls 3

getConjugateFunction · 0.70
getMethod · 0.45
dimsMethod · 0.45

Tested by

no test coverage detected