@@ -693,6 +693,7 @@ class LanguageLatex : public Language<Base> {
693
693
_inEquationEnv = false ;
694
694
auxArrayName_ = " " ;
695
695
_currentLoops.clear ();
696
+ _dependentIDs.clear ();
696
697
697
698
698
699
// save some info
@@ -746,7 +747,7 @@ class LanguageLatex : public Language<Base> {
746
747
const std::vector<FuncArgument>& indArg = _nameGen->getIndependent ();
747
748
const std::vector<FuncArgument>& depArg = _nameGen->getDependent ();
748
749
const std::vector<FuncArgument>& tmpArg = _nameGen->getTemporary ();
749
- CPPADCG_ASSERT_KNOWN (!indArg.empty () && depArg.size () > 0 ,
750
+ CPPADCG_ASSERT_KNOWN (!indArg.empty () && ! depArg.empty () ,
750
751
" There must be at least one dependent and one independent argument" )
751
752
CPPADCG_ASSERT_KNOWN (tmpArg.size () == 3 ,
752
753
" There must be three temporary variables" )
@@ -808,7 +809,6 @@ class LanguageLatex : public Language<Base> {
808
809
*/
809
810
if (info->zeroDependents ) {
810
811
// zero initial values
811
- const std::vector<FuncArgument>& depArg = _nameGen->getDependent ();
812
812
if (!depArg.empty ())
813
813
checkEquationEnvStart ();
814
814
for (size_t i = 0 ; i < depArg.size (); i++) {
@@ -845,7 +845,7 @@ class LanguageLatex : public Language<Base> {
845
845
assignCount += printAssignment (node);
846
846
}
847
847
848
- if (inputLatexFiles.size () > 0 && assignCount > 0 ) {
848
+ if (! inputLatexFiles.empty () && assignCount > 0 ) {
849
849
assignCount = 0 ;
850
850
saveLocalFunction (inputLatexFiles, false );
851
851
}
@@ -858,8 +858,8 @@ class LanguageLatex : public Language<Base> {
858
858
CPPADCG_ASSERT_KNOWN (tmpArg[0 ].array ,
859
859
" The temporary variables must be saved in an array in order to generate multiple functions" )
860
860
printAlgorithmFileStart (_code);
861
- for (size_t i = 0 ; i < inputLatexFiles. size (); i++ ) {
862
- _code << " \\ input{" << inputLatexFiles[i] << " }" << _endline;
861
+ for (auto & inputLatexFile : inputLatexFiles) {
862
+ _code << " \\ input{" << inputLatexFile << " }" << _endline;
863
863
}
864
864
printAlgorithmFileEnd (_code);
865
865
}
@@ -1132,14 +1132,14 @@ class LanguageLatex : public Language<Base> {
1132
1132
1133
1133
inline const std::string& createVariableName (Node& var) {
1134
1134
CGOpCode op = var.getOperationType ();
1135
- CPPADCG_ASSERT_UNKNOWN (getVariableID (var) > 0 );
1136
- CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::AtomicForward);
1137
- CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::AtomicReverse);
1138
- CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::LoopStart);
1139
- CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::LoopEnd);
1140
- CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::Index);
1141
- CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::IndexAssign);
1142
- CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::IndexDeclaration);
1135
+ CPPADCG_ASSERT_UNKNOWN (getVariableID (var) > 0 )
1136
+ CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::AtomicForward)
1137
+ CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::AtomicReverse)
1138
+ CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::LoopStart)
1139
+ CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::LoopEnd)
1140
+ CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::Index)
1141
+ CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::IndexAssign)
1142
+ CPPADCG_ASSERT_UNKNOWN (op != CGOpCode::IndexDeclaration)
1143
1143
1144
1144
if (var.getName () == nullptr ) {
1145
1145
if (op == CGOpCode::ArrayCreation) {
@@ -1164,8 +1164,8 @@ class LanguageLatex : public Language<Base> {
1164
1164
1165
1165
} else if (getVariableID (var) < _minTemporaryVarID) {
1166
1166
// dependent variable
1167
- std::map< size_t , size_t >::const_iterator it = _dependentIDs.find (getVariableID (var));
1168
- CPPADCG_ASSERT_UNKNOWN (it != _dependentIDs.end ());
1167
+ auto it = _dependentIDs.find (getVariableID (var));
1168
+ CPPADCG_ASSERT_UNKNOWN (it != _dependentIDs.end ())
1169
1169
1170
1170
size_t index = it->second ;
1171
1171
var.setName (_nameGen->generateDependent (index ));
@@ -1948,9 +1948,9 @@ class LanguageLatex : public Language<Base> {
1948
1948
* the first argument is the condition, following arguments are
1949
1949
* just extra dependencies that must be defined outside the if
1950
1950
*/
1951
- CPPADCG_ASSERT_KNOWN (node.getOperationType () == CGOpCode::StartIf, " Invalid node type" );
1952
- CPPADCG_ASSERT_KNOWN (node.getArguments ().size () >= 1 , " Invalid number of arguments for an 'if start' operation" );
1953
- CPPADCG_ASSERT_KNOWN (node.getArguments ()[0 ].getOperation () != nullptr , " Invalid argument for an 'if start' operation" );
1951
+ CPPADCG_ASSERT_KNOWN (node.getOperationType () == CGOpCode::StartIf, " Invalid node type" )
1952
+ CPPADCG_ASSERT_KNOWN (node.getArguments ().size () >= 1 , " Invalid number of arguments for an 'if start' operation" )
1953
+ CPPADCG_ASSERT_KNOWN (node.getArguments ()[0 ].getOperation () != nullptr , " Invalid argument for an 'if start' operation" )
1954
1954
1955
1955
checkEquationEnvEnd ();
1956
1956
@@ -2053,7 +2053,7 @@ class LanguageLatex : public Language<Base> {
2053
2053
}
2054
2054
2055
2055
virtual void printUserCustom (Node& node) {
2056
- CPPADCG_ASSERT_KNOWN (node.getOperationType () == CGOpCode::UserCustom, " Invalid node type" );
2056
+ CPPADCG_ASSERT_KNOWN (node.getOperationType () == CGOpCode::UserCustom, " Invalid node type" )
2057
2057
2058
2058
throw CGException (" Unable to generate Latex for user custom operation nodes." );
2059
2059
}
@@ -2171,35 +2171,35 @@ class LanguageLatex : public Language<Base> {
2171
2171
};
2172
2172
2173
2173
template <class Base >
2174
- const std::string LanguageLatex<Base>::_COMP_OP_LT = " <" ;
2174
+ const std::string LanguageLatex<Base>::_COMP_OP_LT = " <" ; // NOLINT(cert-err58-cpp)
2175
2175
template <class Base >
2176
- const std::string LanguageLatex<Base>::_COMP_OP_LE = " \\ le" ;
2176
+ const std::string LanguageLatex<Base>::_COMP_OP_LE = " \\ le" ; // NOLINT(cert-err58-cpp)
2177
2177
template <class Base >
2178
- const std::string LanguageLatex<Base>::_COMP_OP_EQ = " ==" ;
2178
+ const std::string LanguageLatex<Base>::_COMP_OP_EQ = " ==" ; // NOLINT(cert-err58-cpp)
2179
2179
template <class Base >
2180
- const std::string LanguageLatex<Base>::_COMP_OP_GE = " \\ ge" ;
2180
+ const std::string LanguageLatex<Base>::_COMP_OP_GE = " \\ ge" ; // NOLINT(cert-err58-cpp)
2181
2181
template <class Base >
2182
- const std::string LanguageLatex<Base>::_COMP_OP_GT = " >" ;
2182
+ const std::string LanguageLatex<Base>::_COMP_OP_GT = " >" ; // NOLINT(cert-err58-cpp)
2183
2183
template <class Base >
2184
- const std::string LanguageLatex<Base>::_COMP_OP_NE = " \\ ne" ;
2184
+ const std::string LanguageLatex<Base>::_COMP_OP_NE = " \\ ne" ; // NOLINT(cert-err58-cpp)
2185
2185
2186
2186
template <class Base >
2187
- const std::string LanguageLatex<Base>::_C_STATIC_INDEX_ARRAY = " index" ;
2187
+ const std::string LanguageLatex<Base>::_C_STATIC_INDEX_ARRAY = " index" ; // NOLINT(cert-err58-cpp)
2188
2188
2189
2189
template <class Base >
2190
- const std::string LanguageLatex<Base>::_C_SPARSE_INDEX_ARRAY = " idx" ;
2190
+ const std::string LanguageLatex<Base>::_C_SPARSE_INDEX_ARRAY = " idx" ; // NOLINT(cert-err58-cpp)
2191
2191
2192
2192
template <class Base >
2193
- const std::string LanguageLatex<Base>::_ATOMIC_TX = " atx" ;
2193
+ const std::string LanguageLatex<Base>::_ATOMIC_TX = " atx" ; // NOLINT(cert-err58-cpp)
2194
2194
2195
2195
template <class Base >
2196
- const std::string LanguageLatex<Base>::_ATOMIC_TY = " aty" ;
2196
+ const std::string LanguageLatex<Base>::_ATOMIC_TY = " aty" ; // NOLINT(cert-err58-cpp)
2197
2197
2198
2198
template <class Base >
2199
- const std::string LanguageLatex<Base>::_ATOMIC_PX = " apx" ;
2199
+ const std::string LanguageLatex<Base>::_ATOMIC_PX = " apx" ; // NOLINT(cert-err58-cpp)
2200
2200
2201
2201
template <class Base >
2202
- const std::string LanguageLatex<Base>::_ATOMIC_PY = " apy" ;
2202
+ const std::string LanguageLatex<Base>::_ATOMIC_PY = " apy" ; // NOLINT(cert-err58-cpp)
2203
2203
2204
2204
} // END cg namespace
2205
2205
} // END CppAD namespace
0 commit comments