Skip to content

Commit f5154b4

Browse files
authored
Merge pull request #37 from LLNL/fix-warnings
Fix compiler warnings
2 parents 2ac75cd + 54f758c commit f5154b4

19 files changed

+248
-261
lines changed

include/controlbasis.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ class ControlBasis {
3333
virtual int getNSplines() {return 0;};
3434

3535
/* Variation of control parameters */
36-
virtual double computeVariation(std::vector<double>& params, int carrierfreqID){return 0.0;};
37-
virtual void computeVariation_diff(double* grad, std::vector<double>&params, double var_bar, int carrierfreqID){};
36+
virtual double computeVariation(std::vector<double>& /*params*/, int /*carrierfreqID*/){return 0.0;};
37+
virtual void computeVariation_diff(double* /*grad*/, std::vector<double>& /*params*/, double /*var_bar*/, int /*carrierfreqID*/){};
3838

3939
/* Default: do nothing. For some control parameterizations, this can be used to enforce that the controls start and end at zero. E.g. the Splines will overwrite the parameters x of the first and last two splines by zero, so that the splines start and end at zero. */
40-
virtual void enforceBoundary(double* x, int carrier_id) {};
40+
virtual void enforceBoundary(double* /*x*/, int /*carrier_id*/) {};
4141

4242
/* Evaluate the Basis(alpha, t) at time t using the coefficients coeff. */
4343
virtual void evaluate(const double t, const std::vector<double>& coeff, int carrier_freq_id, double* Blt1, double*Blt2) = 0;
@@ -198,8 +198,8 @@ class ConstantTransferFunction : public TransferFunction {
198198
ConstantTransferFunction(double constant_, std::vector<double> onofftimes);
199199
~ConstantTransferFunction();
200200

201-
double eval(double x, double time) {return isOn(constant, time); };
202-
double der(double x, double time) {return 0.0; };
201+
double eval(double /*x*/, double time) {return isOn(constant, time); };
202+
double der(double /*x*/, double /*time*/) {return 0.0; };
203203
};
204204

205205
/*
@@ -212,7 +212,7 @@ class IdentityTransferFunction : public TransferFunction {
212212
~IdentityTransferFunction();
213213

214214
double eval(double x, double time) {return isOn(x, time); };
215-
double der(double x, double time) {return isOn(1.0, time); };
215+
double der(double /*x*/, double time) {return isOn(1.0, time); };
216216
};
217217

218218

