Issue with the example of cpp_for_opencl.md
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 72/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- documentation
Research direction
Open chapters/cpp_for_opencl.md and inspect the complex_t example. Check the getter return types and multiplication operator against the issue's proposed correction, then update the example so it is internally consistent. Done means the documented C++ code uses T for the getters and returns a complex_t instance from multiplication.
Written by the indexing model from the issue text.
Description
In chapters/cpp_for_opencl.md there is an example of how to implement a kernel using C++ of complex number arithmetic.
template<typename T>
class complex_t {
T m_re; // Real component.
T m_im; // Imaginary component.
public:
complex_t(T re, T im): m_re{re}, m_im{im} {};
complex_t operator*(const complex_t &other) const
{
return {m_re * other.m_re - m_im * other.m_im,
m_re * other.m_im + m_im * other.m_re};
}
int get_re() const { return m_re; }
int get_im() const { return m_im; }
};
It seems like:
- the get functions should return T type.
- The multiplication operator should return a new instance of the complex_t class rather than a brace-enclosed list.
Here is what I believe is what was intended:
template<typename T>
class complex_t {
T m_re; // Real component.
T m_im; // Imaginary component.
public:
complex_t(T re, T im): m_re{re}, m_im{im} {};
complex_t operator*(const complex_t &other) const
{
return complex_t<T>(m_re * other.m_re - m_im * other.m_im,
m_re * other.m_im + m_im * other.m_re);
}
T get_re() const { return m_re; }
T get_im() const { return m_im; }
};
- Dominant language
- CMake
- Stars
- 710
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from KhronosGroup/OpenCL-Guide
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
KhronosGroup/OpenCL-Guide#44 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
KhronosGroup/OpenCL-Guide#42 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
KhronosGroup/OpenCL-Guide#41 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
KhronosGroup/OpenCL-Guide#34 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
KhronosGroup/OpenCL-Guide#33 · 1 reaction ·
All issues in KhronosGroup/OpenCL-Guide
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·