Skip to content
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

simple_continued_fraction #970

Open
Tomaqa opened this issue Mar 28, 2023 · 2 comments
Open

simple_continued_fraction #970

Tomaqa opened this issue Mar 28, 2023 · 2 comments

Comments

@Tomaqa
Copy link

Tomaqa commented Mar 28, 2023

Please provide this information in the documentation, it is available only in the source code:

// Deal with non-uniqueness of continued fractions: [a0; a1, ..., an, 1] = a0; a1, ..., an + 1].
// The shorter representation is considered the canonical representation,

Also, I am disappointed that I cannot acces particular coefficients of the continued fraction, so the whole class is useless in the case one does not want to use the provided public functions.
I want to use it for rational approxamations.
So I also need to convert it to rational afterwards.

@mclow mclow transferred this issue from boostorg/boost Mar 28, 2023
@NAThompson
Copy link
Collaborator

NAThompson commented Mar 28, 2023

This seems like a reasonable ask, and not too difficult. Lemme think about how to communicate it.

@Tomaqa
Copy link
Author

Tomaqa commented Mar 28, 2023

I added these member functions as a workaround:

    size_t size() const noexcept { return b_.size(); }

    const auto& operator [](int idx) const { return b_[idx]; }
    auto& operator [](int idx) { return b_[idx]; }

    void reserve(size_t size_) { b_.reserve(size_); }
    void push_back(Z c) { b_.push_back(c); }

Although the non-const functions may cause inconsistency with the private member variable x_, it seems that it is not used anywhere else than in the constructor (which suggests to actually remove the member variable and use only the parameter itself /or its local copy/).

Also, it is a question whether to check index bounds or not.

Tomaqa pushed a commit to Tomaqa/boost-math that referenced this issue Mar 31, 2023
Tomaqa pushed a commit to Tomaqa/boost-math that referenced this issue Mar 31, 2023
Tomaqa pushed a commit to Tomaqa/boost-math that referenced this issue Mar 31, 2023
Tomaqa pushed a commit to Tomaqa/boost-math that referenced this issue Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants