DDC 0.10.0
Loading...
Searching...
No Matches
splines_linear_problem.cpp
1// Copyright (C) The DDC development team, see COPYRIGHT.md file
2//
3// SPDX-License-Identifier: MIT
4
5#include <cassert>
6#include <cstddef>
7#include <iomanip>
8#include <ostream>
9
10#include <Kokkos_Core.hpp>
11
13
14namespace ddc::detail {
15
16template <class ExecSpace>
17SplinesLinearProblem<ExecSpace>::SplinesLinearProblem(std::size_t const size) : m_size(size)
18{
19}
20
21template <class ExecSpace>
22SplinesLinearProblem<ExecSpace>::~SplinesLinearProblem() = default;
23
24template <class ExecSpace>
25std::size_t SplinesLinearProblem<ExecSpace>::size() const
26{
27 return m_size;
28}
29
30template <class ExecSpace>
31std::size_t SplinesLinearProblem<ExecSpace>::required_number_of_rhs_rows() const
32{
33 std::size_t const nrows = impl_required_number_of_rhs_rows();
34 assert(nrows >= size());
35 return nrows;
36}
37
38template <class ExecSpace>
39std::size_t SplinesLinearProblem<ExecSpace>::impl_required_number_of_rhs_rows() const
40{
41 return m_size;
42}
43
44template <class ExecSpace>
45std::ostream& operator<<(std::ostream& os, SplinesLinearProblem<ExecSpace> const& linear_problem)
46{
47 std::size_t const n = linear_problem.size();
48 for (std::size_t i = 0; i < n; ++i) {
49 for (std::size_t j = 0; j < n; ++j) {
50 os << std::fixed << std::setprecision(3) << std::setw(10)
51 << linear_problem.get_element(i, j);
52 }
53 os << "\n";
54 }
55 return os;
56}
57
58#if defined(KOKKOS_ENABLE_SERIAL)
59template class SplinesLinearProblem<Kokkos::Serial>;
60template std::ostream& operator<<(
61 std::ostream& os,
62 SplinesLinearProblem<Kokkos::Serial> const& linear_problem);
63#endif
64#if defined(KOKKOS_ENABLE_OPENMP)
65template class SplinesLinearProblem<Kokkos::OpenMP>;
66template std::ostream& operator<<(
67 std::ostream& os,
68 SplinesLinearProblem<Kokkos::OpenMP> const& linear_problem);
69#endif
70#if defined(KOKKOS_ENABLE_CUDA)
71template class SplinesLinearProblem<Kokkos::Cuda>;
72template std::ostream& operator<<(
73 std::ostream& os,
74 SplinesLinearProblem<Kokkos::Cuda> const& linear_problem);
75#endif
76#if defined(KOKKOS_ENABLE_HIP)
77template class SplinesLinearProblem<Kokkos::HIP>;
78template std::ostream& operator<<(
79 std::ostream& os,
80 SplinesLinearProblem<Kokkos::HIP> const& linear_problem);
81#endif
82#if defined(KOKKOS_ENABLE_SYCL)
83template class SplinesLinearProblem<Kokkos::SYCL>;
84template std::ostream& operator<<(
85 std::ostream& os,
86 SplinesLinearProblem<Kokkos::SYCL> const& linear_problem);
87#endif
88
89} // namespace ddc::detail
The top-level namespace of DDC.