Skip to content

Commit 75b79ba

Browse files
committed
Addressed Dylan's concerns on PR.
1 parent a3a3471 commit 75b79ba

4 files changed

Lines changed: 11 additions & 20 deletions

File tree

lib/algo/manifold_interp/Interpolator.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ std::vector<double> obtainRBFGradientToTrainingPoints(
149149
}
150150
else
151151
{
152-
std::cout << "Interpolated gradients are only implemented for \"LS\" ";
153-
CAROM_VERIFY(interp_method == "LS");
152+
CAROM_ERROR("Interpolated gradients are only implemented for \"LS\"");
154153
}
155154
return rbfs;
156155
}
@@ -160,36 +159,34 @@ double obtainRBFGradient(std::string rbf, double epsilon, const Vector & point1,
160159
{
161160
Vector diff;
162161
point1.minus(point2, diff);
163-
double eps_norm_squared = epsilon * epsilon * diff.norm2();
162+
const double eps_norm_squared = epsilon * epsilon * diff.norm2();
164163
double res = 0.0;
165164

166165
// Gaussian RBF
167166
if (rbf == "G")
168167
{
169-
//res = std::exp(-eps_norm_squared);
168+
//Derivative of Gaussian RBF, res = std::exp(-eps_norm_squared);
170169
res = -2.0*epsilon*epsilon*diff.item(index)*std::exp(-eps_norm_squared);
171170
}
172171
// Inverse quadratic RBF
173172
else if (rbf == "IQ")
174173
{
175-
//res = 1.0 / (1.0 + eps_norm_squared);
174+
//Derivative of Inverse Quadratic RBF, res = 1.0 / (1.0 + eps_norm_squared);
176175
res = -2.0*epsilon*epsilon*diff.item(index)/((1.0+eps_norm_squared)*
177176
(1.0+eps_norm_squared));
178177

179178
}
180179
// Inverse multiquadric RBF
181180
else if (rbf == "IMQ")
182181
{
183-
//res = 1.0 / std::sqrt(1.0 + eps_norm_squared);
182+
//Derivative of Inverse multiquadritic RBF, res = 1.0 / std::sqrt(1.0 + eps_norm_squared);
184183
res = -epsilon*epsilon*diff.item(index)/(std::sqrt(1.0+eps_norm_squared)*
185184
(1.0+eps_norm_squared));
186185
}
187186

188187
return res;
189188
}
190189

191-
192-
193190
double rbfWeightedSum(std::vector<double>& rbf)
194191
{
195192
double sum = 0.0;
@@ -205,7 +202,7 @@ double obtainRBF(std::string rbf, double epsilon, const Vector & point1,
205202
{
206203
Vector diff;
207204
point1.minus(point2, diff);
208-
double eps_norm_squared = epsilon * epsilon * diff.norm2();
205+
const double eps_norm_squared = epsilon * epsilon * diff.norm2();
209206
double res = 0.0;
210207

211208
// Gaussian RBF

lib/algo/manifold_interp/MatrixInterpolator.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,15 @@ std::shared_ptr<Matrix> MatrixInterpolator::interpolate(const Vector & point,
106106
{
107107
if (d_compute_gradients)
108108
{
109-
std::cout << "Gradients are only implemented for B or G";
110-
CAROM_VERIFY(false);
109+
CAROM_ERROR("Gradients are only implemented for B or G");
111110
}
112111
interpolated_matrix = interpolateSPDMatrix(point);
113112
}
114113
else if (d_matrix_type == "NS")
115114
{
116115
if (d_compute_gradients)
117116
{
118-
std::cout << "Gradients are only implemented for B or G";
119-
CAROM_VERIFY(false);
117+
CAROM_ERROR("Gradients are only implemented for B or G");
120118
}
121119
interpolated_matrix = interpolateNonSingularMatrix(point);
122120
}
@@ -526,15 +524,12 @@ std::shared_ptr<Matrix> MatrixInterpolator::interpolateMatrix(
526524
d_rbf, d_epsilon, point, i);
527525

528526
std::shared_ptr<Matrix> gradient_matrix(obtainLogInterpolatedMatrix(rbf));
529-
// *interpolated_matrix += *d_rotated_reduced_matrices[d_ref_point];
530-
531527
d_interpolation_gradient.push_back(gradient_matrix);
532528
}
533529
}
534530
else
535531
{
536-
std::cout << "Interpolated gradients are only implemented for \"LS\" ";
537-
CAROM_VERIFY(d_interp_method == "LS");
532+
CAROM_ERROR("Interpolated gradients are only implemented for \"LS\"");
538533
}
539534
}
540535

lib/algo/manifold_interp/VectorInterpolator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ std::shared_ptr<Vector> VectorInterpolator::interpolate(const Vector & point)
136136
}
137137
else
138138
{
139-
std::cout << "Interpolated gradients are only implemented for \"LS\" ";
140-
CAROM_VERIFY(d_interp_method == "LS");
139+
CAROM_ERROR("Interpolated gradients are only implemented for \"LS\"");
141140
}
142141
}
143142

unit_tests/test_interpolation_gradients.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/******************************************************************************
22
*
3-
* Copyright (c) 2013-2024, Lawrence Livermore National Security, LLC
3+
* Copyright (c) 2013-2025, Lawrence Livermore National Security, LLC
44
* and other libROM project developers. See the top-level COPYRIGHT
55
* file for details.
66
*

0 commit comments

Comments
 (0)