Skip to content

Commit

Permalink
Rename instances that are the same as a class instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnoel committed Feb 13, 2024
1 parent 67f4056 commit 1259ffd
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 44 deletions.
12 changes: 6 additions & 6 deletions src/df1b2-separable/df1b2chkder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,19 @@ dvector laplace_approximation_calculator::
}
#endif

dvector step;
dvector local_step;
#if defined(USE_ATLAS)
if (!ad_comm::no_atlas_flag)
{
step=-atlas_solve_spd(Hess,grad,ierr);
local_step=-atlas_solve_spd(Hess,grad,ierr);
}
else
{
dmatrix A=choleski_decomp_positive(Hess,ierr);
if (!ierr)
{
step=-solve(Hess,grad);
//step=-solve(A*trans(A),grad);
local_step=-solve(Hess,grad);
//local_step=-solve(A*trans(A),grad);
}
}
if (ierr)
Expand All @@ -205,7 +205,7 @@ dvector laplace_approximation_calculator::
break;
}
#else
step=-solve(Hess,grad);
local_step=-solve(Hess,grad);
#endif

#ifdef DIAG_TIMER
Expand All @@ -232,7 +232,7 @@ dvector laplace_approximation_calculator::
f1b2gradlist->nlist3.initialize();

uhat_old=uhat;
uhat+=step;
uhat+=local_step;

