/* *********************************************************************
   | The Q language - A C++ extension for programming quantum machines |
   | Copyright (C) 2000 2001 2002 2003 Stefano Bettelli                |
   | <bettelli@irsamc.ups-tlse.fr>                                     |
   | See the COPYING and LICENSE files for license terms.              |
   ********************************************************************* */

History of changes:

- Oct 30 2003 --> ver 0.7.2
  Stefano Bettelli
  News: this is a special release dedicated to modifications due to the
    comments and suggestions of Chris Lomont about portable C++ (thanks!)
    They were needed to get the library to compile under Microsoft VC++.NET
    2003. Porting it to VC++ 6.0 involves apparently a lot of work.
  Changed all local headers to proper form, that is, replaced #include <*>
    with #include "*". Consequently, the option -I. for inclusion of local
    headers as system headers in the Makefile is no more necessary (removed).
  Removed an extra qualification `big_int::' in qntlib_bigint.h on
    member `mantissa_of_multiplication_by'.
  Modified the second call to "ldexp" in qop_phase_like.cc; the first
    argument is now explicitely cast from mantissa_type to floating_type.
  Changed some arrays into STL vectors (indeed, built-in array types need
    to have their length specified at compile time, so we cannot use 
    variables to specify the dimension, although some compilers allow for
    it). The changes were made in qop_slicelist.cc, qop_builders.cc and
    qinterface_runev.cc.
  Removed a cast of a long to a bool in qbitset.h. Instead, the result of
    the AND is explicitely compared with the value 0.
  Reworked the way mathematical constants are used in the library. It was
    pointed out that there is no portable way to refer to math constants,
    because they are not part of the C++ standard (for instance M_PI is
    ok with g++, requires #define _USE_MATH_DEFINES before the inclusion
    of cmath in VC++.NET, and is undefined for other compilers). The math
    functions like sqrt(), acos() etc... are however part of the standard,
    even in long double precision, and can be used to precalculate the 
    values of the constants. The affected files are test.cc, qsimulator.cc
    and qntlib_bigint.cc
  Replaced the random number initialisation in qsimulator.cc. It was
    reading from /dev/urandom. It now uses the product of the current
    time (in seconds) and of the process ID. This is not very random but
    it is surely POSIX. The whole random generation should be revised though.
  Fixed two warnings about unused arguments in qsummary.cc and qop_slice.h.
  Replaced all the C-style casts with the "new" static_cast<>() syntax.
    Changes were necessary in qsummary.cc, qlist.cc, qop_slicelist.cc,
    qbitset.cc, qregister.cc, qoperator.cc, qop_phase_like.h, qop_phase_like.h,
    qmanager_inlines.h, qinterface_runev.cc, qsimulator.cc, qntlib_bigint.cc.
  Added "-pedantic -std=c++98 -W -Wold-style-cast" to g++ warning options.
    These trigger for instance the variable-size array problem, the extra
    qualification, some unused arguments and the C-style casts.
  Modified poll_feedback in qinterface.cc so that the whole body is ifdef'd,
    depending on the symbol QINTERFACE_USES_PTHREADS. Indeed, this function
    is necessary only in the threaded implementation (in a serial
    implementation, the feedback channel must be filled at this point,
    otherwise there is a problem). Implementations not providing sched_yield
    (which belongs to the POSIX 1003.1b-1993, aka POSIX.4, standard) can
    avoid the problem just by undefining QINTERFACE_USES_PTHREADS. It seems
    that VC++.NET 2003 does not support sched_yield.

- Oct 27 2003 --> ver 0.7.1
  Stefano Bettelli
  News: the paper on the language (cs.PL/0103009 v3) was published as
   refereed article in the European Physical Journal! Full reference:
   Eur. Phys. J. D, Vol. 25, No. 2, pp. 181-200 (2003)
  Tested against g++-3.3.2 on a Debian "testing" system.
  Removed warnings "-Wtraditional", "-Wmissing-declarations" and
   "-Wnested-externs" because the compiler claims that they are
   valid for C/ObjC but not for C++.
  Removed a bug in the measurement section of qinterface_runev.cc. The
   variable bit_index must be updated every time a new qubit is measured.
   When this routine was only a fake, I updated it after every segment.
   So, it is the inner loop which must change it, not the outer one!
   (thanks to Chris Lomont for pointing my attention to this bug)
  Eliminated a ridicoulous check in Qsimulator::set_numqubits, which
   is already forced by the integer type of the argument.
  Added a reset method to the simulator, which recreates the |0> state.
   This is a perfect reset, it removes all the past memory.
  Changed the way the toy simulator handles "noisy gates": the Hadamard
   gate has now a tilt which is one half of what it was before. This
   uniformates the "error weight" for one-qubit gates. You can find more
   informations about this as well as a more detailed description of the
   "noisy gates" implementation and of the algorithm for polynomial maps
   in an article which I recently posted in the arXiv: quant-ph/0310152
   (get it at http://arxiv.org/abs/quant-ph/0310152).
  Added "static errors" to the simulator (for an idea of what they are
   and which are their effects on a quantum computation, have a look at
   Phys. Rev. Lett. 87, 227901 (2001), available as quant-ph/0107036).
   There is now a unified interface to "imperfections", the method
   Qsimulator::set_noise, whose arguments are 1) the noise intensity for
   noisy gates, 2) the maximum of the modulus of the Zeeman coefficients
   and 3) of the coupling coefficients for the natural Hamiltonian.
  Removed from test.cc that old piece of code from the period when I was
   writing the qubit address manager (it showed the content after some
   manipulations). However, the simulator was not available at that time
   and I simply wrote the bytecode to the screen. Now, in order to run
   it would need a quantum memory with ~ 10^2 qubits, which is not viable.
	
- Apr 09 2003 --> ver 0.7.0
  Stefano Bettelli
  Added a toy quantum simulator to the package. This allows for the 
   simulation of the low level primitive gates that we have chosen
   and also provides some limited physical noise. The inclusion of
   this simulator gives a realistic example of how to attach a generic
   simulator to the quantum library, but it is in no way to be intended
   as the de facto or preferred simulator for this library. Credits to
   Alexei Chepelianskii for a previous simulator from which I got
   inspiration for the development of the included code (have a look
   at the beginning of qsimulator.h).
  Moved the method Qinterface::run_evolution to a different file
   (qinterface_runev.cc). This makes it easy to replace this method
   if someone wants to introduce a new simulator. Also, the routine
   was changed to access the simulator instead of just printing the
   bytecode stream to standard output.
  Added Qubit_list::operator[] which accepts an index in a qubit list
   and returns the corresponding element (type = Qubit_list::address).
   This is needed to use proficiently the "locate" command.
  Modified the "test" program, which now implements a streamlined version
   of an algorithm which reproduces the oscillation shown in quant-ph/0202113
  My g++-2.95.4 issues a warning for a redundant declaration of "hypot"
   in the include chain of <complex>, but the compilation is fine.
  Now using a more generic "CXX=g++" in the Makefile.

- Mar 31 2003 --> ver 0.6.8
  Stefano Bettelli
  Introduced an auxiliary class for integers with an arbitrary number of
   digits. The basic elementary operations are implemented, as well as
   the comparison operators. The class is not optimised for speed, but
   it should be anyway sufficiently fast for integers up to some hundreds
   of digits. The integers are internally stored as sequences of "basic_int"
   objects, and are to be interpreted as unlimited binary sequences. If n
   is the average lenght of the operands, then addition and subtraction
   scale as n, multiplication as n^2 and division as n^3. I don't plan to
   develop this class further unless new needs arise for the quantum library.
   The relevant files are qntlib_bigint.h and qntlib_bigint.cc
  Used the big_int class for the bignumber data type of qntlib_expower.
   This allows us to forget about all the problems in determining the
   integer multiplicator of the phase coefficient. A method in the big_int
   class (mantissa_of_multiplication_by) also solves the problem of the
   multiplication times a double. All the *_with_check inline routines in
   qntlib_expower are gone, as well as the relevant exceptions. The
   qntlib_expower* files were affected by this change.

