Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions include/trackcpp/accelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class Accelerator {
// energy < electron_rest_energy -> energy = electron_rest_energy:
Accelerator(const double& energy=-1);
double energy; // [eV]
bool cavity_on;
Copy link
Copy Markdown
Contributor Author

@xresende xresende Jul 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these variables were not being initialized. pyaccel was taking care of it but this PR fixes this issue.
also deleted unnecessary semicolons that were generating pedantic warnings at compilation time.

int radiation_on;
bool vchamber_on;
int harmonic_number;
bool cavity_on = false;
int radiation_on = RadiationState::off;
bool vchamber_on = false;
int harmonic_number = 0;
std::vector<Element> lattice;

bool operator==(const Accelerator& o) const;
Expand Down
45 changes: 24 additions & 21 deletions include/trackcpp/tpsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
//
// TPSA
// ====
// Author: Ximenes R. Resende
// email: xresende@gmail.com, ximenes.resende@lnls.br
// Author: Ximenes R. Resende
// email: xresende@gmail.com, ximenes.resende@lnls.br
// affiliation: LNLS - Laboratorio Nacional de Luz Sincrotron
// Date: August 31st, 2006 @ LNLS
// Date: August 31st, 2006 @ LNLS
//
// Notes:
//
Expand Down Expand Up @@ -189,6 +189,7 @@ template <unsigned int V, unsigned int N, typename TYPE> unsigned int Tpsa<V,N,T
template <unsigned int V, unsigned int N, typename TYPE> unsigned int Tpsa<V,N,TYPE>::powers[et_osip<V,N,N>::val][V];



// Implementations: CONSTRUCTORS
// -----------------------------

Expand All @@ -199,7 +200,7 @@ Tpsa<V,N,TYPE>::Tpsa(const TYPE& a_, const unsigned int v_) {
//for(unsigned int i=1; i<get_size(); i++) c[i] = 0;
c[0] = a_;
if (v_<V) c[v_+1] = 1;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE>::Tpsa(const Tpsa<V,N,TYPE>& a_) {
Expand All @@ -216,38 +217,39 @@ Tpsa<V,N,TYPE> Tpsa<V,N,TYPE>::operator * (const TYPE& o_) const {
Tpsa<V,N,TYPE> r(*this);
for(unsigned int i=0; i<get_size(); i++) r.c[i] *= o_;
return r;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE> Tpsa<V,N,TYPE>::operator / (const TYPE& o_) const {
Tpsa<V,N,TYPE> r(*this);
for(unsigned int i=0; i<get_size(); i++) r.c[i] /= o_;
return r;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE>& Tpsa<V,N,TYPE>::operator += (const TYPE& o_) {
c[0] += o_;
return *this;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE>& Tpsa<V,N,TYPE>::operator -= (const TYPE& o_) {
c[0] -= o_;
return *this;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE>& Tpsa<V,N,TYPE>::operator *= (const TYPE& o_) {
for(unsigned int i=0; i<get_size(); i++) c[i] *= o_;
return *this;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE>& Tpsa<V,N,TYPE>::operator /= (const TYPE& o_) {
for(unsigned int i=0; i<get_size(); i++) c[i] /= o_;
return *this;
};
}



// Implementations: ALGEBRA OF CLASS ELEMENTS
Expand All @@ -258,21 +260,21 @@ Tpsa<V,N,TYPE> Tpsa<V,N,TYPE>::operator - () const {
Tpsa<V,N,TYPE> r(*this);
for(unsigned int i=0; i<get_size(); i++) r.c[i] = -r.c[i];
return r;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE> Tpsa<V,N,TYPE>::operator + (const Tpsa<V,N,TYPE>& o_) const {
Tpsa<V,N,TYPE> r(*this);
for(unsigned int i=0; i<get_size(); i++) r.c[i] += o_.c[i];
return r;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE> Tpsa<V,N,TYPE>::operator - (const Tpsa<V,N,TYPE>& o_) const {
Tpsa<V,N,TYPE> r(*this);
for(unsigned int i=0; i<get_size(); i++) r.c[i] -= o_.c[i];
return r;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE> Tpsa<V,N,TYPE>::operator * (const Tpsa<V,N,TYPE>& o_) const {
Expand All @@ -289,7 +291,7 @@ Tpsa<V,N,TYPE> Tpsa<V,N,TYPE>::operator * (const Tpsa<V,N,TYPE>& o_) const {
}
}
return r;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE> Tpsa<V,N,TYPE>::inverse() const {
Expand All @@ -307,31 +309,32 @@ Tpsa<V,N,TYPE> Tpsa<V,N,TYPE>::inverse() const {
template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE> Tpsa<V,N,TYPE>::operator / (const Tpsa<V,N,TYPE>& o_) const {
return *this * o_.inverse();
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE>& Tpsa<V,N,TYPE>::operator += (const Tpsa<V,N,TYPE>& o_) {
for(unsigned int i=0; i<get_size(); i++) c[i] += o_.c[i];
return *this;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE>& Tpsa<V,N,TYPE>::operator -= (const Tpsa<V,N,TYPE>& o_) {
for(unsigned int i=0; i<get_size(); i++) c[i] -= o_.c[i];
return *this;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE>& Tpsa<V,N,TYPE>::operator *= (const Tpsa<V,N,TYPE>& o_) {
*this = *this * o_;
return *this;
};
}

template <unsigned int V, unsigned int N, typename TYPE>
Tpsa<V,N,TYPE>& Tpsa<V,N,TYPE>::operator /= (const Tpsa<V,N,TYPE>& o_) {
*this = *this * o_.inverse();
return *this;
};
}



// Implementation: BOOLEAN OPERATORS
Expand Down Expand Up @@ -403,6 +406,7 @@ bool Tpsa<V,N,TYPE>::operator >= (const Tpsa<V,N,TYPE>& o_) const {
}



// Implementation: AUXILIARY MEMBER FUNCTIONS
// ------------------------------------------

Expand Down Expand Up @@ -461,6 +465,7 @@ void Tpsa<V,N,TYPE>::get_power(unsigned int idx_, unsigned int* power_) {
}



// Implementation: NON-MEMBER FUNCTIONS AND OPERATORS WITH ARGUMENTS OF CLASS TYPE
// -------------------------------------------------------------------------------
// Note: these functions are generating Stack Overflow at run-time for large N,V
Expand Down Expand Up @@ -711,6 +716,4 @@ bool isfinite(const Tpsa<V,N,TYPE>& a_) {
}




#endif
6 changes: 3 additions & 3 deletions src/lattice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ std::vector<int> latt_findcells_fam_name(const std::vector<Element>& lattice, co
}
};
return r;
};
}

std::vector<int> latt_findcells_frequency(const std::vector<Element>& lattice, const double& value, bool reverse) {
std::vector<int> r;
Expand All @@ -108,7 +108,7 @@ std::vector<int> latt_findcells_frequency(const std::vector<Element>& lattice, c
}
};
return r;
};
}

std::vector<int> latt_findcells_angle(const std::vector<Element>& lattice, const double& value, bool reverse) {
std::vector<int> r;
Expand All @@ -118,7 +118,7 @@ std::vector<int> latt_findcells_angle(const std::vector<Element>& lattice, const
}
};
return r;
};
}

std::vector<int> latt_findcells_polynom_b(const std::vector<Element>& lattice, unsigned int n, const double& value, bool reverse) {
std::vector<int> r;
Expand Down