include/mastereq.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ class MasterEq{
114114
void setTransferOnOffTimes(std::vector<double> tlist);
115115

116116
/* Return the i-th oscillator */
117-
Oscillator* getOscillator(const int i);
117+
Oscillator* getOscillator(const size_t i);
118118

119119
/* Return number of oscillators */
120-
int getNOscillators();
120+
size_t getNOscillators();
121121

122122
/* Return dimension of vectorized system N^2 (for Lindblad solver) or N (for Schroedinger solver) */
123123
int getDim();
@@ -437,7 +437,7 @@ inline void L1decay(const int it, const int n, const int i, const int ip, const
437437

438438

439439
// Transpose of offdiagonal L1decay
440-
inline void L1decay_T(const int it, const int n, const int i, const int ip, const int stridei, const int strideip, const double* xptr, const double decayi, double* yre, double* yim){
440+
inline void L1decay_T(const int it, const int i, const int ip, const int stridei, const int strideip, const double* xptr, const double decayi, double* yre, double* yim){
441441
if (fabs(decayi) > 1e-12) {
442442
if (i > 0 && ip > 0) {
443443
double l1off = decayi * sqrt(i*ip);

include/optimproblem.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class OptimProblem {
2121

2222
/* ODE stuff */
23-
int ninit; /* Number of initial conditions to be considered (N^2, N, or 1) */
23+
size_t ninit; /* Number of initial conditions to be considered (N^2, N, or 1) */
2424
int ninit_local; /* Local number of initial conditions on this processor */
2525
Vec rho_t0; /* Storage for initial condition of the ODE */
2626
Vec rho_t0_bar; /* Adjoint of ODE initial condition */

include/optimtarget.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class OptimTarget{
2121
If target is a gate, this holds the transformed state VrhoV^\dagger.
2222
If target is read from file, this holds the target density matrix from that file. */
2323
InitialConditionType initcond_type; /* Type of initial conditions */
24-
std::vector<int> initcond_IDs; /* Integer list for pure-state initialization */
24+
std::vector<size_t> initcond_IDs; /* Integer list for pure-state initialization */
2525
LindbladType lindbladtype; /* Type of decoherence (lindblad vs schroedinger) */
2626

2727
Vec aux; /* auxiliary vector needed when computing the objective for gate optimization */

include/oscillator.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ class Oscillator {
4848
int dim_postOsc; // Dimension of coupled subsystem following this oscillator
4949

5050
Oscillator();
51-
Oscillator(MapParam config, int id, std::vector<int> nlevels_all_, std::vector<std::string>& controlsegments, std::vector<std::string>& controlinitializations, double ground_freq_, double selfkerr_, double rotational_freq_, double decay_time_, double dephase_time_, std::vector<double> carrier_freq_, double Tfinal_, LindbladType lindbladtype_, std::default_random_engine rand_engine);
51+
Oscillator(MapParam config, size_t id, std::vector<int> nlevels_all_, std::vector<std::string>& controlsegments, std::vector<std::string>& controlinitializations, double ground_freq_, double selfkerr_, double rotational_freq_, double decay_time_, double dephase_time_, std::vector<double> carrier_freq_, double Tfinal_, LindbladType lindbladtype_, std::default_random_engine rand_engine);
5252
virtual ~Oscillator();
5353

5454
/* Return the constants */
55-
int getNParams() { return params.size(); };
56-
int getNLevels() { return nlevels; };
55+
size_t getNParams() { return params.size(); };
56+
size_t getNLevels() { return nlevels; };
5757
double getSelfkerr() { return selfkerr; };
5858
double getDetuning() { return detuning_freq; };
5959
double getDecayTime() {return decay_time; };
6060
double getDephaseTime() {return dephase_time; };
61-
int getNSegments() {return basisfunctions.size(); };
62-
int getNCarrierfrequencies() {return carrier_freq.size(); };
61+
size_t getNSegments() {return basisfunctions.size(); };
62+
size_t getNCarrierfrequencies() {return carrier_freq.size(); };
6363
ControlType getControlType(int isegment=0) {return basisfunctions[isegment]->getType(); };
6464
int getNSplines(int isegment=0) {return basisfunctions[isegment]->getNSplines();};
6565
double getRotFreq() {return (ground_freq - detuning_freq) / (2.0*M_PI); };

include/timestepper.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ class TimeStepper{
5050
bool storeFWD; /* Flag that determines if primal states should be stored during forward evaluation */
5151

5252
TimeStepper();
53-
TimeStepper(MapParam config, MasterEq* mastereq_, int ntime_, double total_time_, Output* output_, bool storeFWD_);
53+
TimeStepper(MasterEq* mastereq_, int ntime_, double total_time_, Output* output_, bool storeFWD_);
5454
virtual ~TimeStepper();
5555

5656
/* Return the state at a certain time index */
57-
Vec getState(int tindex);
57+
Vec getState(size_t tindex);
5858

5959
/* Solve the ODE forward in time with initial condition rho_t0. Return state at final time step */
6060
Vec solveODE(int initid, Vec rho_t0);
6161

6262
/* Solve the adjoint ODE backwards in time from terminal condition rho_t0_bar */
63-
void solveAdjointODE(int initid, Vec rho_t0_bar, Vec finalstate, double Jbar_penalty, double Jbar_penalty_dpdm, double Jbar_penalty_energy);
63+
void solveAdjointODE(Vec rho_t0_bar, Vec finalstate, double Jbar_penalty, double Jbar_penalty_dpdm, double Jbar_penalty_energy);
6464

6565
/* evaluate the penalty integral term */
6666
double penaltyIntegral(double time, const Vec x);
@@ -84,7 +84,7 @@ class TimeStepper{
8484
class ExplEuler : public TimeStepper {
8585
Vec stage;
8686
public:
87-
ExplEuler(MapParam config, MasterEq* mastereq_, int ntime_, double total_time_, Output* output_, bool storeFWD_);
87+
ExplEuler(MasterEq* mastereq_, int ntime_, double total_time_, Output* output_, bool storeFWD_);
8888
~ExplEuler();
8989

9090
/* Evolve state forward from tstart to tstop */
@@ -116,7 +116,7 @@ class ImplMidpoint : public TimeStepper {
116116
Vec tmp, err; /* Auxiliary vector for applying the neuman iterations */
117117

118118
public:
119-
ImplMidpoint(MapParam config, MasterEq* mastereq_, int ntime_, double total_time_, LinearSolverType linsolve_type_, int linsolve_maxiter_, Output* output_, bool storeFWD_);
119+
ImplMidpoint(MasterEq* mastereq_, int ntime_, double total_time_, LinearSolverType linsolve_type_, int linsolve_maxiter_, Output* output_, bool storeFWD_);
120120
~ImplMidpoint();
121121

122122

@@ -140,7 +140,7 @@ class CompositionalImplMidpoint : public ImplMidpoint {
140140
int order;
141141

142142
public:
143-
CompositionalImplMidpoint(MapParam config, int order_, MasterEq* mastereq_, int ntime_, double total_time_, LinearSolverType linsolve_type_, int linsolve_maxiter_, Output* output_, bool storeFWD_);
143+
CompositionalImplMidpoint(int order_, MasterEq* mastereq_, int ntime_, double total_time_, LinearSolverType linsolve_type_, int linsolve_maxiter_, Output* output_, bool storeFWD_);
144144
~CompositionalImplMidpoint();
145145

146146
void evolveFWD(const double tstart, const double tstop, Vec x);

src/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ if(WITH_SLEPC)
5050
target_compile_options(quandary PRIVATE -DWITH_SLEPC)
5151
endif()
5252

53-
# Suppress compiler warnings temporarily
54-
# TODO fix these and remove this!
55-
add_definitions(-w)
56-
5753
install(
5854
TARGETS quandary
5955
RUNTIME DESTINATION bin

src/config.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ void MapParam::GetVecIntParam(std::string key, std::vector<int> &fillme, int def
184184
{
185185
std::map<std::string, std::string>::const_iterator it_value = this->find(key);
186186
std::string lineexp;
187-
double val;
188187
if (it_value == this->end())
189188
{
190189
if (mpi_rank == 0 && !quietmode && warnme)

src/controlbasis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void BSpline2nd::evaluate(const double t, const std::vector<double>& coeff, int
6565

6666
}
6767

68-
void BSpline2nd::derivative(const double t, const std::vector<double>& coeff, double* coeff_diff, const double valbar1, const double valbar2, int carrier_freq_id) {
68+
void BSpline2nd::derivative(const double t, const std::vector<double>& /*coeff*/, double* coeff_diff, const double valbar1, const double valbar2, int carrier_freq_id) {
6969

7070
/* Iterate over basis function */
7171
for (int l=0; l<nsplines; l++) {
@@ -242,7 +242,7 @@ void BSpline0::evaluate(const double t, const std::vector<double>& coeff, int ca
242242
}
243243
}
244244

245-
void BSpline0::derivative(const double t, const std::vector<double>& coeff, double* coeff_diff, const double valbar1, const double valbar2, int carrier_freq_id) {
245+
void BSpline0::derivative(const double t, const std::vector<double>& /*coeff*/, double* coeff_diff, const double valbar1, const double valbar2, int carrier_freq_id) {
246246

247247
// Figure out which basis function is active at this time point
248248
int splineID = ceil((t-tstart)/dtknot - 0.5);
@@ -332,7 +332,7 @@ void TransferFunction::storeOnOffTimes(std::vector<double>onofftimes_){
332332

333333
// Copy the list of time points that determine when the transfer functions are active
334334
onofftimes.clear();
335-
for (int i=0; i<onofftimes_.size(); i++) {
335+
for (size_t i=0; i<onofftimes_.size(); i++) {
336336
onofftimes.push_back( onofftimes_[i] );
337337
}
338338
}

src/gate.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ Gate::Gate(std::vector<int> nlevels_, std::vector<int> nessential_, double time_
1717
final_time = time_;
1818
gate_rot_freq = gate_rot_freq_;
1919
lindbladtype = lindbladtype_;
20-
for (int i=0; i<gate_rot_freq.size(); i++){
20+
for (size_t i=0; i<gate_rot_freq.size(); i++){
2121
gate_rot_freq[i] *= 2.*M_PI;
2222
}
2323

2424
/* Dimension of gate = \prod_j nessential_j */
2525
dim_ess = 1;
26-
for (int i=0; i<nessential.size(); i++) {
26+
for (size_t i=0; i<nessential.size(); i++) {
2727
dim_ess *= nessential[i];
2828
}
2929

3030
/* Dimension of system matrix rho */
3131
dim_rho = 1;
32-
for (int i=0; i<nlevels.size(); i++) {
32+
for (size_t i=0; i<nlevels.size(); i++) {
3333
dim_rho *= nlevels[i];
3434
}
3535

@@ -98,10 +98,10 @@ void Gate::assembleGate(){
9898
for (PetscInt row=0; row<dim_ess; row++){
9999
int r = row;
100100
double freq = 0.0;
101-
for (int iosc=0; iosc<nlevels.size(); iosc++){
101+
for (size_t iosc=0; iosc<nlevels.size(); iosc++){
102102
// compute dimension of essential levels of all following subsystems
103103
int dim_post = 1;
104-
for (int josc=iosc+1; josc<nlevels.size();josc++) {
104+
for (size_t josc=iosc+1; josc<nlevels.size();josc++) {
105105
dim_post *= nessential[josc];
106106
}
107107
// compute the frequency

0 commit comments

Comments
 (0)