96 friend FFDep operator+ (
const double,
const FFDep& );
97 friend FFDep operator+ (
const FFDep&,
const double );
100 friend FFDep operator- (
const double,
const FFDep& );
101 friend FFDep operator- (
const FFDep&,
const double );
103 friend FFDep operator* (
const FFDep&,
const double );
104 friend FFDep operator* (
const double,
const FFDep& );
106 friend FFDep operator/ (
const FFDep&,
const double );
107 friend FFDep operator/ (
const double,
const FFDep& );
108 friend std::ostream& operator<< ( std::ostream&,
const FFDep& );
109 friend bool operator== (
const FFDep&,
const FFDep& );
110 friend bool operator!= (
const FFDep&,
const FFDep& );
111 friend bool operator<= (
const FFDep&,
const FFDep& );
112 friend bool operator>= (
const FFDep&,
const FFDep& );
113 friend bool operator< (
const FFDep&,
const FFDep& );
114 friend bool operator> (
const FFDep&,
const FFDep& );
132 friend FFDep pow (
const FFDep&,
const double );
136 friend FFDep min (
const unsigned int,
const FFDep* );
137 friend FFDep max (
const unsigned int,
const FFDep* );
138 friend FFDep sum (
const unsigned int,
const FFDep* );
139 friend FFDep prod (
const unsigned int,
const FFDep* );
162 return "mc::FFDep\t Feature not yet implemented in MC++";
164 return "mc::FFDep\t Undocumented error";
169 typedef std::map<int,bool> t_FFDep;
170 typedef t_FFDep::iterator it_FFDep;
171 typedef t_FFDep::const_iterator cit_FFDep;
176 { _dep.clear();
return *
this; }
179 {
if(
this != &S ) _dep = S._dep;
return *
this; }
197 {
return combine( S,
false ); }
203 {
return combine( S,
false ); }
210 (
const double c=0. )
224 { _dep.clear(); _dep.insert( std::make_pair(ind,
true) );
return *
this; }
227 std::pair<bool,bool>
dep
229 { cit_FFDep it = _dep.find(ind);
230 return( it==_dep.end()? std::make_pair(
false,
true):
231 std::make_pair(
true,it->second) ); }
234 const t_FFDep&
dep()
const
241 (
const FFDep&S,
const bool linear=
true );
244 (
const FFDep&S1,
const FFDep&S2,
const bool linear=
true );
264 it_FFDep it = _dep.begin();
265 for( ; it != _dep.end(); ++it ) it->second =
false;
279 (
const FFDep&S,
const bool linear )
281 cit_FFDep cit = S._dep.begin();
282 for( ; cit != S._dep.end(); ++cit ){
283 std::pair<it_FFDep,bool> ins = _dep.insert( *cit );
284 if( !ins.second ) ins.first->second = ( ins.first->second && cit->second );
286 return( linear? *
this: nonlinear() );
294 return S3.
combine( S2, linear );
299 ( std::ostream&out,
const FFDep&S)
302 FFDep::cit_FFDep iS = S._dep.begin();
303 for( ; iS != S._dep.end(); ++iS )
304 out << iS->first << (iS->second?
"L":
"NL") <<
" ";
325 (
const double c,
const FFDep&S )
332 (
const FFDep&S,
const double c )
339 (
const FFDep&S1,
const FFDep&S2 )
346 (
const unsigned int n,
const FFDep*S )
348 if( n==2 )
return S[0] + S[1];
349 return S[0] + sum( n-1, S+1 );
354 (
const double c,
const FFDep&S )
361 (
const FFDep&S,
const double c )
368 (
const FFDep&S1,
const FFDep&S2 )
375 (
const double c,
const FFDep&S )
382 (
const FFDep&S,
const double c )
389 (
const FFDep&S1,
const FFDep&S2 )
391 if( S1._dep.empty() )
return S2;
392 if( S2._dep.empty() )
return S1;
398 (
const unsigned int n,
const FFDep*S )
400 if( n==2 )
return S[0] * S[1];
401 return S[0] * prod( n-1, S+1 );
406 (
const FFDep&S,
const double c )
413 (
const double c,
const FFDep&S )
420 (
const FFDep&S1,
const FFDep&S2 )
422 if( S1._dep.empty() )
return inv( S2 );
423 if( S2._dep.empty() )
return S1;
450 (
const FFDep &S,
const double a )
513 (
const FFDep&S,
const int n )
515 if( n == 0 ){ FFDep S2;
return S2; }
516 if( n == 1 )
return S;
522 (
const FFDep&S,
const double a )
529 (
const FFDep&S1,
const FFDep&S2 )
538 (
const FFDep&S1,
const FFDep&S2 )
540 if( S1._dep.empty() )
return S2;
541 if( S2._dep.empty() )
return S1;
547 (
const FFDep&S1,
const FFDep&S2 )
549 if( S1._dep.empty() )
return S2;
550 if( S2._dep.empty() )
return S1;
556 (
const unsigned int n,
const FFDep*S )
558 if( n==2 )
return min( S[0], S[1] );
559 return min( S[0], min( n-1, S+1 ) );
564 (
const unsigned int n,
const FFDep*S )
566 if( n==2 )
return max( S[0], S[1] );
567 return max( S[0], max( n-1, S+1 ) );
614 (
const FFDep&S1,
const FFDep&S2 )
616 return( S1._dep == S2._dep );
621 (
const FFDep&S1,
const FFDep&S2 )
623 return( S1._dep != S2._dep );
628 (
const FFDep&S1,
const FFDep&S2 )
630 return( S1._dep <= S2._dep );
635 (
const FFDep&S1,
const FFDep&S2 )
637 return( S1._dep >= S2._dep );
642 (
const FFDep&S1,
const FFDep&S2 )
644 return( S1._dep < S2._dep );
649 (
const FFDep&S1,
const FFDep&S2 )
651 return( S1._dep > S2._dep );
Exceptions(TYPE ierr)
Constructor for error ierr
Definition: ffdep.hpp:152
FFDep & nonlinear()
Turns current dependent variables into nonlinear.
Definition: ffdep.hpp:262
C++ class for evaluation of the sparsity pattern of a factorable function.
Definition: ffdep.hpp:90
FFDep(const double c=0.)
Default constructor (needed to declare arrays of FFDep class)
Definition: ffdep.hpp:210
const t_FFDep & dep() const
Returns the dependency set.
Definition: ffdep.hpp:234
FFDep & combine(const FFDep &S, const bool linear=true)
Combines with the dependency sets of another variable.
Definition: ffdep.hpp:279
~FFDep()
Destructor.
Definition: ffdep.hpp:218
Exceptions of mc::FFDep.
Definition: ffdep.hpp:144
FFDep & indep(const int ind)
Sets as independent with index ind
Definition: ffdep.hpp:223
TYPE
Enumeration type for FFDep exception handling.
Definition: ffdep.hpp:148
int ierr()
Inline function returning the error flag.
Definition: ffdep.hpp:155
Error due to calling a function/feature not yet implemented in mc::FFDep.
Definition: ffdep.hpp:149