X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fstd%2Fsrc%2FbbstdMathOperation.cxx;h=fdedc101c8e7997c6978e0a25f7193d024df4e3a;hb=433d792763e9cebb963243fbd49fff719f69ed4a;hp=be243d7d09b54bd7801a8eadfe4a47825f8b51df;hpb=12f2166f201f4e5a99c9c7876dadd09da81bfb51;p=bbtk.git diff --git a/packages/std/src/bbstdMathOperation.cxx b/packages/std/src/bbstdMathOperation.cxx index be243d7..fdedc10 100644 --- a/packages/std/src/bbstdMathOperation.cxx +++ b/packages/std/src/bbstdMathOperation.cxx @@ -11,6 +11,7 @@ namespace bbstd { + BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MathOperation) BBTK_BLACK_BOX_IMPLEMENTATION(MathOperation,bbtk::AtomicBlackBox); //===== @@ -36,17 +37,20 @@ void MathOperation::Process() { firsttime=false; /* initialize random seed: */ - srand (time(NULL)); + srand (time(NULL)); if (bbGetInputType()==7) acum=bbGetInputIn1(); } - if (bbGetInputType()==0) bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() ); + if (bbGetInputType()==0) + { + bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() ); + } if (bbGetInputType()==1) bbSetOutputOut( bbGetInputIn1() - bbGetInputIn2() ); if (bbGetInputType()==2) bbSetOutputOut( bbGetInputIn1() * bbGetInputIn2() ); if (bbGetInputType()==3) { - if (bbGetInputIn2()!=0) bbSetOutputOut( bbGetInputIn1() / bbGetInputIn2() ); + if (bbGetInputIn2()!=0) bbSetOutputOut( bbGetInputIn1() / bbGetInputIn2() ); else bbSetOutputOut( 99999999 ); } @@ -54,7 +58,7 @@ void MathOperation::Process() if (bbGetInputType()==5) { - if (bbGetInputIn2()>0) bbSetOutputOut( log( bbGetInputIn1() ) ); + if (bbGetInputIn1()>0) bbSetOutputOut( log( bbGetInputIn1() ) ); else bbSetOutputOut( -99999999 ); } @@ -62,18 +66,25 @@ void MathOperation::Process() if (bbGetInputType()==7) { - bbSetOutputOut( acum ); - acum++; - if (acum>bbGetInputIn2()) acum=bbGetInputIn1(); + if ( back_acum_In1!=bbGetInputIn1() ) acum=bbGetInputIn1(); + if (acumbbGetInputIn2()) acum=bbGetInputIn1(); + back_acum_In1=bbGetInputIn1(); } - if (bbGetInputType()==8) bbSetOutputOut( rand() % (int) (bbGetInputIn2()-bbGetInputIn1()) + bbGetInputIn1() ); - if (bbGetInputType()==9) bbSetOutputOut( sin( bbGetInputIn1() ) ); + if (bbGetInputType()==8 ) bbSetOutputOut( rand() % (int) (bbGetInputIn2()-bbGetInputIn1()) + bbGetInputIn1() ); + if (bbGetInputType()==9 ) bbSetOutputOut( sin( bbGetInputIn1() ) ); if (bbGetInputType()==10) bbSetOutputOut( cos( bbGetInputIn1() ) ); if (bbGetInputType()==11) bbSetOutputOut( tan( bbGetInputIn1() ) ); if (bbGetInputType()==12) bbSetOutputOut( asin( bbGetInputIn1() ) ); if (bbGetInputType()==13) bbSetOutputOut( acos( bbGetInputIn1() ) ); if (bbGetInputType()==14) bbSetOutputOut( atan( bbGetInputIn1() ) ); if (bbGetInputType()==15) bbSetOutputOut( atan2( bbGetInputIn1(),bbGetInputIn2() ) ); + if (bbGetInputType()==16) bbSetOutputOut( std::min( bbGetInputIn1(),bbGetInputIn2() ) ); + if (bbGetInputType()==17) bbSetOutputOut( std::max( bbGetInputIn1(),bbGetInputIn2() ) ); + if (bbGetInputType()==18) bbSetOutputOut( fabs( bbGetInputIn1() ) ); + if (bbGetInputType()==19) bbSetOutputOut( (int)bbGetInputIn1() % (int)bbGetInputIn2() ); } //===== // 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) @@ -90,6 +101,7 @@ void MathOperation::bbUserSetDefaultValues() firsttime=true; acum=0; } + //===== // 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) //===== @@ -100,22 +112,19 @@ void MathOperation::bbUserInitializeProcessing() // Here does nothing // but this is where you should allocate the internal/output pointers // if any - - } + //===== // 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) //===== void MathOperation::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers -// if any - -} +// if any } -// EO namespace bbstd + +}// EO namespace bbstd