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

  • 03eed85
  • /
  • include
  • /
  • ntcard.hpp
Raw File Download
Permalinks

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
  • directory
content badge Iframe embedding
swh:1:cnt:c8923864f29f323ea46a5cbf572a54e44855b025
directory badge Iframe embedding
swh:1:dir:dd96c551e21cb1cd1467f1639a4475c9402b3350
Citations

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
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
ntcard.hpp
#ifndef NTCARD_NTCARD_HPP
#define NTCARD_NTCARD_HPP

#include <string>
#include <vector>

namespace ntcard {

using counter_t = uint16_t;

class NtCard
{
  private:
	unsigned kmer_size;
	unsigned left_bits, right_bits;
	counter_t* t_counter;
	size_t r_buck;
	unsigned left_mask;
	double mean_f0;
	double* mean_f;

	void update_estimations();

  protected:
	size_t total;

	void update_counts(uint64_t hash_value);

  public:
	explicit NtCard(
	    const unsigned kmer_size,
	    const unsigned left_bits = 11,
	    const unsigned right_bits = 27)
	  : kmer_size(kmer_size)
	  , left_bits(left_bits)
	  , right_bits(right_bits)
	  , total(0)
	  , r_buck(((size_t)1) << right_bits)
	  , left_mask((((size_t)1) << (left_bits - 1)) - 1)
	  , mean_f0(0.0)
	  , mean_f(new double[1 << sizeof(counter_t) * 8])
	{
		t_counter = new counter_t[r_buck]();
	}

	virtual void process(const std::string& seq);

	std::vector<size_t> get_histogram(unsigned max_coverage);
};

class SeedNtCard : public NtCard
{
  private:
	std::string seed;

  public:
	explicit SeedNtCard(
	    const std::string& seed,
	    const unsigned left_bits = 7,
	    const unsigned right_bits = 27)
	  : NtCard(seed.size(), left_bits, right_bits)
	  , seed(seed)
	{
	}

	void process(const std::string& seq) override;
};

}

#endif // NTCARD_NTCARD_HPP

back to top

Software Heritage — Copyright (C) 2015–2025, 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— Contact— JavaScript license information— Web API