Skip to content

C++ sample code for The Barnsley Fern #835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 24, 2021

Conversation

mika314
Copy link
Contributor

@mika314 mika314 commented Aug 22, 2021

The Barnsley Fern with 100000 points
image

@Amaras Amaras added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label Aug 22, 2021
@Amaras
Copy link
Member

Amaras commented Aug 22, 2021

Thanks for the PR
I am not completely comfortable reviewing templated C++ code, but I quite like what you've done here.
From what I can see, it's all correct, and the fern looks good, so I am sure it's a good fit for the AAA, but I'd like to get a second opinion to be sure.

Copy link
Contributor

@ShadowMitia ShadowMitia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed a few things, this should disable warnings about "unsigned/signed" conversions.

Otherwise looks good to me.

It should be probably written somewhere that this is C++17 code?

using Row = std::array<double, 3>;
using Op = std::array<Row, 3>;

constexpr auto OpN = 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be 4U, because of signedness.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is your motivation? I do not understand why it should be unsigned?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I get warnings of signed/unsigned comparisons. Sorry I should've been clearer on this...


constexpr auto OpN = 4;

template <int N>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be template

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is a template. What do you mean?

Copy link
Contributor

@ShadowMitia ShadowMitia Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wooops, not sure what happened here.
I meant, this should probably be template <unsigned int N>, again because of signed/unsigned comparison warngings

return x;
}

template <int N>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, this should probably be template

return v;
}

template <int N>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, this should probably be template


auto operator*(const Op& x, const Vec3& y) {
auto ret = Vec3{};
for (auto i = 0; i < 3; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be auto i = 0U

auto ret = Vec3{};
for (auto i = 0; i < 3; ++i) {
ret[i] = 0;
for (auto j = 0; j < 3; ++j)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be auto j = 0U

@mika314
Copy link
Contributor Author

mika314 commented Aug 23, 2021

Mitia, I pushed fixes.

Copy link
Member

@leios leios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for the code and thanks to @ShadowMitia for the review!

@leios leios merged commit 495bc8a into algorithm-archivists:master Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants