Skip to content

Fix container type and empty-vector defects in the composite quadratures - #105

Open
susilehtola wants to merge 1 commit into
wavefunction91:masterfrom
susilehtola:fix/subquadrature-and-partition
Open

Fix container type and empty-vector defects in the composite quadratures#105
susilehtola wants to merge 1 commit into
wavefunction91:masterfrom
susilehtola:fix/subquadrature-and-partition

Conversation

@susilehtola

Copy link
Copy Markdown
Collaborator

Three unrelated defects in the same two headers.

SubQuadrature's generator declared its weights in the point container
type and returned it as the weight_container half of the tuple:

point_container points ( ... );
point_container weights( ... );   // wrong type

This compiles today only because every radial quadrature happens to use
std::vector for both. It breaks as soon as the two differ, which
is exactly what mixed precision needs: SubQuadrature<Becke<float,double>>
does not compile before this change. Two of the surrounding assertions
also tested >= 0 on size_t, which is vacuous; drop them and keep the
bounds that say something.

RadialGridPartition::finalize() read partition_idx_.back() without
checking that anything had been added, which is undefined behaviour on an
empty vector. make_pruned_grid() guards against an empty region list one
layer up, but finalize() is public and the class is default-constructible,
so the guard is not structural. Throw instead.

Six adaptor overrides in the two spherical quadrature headers were
written as override {; -- a stray empty statement after the opening
brace. Harmless, but remove them.

Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01FDTFYJMQ76iujDFNHzZyXF

Three unrelated defects in the same two headers.

SubQuadrature's generator declared its weights in the *point* container
type and returned it as the weight_container half of the tuple:

    point_container points ( ... );
    point_container weights( ... );   // wrong type

This compiles today only because every radial quadrature happens to use
std::vector<double> for both. It breaks as soon as the two differ, which
is exactly what mixed precision needs: SubQuadrature<Becke<float,double>>
does not compile before this change. Two of the surrounding assertions
also tested `>= 0` on size_t, which is vacuous; drop them and keep the
bounds that say something.

RadialGridPartition::finalize() read partition_idx_.back() without
checking that anything had been added, which is undefined behaviour on an
empty vector. make_pruned_grid() guards against an empty region list one
layer up, but finalize() is public and the class is default-constructible,
so the guard is not structural. Throw instead.

Six adaptor overrides in the two spherical quadrature headers were
written as `override {;` -- a stray empty statement after the opening
brace. Harmless, but remove them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FDTFYJMQ76iujDFNHzZyXF
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 this pull request may close these issues.

1 participant