double maxg_old=maxg;
maxg=fabs(evaluate_function(uhat,pfmin));
Expand Down
12 changes: 6 additions & 6 deletions src/df1b2-separable/df1b2fnl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Description not yet available.
*/
#include <df1b2fnl.h>
#ifndef OPT_LIB
#ifdef DEBUG
#include <cassert>
#include <climits>
#endif
Expand Down Expand Up @@ -41,7 +41,7 @@ imatrix * funnel_init_var::plist=0;
*/
void funnel_init_var::add_to_list(void)
{
#ifndef OPT_LIB
#ifdef DEBUG
assert(num_vars <= INT_MAX);
#endif
index = (int)num_vars;
Expand All @@ -55,7 +55,7 @@ void funnel_init_var::add_to_list(void)
*/
void funnel_init_var::delete_from_list(void)
{
#ifndef OPT_LIB
#ifdef DEBUG
assert(num_vars <= INT_MAX);
#endif
if (index != (int)(num_vars - 1))
Expand Down Expand Up @@ -107,7 +107,7 @@ void funnel_init_var::deallocate_all(void)
{
if (plist)
{
#ifndef OPT_LIB
#ifdef DEBUG
assert(num_active_parameters <= INT_MAX);
#endif
if (plist->indexmax() != (int)num_active_parameters)
Expand Down Expand Up @@ -138,7 +138,7 @@ void funnel_init_var::allocate_all(void)
}
}
num_active_parameters=funnel_init_var::nvarcalc_all();
#ifndef OPT_LIB
#ifdef DEBUG
assert(num_active_parameters <= INT_MAX);
#endif
if (py)
Expand Down Expand Up @@ -618,7 +618,7 @@ unsigned int funnel_init_var::nvarcalc_all(void)
{
n += list[i]->nvar_calc();
}
#ifndef OPT_LIB
#ifdef DEBUG
assert(n >= 0);
#endif
return (unsigned int)n;
Expand Down
8 changes: 4 additions & 4 deletions src/df1b2-separable/df1b2lap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,10 +945,10 @@ laplace_approximation_calculator::laplace_approximation_calculator
break;
case 3:
{
int bw=2;
if (ad_comm::bandwidth) bw=ad_comm::bandwidth;
bHess=new banded_symmetric_dmatrix(1,usize,bw);
bHessadjoint=new banded_symmetric_dmatrix(1,usize,bw);
int local_bw=2;
if (ad_comm::bandwidth) local_bw=ad_comm::bandwidth;
bHess=new banded_symmetric_dmatrix(1,usize,local_bw);
bHessadjoint=new banded_symmetric_dmatrix(1,usize,local_bw);
grad.allocate(1,usize);
Dux.allocate(1,usize,1,xsize);
}
Expand Down
34 changes: 17 additions & 17 deletions src/df1b2-separable/df1b2lp1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <admodel.h>
#include <df1b2fun.h>
#include <adrndeff.h>
#ifndef OPT_LIB
#ifdef DEBUG
#include <cassert>
#include <climits>
#endif
Expand Down Expand Up @@ -205,7 +205,7 @@ dvector laplace_approximation_calculator::default_calculations
}
}
#endif
dvector step;
dvector local_step;
#ifdef DIAG
int print_hess_in_newton_raphson_flag=0;
if (print_hess_in_newton_raphson_flag)
Expand All @@ -224,15 +224,15 @@ dvector laplace_approximation_calculator::default_calculations
#if defined(USE_ATLAS)
if (!ad_comm::no_atlas_flag)
{
step=-atlas_solve_spd(Hess,grad,ierr);
local_step=-atlas_solve_spd(Hess,grad,ierr);
}
else
{
dmatrix A=choleski_decomp_positive(Hess,ierr);
if (!ierr)
{
step=-solve(Hess,grad);
//step=-solve(A*trans(A),grad);
local_step=-solve(Hess,grad);
//local_step=-solve(A*trans(A),grad);
}
}
if (ierr)
Expand All @@ -247,7 +247,7 @@ dvector laplace_approximation_calculator::default_calculations
break;
}
#else
//step=-solve(Hess,grad);
//local_step=-solve(Hess,grad);
int ierror=0;
int icount=0;
int trust_update_flag=0;
Expand All @@ -256,11 +256,11 @@ dvector laplace_approximation_calculator::default_calculations
icount++;
if (saddlepointflag==1 || saddlepointflag==2)
{
step=choleski_solve_neghess_error(Hess,grad,ierror);
local_step=choleski_solve_neghess_error(Hess,grad,ierror);
}
else
{
step=-choleski_solve_error(Hess,grad,ierror);
local_step=-choleski_solve_error(Hess,grad,ierror);
}
if (ierror==1)
{
Expand All @@ -277,14 +277,14 @@ dvector laplace_approximation_calculator::default_calculations
const dvector & cmgrad = -grad;
dmatrix & mHess = (dmatrix &) (cmHess);
dvector & mgrad = (dvector &) (cmgrad);
step=local_minimization(s,mHess,mgrad,lambda);
local_step=local_minimization(s,mHess,mgrad,lambda);
}
else
{
step=local_minimization(s,Hess,grad,lambda);
local_step=local_minimization(s,Hess,grad,lambda);
}
if(!ad_comm::print_hess_and_exit_flag){
uhat+=step;
uhat+=local_step;
}
for (int i=1;i<=usize;i++)
{
Expand Down Expand Up @@ -350,7 +350,7 @@ dvector laplace_approximation_calculator::default_calculations
{
uhat_old=uhat;
if(!ad_comm::print_hess_and_exit_flag){
uhat+=step;
uhat+=local_step;
}
}

Expand Down Expand Up @@ -581,7 +581,7 @@ dvector laplace_approximation_calculator::default_calculations
}
if (initial_df1b2params::separable_flag)
{
#ifndef OPT_LIB
#ifdef DEBUG
assert(nvar <= INT_MAX);
#endif
dvector scale(1,(int)nvar); // need to get scale from somewhere
Expand Down Expand Up @@ -611,7 +611,7 @@ dvector laplace_approximation_calculator::default_calculations
initial_params::straight_through_flag=0;
funnel_init_var::lapprox=0;
block_diagonal_flag=0;
#ifndef OPT_LIB
#ifdef DEBUG
assert(nvar <= INT_MAX);
#endif
dvector scale1(1,(int)nvar); // need to get scale from somewhere
Expand All @@ -622,9 +622,9 @@ dvector laplace_approximation_calculator::default_calculations
quadratic_prior::in_qp_calculations=1;
funnel_init_var::lapprox=this;
df1b2_gradlist::set_no_derivatives();
dvector scale(1,(int)nvar); // need to get scale from somewhere
/*check=*/initial_params::stddev_scale(scale,x);
dvector sscale=scale(1,Dux(1).indexmax());
dvector local_scale(1,(int)nvar); // need to get scale from somewhere
/*check=*/initial_params::stddev_scale(local_scale,x);
dvector sscale=local_scale(1,Dux(1).indexmax());

for (int i=1;i<=usize;i++)
{
Expand Down
18 changes: 9 additions & 9 deletions src/df1b2-separable/f1b2fnl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void laplace_approximation_calculator::
{
int i2=list(*plre_indexi,2);

int* plfe_indexj = lfe_index.get_v() + 1;
plfe_indexj = lfe_index.get_v() + 1;
double* plocal_Duxij = plocal_Duxi->get_v() + 1;
for (int j=1;j<=xs;j++)
{
Expand All @@ -265,10 +265,10 @@ void laplace_approximation_calculator::
{
//int nvar=us*us;
double f;// 0.5*log(det(local_Hess))
dmatrix Hessadjoint=get_gradient_for_hessian_calcs(local_Hess,f);
dmatrix local_Hessadjoint=get_gradient_for_hessian_calcs(local_Hess,f);
initial_df1b2params::cobjfun+=f; // Adds 0.5*log(det(local_Hess))

dvector* pHessadjointi = &Hessadjoint(1);
dvector* pHessadjointi = &local_Hessadjoint(1);
plre_indexi = lre_index.get_v() + 1;
for (int i=1;i<=us;i++)
{
Expand Down Expand Up @@ -314,9 +314,9 @@ void laplace_approximation_calculator::
dvector utmp(1,us);
utmp.initialize();

int* plre_indexi = lre_index.get_v() + 1;
plre_indexi = lre_index.get_v() + 1;
double* putmpi = utmp.get_v() + 1;
double* plocal_uadjointi = local_uadjoint.get_v() + 1;
plocal_uadjointi = local_uadjoint.get_v() + 1;
for (int i=1;i<=us;i++)
{
int i2=list(*plre_indexi, 2);
Expand Down Expand Up @@ -362,8 +362,8 @@ dmatrix laplace_approximation_calculator::get_gradient_for_hessian_calcs
(const dmatrix& local_Hess,double & f)
{
int us=local_Hess.indexmax();
int nvar=us*us;
independent_variables cy(1,nvar);
int local_nvar=us*us;
independent_variables cy(1,local_nvar);
cy.initialize();

double* pcyii = cy.get_v() + 1;
Expand Down Expand Up @@ -410,8 +410,8 @@ dmatrix laplace_approximation_calculator::get_gradient_for_hessian_calcs
vf-=w_i*d*.91893853320467241;
}
f=value(vf);
dvector g(1,nvar);
gradcalc(nvar,g);
dvector g(1,local_nvar);
gradcalc(local_nvar,g);

dmatrix hessadjoint(1,us,1,us);

Expand Down
4 changes: 2 additions & 2 deletions src/df1b2-separable/test_trust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,9 @@ double laplace_approximation_calculator::do_one_feval
dvector g(1,usize);
dvector ub(1,usize);
initial_params::set_active_random_effects();
int nvar=initial_params::nvarcalc();
int local_nvar=initial_params::nvarcalc();
int nvar1=initial_params::nvarcalc_all();
cout << nvar << " " << nvar1 << endl;
cout << local_nvar << " " << nvar1 << endl;
gradient_structure::set_NO_DERIVATIVES();
dvariable vf=0.0;
dvariable pen=initial_params::reset(dvar_vector(x));
Expand Down

0 comments on commit 1259ffd

Please sign in to comment.