2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
4 #include "bbstdMathOperation.h"
5 #include "bbstdPackage.h"
14 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MathOperation)
15 BBTK_BLACK_BOX_IMPLEMENTATION(MathOperation,bbtk::AtomicBlackBox);
17 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
19 void MathOperation::Process()
22 // THE MAIN PROCESSING METHOD BODY
23 // Here we simply set the input 'In' value to the output 'Out'
24 // And print out the output value
25 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
26 // void bbSet{Input|Output}NAME(const TYPE&)
27 // const TYPE& bbGet{Input|Output}NAME() const
29 // * NAME is the name of the input/output
30 // (the one provided in the attribute 'name' of the tag 'input')
31 // * TYPE is the C++ type of the input/output
32 // (the one provided in the attribute 'type' of the tag 'input')
38 /* initialize random seed: */
40 if (bbGetInputType()==7) acum=bbGetInputIn1();
43 if (bbGetInputType()==0) bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() );
44 if (bbGetInputType()==1) bbSetOutputOut( bbGetInputIn1() - bbGetInputIn2() );
45 if (bbGetInputType()==2) bbSetOutputOut( bbGetInputIn1() * bbGetInputIn2() );
47 if (bbGetInputType()==3)
49 if (bbGetInputIn2()!=0) bbSetOutputOut( bbGetInputIn1() / bbGetInputIn2() );
50 else bbSetOutputOut( 99999999 );
53 if (bbGetInputType()==4) bbSetOutputOut( sqrt( bbGetInputIn1() ) );
55 if (bbGetInputType()==5)
57 if (bbGetInputIn2()>0) bbSetOutputOut( log( bbGetInputIn1() ) );
58 else bbSetOutputOut( -99999999 );
61 if (bbGetInputType()==6) bbSetOutputOut( exp( bbGetInputIn1() ) );
63 if (bbGetInputType()==7)
65 bbSetOutputOut( acum );
67 if (acum>bbGetInputIn2()) acum=bbGetInputIn1();
69 if (bbGetInputType()==8) bbSetOutputOut( rand() % (int) (bbGetInputIn2()-bbGetInputIn1()) + bbGetInputIn1() );
70 if (bbGetInputType()==9) bbSetOutputOut( sin( bbGetInputIn1() ) );
71 if (bbGetInputType()==10) bbSetOutputOut( cos( bbGetInputIn1() ) );
72 if (bbGetInputType()==11) bbSetOutputOut( tan( bbGetInputIn1() ) );
73 if (bbGetInputType()==12) bbSetOutputOut( asin( bbGetInputIn1() ) );
74 if (bbGetInputType()==13) bbSetOutputOut( acos( bbGetInputIn1() ) );
75 if (bbGetInputType()==14) bbSetOutputOut( atan( bbGetInputIn1() ) );
76 if (bbGetInputType()==15) bbSetOutputOut( atan2( bbGetInputIn1(),bbGetInputIn2() ) );
79 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
81 void MathOperation::bbUserSetDefaultValues()
84 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
85 // Here we initialize the input 'In' to 0
94 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
96 void MathOperation::bbUserInitializeProcessing()
99 // THE INITIALIZATION METHOD BODY :
101 // but this is where you should allocate the internal/output pointers
107 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
109 void MathOperation::bbUserFinalizeProcessing()
112 // THE FINALIZATION METHOD BODY :
114 // but this is where you should desallocate the internal/output pointers
119 // EO namespace bbstd