430 {
431 debug_printf("%s\n", __PRETTY_FUNCTION__);
435 for(
int j = 0; j != this->
outerSize(); ++j) {
437
439 }
440 }
441 Eigen::ArrayX<int> resOuterIndex(res.
nonZeros());
442 for(
int j = 0; j != this->
nonZeros(); ++j) {
445 }
446
447#ifdef __CUDA_ARCH__
448 Eigen::ArrayX<int> resOuterIndexCpy(resOuterIndex);
449 thrust::sort_by_key(thrust::seq, resOuterIndexCpy.data(),
451 thrust::sort_by_key(thrust::seq, resOuterIndex.data(),
453#else
454 Eigen::ArrayX< std::tuple<int, int, Scalar_t> > data(res.
nonZeros());
455 #pragma omp parallel
456 {
457 #pragma omp for
458 for(
int j = 0; j < res.
nonZeros(); ++j) {
459 data(j) = std::tuple<int, int, Scalar_t>(
461 }
462 #pragma omp single
463 std::sort(data.data(), data.data() + res.
nonZeros(),
464 [](auto& lhs, auto& rhs) { return std::get<0>(lhs) < std::get<0>(rhs); });
465 #pragma omp for
466 for(
int j = 0; j < res.
nonZeros(); ++j) {
467 resOuterIndex(j) = std::get<0>(data(j));
469 res.
valuePtr()[j] = std::get<2>(data(j));
470 }
471 }
472#endif
473
474 int prev = 0;
477 for(
int count = 0; count != res.
nonZeros(); ++count) {
478 if(prev != resOuterIndex(count)) {
479 assert(resOuterIndex(count) < res.
nonZeros()
480 && "Out of bounds for resOuterIndex.");
481 for(int j = prev + 1; j != resOuterIndex(count); ++j) {
483 }
485 }
486 prev = resOuterIndex(count);
487 }
488 return res;
489 }
Definition MatrixUtils.cuh:280
__host__ __device__ int & setNonZeros(int input)
Definition MatrixUtils.cuh:417
__host__ __device__ int outerSize() const
Definition MatrixUtils.cuh:414