class smooth::Workspace#

Overview#

Switch, candidate topology, rebuild reference and state clauses. More…

#include <src/include/internal/smooth_cv.hpp>
 
class Workspace {
public:
    // structs
 
    struct Clause;
 
    // construction
 
    Workspace(const RationalSwitch& sw, int maxRing);
 
    // methods
 
    void rebuild(const Cloud& cloud, std::vector<int> selected, double skin);
    bool built() const;
    bool stale(const Cloud& cloud) const;
    const Topology& topology() const;
    const RationalSwitch& switching() const;
    int maxRing() const;
    int stateCount() const;
    void checkKind(Kind kind, int arg) const;
    double value(const Cloud& cloud, Kind kind, int arg, double* grad);
    void addClause(int state, Kind kind, int arg, double threshold, double width, bool above);
    void states(const Cloud& cloud, double* chi, double* grad);
};

Detailed Documentation#

Switch, candidate topology, rebuild reference and state clauses.

rebuild() lists the selected atoms within dMax + skin with linkcell and fixes the candidate topology. value() equals the value after a fresh rebuild (for the gyration kinds, of a compact selection) while no selected atom has moved more than skin / 2 from its position at the rebuild, the cell is unchanged, and every atom type is the type recorded at the rebuild. stale() reports when that fails. Any type change marks the selection stale so the next rebuild filters again.

Methods#

void rebuild(const Cloud& cloud, std::vector<int> selected, double skin)

Lists the graph and builds the topology. selected holds frame indices, ascending and unique. Throws std::invalid_argument when the cell has no volume or dMax + skin is not below half its narrowest width. Throws std::length_error, naming the limit, when the ring or shortcut search exceeds its documented budget. Records every atom type so a later type change makes stale() true.

void checkKind(Kind kind, int arg) const

Throws std::invalid_argument when kind and arg do not name a variable of this workspace.

double value(const Cloud& cloud, Kind kind, int arg, double* grad)

Value of one variable. With grad non-null, 3 * cloud.nop entries of d value / d x are written, zero for unselected atoms. Throws std::range_error, writing nothing, when the value or a gradient entry is not finite.

void addClause(int state, Kind kind, int arg, double threshold, double width, bool above)

Appends a factor to state state (state == stateCount() opens a new state). The factor is sigma((v - threshold) / width) when above is true and 1 - sigma(…) otherwise, sigma the logistic function. With kind State and width 0 the factor is chi_arg or 1 - chi_arg.

void states(const Cloud& cloud, double* chi, double* grad)

chi of every state; with grad non-null, stateCount() rows of 3 * cloud.nop entries. Throws std::range_error, writing nothing, when a chi or a gradient entry is not finite.