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) {
185 i = container_type::insert(i,
value_type(
x, JMATH::getZero<ordinate_type>()));
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();
269 for (
iterator i = this->begin(); i != this->end(); ++i) {
270 *i = transformer(*i);
282 std::sort(this->begin(), this->end(),
compare);
294 return std::lower_bound(this->begin(), this->end(), x,
compare);
306 return std::lower_bound(this->begin(), this->end(), x,
compare);
320 if (i == this->end() || this->
getDistance(element.
getX(), i->getX()) > 0.0)
321 return pair_type(container_type::insert(i, element),
true);
334 configure(bounds, JMATH::getZero<ordinate_type>());
349 for (
iterator i = this->begin(); i != this->end(); ++i) {
364 template<
class JFunction1D_t>
366 const JFunction1D_t&
function)
368 using namespace JLANG;
372 for (
int i = 0; i != bounds.
getSize(); ++i) {
376 out->put(x,
function(x));
396 if (this->empty() || collection.empty()) {
407 if (
getDistance(p->getX(), q->getX()) > precision) {
411 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
413 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
417 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
420 for ( ; p != this->end() && q != collection.end(); ++p, ++q) {
421 if (fabs(
getDistance(p->getX(), q->getX())) > precision) {
438 for (
iterator i = this->begin(); i != this->end(); ++i) {
439 i->
getY() = -i->getY();
454 if (!collection.empty()) {
458 for (
const_iterator i = collection.begin(); i != collection.end(); ++i) {
459 this->
put(i->getX(), +i->getY());
469 if (
getDistance(p->getX(), q->getX()) > precision) {
473 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
475 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
479 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
484 for ( ; p != this->end() && i != collection.end(); ++p, ++i) {
485 p->
getY() += i->getY();
488 for ( ; i != collection.end(); ++i) {
489 this->
put(i->getX(), +i->getY());
492 for (i = collection.begin(); i != q; ++i) {
493 this->
put(i->getX(), +i->getY());
510 if (!collection.empty()) {
514 for (
const_iterator i = collection.begin(); i != collection.end(); ++i) {
515 this->
put(i->getX(), -i->getY());
525 if (
getDistance(p->getX(), q->getX()) > precision) {
529 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
531 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
535 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
540 for ( ; p != this->end() && i != collection.end(); ++p, ++i) {
541 p->
getY() -= i->getY();
544 for ( ; i != collection.end(); ++i) {
545 this->
put(i->getX(), -i->getY());
548 for (i = collection.begin(); i != q; ++i) {
549 this->
put(i->getX(), -i->getY());
554 throw JException(
"JCollection::add() collections incompatible.");
570 for (
iterator i = this->begin(); i != this->end(); ++i) {
586 for (
iterator i = this->begin(); i != this->end(); ++i) {
602 for (
iterator i = this->begin(); i != this->end(); ++i) {
618 for (
iterator i = this->begin(); i != this->end(); ++i) {
632 template<
class JFunction1D_t>
635 for (
iterator i = this->begin(); i != this->end(); ++i) {
636 i->
getY() +=
function(i->getX());
649 template<
class JFunction1D_t>
652 for (
iterator i = this->begin(); i != this->end(); ++i) {
653 i->
getY() -=
function(i->getX());
669 return collection.
add(value);
682 return collection.
sub(value);
693 template<
class JFunction1D_t>
696 return collection.
add(
function);
707 template<
class JFunction1D_t>
710 return collection.
sub(
function);
747 const int n = collection.size();
788 void resize(
typename container_type::size_type size)
790 container_type::resize(size);
809 template<
class JElement_t,
811 inline typename JElement_t::ordinate_type
821 output.
put(input.begin()->
getX(),
V);
823 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
825 V += 0.5 * input.
getDistance(i->getX(),
j->getX()) * (i->getY() +
j->getY());
827 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.
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
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.
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in