- Feb 27 2003 --> ver 0.6.7
  Stefano Bettelli
  Replaced all the occurrencies of the term "swap" with "invert" when
   it concerns a Qop permutation (the term for the qubit permutation
   in a register and for the QSwap primitive is left unchanged),
   according to the suggestion of a referee of our paper. The concerned
   files are: qlist.h, qoperator.h, qoperator_inlines.h, qop_slice.h,
   qop_slice_inlines.h, qop_slicelist.h, qop_slicelist_inl.h, qlist.cc.
  Modified the Qop_phase_like class so that it throws an exception of
   type angle_underflow (and not invalid_angle) when the angle cannot
   be encoded as different from zero. Also modified the routine expower
   in the quantum library so that it prints a warning instead of
   aborting when faced with the same problem.
  Update to "Copyright (C) 2000 2001 2002 2003 Stefano Bettelli"
  Checked (on Qubit_list::get_subrange(5 arguments)) that the return
   value optimisation works as expected at least with g++-3.2.
  Reworked Qubit_list::run_translation (the deep engine for formal to
   real address translation) into Qubit_list::extract, a more general
   routine which extracts a sublist of the current list given two of
   its elements and the segments where they can be found. Indeed, the
   routine did not need to be so specific! I hope it is now more efficient.
  Reworked Qubit_list::translate_map and translate_nomap, so that they
   now share the common code in Qubit_list::translate_segment. Also
   added a list minimisation at the end of translate_nomap. Also, those
   methods which really do not use a map were moved to qlist.cc.
  Changed Qop_slicelist::size into Qop_slicelist::get_size.	
  Qop_slicelist::set_ancillae() is now private (because it is dangerous)
  Completely revised the Qop ctor for controlled operator and the related
   method Qop_slicelist::controlled (most of the work has been moved to
   the second method). The result is still unsatisfactory though. The
   "controlled" method should be revised again, and writing it correctly
   is in some sense linked to the problem of pseudoclassical operators.
  Renamed Qinterface_base::modify_permutation() to submit_permutation()
   and Qop_slice::modify_permutation() to classical_permutation().
  Generalised the second channel of a quantum interface to be a feedback
   channel, not just a measurement result channel. Many cosmetic changes
   in Qinterface_base and in Qinterface. Simplified the call tree of
   get_measurement result (merged with Qinterface::read_measurement).
   Introduced a private method for the blocking polling of the this
   feedback channel.
  Written a generalised Qinterface_base::submit_request which defines
   the communication protocol. All the other public submit_* methods
   which imply an interaction with the quantum device in Qinterface_base
   should be wrappers around this method.
  Introduced the operation type OPTYPE_DEVICE (for controlling the quantum
   device driver), the operation code OPCODE_LOCATE (for locating some
   physical qubits on the quantum device) in qop_codes.h. The methods
   submit_locate_request and get_locate_result in Qinterface_base for
   accessing this capability and its interface locate() in the Qreg class.
   This is to allow simulators to give a meaning to their raw memory.
	
- Nov 18 2002 --> ver 0.6.6
  Stefano Bettelli
  Modified the instantiation of Qinterface. The dynamical allocation
   is gone, get_quantum_interface() returns now a Qinterface_base
   reference to a Qinterface object, which is automatically and
   statically allocated in qinterface.cc. In this way, you don't need
   to delete the interface object explicitely (the destructor is
   called automatically when the program terminates).
  Introduced a class for base gate properties (Qop_slice_basegate class,
   the qop_slice_basegate.* files). A base gate is the quantum gate
   associated to a time slice. All the properties of a gate (exception
   made for an additional parameter, like in Qop_phase_like slices) can
   be stored here. Only a few instances of this class are created, as
   constant objects, in the qop_basegate.* files, and they are referenced
   by all the slices to retrive the properties' values. The base gate
   opcode, the human-readable name and a flag about the gate being
   parametrised or not have been moved into this class.
  Introduced a sort of database (Qop_summary class) which knows about
   the basic gates used in the library. Infact, each base gate registers
   itself at contruction time, and receives back its index into the
   database. The registration is dynamic, i.e. as soon a Qop_slice_basegate
   becomes available, a pointer to it is written in the database.
  Modified Qop_slice and its derived classes in order to fit with the
   new Qop_slice_basegate class: the opcode member has been replaced
   by a pointer to a constant instance of Qop_slice_basegate. Other
   minor modifications took place too.
  Changed Qop_slice and Qop_phase_like's output_details into get_details
   and simplified their behaviour a bit.
  Introduced a version of Qubit_list::is_overlapping which accepts a
   segment as argument. Modified the other method with the same name
   in order to use this simplified version when possible. Introduced
   Qop_slice::is_referencing which accepts one address and returns true
   iff the address is referenced in at least one slice's address list.
  Added "print_statistics" to the interface of a quantum operator
   (but the routine is implemented in the Qop_slicelist class' method
   with the same name). It, obviously, prints statistics about a given
   quantum operator: there is a general section and a per-line section,
   with separate counts for each type of base gate (it uses information
   from the Qop_summary class).
  Moved to g++-3.2 from g++-3.1
  Added a few std:: in qexception.h
	
- Nov 04 2002 --> ver 0.6.5
  Stefano Bettelli
  Extended the functionalities of the highest() and lowest() methods
   from the Qubit_segment class to Qubit_list. Moreover, now also
   Qop_slice and Qop_slicelist have a similar get_occupation() method,
   which reports the highest used formal address in the slice or slice
   list + 1 (subtracting the number of ancillae, so that get_occupation()
   can be used as a lower treshold for the size of the register to be
   fed into the slice or slice list).
  Changed the approach to ancilla qubits handling. Now the "number of
   ancillae" is a property of a Qop_slicelist, not of each Qop_slice
   separately. Pros: addresses in the slices' address lists are directly
   comparable (identical address refer to the same physical qubit, it
   is easier to simplify circuits), the number of ancillae is known
   in advance. Cons: all ancillae are permanently allocated during the
   execution of an operator, composing two operators in general requires
   shifting one of them. This required a lot of changes in the Qop_slice,
   Qop_slicelist and derived classes, as well as in the controlled
   operator construction, which are too long to describe here.
  When two slice lists with a different value for the number of ancillae
   are sticked together, that with fewer ancillae is "appropriately"
   offset. It is not clear what "appropriately" means here, i.e. whether
   the additional ancillae are to be inserted at the beginning or at the
   end of the ancilla space. They are currently inserted at the end, but
   don't assume this will remain true forever ...
  The methods Qreg::operator+= and Qreg::operator-= are not used
   anymore in the library (they were used in Qop_slicelist::operator()),
   but they remain in the Qreg class (as required by specs).
  In the Qop_slicelist class, the border simplification routine simplify()
   is now called also by push_front() and push_back() (if the list was
   not previously empty), in addition to append() and splice().
  Corrected a terrible bug in generate_AND_circuit(), which went
   unnoticed for a long time: when updating control_2, one should use
   assignment (=), not subtraction (-=).
  Added methods get_occupation(), get_ancillae() and get_parallelisation()
   to the Qop class, for knowing in advance how many qubits are to be
   explicitely supplied at run time, how many are needed in the q.c. or
   simulator and what is the maximum parallelisation index.
  Added a lot of methods to the Qubit_list class: is_empty (true if the
   list is empty, renames empty()), is_single (true if the list has
   exactly one segment), is_multiple (true if the list has two or more
   segments), reorder (put all addresses in increasing value order).
  Revised all methods of the Qubit_list class, so that they use optimised
   algorithms for the very typical case of lists with zero or one segments.
  Added method "reorder_and_annihilate" in Qubit_list; this can be used
   to simplify slices with adjoint 1-qubit base gate but not identical
   address list. 
  Moved Qop_slicelist::simplify to a different file.

