vash
Fast genetic similarity estimation with hash tables
Loading...
Searching...
No Matches
BayesicSpace::SimilarityMatrix Class Reference

Similarity matrix. More...

#include <similarityMatrix.hpp>

Public Member Functions

 SimilarityMatrix () noexcept=default
 Default constructor.
 
 SimilarityMatrix (const SimilarityMatrix &toCopy)=default
 Copy constructor.
 
SimilarityMatrixoperator= (const SimilarityMatrix &toCopy)=default
 Copy assignment operator.
 
 SimilarityMatrix (SimilarityMatrix &&toMove) noexcept=default
 Move constructor.
 
SimilarityMatrixoperator= (SimilarityMatrix &&toMove) noexcept=default
 Move assignment operator.
 
 ~SimilarityMatrix ()=default
 Destructor.
 
size_t objectSize () const noexcept
 Object size in bytes.
 
size_t nElements () const noexcept
 Number of elements in the matrix.
 
void insert (const RowColIdx &rowColPair, const JaccardPair &jaccardCounts)
 Insert a value (updating the index)
 
void merge (SimilarityMatrix &toMerge)
 Merge two matrices.
 
void save (const std::string &outFileName, const size_t &nThreads, const std::string &locusNameFile="") const
 Save to file.
 

Static Public Member Functions

static size_t elementSize () noexcept
 Matrix element size.
 

Detailed Description

Similarity matrix.

A representation of a square symmetric similarity matrix, excluding the diagonal. Stores only the values present in the lower triangle by row. The representation is memory efficient if the matrix is sparse and attempts to strike a compromise between memory use and matrix manipulation speed.

Constructor & Destructor Documentation

◆ SimilarityMatrix() [1/2]

BayesicSpace::SimilarityMatrix::SimilarityMatrix ( const SimilarityMatrix & toCopy)
default

Copy constructor.

Parameters
[in]toCopyobject to copy

◆ SimilarityMatrix() [2/2]

BayesicSpace::SimilarityMatrix::SimilarityMatrix ( SimilarityMatrix && toMove)
defaultnoexcept

Move constructor.

Parameters
[in]toMoveobject to move

Member Function Documentation

◆ elementSize()

static size_t BayesicSpace::SimilarityMatrix::elementSize ( )
inlinestaticnoexcept

Matrix element size.

Returns
matrix element size in bytes

◆ insert()

void BayesicSpace::SimilarityMatrix::insert ( const RowColIdx & rowColPair,
const JaccardPair & jaccardCounts )

Insert a value (updating the index)

Inserts a new value into the matrix. Addresses the lower triangle of the similarity matrix, therefore the row index must be larger than the column index. If not, the values are swapped. If the indexes are equal or the row index is 0, throws an exception. Inserts a quantized value of the Jaccard similarity calculated from the intersection and union counts provided.

Parameters
[in]rowColPairrow and index pair
[in]jaccardCountsintersection and union counts for Jaccard similarity

◆ merge()

void BayesicSpace::SimilarityMatrix::merge ( SimilarityMatrix & toMerge)

Merge two matrices.

Merge a matrix with the current object, destroying the donor object. Duplicated indexes are discarded even if they differ in similarity values.

Parameters
[in]toMergeobject to merge

◆ nElements()

size_t BayesicSpace::SimilarityMatrix::nElements ( ) const
inlinenoexcept

Number of elements in the matrix.

Returns
number of elements

◆ objectSize()

size_t BayesicSpace::SimilarityMatrix::objectSize ( ) const
inlinenoexcept

Object size in bytes.

Returns
object size in bytes

◆ operator=() [1/2]

SimilarityMatrix & BayesicSpace::SimilarityMatrix::operator= ( const SimilarityMatrix & toCopy)
default

Copy assignment operator.

Parameters
[in]toCopyobject to copy
Returns
SimilarityMatrix object

◆ operator=() [2/2]

SimilarityMatrix & BayesicSpace::SimilarityMatrix::operator= ( SimilarityMatrix && toMove)
defaultnoexcept

Move assignment operator.

Parameters
[in]toMoveobject to move
Returns
SimilarityMatrix object

◆ save()

void BayesicSpace::SimilarityMatrix::save ( const std::string & outFileName,
const size_t & nThreads,
const std::string & locusNameFile = "" ) const

Save to file.

Uses multi-threaded data prep to speed up saving. If the output file already exists, appends to it.

Parameters
[in]outFileNameoutput file name
[in]nThreadsnumber of threads
[in]locusNameFilename of the file with locus names (empty by default)

The documentation for this class was generated from the following file: