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

check internal matrices are consistent #419

Merged
merged 2 commits into from
Oct 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/flare_pp/bffs/sparse_gp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ std::vector<Eigen::VectorXd>
SparseGP ::compute_cluster_uncertainties(const Structure &structure) {
// TODO: this only computes the energy-energy variance, and the Sigma matrix is not considered?

if (L_inv.rows() != Kuu.rows()) {
throw std::runtime_error(
"L_inv must be up to date to evaluate uncertainties. Please call update_matrices_QR and try again."
);
}

// Create cluster descriptors.
std::vector<ClusterDescriptor> cluster_descriptors;
for (int i = 0; i < structure.descriptors.size(); i++) {
Expand Down Expand Up @@ -632,6 +638,12 @@ void SparseGP ::update_matrices_QR() {

void SparseGP ::predict_mean(Structure &test_structure) {

if (L_inv.rows() != Kuu.rows()) {
throw std::runtime_error(
"L_inv must be up to date to make predictions. Please call update_matrices_QR and try again."
);
}

int n_atoms = test_structure.noa;
int n_out = 1 + 3 * n_atoms + 6;

Expand All @@ -650,6 +662,12 @@ void SparseGP ::predict_mean(Structure &test_structure) {

void SparseGP ::predict_SOR(Structure &test_structure) {

if (L_inv.rows() != Kuu.rows()) {
throw std::runtime_error(
"L_inv must be up to date to make predictions. Please call update_matrices_QR and try again."
);
}

int n_atoms = test_structure.noa;
int n_out = 1 + 3 * n_atoms + 6;

Expand All @@ -671,6 +689,12 @@ void SparseGP ::predict_SOR(Structure &test_structure) {

void SparseGP ::predict_DTC(Structure &test_structure) {

if (L_inv.rows() != Kuu.rows()) {
throw std::runtime_error(
"L_inv must be up to date to make predictions. Please call update_matrices_QR and try again."
);
}

int n_atoms = test_structure.noa;
int n_out = 1 + 3 * n_atoms + 6;

Expand Down Expand Up @@ -701,6 +725,12 @@ void SparseGP ::predict_DTC(Structure &test_structure) {
}

void SparseGP ::predict_local_uncertainties(Structure &test_structure) {
if (L_inv.rows() != Kuu.rows()) {
throw std::runtime_error(
"L_inv must be up to date to make predictions. Please call update_matrices_QR and try again."
);
}

int n_atoms = test_structure.noa;
int n_out = 1 + 3 * n_atoms + 6;

Expand Down