1 #ifndef __JTOOLS__JCOLLECTION__
2 #define __JTOOLS__JCOLLECTION__
27 namespace JPP {
using namespace JTOOLS; }
72 template<
class JElement_t,
class JDistance_t = JDistance<
typename JElement_t::abscissa_type> >
76 typename JElement_t::ordinate_type>,
78 public JMath< JCollection<JElement_t, JDistance_t> >
93 typedef typename container_type::iterator
iterator;
114 const JElement_t& second)
const
116 return this->
getDistance(first.getX(), second.getX()) > 0.0;
152 container_type::clear();
166 if (i == this->end() || this->
getDistance(x, i->getX()) > distance_type::precision) {
184 if (i == this->end() || this->
getDistance(x, i->getX()) > distance_type::precision) {
199 return (
int) this->size();
211 return this->at(index).getX();
222 return this->begin()->getX();
233 return this->rbegin()->getX();
246 return this->at(index).getY();
258 return this->at(index).getY();
274 this->
insert(transformer(*i));
284 std::sort(this->begin(), this->end(),
compare);
296 return std::lower_bound(this->begin(), this->end(), x,
compare);
308 return std::lower_bound(this->begin(), this->end(), x,
compare);
322 if (i == this->end() || this->
getDistance(element.
getX(), i->getX()) > 0.0)
323 return pair_type(container_type::insert(i, element),
true);
336 configure(bounds, JMATH::getZero<ordinate_type>());
351 for (
iterator i = this->begin(); i != this->end(); ++i) {
366 template<
class JFunction1D_t>
368 const JFunction1D_t&
function)
370 using namespace JLANG;
374 for (
int i = 0; i != bounds.
getSize(); ++i) {
378 out->put(x,
function(x));
398 if (this->empty() || collection.empty()) {
409 if (
getDistance(p->getX(), q->getX()) > precision) {
413 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
415 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
419 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
422 for ( ; p != this->end() && q != collection.end(); ++p, ++q) {
423 if (fabs(
getDistance(p->getX(), q->getX())) > precision) {
440 for (
iterator i = this->begin(); i != this->end(); ++i) {
441 i->
getY() = -i->getY();
456 if (!collection.empty()) {
460 for (
const_iterator i = collection.begin(); i != collection.end(); ++i) {
461 this->
put(i->getX(), +i->getY());
471 if (
getDistance(p->getX(), q->getX()) > precision) {
475 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
477 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
481 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
486 for ( ; p != this->end() && i != collection.end(); ++p, ++i) {
487 p->
getY() += i->getY();
490 for ( ; i != collection.end(); ++i) {
491 this->
put(i->getX(), +i->getY());
494 for (i = collection.begin(); i != q; ++i) {
495 this->
put(i->getX(), +i->getY());
512 if (!collection.empty()) {
516 for (
const_iterator i = collection.begin(); i != collection.end(); ++i) {
517 this->
put(i->getX(), -i->getY());
527 if (
getDistance(p->getX(), q->getX()) > precision) {
531 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
533 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
537 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
542 for ( ; p != this->end() && i != collection.end(); ++p, ++i) {
543 p->
getY() -= i->getY();
546 for ( ; i != collection.end(); ++i) {
547 this->
put(i->getX(), -i->getY());
550 for (i = collection.begin(); i != q; ++i) {
551 this->
put(i->getX(), -i->getY());
556 throw JException(
"JCollection::add() collections incompatible.");
572 for (
iterator i = this->begin(); i != this->end(); ++i) {
588 for (
iterator i = this->begin(); i != this->end(); ++i) {
604 for (
iterator i = this->begin(); i != this->end(); ++i) {
620 for (
iterator i = this->begin(); i != this->end(); ++i) {
634 template<
class JFunction1D_t>
637 for (
iterator i = this->begin(); i != this->end(); ++i) {
638 i->
getY() +=
function(i->getX());
651 template<
class JFunction1D_t>
654 for (
iterator i = this->begin(); i != this->end(); ++i) {
655 i->
getY() -=
function(i->getX());
671 return collection.
add(value);
684 return collection.
sub(value);
695 template<
class JFunction1D_t>
698 return collection.
add(
function);
709 template<
class JFunction1D_t>
712 return collection.
sub(
function);
748 const int n = collection.size();
789 void resize(
typename container_type::size_type size)
791 container_type::resize(size);
810 template<
class JElement_t,
812 inline typename JElement_t::ordinate_type
822 output.
put(input.begin()->
getX(), V);
824 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
826 V += 0.5 * input.
getDistance(i->getX(),
j->getX()) * (i->getY() +
j->getY());
828 output.
put(
j->getX(), V);
Interface for binary output.
Auxiliary base class for aritmetic operations of derived class types.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
static const JZero zero
Function object to assign zero value.
Definition of zero value for any class.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
bool is_identical(JFirst_t &first, JSecond_t &second)
Check if two objects are indentical.
JArgument< T >::argument_type argument_type
Template definition of auxiliary class to compare objects.
Interface for binary input.
Template for generic class types.
alias put_queue eval echo n
Base class for data structures with artithmetic capabilities.
Exception for accessing a value in a collection that is outside of its range.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in