Module: QuantumVector

Includes:
ExceptionForQuantum
Included in:
Qubit, State
Defined in:
lib/quantum_ruby.rb

Overview

Contains helper functions for Qubit and State objects

Constant Summary collapse

PRECISION =
14

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



79
80
81
# File 'lib/quantum_ruby.rb', line 79

def ==(other)
  @vector.map { |i| i.round(PRECISION) } == other.vector.map { |i| i.round(PRECISION) }
end

#stateObject



83
84
85
86
87
88
89
90
# File 'lib/quantum_ruby.rb', line 83

def state
  out = '['
  out << @vector[0, 0].to_s
  @vector.drop(1).each do |i|
    out << "\n " << i.to_s
  end
  out << ']'
end