1 #ifndef __JTOOLS__JCOLLECTION__
2 #define __JTOOLS__JCOLLECTION__
27 namespace JPP {
using namespace JTOOLS; }
71 template<
class JElement_t,
class JDistance_t = JDistance<
typename JElement_t::abscissa_type> >
75 typename JElement_t::ordinate_type>,
77 public JMATH::JMath< JCollection<JElement_t, JDistance_t> >
92 typedef typename container_type::iterator
iterator;
113 const JElement_t& second)
const
115 return this->
getDistance(first.getX(), second.getX()) > 0.0;
151 container_type::clear();
165 if (i == this->end() || this->
getDistance(x, i->getX()) > distance_type::precision) {
183 if (i == this->end() || this->
getDistance(x, i->getX()) > distance_type::precision) {
198 return (
int) this->size();
210 return this->at(index).getX();
221 return this->begin()->getX();
232 return this->rbegin()->getX();
245 return this->at(index).getY();
257 return this->at(index).getY();
273 this->
insert(transformer(*i));
283 std::sort(this->begin(), this->end(),
compare);
295 return std::lower_bound(this->begin(), this->end(), x,
compare);
307 return std::lower_bound(this->begin(), this->end(), x,
compare);
321 if (i == this->end() || this->
getDistance(element.
getX(), i->getX()) > 0.0)
322 return pair_type(container_type::insert(i, element),
true);
335 configure(bounds, JMATH::getZero<ordinate_type>());
350 for (
iterator i = this->begin(); i != this->end(); ++i) {
365 template<
class JFunction1D_t>
367 const JFunction1D_t&
function)
369 using namespace JLANG;
373 for (
int i = 0; i != bounds.
getSize(); ++i) {
377 out->put(x,
function(x));
397 if (this->empty() || collection.empty()) {
408 if (
getDistance(p->getX(), q->getX()) > precision) {
412 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
414 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
418 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
421 for ( ; p != this->end() && q != collection.end(); ++p, ++q) {
422 if (fabs(
getDistance(p->getX(), q->getX())) > precision) {
439 for (
iterator i = this->begin(); i != this->end(); ++i) {
440 i->
getY() = -i->getY();
455 if (!collection.empty()) {
459 for (
const_iterator i = collection.begin(); i != collection.end(); ++i) {
460 this->
put(i->getX(), +i->getY());
470 if (
getDistance(p->getX(), q->getX()) > precision) {
474 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
476 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
480 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
485 for ( ; p != this->end() && i != collection.end(); ++p, ++i) {
486 p->
getY() += i->getY();
489 for ( ; i != collection.end(); ++i) {
490 this->
put(i->getX(), +i->getY());
493 for (i = collection.begin(); i != q; ++i) {
494 this->
put(i->getX(), +i->getY());
511 if (!collection.empty()) {
515 for (
const_iterator i = collection.begin(); i != collection.end(); ++i) {
516 this->
put(i->getX(), -i->getY());
526 if (
getDistance(p->getX(), q->getX()) > precision) {
530 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
532 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
536 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
541 for ( ; p != this->end() && i != collection.end(); ++p, ++i) {
542 p->
getY() -= i->getY();
545 for ( ; i != collection.end(); ++i) {
546 this->
put(i->getX(), -i->getY());
549 for (i = collection.begin(); i != q; ++i) {
550 this->
put(i->getX(), -i->getY());
555 throw JException(
"JCollection::add() collections incompatible.");
571 for (
iterator i = this->begin(); i != this->end(); ++i) {
587 for (
iterator i = this->begin(); i != this->end(); ++i) {
603 for (
iterator i = this->begin(); i != this->end(); ++i) {
619 for (
iterator i = this->begin(); i != this->end(); ++i) {
633 template<
class JFunction1D_t>
636 for (
iterator i = this->begin(); i != this->end(); ++i) {
637 i->
getY() +=
function(i->getX());
650 template<
class JFunction1D_t>
653 for (
iterator i = this->begin(); i != this->end(); ++i) {
654 i->
getY() -=
function(i->getX());
670 return collection.
add(value);
683 return collection.
sub(value);
694 template<
class JFunction1D_t>
697 return collection.
add(
function);
708 template<
class JFunction1D_t>
711 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.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
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.