Documentation ¶
Overview ¶
Package vector contains binary vector abstractions.
Index ¶
- Constants
- type Vector
- func (v *Vector) And(u, w *Vector) *Vector
- func (v *Vector) Bits() []byte
- func (v *Vector) Cmp(u *Vector) int
- func (v *Vector) Concatenate(u, w *Vector) *Vector
- func (v *Vector) Get(i uint) byte
- func (v *Vector) Iter() <-chan byte
- func (v *Vector) LaTeXString() string
- func (v *Vector) Len() uint
- func (v *Vector) Not(u *Vector) *Vector
- func (v *Vector) Or(u, w *Vector) *Vector
- func (v *Vector) Parse(s string) (*Vector, error)
- func (v *Vector) PrettyString() string
- func (v *Vector) Resize(w *Vector, r int) *Vector
- func (v *Vector) RotateLeft(w *Vector, r uint) *Vector
- func (v *Vector) RotateRight(w *Vector, r uint) *Vector
- func (v *Vector) SetBit(w *Vector, i uint, b byte) *Vector
- func (v *Vector) SetBitArray(array []byte) *Vector
- func (v *Vector) SetBytes(b []byte, n uint) *Vector
- func (v *Vector) SetRandom(n uint) *Vector
- func (v *Vector) SetSupport(n uint, sup []uint) *Vector
- func (v *Vector) SetUnits(n uint) *Vector
- func (v *Vector) SetV(u *Vector) *Vector
- func (v *Vector) SetZero(n uint) *Vector
- func (v *Vector) ShiftLeft(w *Vector, r uint) *Vector
- func (v *Vector) ShiftRight(w *Vector, r uint) *Vector
- func (v *Vector) String() string
- func (v *Vector) Support() []uint
- func (v *Vector) Wt() uint
- func (v *Vector) Xor(u, w *Vector) *Vector
- func (v *Vector) Zeros() []uint
Constants ¶
const MaxInteger = ^word(0)
const WordSize = uint(unsafe.Sizeof(word(0))) << 3
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Vector ¶
type Vector struct {
// contains filtered or unexported fields
}
Vector represents binary vector This type is immutable
func (*Vector) Cmp ¶
Cmp compares vector v and vector u and returns -1 if v < u
0 if v == u 1 if v > u
v < u if len(u) > len(v) or len(u)==len(v) and for some i holds v[0]=u[0],..., v[i-1]=u[i-1], v[i] < u[i] For example,
10 < 000110 000010 < 000110
func (*Vector) Concatenate ¶
Concatenate sets v to concatenation of u and w and returns v
func (*Vector) LaTeXString ¶
LaTeXString returns string of vector representation to use in LaTeX matrix environment Example: 0101011 -> 0&1&0&1&0&1&1
func (*Vector) Parse ¶
Parse converts string to Vector and sets v to result, returns v Function supports the following filler for zero symbol:
"0" == "0", "-", "*"
Example:
"--110-1- - - 1- * 11 0 " -> 0011001000100110
func (*Vector) PrettyString ¶
PrettyString returns pretty formatted string of vector representation Example: 0101011 -> -1-1-11
func (*Vector) RotateLeft ¶
RotateLeft cyclical shifts vector w for r position left and sets vector v to shifted w, returns v That's it v = w rotl r
func (*Vector) RotateRight ¶
RotateRight cyclical shifts vector w for r position right and sets vector v to shifted w, returns v That's it v = w rotr r
func (*Vector) SetBit ¶
SetBit sets v to vector w with change coordinate i by bit b % 2 m = w[i] <- b%2
func (*Vector) SetBitArray ¶
SetBitArray converts bit array to Vector and sets v to the result
func (*Vector) SetBytes ¶
SetBytes packs byte array b into the vector of length n and sets v to that new vector
Examples: SetBytes([]byte{0x01, 0x02, 0x03}, 24) -> 000000010000001000000011 SetBytes([]byte{0x01, 0x02, 0x03}, 11) -> 00000001000 SetBytes([]byte{0x01, 0x02, 0x03}, 30) -> 000000010000001000000011000000 SetBytes([]byte{}, 3) -> 000
func (*Vector) SetSupport ¶
SetSupport sets v to vector with units from the support array Example:
v.SetSupport(10, []int{0, 1, 5, 9}) -> 1100010001
func (*Vector) ShiftLeft ¶
ShiftLeft shifts vector w for r position left and sets vector v to shifted w, returns v That's it v = w << r
func (*Vector) ShiftRight ¶
ShiftRight shifts vector w for r position right and sets vector v to shifted w, returns v That's it v = w >> r