Binary vectors

From diagham
Jump to navigation Jump to search

DiagHam stores vectors in binary mode. A full set of tools is provided in to manipulate them.

Tools

GenericOverlap
compute overlaps between binary vectors
NormalizeVector
normalize a binary vector
VectorBinary2Ascii
convert from a binary vector to a text file
VectorAscii2Binary
convert from a column formated text file to a binary file
CountingZero
count the number of zero components in a binary vector
BuildSuperPosition
create a linear superposition of binary vectors
ExtractLinearlyIndependentVectors
extract a set of linearly independent vectors from a given set of vectors
VectorPhaseMultiply
multiply a binary vector with a complex phase factor
DiffBinaryVectors
compares two binary vectors


File Format

   import numpy as np
   import os
   
   InputFile = open('test.vec','rb')
   
   Dimension = np.fromfile(InputFile, '<i4', count=1)[0]
   print ('Vector Dimension = '+str(Dimension))
      
   Vector = np.fromfile(InputFile, '<d', count=Dimension)
   Norm = 0.0
   for Component in Vector:
       Norm += Component * Component
   
   print ('Sqr Norm = '+str(Norm))
   InputFile.close()