- Sep 26 2002 --> ver 0.6.4
  Stefano Bettelli
  Fixed a stupid bug in qinterface.cc. Since the POP macro is expanded
   in a function call, it is not healthy to use it twice among the
   arguments of a function call, since the call order is undefined.
	
- Jul 31 2002 --> ver 0.6.3
  Stefano Bettelli
  Patched the QSwap constructor with size and that with a single list,
   so that they now check that at least two addresses are present; if
   this is not true, the identity Qop is returned. I had to add a test
   in the protected constructor Qop::Qop(QSlice *) for this, which
   ignores the input if the passed pointer is NULL. Also corrected
   QFourier_slices for the same problem.
  Implemented operator<< for the Qbitset class and reworked the logic
   of some of its methods so that now the first bit in the container
   is the most significant bit (MSB) and the last bit among those which
   are significant in the container is the least significant bit (LSB).
  Modified also gate_calculator::calculate_factor in qntlib_expower.cc
   in order to comply with the assumption that the first formal or real
   qubit in each quantum library structure is the MSB. Now the classes
   [Qubit_segment Qubit_list Qreg Qbitset] are compliant as well as the
   library function expower.
  Modified the subroutine which builds a doubly controlled phase time
   slice: it uses a circuit suggested by Klaus Frahm which requires
   only 9 gates (instead of 17 as before). This is a nice improvement.
  Modified Qinterface::run_evolution() so that now it sends correctly
   also the initialisation value. Moreover, it does not copy the
   command queue but consumes it (it is not the final solution though).
  Modified Qaddress_manager_base and Qaddress_manager, so that it is
   now possible to print out the details of the most derived class
   through a pointer to the base class.
  Redistribution of methods between Qinterface_base and Qinterface; now
   all the bytecode protocol related routines are collected in the "base"
   class, which also contains the Qaddress_manager_base pointer and the
   permutation list. As a byproduct, now registers and time slices are
   no more friend class or Qinterface_base.
  The Qinterface class now implements (with additional help from its
   base class) two examples of "simulators", depending on the value
   of the compile time symbol QINTERFACE_USES_PTRHEADS. In the "serial"
   example the bytecode is consumed syncronously, while in the "threaded"
   example a consumer thread is created which processes the bytecode
   asyncronously. Probably due to a problem with STL allocators the
   threaded example is much slower than the other, and is not the default
   although it is more realistic. In any case, the "simulation" consists
   in printing to stdout the decode bytecode.
  Moved qinterface.o to libqprimitives.so since now it is dependent on
   the low level primitive set.
  Added methods set(), read(), set_element() and read_element() to the
   Qbitset class for addressing individual bits and storage elements.
   This is necessary for register measurement (and simplifies operator<< 
   for Qbitset a lot, which is no more a friend function). The Qbitset
   class is now no more implemented on top of an STL vector, but it uses
   a plain C++ vector.
  Swapped the order of arguments in the main constructor of a Qbitset;
   now the first argument is the size and the second is the initial
   value (which defaults to zero).
  Added code for reading measurement results in the Qinterface* classes.
   Of course, it still generates dummy patterns (0xaaaaaaaa), but now
   the programmer has all the hooks for attaching a real simulator.
  Added a private boolean flag in Qinterface_base which can tell if the
   permutation list is trivial or not. In this case we can spare a call
   to Qubit_list::translate() which is very expensive.
  Added an optimisation for Qubit_list::translate(); this is now an
   inline method which selects translate_map (the old translate, with
   STL maps) or translate_nomap (which is instead appropriate when the
   number of segments in the two lists is not "too much"). Apparently
   this was the most expensive routine during access to the quantum device.
	
- Jun 26 2002 --> ver 0.6.2
  Stefano Bettelli
  Modified the Makefile so that it now builds three separate libraries.
   ** libquantum.so contains all the intrinsic elements of the Q
   language; ** libqprimitives.so contains our choice for primitive
   time slices (it includes qop_phase_like.o, qop_builders.o,
   qop_primitives.o and qprimitives.o; their include files are confined
   in the .cc files, exception made for qprimitives.h which is the link
   with the libquantum environment toghether with qop_codes.h);
   ** libqstdlib.so contains the "standard quantum library" (actually,
   only the expower function for the time being). My point is that now
   the set of primitive time slices can be replaced without touching
   libquantum.so and libqstdlib.so (which was a claim of the paper).
  Corrected an error in the estimation of significant digits in expower
   which could lead to spurious warnings.
  Corrected operator= in qbitset.h and qop_slicelist.h, which did
   not return *this as customary.
  Added the QNot high level primitive (the construction is similar to
   that of QCnot, but it is a one qubit gate).
  Patched the software for compilation with the new g++-3.1, which 
   applies the long awaited named return value optimisation. Removed
   the __USE_MALLOC symbol from the Makefile since it was causing
   problems. Also replace hash_maps & multimaps in qmanager.h with
   more standard binary tree containers, since they are changing
   header file location and namespace too often. g++-3.1 will be the
   default compiler from now on (I want to be as much C++ compliant
   as possible!).
  Changed Qop::get_depth() into Qop::depth() (it is easier !).
  Modified Qop ctor for controlled operations (in qoperator_control.cc)
   and Qop_slicelist::controlled for handling controlled operations
   with less confusion.
	
- May 14 2002 --> ver 0.6.1
  Stefano Bettelli
  Corrected a small bug in the ctor of Qop_phase_like about the use
   of the modf function (you can't use NULL as second argument).
  Found a terrible bug in the construction of controlled operators.
   It has been fixed with a hack in the Qop ctor in qoperator_control.cc,
   but this code needs to be revised more seriously. It seems that this
   bug had always been there, but it shows up only for small control sizes.
  Created a Qubit_list::run_remap() method, in close analogy with
   run_split() and run_swap(). It permutes the current qubit list, and
   is slightly more than an interface to translate() for Qubit_lists.
  Created a remap(const Qubit_list &) method both in the Qop_slice and
   in the Qop_slicelist classes, which export the behaviour of the
   Qubit_list::run_remap method to higher levels. The method in the
   time slice class takes care not to remap the ancillae!
  Created a remap method in the Qop class, which obvioulsy uses the fun-
   ctionalities provided by the same methods in the lower level classes.
  Created a Qubit_list constructor accepting a vector of qubit addresses.
   It tests that the vector is overlapfree before building the list.
  Written the "expower" function in the quantum library. It has taken
   a lot because it is numerically very demanding. I will need it
   during the preparation of my next paper on chaos assisted quantum
   tunneling and error correction codes.
  Written a preliminary implementation of to the quantum interface stream
   (Qinterface::run_evolution). This will evolve (I hope) into a complete
   interface to a quantum simulator.
  Modified qmanager.h so that it now includes <hash_map> and not the
   standard <ext/hash_map> when compiled with gcc ver2. This allows to
   compile the code also with these "old" compilers.
	
- May 04 2002 --> ver 0.6.0
  Stefano Bettelli
  Started a post-doc position at IRSAMC, University Paul Sabatier
   in Toulouse, France. The new release number reflects the shift
   in the group interests. We are going to focus on error correction
   codes for a while! Moved email to "bettelli@irsamc.ups-tlse.fr".
  Forgotten about ::quantum_message_signed_type
  Changed all #include statements for standard includes (not mine)
   so that they do not have the '.h'. <math.h> becomes <cmath> and
   <limits.h> becomes <climit>. Also, I had to add some std:: in
   front of the ostream classes to be compliant with recent g++s.
  Completely rewritten the implementation of the Qop_phase_like class:
   it now stores a mantissa which specifies an angle with a precision 
   of 2 PI 2^{-word_length} (word_lenght is 32 on my machine). It is
   a fixed point representation. The interface to phase gates remains
   the same, exception made for an optional additonal parameter x
   whose default value is 1. The pair (k,x) specifies the phase
   exp(2 PI i x / 2^k). A lot of small changes to the phase classes.
   This modification will allow a generic phase gate, not only those
   with x=1 (this is necessary for my new simulations!).
  Defined the quantum_phase_power_type and quantum_phase_floating_type
   types for phase-like gates in qinterface_types.h. This avoids some
   horrible "#include"s.
  Changed some calls in qop_primitives, qop_builders and qprimitives
   in order to be consistent with the new phase like operations: the
   constructors for Qop_slice_Phase and Qop_slice_CondPhase, the
   "control" methods of the same two classes, the control circuit
   builder class constructor QCondCondPhase_slices and the ctors
   for the primitives QPhase and QCondPhase.
  Created a new Qop (i.e. high level) primitive, QCondCondPhase, which
   uses the "control" circuit for QCondPhase. This could infact be built
   also by first building a QCondPhase and then controlling it with a
   one qubit register. This primitive is to be sure that we don't use
   ancilla qubit for doubly controlled operations.
  Moved operator~ from the classes in qop_builders.h directly into
   the base class Qop_slicelist.
  "Simplified" the operator& for Qops so that it does not use the "low
   level" Qop_slicelist's but only the Qop copy ctor and Qop::operator<<
   Slightly modified the controlled constructor for efficiency.
  Deleted method Qop_slicelist::swap(); it was used only in the protected
   constructor Qop::Qop(Qop_slicelist &), which can use splice() as well.
   Slightly optimised Qop_slicelist::splice for this case.
  Deleted operator~ method from the Qubit_list class: it was not really
   necessary, so it is better not to create additional ties. Updated the
   methods Qop_slice::translate and Qinterface::submit_segments in order
   not to use operator~.
	
- Feb 18 2002 --> ver 0.5.8
  Stefano Bettelli
  Update to "Copyright (C) 2000 2001 2002 Stefano Bettelli"
  Update the README file with a reference to my PhD thesis

- Jan 13 2002 --> ver 0.5.7
  Stefano Bettelli
  Changed the name QSliceList into a more standard Qop_slicelist
  Collapsed Qop_slice::has_adjoint_basegate and has_equivalent_indexes
   into is_adjoint_of (basegate method can still be overridden)
  Changed Qop_slicelist::get_max_parallelisation into get_parallelisation
  Changed verb "to wrap" into "to overflow", verb "to merge" into
   "to join", "joint" into "joined"
  Changed Qinterface::modify_permutation and Qubit_list::create_permutation
   so that they accept two Qubit_lists and not a Qubit_list_collection
  Introduced an obvious method Qop_slicelist::offset
  Changed Qop_slicelist::become_controlled into Qop_slicelist::controlled
   (which is constant). The previous interface was too strange.
  Explicitely written the assignment operator for Qops
  Removed obsolete exception Qop::operator_ctor_failed
  Small change in create_AND_circuit in the calculation of control_2
  Modified Qop_slicelist::adjoin, which now BOTH adjoins each slice AND
   reverses the slice list. Also modified Qop::adjoin, which now simply
   calls the method with the same name on the internal slice list.
  Moved almost all Qop methods as inline methods and simplified the
   Qop::operator! a bit taking Qop::operator>> as a reference.
  Qop_phase_like::has_adjoint_basegate : !== is the same as !=  (!)
  Removed all the references to the OPCODE_COLLAPSE macro and edited
   the BYTECODE documentation file

- Jan 04 2002 --> ver 0.5.6
  Stefano Bettelli
  Small changes in Qaddress_manager::checkout_qubits which eliminate
   a boolean variable + additional test for main list past-the-end
  Small changes to Qaddress_manager::recollect_segments + added a test
   to exclude the case of a main list with exactly one segment (which
   is VERY unlikely anyway).
  Added a check in Qaddress_manager::get_qubits; if the requested 
   number of qubits is zero, an exception is thrown.
  Wrote the copy ctor and the assignement operator for Qbitsets. Also
   changed comment on the algorithm for Qbitset::bits_for
  Replaced all "ization" with "isation" and similar (US -> brittish, 
   for uniformity with other already written descriptions).
  Simplified a bit the Qreg::operator-= method, by taking a reference
   to the first segment in the address list at the beginning
  Corrected a "stupid" bug introduce in ver 0.5.5 (in test.cc the "add"
   operator was offset with the non-mutable operator>> instead of with
   offset(), leading to a no-op invalidating the rest of the program).
  Another little revolution! Got rid of the Qop_fixed_arity class: now
   all the index lists are private members of Qop_slice, and some 
   methods are no more virtual.
  Clean-up of the Qop_slice class: has_same_gatetype removed, 
   has_adjoint_basegate and has_equivalent_indexes are protected,
   new method is_adjoint_of which summarises the previous three.
   Some other methods are now protected or private.

- Jan 01 2002 --> ver 0.5.5
  Stefano Bettelli
  Minor changes to test.cc
  Minor changes to Qubit_list::pop_front
  Changed the name of Qubit_list::translate(index, iterator) into
   Qubit_list::find_element to avoid confusion in the code description
  Minor changes to Qubit_list::get_subrange(5 arguments)
  Modified operator< between list iterators in qlist_map.cc. It now
   really uses operator< between segments, not a custom algorithm.
  Used segment comparison (operator< between segments) instead of
   explicit test in Qubit_list::is_overlapping
  Renamed const_map_type into const_set_type in qlist_map.cc
  Moved Qubit_list::split_at into qlist.h and moved Qubit_list::run_split
   and run_swap into qlist.cc (they really don't need map structures).
   Qubit_list::run_translation goes into qlist_map.cc, since it is only
   used by the translation method.
  Removed some unnecessary methods from the Qubit_summary class: the ctor
   with (firs,last,bool) (all segment summaries are direct!)
  Changed boundary into border in all files.
  Changed (in Qubit_summary) get_count_* into get_*, set_count_* into
   set_*, add_user_* into add_* and del_user_* into del_* (the set_counts()
   method became set())
  Changed Qaddress_manager::split_direct to return an iterator to the
   second segment when possible. This simplifies a bit get_qubits()
   in the address manager class (qmanager.cc). Now split_direct throws
   an exception if new size is >= old size, not > only (because the
   method is private and should always be called with new < old).
  Changed insert(), free_insert(), busy_insert() and the corresponding
   erase methods in Qaddress_manager so that they accept a constant 
   main list iterator by value instead of a mutable main list iterator
   by reference. This simplifies allocate_resources() in qmanager.cc
  Small changes in Qaddress_manager::checkin_qubits which eliminate a
   boolean variable + additional test for main list past-the-end

- Dec 16 2001 --> ver 0.5.4
  Stefano Bettelli
  Modified Qubit_segment::operator< in order to have a strict total
   order relation among segments, compatible with Qubit_segment::operator==
  Changed Qubit_segment::shift_back into Qubit_segment::shift_backward
  The Qubit_list_type constructor which accepts two iterators is now
   private (one could not check in advance the validity of the range).
  Changed the name of the Qubit_list_type class to Qubit_list
   (ok, this is only for shorter names in my thesis!)
  Removed the Qubit_list::operator[] method: it was used only in the
   ctor of the QFourier_slices class. Instead one can use the operator()
   method with size = 1 (the () method checks the "size" argument and
   calls the most appropriate get_subrange).
  The two static methods of the Qubit_list class (create_permutation
   and mix_lists) now accept references to list collections, not pointers.
  Renamed Qubit_list::splice_and_recollect to join() and 
   Qreg::run_splice_and_recollect() to run_join().
  Patched Qubit_list::try_join_and_cleanup_forward to use the logic 
   which is already available in Qubit_segment::try_join(), without
   resorting to use Qubit_segment::can_join() at a lower level.
  Added a test in Qubit_list::join() which returns immediately if the
   passed list is emtpy (it segfaulted before).
  Modified Qreg::operator-- : removing elements from the first segment
   of the list is now demanded to the list itself, so that push_front()
   needs not be exported from the Qubit_list class. We need however the
   method Qubit_list::pop_front(a_size) which removes "a_size" qubits
   from the first segment (if a_size is zero, removes the first segment).
  Simplified Qinterface::modify_permutation, the index list is now comple-
   tely calculated by the Qubit_list class, no need for another push_back.
  Qubit_list::split(iterator, size) is now private.
  The Qubit_list now inherits privately from an STL list; this required
   exporting some of the base class methods, but now no one can build or
   modify a Qubit_list in order to make it invalid (i.e. with a qubit 
   referenced more than one time).
  Eliminated Qubit_list::is_overlapfree(), since all lists should be
   overlapfree now! Also removed the tests in qop_fixed_arity.cc

- Dec 08 2001 --> ver 0.5.3
  Stefano Bettelli
  Eliminated a redundant #include <algorithms> in qsegment.h
  Begun writing my PhD thesis, the last chapter is a description of
   the code in this library. Writing it down will help fixing the
   operational semantics; let's start with Qubit_segments.
  Changed the internal representation in class Qubit_segments: it now
   uses first() and last() (the orientation variable was dropped).
   Reworked the two qsegment.* files to work with the new represent.
  Introduced checks in Qubit_segment::operator[] and index() in order
   to be sure that the referenced addresses are really inside the
   segment (this check may throw an exception).

- Dec 07 2001 --> ver 0.5.2
  Stefano Bettelli
  Added an erase() method to QSliceList which also deallocates the slice
  Moved the automatic boundary simplification routine into the splice()
   method of QSliceList. Also rewritten its append() method for making
   a copy of the passed list, then calling splice()
  Commented the simplify routine and fixed it: it now uses an iterator
   to the left side of the junction boundary after a composition for
   running the test more efficiently.
  Eliminated the esplicit simplify() calls in the composition methods
   in the Qop class.
	
- Dec 05 2001 --> ver 0.5.1
  Stefano Bettelli
  Fixed a bug (?) in Qubit_segment::is_overlapping() which was missing
   some overlaps (too many ands !, how long has it been there ???)
  Fixed a bug in Qubit_list_type::is_overlapfree(), which was returning
   the wrong answer when the list had exactly two segments. 
  Changed some methods in the Qubit_segment class so that segments
   with only one address (i.e. those for which is_single() is true)
   always have is_direct() = true.
  Added operator== and operator!= to the Qubit_segment class. Since the
   orientation of single address segments is fixed now, there is no
   ambiguity on testing when two segments are "equal".
  Added operator==, operator!= and the is_equivalent() method to the
   Qubit_list_type class. Note that operator== tests whether the data
   structures are identical, while is_equivalent() tests whether the
   two lists are associated to the same ordered sequence of addresses.
  Added has_same_gatetype() and has_adjoint_basegate() in the hierarchy
   for time slices. Also supplied a default implementation for adjoin().
   These three methods are virtual, but the default version is already
   enough for some simple time slices. adjoin() and has_adjoint_basegate()
   had to be rewritten for phase like operators (new qop_phase_like.cc)
  Added has_equivalent_indexes in the hierarchy for time slices, which
   is a first approximation of the equivalence test for internal lists.
   (maybe the list collection should be moved inside the Qop_slice class).
  Moved the virtual destructors in qop_primitives.h into the 
   standard_methods macro.
  Implemented a preliminary QSliceList::simplify() !

- Dec 04 2001 --> ver 0.5.0
  Stefano Betteli
  Added method Qop::get_depth() for returning the circuit depth.
  Removed the Qlink_list_type class: it has been merged with the
   Qubit_list_type class. The reason for this is that this separation
   was causing a real mess! The Qubit_list_class remains a list of
   segments, the qubit maps are calculated on the fly when they are
   needed. Many changes in qlist.*, qregister.*, qop_fixed_arity.*,
   qinterface.* and qop_slice.*
  Added optimization for Qubit_list_type::is_overlapping() when
   both lists contain only one segment (don't use maps in that case)
   and for Qubit_list_type::is_overlapfree() when the number of
   segments in the list is less than three.
  Reworked Qubit_list_type::run_swap(): most of the logic for the
   final merging has been moved to three private rotines in the
   class: try_join_and_cleanup_X (X = forward, backward, both_sides).
  Reworked Qubit_list_type::translate() for the index to address 
   translation: now it uses a binary tree, not a hash map, and there
   is a final check on the consistency of the translation which can
   generate an exception.
  Splitted qlist.cc (which was getting enormous) into qlist.cc and
   qlist_map.cc (the second source file contains all the methods 
   which are related to the second ordering of the list).
  Qubit_list_type::split_at() is now a private inline method in qlist_map.cc
  Posted version 2 of our paper ("Toward an architecture for quantum
   programming") after a very long delay! (23 Nov 2001). This is the
   new reference paper now, and introduces the second address translation
   stage for the implementation of a software QSwap. Sync code <-> paper
  Removed Qreg::collapse() : it was not useful!
  Changed the return value of Qubit_list_type::reverse() from void to
   Qubit_list_type & (it returns a reference to the current object now)
  Introduced the global permutation (in Qinterface) and implemented
   QSwap as a software only operation: it looks like a two qubit fixed
   arity operation, but operator() is overridden (it does not send
   commands to the device but modifies the permuation list of the
   quantum interface). Controlling a swap however remains a quantum
   operation! Added routine Qubit_list_type::create_permutation().
  Modified qprimitives.h for QSwap: its ctor can accept 2 lists (obvious),
   1 list (exchange of the two sides) or a size (falls back on 2nd ctor).
  Modified qprimitives.cc, qop_primitives.h, qop_fixed_arity.* and
   qop_phase_like.h: all constructors accept only Qubit_list_type
   objects, exception made for the constructors in qprimitives.cc
   which accept also the "the_size" parameter, which is converted
   into a list on the fly. QSwap has also a ctor with only one list,
   though it is a two qubit operation.
  Eliminated Qreg::measure and renamed Qreg::measure_bitset to
   Qreg::measure. Therefore now there is only one measure() in the
   Qreg class: conversion to integers (when possible) is automatically
   performed by a cast operator in the Qbitset class.
  Fixed the possibility of creating a Qop_phase_like with k=0 (this
   generates an exception of type invalid_power() now).
  Fixed the submit_booleans() and submit_segments() methods in the
   "quantum interface": the number of meaningful bits and the number
   of segments were not prepended.
  Fixed a bug in make_minimal(): after a successful join the current
   iterator was not retried, so that some minimization could be lost.
  The 'test' program reproduces the examples of fig.2 at pag.5 and
   sec.4.1 at pag.12 of the reference article.

- Oct 06 2001 --> ver 0.4.4
  Stefano Bettelli
  This release is here only because I have eliminated every reference
   to the quantum Fourier transform as a hardware primitive. If you
   want to see what was taken away, run a diff with respect to the
   previous release. Fourier as a hardware primitive was present just
   to show how these things can be done in case they are needed.
   I took it away because it was impossible (?) to build a controlled
   Fourier transform using only the standard primitives and the 
   transform itself in constant time (the standard contruction uses
   a number of gates which is quadratic in the qubit lines interested
   by the transformation).

- Oct 06 2001 --> ver 0.4.3
  Stefano Bettelli
  Fixed a few compiler (g++ 2.95.4) warnings: two missing return
   statements and a strange new with cast in QFourier_slices.
  Eliminated cpu specific optimization from the Makefile
  Corrected a bug in build_CondHadamard (last phase shift was -3, not 2)
  Corrected a bug in QSliceList (copy ctor and operator= were missing)
  A lot of cleanups to the methods which implements controlled operations
   to make them more understandable.
  Added updated "requirements" to the comments in qregister.h/qoperator.h
  Cleanup of QSliceList internals with some helper methods.
  Added comments on the Qop_slice::control method and its implementations.

- Oct 03 2001 --> ver 0.4.2
  Stefano Bettelli
  Operators & and &= for Qops now call the simplify() routine for their
   operation list (though the routine is still empty).
  Supplied builders for various basic circuits like controlled Hadamard
   and doubly controlled Phase gates: they are needed for implementing
   "primitive" operators and controlled operators. 
  Eliminated phase shifts with real parameters: it's a terrible headache
   for no apparent gain. I decided to remove them in order to simplify
   the overall picture. Moreover, I will now use an unsigned integer for
   encoding the phase and a boolean flag for remembering the adjoining.
  IMPORTANT! The syntax for composition of operators has been changed!
   Now (A & B) means applying operator A, then operator B. This is consi-
   stent with the standard diagrams for quantum circuits, where time
   flows from left to right (and is simpler when translating diagrams
   into Qops), but remember that the standard matrix notation for the
   same thing would be BA, since BA|psi> is B(A|psi>). The method which
   required a change are operator&(Qop, Qop) and Qop::operator&=.
   (also QSliceList now has methods append() instead of prepend()).
  Substituted all "ancillas" with "ancillae".
  Corrected a bug in Qreg::operator+= (the free_list was incorporated,
   hence depleted, before run_initialization() used it).
  Reorganized split* methods in Qubit_list_type and Qlink_list_type. The
   core method split() and its interface split_at() are now located in
   Qubit_list_type, while Qlink_list_type has only a private wrapper for
   split_at(), which is enough for its pourposes. Similar reorganizations
   for run_split().
  Moved Qlink_list_type::push_update() into update_map().
  Changed all postfixed increment operators into prefixed ones (efficiency)
  Added method Qop::operator<<(Qop &) which is just like operator&= but
   splices instead of copying the second operator list (it is more efficient
   but the second operator is empty after this call!).
  Implemented a first version of the Qop constructor for controlled ops!
  
- Sep 13 2001 --> ver 0.4.1
  Stefano Bettelli
  VERY nasty bug solved, due to an interaction among iterators, overloaded
   functions and a stupid programmer. QSliceList::prepend(Qop_slice *) 
   is now more wisely called push_front.
  Reorganization of Qop_slices and primitives: for good reasons to long to
   explain there is no more a Qop_basic class, but a separate hierarchy for
   Qop_slices and Qops. RTTI is no more needed for resolving Qop operations.
   This led to saves in the library and executable sizes of up to 30% but
   (apparently ?) nothing in the execution time. The picture is anyway much
   clearer now: all manipulation of quantum circuits is done through Qop 
   and Qop_slices are used only by internal routines. This allows us to
   decouple Qop "primitives" from Qop_slice "primitives": if a quantum
   programmer uses only Qop primitives, his/her program is guaranteed to
   remain valid even if the set of hardware/software(slice) primitives
   changes. In this way we could introduce the QFourier Qop primitive which
   can be implemented either in terms of a single Qop_slice_Fourier slice
   or as a quadratic circuit made out of Hadamard and conditional phase gates.
  Eliminated the need for typeinfo in operator<< for Qop_slices; the name
   of the most derived class is retrived through a class method.
  Added an appropriate clear method in the QSliceList class.
  Successfully implemented QCnot and QSwap, the first Qop primitives
   which are not Qop_slice primitives (swap is physical ...). Written
   and slightly debugged the builder for the Fourier transform.
  The code for address subrange extraction has been moved from the operator()
   and operator[] methods in the Qreg class into the get_subrange() methods
   in the Qubit_list_type class (which now also exports an operator() and
   an operator[] which don't return the additional informations required
   for fragmentation). The same methods have been exported in Qlink_list_type.
  Replaced all constructor prototypes in the Qop_slice hierarchy to accept
   Qubit_list_type objects instead of Qlink_list_type ones (because the
   former objects are lighter and the hash map in Qlink cannot be copied
   efficiently inside a copy constructor). All these primitive slices export
   the Qubit_list_type part of their internal lists through get_list().
   It turned out that only the Qop_fixed_arity class needs a real knowledge
   of the Qlink_list_type class.

- Sep 07 2001 --> ver 0.4.0
  Stefano Bettelli
  The slice list is now a subobject in Qop (it was only dinamically
   allocated and saved through a pointer before); this required a new
   swap method in QSliceList.
  Qreg::operator() has a new feature: if the size field is set to zero,
   then it means "up to the end of the register". That is Qreg a = b(3)
   creates a Qreg "a" which references all qubits of "b" in the same
   order exception made for the first three.
  Moved core of Qreg::operator= (initialization) to a different routine
   (Qreg::run_initialization()) which only interacts with the 
   Qubit_list_type structure (and not with the whole register) +
   bug correction (qubit list encoding was not sent!)
  Moved core of list splicing for register (which previously was in
   Qreg::operator&=) into a separate routine (Qreg::run_splice_and_recollect)
   Done the same thing for the address manager's main list fragmentation
   by Qregs (Qreg::run_fragmentation).
  Exported the address manager methods checkin_qubits() and chekout_qubits()
   also for single segments (they accepted only lists before, and these
   methods are now in the base class); this leads to some simplification
   in the Qreg class and makes the Qaddress_manager::update_boundary_usage()
   unuseful (it has been deleted).
  Added methods Qreg::operator+= and Qreg::operator-= which add and
   subtract qubits from the beginning of the register list. These fast
   modifications are needed for managing ancilla qubits.
  Added an "ancillas" field to Qop_slices. The first "ancilla" qubits in
   each slice list are now considered ancillas and they are not concerned
   by split(), swap() and offset() operations.
  Added ability for Qop to spawn ancilla qubits during a computation. The
   modification is indeed in QSliceList::operator(Qreg &), which takes
   care to prepend the ancilla qubits to the user register. Use of ancillas
   has some restrictions and need to be explained better in the documentation.
   This modification will allow the implementation of multicontrolled ops.

- Sep 04 2001 --> ver 0.3.8
  Stefano Bettelli
  Checked virtuality of destructor of all non-trivial classes (and fixed some)
  Moved qop_utils.* into qop_phase_like.*
  Implemented a FIFO queue in the quantum interface for holding the
   command queue (it uses a standard STL queue)
  Corrected a bug in Qreg standard constructor: the incorporate_qubits()
   function checked in the qubits a second time (after get_qubits())!
   Now the qubit checkin can be disallowed by a boolean variable in the
   incorporate_qubits method (the variable defaults to "checkin").
  Many small changes to make the code compatible with both g++-3.0.2 and
   g++-2.95.4; moved <hash_map> includes to <hash_map.h>; explicitely set
   std:: on STL containers' names; included <iostream> wherever necessary;
   declared Qreg::operator=(const Qreg &) a const function to fool a
   resolution problem with g++-3.0;
  Eliminated the need for std::string and std::strstream in get_details(),
   which has been moved to output_details(std::ostream &). Now strstream,
   which is not a part of C++ standard library, is not used anymore, and
   string is used only in the Qexception class.
  Introduced a new class (Qbitset) which replaces the vector<bool> objects
   needed for initialization and measurement of registers.
  Checked inline functions for not being too big and moved some.

- Sep 01 2001 --> ver 0.3.7
  Stefano Bettelli
  Qop_phase_like now inherits from Qop_fixed_arity and a few common methods
   from QPhase and QCondPhase have been moved there. get_parameter() has
   been specialized for these classes.
  Added a small memo (BYTECODE) on the communication protocol.
  Implemented measurement and collapse methods in Qreg, as well as register
   initialization. This required the introduction of vector<bool> arguments
   /return values in many methods and the rationalization of others.
  Implemented Qinterface::submit_booleans for sending bit masks to the
   command channel of the quantum interface.

- Aug 30 2001 --> ver 0.3.6
  Stefano Bettelli
  Substituted all occurencies of qbit with qubit, and set all class names
   to begin with a capital Q (including Qlink_list_type and Qubit_list_type).
  Implemented a translation routine from formal addresses into real
   addresses (Qubit_link_type::translate() and run_translation())
  Moved all (const [const_]iterator &) arguments to ([const_]iterator)
   in the link_list_type class (iterators are small ...)
  Created class Qubit_list_type which is the list core of Qlink_list_type;
   this allows faster operations when the qbit_map is not strictly required.
   All methods which do not require a qbit_map have been moved from
   Qlink_list_type class to Qubit_list_type class. This affected particularly
   the interaction between the address manager and the quantum registers
   (the address manager doesn't need to know about Qlink_list_type !)
  Moved some methods from Qlink_list_type to Qubit_list_type:
  Added more warning flags to the Makefile
  Moved the list merging routines inside qop_fixed_arity
  Removed the Qaddress_manager_list class (and its files) and integrated
   the functionality of split_direct in the Qaddress_manager class.
  General clean-up of the address translation interface.
  Qubit_link_type::map_type now holds constant iterators to the list_type.
  Rationalization of ctors of Qubit_list_type and Qlink_list_type, as
   well as those in the Qreg class.

- Jul 30 2001 --> ver 0.3.5
  Stefano Bettelli
  Various clean-ups for the Qinterface* classes.
  Moved qop_macro to a different file for simplicity (qop_macro.h)
  Changed the link_list_type** field in qop_fixed_arity class to a more
   robust vector<link_list_type>. This made the copy constructor, the
   destructor and the list cloning method unnecessary.
  Eliminated the qop_fixed_arity variadic constructors; it now uses
   an STL container for passing the user lists. Supplied a specialization
   for the case of arity=1 and arity=2. Modified accordingly the
   qop_macro.h and qprimitives.h constructors.
  Templates for submit_* methods in Qinterface_base and Qinterface
  Implementation of a first version of Qop_slice::operator() which 
   generates the code for time slices and sends it to the quantum interface
  Force method demangle_addresses in every Qop_slice for translation of
   formal addresses into real addresses and their encoding.
  Moved logic of Qreg::swap() into link_list_type::reverse(), since we
   need not to expose link_list_type internal structures.
  Moved translate(address an_index, const_iterator &a_segment) const from
   Qreg:: to link_list_type:: for the same reason.
  Moved Qop_slice::swap_the_list() and split_the_list() to the link_list_type
   class with names run_split() and run_swap() for the same reason.
  General const cleanups on Qreg::get_manager, Qreg::operator[],
   Qreg::operator(), range link_list_type constructor
  Removed uses of link_list_type::iterator from the Qreg class, the type
   qubits_iterator is now typedef'ed to link_list_type::const_iterator
  Major clean-up of the Qreg class; the embedded location list is now
   saved directly as a member, and not through a pointer, so that you
   can't touch a qubit list of a const Qreg anymore. Many simplification
   in the class methods and two exceptions less. Some methods added to
   the link_list_type class for supporting this transition.
  Modified checkin_qubits(), checkout_qubits() and get_qubits() in the
   address manager classes to accept and return link_list_type objects
   instead of pointers to such objects.
  Made some methods private in link_list_type after all these changes.
  All methods in link_list_type now explicitate whether begin() and end()
   refer to the qbit_list or the absolute_list.
  Changed all occurencies of absolute_list in the link_list_type class
   with a more meaningful qbit_map.
  Replaced all link_list_type::value_type typedefs with a simpler Qbit_segment
   (this also avoids some unnatural dependencies).
  Moved test on disjointness of lists and exception throwing from
   Qreg::operator& and operator&= into link_list_type::splice_and_recollect.
  Moved core logic for a segment merge + qbit_list and qbit_map update in
   the new private method link_list_type::try_merge().
  Implemented minimality reduction in link_list_type::run_swap.
  Those methods in link_list_type (try_join_and_cleanup(), split(),
   splice_and_recollect(), make_minimal(), run_split(), run_swap()) which
   could mess up the qbit_map have been reviewed and some of them have
   been fixed.

- Jul 21 2001 --> ver 0.3.4
  Stefano Bettelli
  Moved small methods in Qop into inline methods.
  Added QSliceList::operator()(const Qreg &a_register)
  Removed address manager creation/destruction from the Qreg class. Now
   each register can access its manager through a call to get_manager().
   This will make it easier to move to multiple managers in the future.
  Removed qmanager_friends.h and qmanager_init.cc. This functionality is
   now handled by the Qinterface class.
  Removed singleton condition from the Qmanager class
  Created the Qinterface_base abstraction and the Qinterface class for
   handling communication with the quantum device. The interface now
   also contains the address manager. An instance of the quantum interface
   is created by the quantum library before main() is called. (OK?)

- Jul 11 2001 --> ver 0.3.3
  Stefano Bettelli
  Modified the two Qreg::swap() methods to return a reference to the
   current register (though the second might be not natural ...).
  Added a new structure in link_list_type objects which is able to
   remember a path among segments which follows the ordering of the
   absolute lowest address of the segment. In this way the is_overlapping()
   and is_overlapfree() methods are linear time in the number of segments
   in the registers (and not in the product).
  Changed prototypes of dispose_segment() and upload_segment() in the
   Qaddress_manager class to accept a "const Qbit_segment &"
  Modified Qaddress_manager::checkout_qubits_and_delete into the more
   polite Qaddress_manager::checkout_qubits (deleting is in charge to Qreg)
  Eliminated unuseful Qop_macro::get_locations()
  Some small patches (in #endifs and qop_utils.h) for letting g++ 2.96
   compile without warnings.

- Jul 09 2001 --> ver 0.3.2
  Stefano Bettelli
  Moved Qop::for_each_time_slice_in macro to QSliceList::for_each; the
   whole logic for iterating through the slice list and running a base
   method has been embedded in QSliceList.
  Created class Qaddress_manager_list to which the main_list_type in the
   Qaddress_manager is typedef'ed. It is nothing more than a list of
   direct Qbit_summary's with a split method (renamed split_direct()).
   This eliminates the need for a template Qbit_list.
  qlink.h absorbed qlist.h and qlist.cc became qlink.cc
  Detempletized the link_list_type (now it is a self-standing class
   instead of a typedef to Qbit_list<Qbit_segment>). The size of the
   shared library dropped by ~ 13%. link_list_type is no more typedef'ed
   in the Qaddress_manager_base, Qreg and Qop_basic classes.
  The list<Qbit_segment> list is now private in the link_list_type class.
   I had to export size_type, iterator and const_iterator as types and
   begin(), end(), reverse(), push_front() and push_back() as methods.
   This is in preparation to the introduction of a second ordering.

- Jul 06 2001 --> ver 0.3.1
  Stefano Bettelli
  Now I'm sure (1997 C++ Public Review Document, 5.2.3) that constructors
   can be used as returning an rvalue to the newly created object (this
   means that expressions like QHadamard().offset(3) are legal and working,
   although the address cannot be taken.
  The list<Slice *> inside QSliceList has been made private and some methods
   for traversing it and accessing pointed elements have been supplied. The
   action of cloning Qop_slices is now completely transparent to other classes.
  Corrected a bug in make_minimal(): can_join() had to be try_join() !
  Reduction to minimality has been removed from swap_the_list, because the
   gain is negligible: this kind of reduction should be rethought from
   scratch for all Qop_slices containing link_list_type lists.
  Decided that Qop_slice destructor as a public method is not dangerous.
  Removed "Dump of " from operator<< output when present.
  Removed use of printf in get_parameters() (still the solution is not
   optimal since strstream is not standard, stringstream is the way to
   go once there is support for it in g++).
  Removed operator<< for Qop_fixed_ariety (it was never used)
  Added a boolean flag in Qop_macro for adjoin status
  Removed all unnecessary get_parameters() and get_parameter_string()
   and get_details() from Qop_basic hierarchy. Now we only have a
   get_details() in the Qop_slice hierarchy (which makes much more sense).
   Derived get_details() usually call their ancestors.

- Jul 02 2001 --> ver 0.3.0
  Stefano Bettelli
  Changed for_each_time_slice_in from local function to a macro: this
   allows the shortcut to be used also in swap() and split().
  Supplied non-mutable versions of the Qop permutations, through use of
   operator>> (for offset) and operator() (for split and swap).
  Included <exception> in qexception.h

- Jun 17 2001 --> ver 0.2.9
  Stefano Bettelli
  Removed specialized variants of Qop::operator& because the gain seems
   negligible (it doesn't justify the code bloat ...).
  The same was done with Qop::operator&= specializations.
  Added split_temp and swap_temp.

- Jun 15 2001 --> ver 0.2.8
  Stefano Bettelli
  Small change in operator<< for qlists. Now each line is offset with
    two tabs, which produces a cleaner output for Qops without messying
    everything up for registers. It is however clear that pretty
    printing cannot be achieved with ostreams and that these output
    functions should be used only for debugging.
  Constructor for Qop_fixed_arity with user lists was changed to check
    for all lists having the same size.
  Introduced unnecessary complication in Qop methods through STL algorithms
  Added Qop operator&(const Qop_basic &op_1, const Qop_basic &op_2);
  Added Qop Qop::operator&=(const Qop_basic &an_operator);
  Added Qop(const Qop_basic &an_operator);
    now arguments can be the most generic operators (need RTTI!)

- Jun 13 2001 --> ver 0.2.7
  Stefano Bettelli
  Revised default constructor, copy constructor and virtual destructors
    for the Qop_slice hierarchy. The strategy is not clear yet though.
    Also added a clone() function for all primitives.
  First rough implementation of Qop methods. This required a large
    rethinking of the QSliceList class.
  Separated qop_slice.* into qop_slice.* and qop_slicelist.*
  "Fixed" output functions for classes derived from Qop_slice

- Jun 12 2001 --> ver 0.2.6
  Stefano Bettelli
  Introduced class Qop_fixed_arity (inherits from Qop_slice) different
    from Qop_macro (where arity is a variable parameter). This makes
    classes Qop_single and Qop_double unnecessary (thanks to Luciano S.
    for helpful discussions). This is a bit revolution!
  Reformulation of split_the_list() and swap_the_list(): the following
    functions from qlists are no more necessary: is_ordered(), 
    make_ordered() and reverse_and_recollect(). The relative order
    of formal addresses is now safe.
  get_name_by_opcode() has been replaced with type-info::name() from
    the RTTI subsystem (I didn't know about it).
  introduced Qop_phase_like class: QPhase and QCondPhase both derive
    from it and from Qop_fixed_arity. The new class contains the phase
    angle and related tools. This "fixes" get_parameters().
  Qop_macro was reformulated as a fully inlined class inheriting from
    Qop_fixed_arity with arity equal to one (dangerous?)

- Jun 11 2001 --> ver 0.2.5
  Stefano Bettelli
  Cleanup of constructors for Qop_single, Qop_double, Qop_macro. The
    two lists in a Qop_double (currently) don't have to have the same
    same segmentation, only the same total size.
  Qop_slice::split_the_list() patched to work with segments which are
    not direct. This is important for Qop_macros and Qop_doubles
  Added split_at() for lists (it's a wrapper for split())

- Jun 04 2001 --> ver 0.2.4
  Stefano Bettelli
  Add a can_join() method to segments (analogous to try_join(), but it
    can be run on constant segments for checking minimality).
  Move basic list checking and management from Qop_slice to the list
    class: is_overlapfree(), is_minimal(), is_ordered() and make_minimal().
    They were check_list_consistency() and check_list_order().

- Jun 02 2001 --> ver 0.2.3
  Stefano Bettelli
  Completed setup for macros (Qop_macro)
  Added support for QFourier (as a quantum macro)

- Jun 01 2001 --> ver 0.2.2
  Stefano Bettelli
  Added check_list_consistency() and check_list_order() in Qop_slice:
    these functions are needed for constructors for primitives which
    accept a non trivial link_list_type object.
  Implemented constructors as explained above.
  Moved logic for swapping and splitting from Qop_single to Qop_slice
    (the methods split_the_list() and swap_the_list())
  Completed setup for two qubit operations.
  Added support for conditional phase operations (QCondPhase)

- May 30 2001 --> ver 0.2.1
  Stefano Bettelli
  Added shift_lowest() to Qbit_segment class
  Added try_join_and_cleanup() and reverse_and_recollect() to
    the Qbit_list template class for a better Qop_single::swap()
  Rewritten Qop_single::swap() as a better function
  General improvements to the operator APIs (QPhase now works)

- May 29 2001 --> ver 0.2.0
  Stefano Bettelli
  print_address_manager_status() is a new shortcut.
  Changed all occurecies of "Q++ - An extension to C++ for ..."
    into "The Q language - A C++ extension for ..."
  Moved non inlined templetized functions of Qbit_list in qlist.cc,
    and used explicit template instantiation.
  Moved some interface typedefs into qinterface.h
  Added shift_ahead(), shift_back() and exception to Qbit_segment
  Added skeleton for quantum operations (Hadamard is ~ working).

- May 07 2001 --> ver 0.1.4
  Stefano Bettelli
  Redesign of the internal representation of Qbit_segments
    (they store the lowest and highest addresses now, as well as a
    boolean for orientation).
  Zero-sized segments are no more allowed.
  Rewritten Qbit_segment::try_join() method; it is very simple now!
  Written the recollection routine for both free and busy segments.

- May 05 2001 --> ver 0.1.3
  Stefano Bettelli
  Update of segment boundaries usage counts during the augmentation
    operation (need new update_boundary_usage() in address manager
    abstract interface for this to work) is implemented now.
  Moved recollection operations for both free and busy segments in
    the same routine (which is currently emtpy, need to redesign segments
    before ...).

- May 04 2001 --> ver 0.1.2
  Stefano Bettelli
  Added register augmentation (operator&=).
  Added counters for segment boundary usage. These additional data are
    needed in order to perform recollection of busy segment at register
    destruction and segment merging during register concatenation.
  Changed logic of qsegment::try_join() (it preserves the order now,
    but the code should be simplified and made faster!).
  Added segment recollection at register concatenation and augmentation.
  No correct handling of segment boundary usage counters during the
    augmentation operation yet ...
  Started Changelog

- Apr 20 2001 --> ver 0.1.1
  Stefano Bettelli
  "simplification" of the fragment() call syntax. Segfaulting bugs are
    solved (reversed segments were not handled correctly during extraction
    of a register range). The long pause was due to Easter and brainstorming
    about operator syntax.

- Mar 28 2001 --> ver 0.1
  Stefano Bettelli
  First distribution, most of quantum registers, nothing for quantum
    operators. The address manager is already there. Some bug during
    execution of the test program (it segfaults!). Started TODO list.
  Using the GPL license for distribution (it isn't public yet though).
  Submitted our paper "Toward an architecture for quantum computing".

- January 2001
  Stefano Bettelli --> Start major rewrite

- November 2000
  Stefano Bettelli --> First try
