/
bioSeveralExpressions.cc
84 lines (72 loc) · 2.38 KB
/
bioSeveralExpressions.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//-*-c++-*------------------------------------------------------------
//
// File name : bioSeveralExpressions.cc
// @date Wed Mar 3 18:08:39 2021
// @author Michel Bierlaire
// @version Revision 1.0
//
//--------------------------------------------------------------------
#include "bioSeveralExpressions.h"
#include "bioExceptions.h"
#include "bioDebug.h"
#include <sstream>
bioSeveralExpressions::bioSeveralExpressions(std::vector<bioExpression*> exprs):
theExpressions(exprs) {
for (std::vector<bioExpression*>::iterator i = exprs.begin() ;
i != exprs.end();
++i) {
listOfChildren.push_back(*i) ;
}
}
bioSeveralExpressions::~bioSeveralExpressions() {
}
bioString bioSeveralExpressions::print(bioBoolean hp) const {
std::stringstream str ;
str << "MultipleExpressions[" ;
for (std::vector<bioExpression*>::const_iterator i = theExpressions.begin() ;
i != theExpressions.end() ;
++i) {
if ((*i) == NULL) {
throw bioExceptNullPointer(__FILE__,__LINE__,"bioExpression") ;
}
if (i != theExpressions.begin()) {
str << ", " ;
}
str << (*i)->print(hp) ;
}
str << "]" ;
return str.str() ;
}
bioReal bioSeveralExpressions::getValue() {
std::stringstream str ;
str << "This function cannot be called for multiple expressions." ;
throw bioExceptions(__FILE__,__LINE__,str.str()) ;
}
std::vector<bioReal > bioSeveralExpressions::getValues() {
std::vector<bioReal > results ;
for (std::vector<bioExpression*>::iterator i = theExpressions.begin() ;
i != theExpressions.end() ;
++i) {
results.push_back((*i)->getValue()) ;
}
return results ;
}
const bioDerivatives* bioSeveralExpressions::getValueAndDerivatives(std::vector<bioUInt> literalIds,
bioBoolean gradient,
bioBoolean hessian) {
std::stringstream str ;
str << "This function cannot be called for multiple expressions." ;
throw bioExceptions(__FILE__,__LINE__,str.str()) ;
}
std::vector<const bioDerivatives*>
bioSeveralExpressions::getAllValueAndDerivatives(std::vector<bioUInt> literalIds,
bioBoolean gradient,
bioBoolean hessian) {
std::vector<const bioDerivatives* > results ;
for (std::vector<bioExpression*>::iterator i = theExpressions.begin() ;
i != theExpressions.end() ;
++i) {
results.push_back((*i)->getValueAndDerivatives(literalIds, gradient, hessian)) ;
}
return results ;
}