How hnthap/rrcal works
Project type and purpose
• This is a standalone command-line tool (“rrcal”) written in C99 that computes all rational roots of an integer-coefficient polynomial using the Rational Root Theorem.
• It is a small, monolithic, open-source C project with no dynamic memory, organized as separate compilation units and headers.
File structure
• Top-level:
• Makefile & build artifacts → build process
• README.md → documentation
• / → public headers that define interfaces (argparse, polynomial representation, math utilities, macros, types)
• source/ → implementation of each module (argparse.c, polynomial.c, rational.c, moremath.c, checkvalue.c, roottest.c, main.c)
README
• Confirms the tool’s purpose and usage: “rrcal -6 -1 1”
• References static memory, C99, and locations of settings in include/macros.h
• No external services or databases—pure CPU computation and CLI I/O
a. Main components
1. User / CLI Interface
2. Argument Parser (argparse)
3. Polynomial Data Model (polynomial, types)
4. Math Utilities (moremath, macros)
5. Rational Root Hunter (rational, roottest, checkvalue)
6. Output Renderer (to stdout)
7. Build System (Makefile → gcc → rrcal executable)
b. Relationships & interactions
• User invokes rrcal executable → CLI Interface
• CLI → Argument Parser → produces array of coefficients
• Coefficients → Polynomial Data Model → normalized representation
• Polynomial + Math Utilities → generate candidate p/q pairs
• For each candidate → Root Tester + Checkvalue → filter valid roots
• Valid roots → Output Renderer → stdout
• Build System orchestrates compilation of each module and links into one binary
c. Architectural patterns / design principles
• Modular monolith: separate header + source per logical unit
• Single responsibility: each module (argparse, polynomial, rational, roottest, moremath, checkvalue) has a well-defined function
• Static memory / predictable footprint: no heap, everything stack or static
• Interface layering: include/ defines public APIs, source/ contains private implementations
d. Relevant technologies
• Language: C99
• Build: GNU Make + gcc
• Static analysis / documentation: Doxygen-style comments in headers
Detailed capture of architectural elements
• That macros.h and types.h are foundational and imported by nearly every module
• Makefile invoking gcc on all source files and producing build/bin/rrcal