Commit 953a25eb authored by thomas.forbriger's avatar thomas.forbriger
Browse files

croposp [WP]: provide triples indexer

parent 99ad57c8
......@@ -644,7 +644,8 @@ int main(int iargc, char* argv[])
TFXX_assert(pairs.size()>2, "requires at least three input time series");
croposp::TNamedSeriesVector transfer_vector(pairs.triples());
croposp::Triples triples(pairs, true);
croposp::TNamedSeriesVector transfer_vector(triples.triples());
TFXX_assert(PSD_vector.size()==pairs.size(),
"inconsistency; report this as a bug");
......
......@@ -109,7 +109,8 @@ namespace croposp {
class Triples {
public:
Triples(const Pairs& p, const bool& pairs_first=false);
unsigned int operator()(const unsigned int& k,
unsigned int operator()(const unsigned int& i,
const unsigned int& k,
const unsigned int& l) const;
bool swap(const unsigned int& k,
const unsigned int& l) const;
......
......@@ -101,15 +101,6 @@ namespace croposp {
return(retval);
} // unsigned int Pairs::size() const
/* ---------------------------------------------------------------------- */
unsigned int Pairs::triples() const
{
TFXX_assert(this->size()>2, "size is too small to build triples");
unsigned int retval=(this->Mn*(this->Mn-1)*(this->Mn-2))/2;
return(retval);
} // unsigned int Pairs::triples() const
} // namespace croposp
/* ----- END OF pairs.cc ----- */
......@@ -47,14 +47,59 @@
namespace croposp {
Triples::Triples(const Pairs& p, const bool& pairs_first=false):
Triples::Triples(const Pairs& p, const bool& pairs_first):
Mpairs(p), Mpairs_first(pairs_first)
{
TFXX_assert(this->size()>2,
"collection must have at least three elements to make a triple");
}
} // Triples::Triples(const Pairs& p, const bool& pairs_first=false):
/* ---------------------------------------------------------------------- */
unsigned int Triples::operator()(const unsigned int& i,
const unsigned int& k,
const unsigned int& l) const
{
unsigned int retval=0;
TFXX_assert((i!=k) && (k!=l) && (l!=i),
"triple indices must be unique");
return(retval);
} // unsigned int Triples::operator()(const unsigned int& i,
// const unsigned int& k,
// const unsigned int& l) const
/* ---------------------------------------------------------------------- */
bool Triples::swap(const unsigned int& k,
const unsigned int& l) const
{
return(this->Mpairs.swap(k, l));
} // bool Triples::swap(const unsigned int& k,
// const unsigned int& l) const
/* ---------------------------------------------------------------------- */
unsigned int Triples::size() const
{
return(this->Mpairs.size());
} // unsigned int Triples::size() const
/* ---------------------------------------------------------------------- */
unsigned int Triples::pairs() const
{
return(this->Mpairs.pairs());
} // unsigned int Triples::pairs() const
/* ---------------------------------------------------------------------- */
unsigned int Triples::triples() const
{
unsigned int n=this->size();
unsigned int retval=n*(n-1)*(n-2)/2;
return(retval);
} // unsigned int Triples::triples() const
} // namespace croposp
/* ----- END OF triples.cc ----- */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment