Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
content badge
swh:1:cnt:fbbf64ecf80d1b8ff5d3834940fbfb3df865f413

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
(requires biblatex-software package)
Generating citation ...
#include "Binding.hpp"
#include "algo.hpp"

namespace macrovsa {
  Binding::Binding(const Symbol& y, const Symbol& x, bool b, bool normalized) : Symbol("B_(" + y.getName() + (b ? "" : "~") + ")(" + x.getName() + ")", binding), y_(clone(y)), x_(clone(x)), b_(b), normalized_(normalized)
  {
    x_->setBelief(x_->getBelief().tau * y_->getBelief().tau, y_->getBelief().tau * x_->getBelief().sigma + x_->getBelief().tau * y_->getBelief().sigma);
    y_->setBelief(1, 0);
    setBelief(x_->getBelief().tau, algo::sigma_04 * fabs(x_->getBelief().tau) + x_->getBelief().sigma);
  }
  Binding::Binding(const Binding& symbol) : Binding(*symbol.y_, *symbol.x_, symbol.b_, symbol.normalized_)
  {}
  Binding::~Binding()
  {
    delete x_, delete y_;
  }
  void Binding::setBelief(double tau, double sigma)
  {
    Symbol::setBelief(tau, sigma);
    x_->setBelief(tau, sigma - algo::sigma_04 * fabs(x_->getBelief().tau));
  }
  bool Binding::equals(const Symbol& symbol, char what) const
  {
    if(symbol.getType() == binding) {
      const Binding& s = dynamic_cast < const Binding& > (symbol);
      return x_->equals(*s.x_, what) && y_->equals(*s.y_, what);
    }
    return false;
  }
  std::string Binding::asString() const
  {
    return ("B_(" + y_->asString() + (b_ ? "" : "~") + ")(" + x_->asString() + ")") + asStringTail();
  }
  void Binding::setVector(double *vector) const
  {
    static double dimension_sqrt_sqrt;
    // Indexes buffers {alpha|beta}[i] for binding {alpha|beta}[dimension + i] for unbinding
    static unsigned int *alpha = NULL, *beta = NULL, *sigma = NULL, current_dimension = -1;
    if(current_dimension != dimension) {
      dimension_sqrt_sqrt = sqrt(dimension_sqrt);
      delete[] alpha;
      delete[] beta;
      delete[] sigma;
      alpha = new unsigned int[dimension], beta = new unsigned int[dimension], sigma = new unsigned int[dimension];
      for(unsigned int i = 0; i < dimension; i++) {
        alpha[i] = dimension_sqrt * (i / dimension_sqrt);
        beta[i] = dimension_sqrt * (i % dimension_sqrt);
        sigma[i] = dimension_sqrt * (i % dimension_sqrt) + (i / dimension_sqrt);
      }
      current_dimension = dimension;
    }
    const double *x = x_->getVector(), *y = y_->getVector();
    for(unsigned int i = 0; i < dimension; i++) {
      vector[i] = 0;
      if(b_) {
        for(unsigned int j = 0; j < dimension_sqrt; j++) {
          vector[i] += y[j + beta[i]] * x[j + alpha[i]];
        }
      } else {
        for(unsigned int j = 0; j < dimension_sqrt; j++) {
          vector[i] += y[sigma[j + beta[i]]] * x[j + alpha[i]];
        }
      }
      vector[i] *= dimension_sqrt_sqrt;
    }
    if(normalized_) {
      double m = 0;
      for(unsigned int i = 0; i < dimension; i++) {
        m += vector[i] * vector[i];
      }
      if(m > 0) {
        m = sqrt(m);
        for(unsigned int i = 0; i < dimension; i++) {
          vector[i] /= m;
        }
      }
    }
  }
  double Binding::getComputationTIme()
   {
     return 0.048 + 0.28e-4 * pow(dimension, 1.35);
   }
}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API