Skip to content

simple_continued_fraction #970

Closed

Description

@Tomaqa

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.

Activity

  1. transferred this issue fromboostorg/booston Mar 28, 2023
  2. NAThompson commented on Mar 28, 2023

    @NAThompson
    Collaborator

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

  3. Tomaqa commented on Mar 28, 2023

    @Tomaqa
    Author

    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.

  4. added a commit that references this issue on Sep 5, 2026
    28bf4d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions