mirror of
https://github.com/libquantum/libquantum.git
synced 2025-10-03 16:51:37 +00:00
updated libquantum 0.1.1 source files
This commit is contained in:
7
CHANGES
Normal file
7
CHANGES
Normal file
@@ -0,0 +1,7 @@
|
||||
libquantum 0.1.1:
|
||||
- Completed rotation gates (quantum_r_z)
|
||||
- Fixed a build problem with the demo program
|
||||
- Fixed some header inconsistencies
|
||||
|
||||
libquantum 0.1.0:
|
||||
initial public release
|
2
INSTALL
2
INSTALL
@@ -1,4 +1,4 @@
|
||||
libquantum 0.1.0 installation guide
|
||||
libquantum 0.1.1 installation guide
|
||||
-----------------------------------
|
||||
|
||||
Contents:
|
||||
|
13
Makefile.in
13
Makefile.in
@@ -37,7 +37,7 @@ top_builddir=.
|
||||
|
||||
MAJOR=0
|
||||
MINOR=1
|
||||
RELEASE=0
|
||||
RELEASE=1
|
||||
|
||||
# Tools needed to build libquantum
|
||||
|
||||
@@ -48,7 +48,7 @@ LIBTOOL=@LIBTOOL@
|
||||
# Flags passed to C compiler
|
||||
|
||||
CFLAGS=@CFLAGS@
|
||||
LDFLAGS=-rpath $(LIBDIR) -version-info 1:0:1
|
||||
LDFLAGS=-rpath $(LIBDIR) -version-info 1:1:1
|
||||
|
||||
# Dependencies
|
||||
|
||||
@@ -103,23 +103,24 @@ install: libquantum.la
|
||||
# Build a demo showing Shor's factoring algorithm
|
||||
|
||||
shor: libquantum.la shor.c Makefile
|
||||
$(LIBTOOL) $(CC) $(CFLAGS) -o shor shor.c -I./ -lquantum -lm
|
||||
$(LIBTOOL) $(CC) $(CFLAGS) -o shor shor.c -I./ -lquantum -static -lm
|
||||
|
||||
# Make everything neat and tidy
|
||||
|
||||
clean:
|
||||
-rm -rf .libs
|
||||
rm shor libquantum.la *.lo *.o
|
||||
-rm shor libquantum.la *.lo *.o
|
||||
|
||||
distclean:
|
||||
-rm -rf .libs
|
||||
rm shor *.lo *.o config.h quantum.h config.status config.log\
|
||||
-rm shor *.lo *.o config.h quantum.h config.status config.log\
|
||||
libquantum.la
|
||||
|
||||
dist:
|
||||
-rm quantum.h config.h
|
||||
mkdir libquantum-$(MAJOR).$(MINOR).$(RELEASE)
|
||||
cp *.c *.h quantum.h.in Makefile.in config.h.in configure COPYING\
|
||||
install-sh ltmain.sh config.sub config.guess README INSTALL\
|
||||
install-sh ltmain.sh config.sub config.guess README INSTALL CHANGES\
|
||||
libquantum-$(MAJOR).$(MINOR).$(RELEASE)
|
||||
tar czf libquantum-$(MAJOR).$(MINOR).$(RELEASE).tar.gz\
|
||||
libquantum-$(MAJOR).$(MINOR).$(RELEASE)/
|
||||
|
2
README
2
README
@@ -1,4 +1,4 @@
|
||||
libquantum 0.1.0 README file
|
||||
libquantum 0.1.1 README file
|
||||
----------------------------
|
||||
|
||||
libquantum is a C library for quantum computing. It provides quantum
|
||||
|
18
configure
vendored
18
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.57 for libquantum 0.1.0.
|
||||
# Generated by GNU Autoconf 2.57 for libquantum 0.1.1.
|
||||
#
|
||||
# Report bugs to <libquantum@enyo.de>.
|
||||
#
|
||||
@@ -427,8 +427,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='libquantum'
|
||||
PACKAGE_TARNAME='libquantum'
|
||||
PACKAGE_VERSION='0.1.0'
|
||||
PACKAGE_STRING='libquantum 0.1.0'
|
||||
PACKAGE_VERSION='0.1.1'
|
||||
PACKAGE_STRING='libquantum 0.1.1'
|
||||
PACKAGE_BUGREPORT='libquantum@enyo.de'
|
||||
|
||||
ac_unique_file="classic.c"
|
||||
@@ -938,7 +938,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures libquantum 0.1.0 to adapt to many kinds of systems.
|
||||
\`configure' configures libquantum 0.1.1 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@@ -999,7 +999,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of libquantum 0.1.0:";;
|
||||
short | recursive ) echo "Configuration of libquantum 0.1.1:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@@ -1092,7 +1092,7 @@ fi
|
||||
test -n "$ac_init_help" && exit 0
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
libquantum configure 0.1.0
|
||||
libquantum configure 0.1.1
|
||||
generated by GNU Autoconf 2.57
|
||||
|
||||
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
|
||||
@@ -1107,7 +1107,7 @@ cat >&5 <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by libquantum $as_me 0.1.0, which was
|
||||
It was created by libquantum $as_me 0.1.1, which was
|
||||
generated by GNU Autoconf 2.57. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@@ -8620,7 +8620,7 @@ _ASBOX
|
||||
} >&5
|
||||
cat >&5 <<_CSEOF
|
||||
|
||||
This file was extended by libquantum $as_me 0.1.0, which was
|
||||
This file was extended by libquantum $as_me 0.1.1, which was
|
||||
generated by GNU Autoconf 2.57. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@@ -8680,7 +8680,7 @@ _ACEOF
|
||||
|
||||
cat >>$CONFIG_STATUS <<_ACEOF
|
||||
ac_cs_version="\\
|
||||
libquantum config.status 0.1.0
|
||||
libquantum config.status 0.1.1
|
||||
configured by $0, generated by GNU Autoconf 2.57,
|
||||
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
|
||||
|
||||
|
23
expn.c
23
expn.c
@@ -1,3 +1,26 @@
|
||||
/* expn.c: x^a mod n
|
||||
|
||||
Copyright 2003 Bjoern Butscher, Hendrik Weimer
|
||||
|
||||
This file is part of libquantum
|
||||
|
||||
libquantum is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published
|
||||
by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
libquantum is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with libquantum; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA
|
||||
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
26
expn.h
26
expn.h
@@ -1,9 +1,33 @@
|
||||
/* expn.h: Declarations for expn.c
|
||||
|
||||
Copyright 2003 Bjoern Butscher, Hendrik Weimer
|
||||
|
||||
This file is part of libquantum
|
||||
|
||||
libquantum is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published
|
||||
by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
libquantum is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with libquantum; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __EXPN_H
|
||||
|
||||
#define __EXPN_H
|
||||
|
||||
#include "qureg.h"
|
||||
|
||||
extern void quantum_exp_mod_n(int, int, int, int, quantum_reg *);
|
||||
extern void quantum_exp_mod_n(int N, int x, int width_input, int width,
|
||||
quantum_reg *reg);
|
||||
|
||||
#endif
|
||||
|
22
gates.c
22
gates.c
@@ -404,8 +404,8 @@ quantum_r_x(int target, float gamma, quantum_reg *reg)
|
||||
|
||||
m = quantum_new_matrix(2, 2);
|
||||
|
||||
m.t[0] = cos(gamma / 2); m.t[1] = IMAGINARY * sin(gamma / 2);
|
||||
m.t[2] = IMAGINARY * sin(gamma / 2); m.t[3] = cos(gamma / 2);
|
||||
m.t[0] = cos(gamma / 2); m.t[1] = -IMAGINARY * sin(gamma / 2);
|
||||
m.t[2] = -IMAGINARY * sin(gamma / 2); m.t[3] = cos(gamma / 2);
|
||||
|
||||
quantum_gate1(target, m, reg);
|
||||
|
||||
@@ -431,6 +431,24 @@ quantum_r_y(int target, float gamma, quantum_reg *reg)
|
||||
|
||||
}
|
||||
|
||||
/* Apply a rotation about the z-axis by the angle GAMMA */
|
||||
|
||||
void
|
||||
quantum_r_z(int target, float gamma, quantum_reg *reg)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<reg->size; i++)
|
||||
{
|
||||
if(reg->node[i].state & ((MAX_UNSIGNED) 1 << target))
|
||||
reg->node[i].amplitude *= quantum_cexp(gamma/2);
|
||||
else
|
||||
reg->node[i].amplitude *= quantum_cexp(-gamma/2);
|
||||
}
|
||||
|
||||
quantum_decohere(reg);
|
||||
}
|
||||
|
||||
/* Apply a phase kick by the angle GAMMA */
|
||||
|
||||
void
|
||||
|
13
gates.h
13
gates.h
@@ -41,14 +41,15 @@ extern void quantum_swaptheleads_omuln_controlled(int control, int width,
|
||||
|
||||
extern void quantum_gate1(int target, quantum_matrix m, quantum_reg *reg);
|
||||
|
||||
extern void quantum_r_x(int a, float gamma, quantum_reg *reg);
|
||||
extern void quantum_r_y(int a, float gamma, quantum_reg *reg);
|
||||
extern void quantum_r_x(int target, float gamma, quantum_reg *reg);
|
||||
extern void quantum_r_y(int target, float gamma, quantum_reg *reg);
|
||||
extern void quantum_r_z(int target, float gamma, quantum_reg *reg);
|
||||
|
||||
extern void quantum_hadamard(int a, quantum_reg *reg);
|
||||
extern void quantum_walsh(int a, quantum_reg *reg);
|
||||
extern void quantum_hadamard(int target, quantum_reg *reg);
|
||||
extern void quantum_walsh(int target, quantum_reg *reg);
|
||||
|
||||
extern void quantum_phase_kick(int a, float gamma, quantum_reg *reg);
|
||||
extern void quantum_cond_phase(int a, int b, quantum_reg *reg);
|
||||
extern void quantum_phase_kick(int target, float gamma, quantum_reg *reg);
|
||||
extern void quantum_cond_phase(int control, int target, quantum_reg *reg);
|
||||
|
||||
extern int quantum_gate_counter(int inc);
|
||||
|
||||
|
24
oaddn.h
24
oaddn.h
@@ -1,3 +1,26 @@
|
||||
/* oaddn.h: Declarations for oaddn.c
|
||||
|
||||
Copyright 2003 Bjoern Butscher, Hendrik Weimer
|
||||
|
||||
This file is part of libquantum
|
||||
|
||||
libquantum is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published
|
||||
by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
libquantum is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with libquantum; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __OADDN_H
|
||||
|
||||
#define __OADDN_H
|
||||
@@ -23,4 +46,5 @@ extern void addn(int,int,int, quantum_reg *);
|
||||
extern void addn_inv(int, int, int, quantum_reg *);
|
||||
|
||||
extern void add_mod_n(int, int, int, quantum_reg *);
|
||||
|
||||
#endif
|
||||
|
23
omuln.c
23
omuln.c
@@ -1,3 +1,26 @@
|
||||
/* omuln.c: Multiplication modulo an integer N
|
||||
|
||||
Copyright 2003 Bjoern Butscher, Hendrik Weimer
|
||||
|
||||
This file is part of libquantum
|
||||
|
||||
libquantum is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published
|
||||
by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
libquantum is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with libquantum; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA
|
||||
|
||||
*/
|
||||
|
||||
#include "defs.h"
|
||||
#include "matrix.h"
|
||||
#include "gates.h"
|
||||
|
23
omuln.h
23
omuln.h
@@ -1,3 +1,26 @@
|
||||
/* omuln.h: Declarations for omuln.c
|
||||
|
||||
Copyright 2003 Bjoern Butscher, Hendrik Weimer
|
||||
|
||||
This file is part of libquantum
|
||||
|
||||
libquantum is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published
|
||||
by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
libquantum is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with libquantum; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __OMULN_H
|
||||
|
||||
#define __OMULN_H
|
||||
|
33
quantum.h.in
33
quantum.h.in
@@ -74,28 +74,31 @@ extern void quantum_delete_qureg(quantum_reg *reg);
|
||||
extern void quantum_print_qureg(quantum_reg reg);
|
||||
extern void quantum_addscratch(int bits, quantum_reg *reg);
|
||||
|
||||
extern void quantum_cnot(int, int, quantum_reg *);
|
||||
extern void quantum_toffoli(int, int, int, quantum_reg *);
|
||||
extern void quantum_X_gate(int, quantum_reg *);
|
||||
extern void quantum_Y_gate(int a, quantum_reg *reg);
|
||||
extern void quantum_Z_gate(int a, quantum_reg *reg);
|
||||
extern void quantum_gate1(quantum_matrix m, int a, quantum_reg *reg);
|
||||
extern void quantum_r_x(int a, float gamma, quantum_reg *reg);
|
||||
extern void quantum_r_y(int a, float gamma, quantum_reg *reg);
|
||||
extern void quantum_phase_kick(int a, float gamma, quantum_reg *reg);
|
||||
extern void quantum_hadamard(int a, quantum_reg *reg);
|
||||
extern void quantum_walsh(int a, quantum_reg *reg);
|
||||
extern void quantum_cond_phase(int a, int b, quantum_reg *reg);
|
||||
extern void quantum_cnot(int control, int target, quantum_reg *reg);
|
||||
extern void quantum_toffoli(int control1, int control2, int target,
|
||||
quantum_reg *reg);
|
||||
extern void quantum_sigma_x(int target, quantum_reg *reg);
|
||||
extern void quantum_sigma_y(int target, quantum_reg *reg);
|
||||
extern void quantum_sigma_z(int target, quantum_reg *reg);
|
||||
extern void quantum_gate1(int target, quantum_matrix m, quantum_reg *reg);
|
||||
extern void quantum_r_x(int target, float gamma, quantum_reg *reg);
|
||||
extern void quantum_r_y(int target, float gamma, quantum_reg *reg);
|
||||
extern void quantum_r_z(int target, float gamma, quantum_reg *reg);
|
||||
extern void quantum_phase_kick(int target, float gamma, quantum_reg *reg);
|
||||
extern void quantum_hadamard(int target, quantum_reg *reg);
|
||||
extern void quantum_walsh(int target, quantum_reg *reg);
|
||||
extern void quantum_cond_phase(int control, int target, quantum_reg *reg);
|
||||
extern int quantum_gate_counter(int inc);
|
||||
|
||||
extern void quantum_qft(int width, quantum_reg *reg);
|
||||
|
||||
extern void quantum_exp_mod_n(int, int, int, int, quantum_reg *);
|
||||
extern void quantum_exp_mod_n(int N, int x, int width_input, int width,
|
||||
quantum_reg *reg);
|
||||
|
||||
extern MAX_UNSIGNED quantum_measure(quantum_reg reg);
|
||||
extern int quantum_bmeasure(int pos, quantum_reg *reg);
|
||||
|
||||
extern quantum_matrix quantum_new_matrix(int ,int );
|
||||
extern quantum_matrix quantum_new_matrix(int cols, int rows);
|
||||
extern void quantum_delete_matrix(quantum_matrix *m);
|
||||
|
||||
extern int quantum_ipow(int a, int b);
|
||||
@@ -109,8 +112,6 @@ extern float quantum_prob(COMPLEX_FLOAT a);
|
||||
extern void quantum_set_decoherence(float lambda);
|
||||
extern void quantum_decohere(quantum_reg *reg);
|
||||
|
||||
extern void quantum_add_hash(MAX_UNSIGNED a, int pos, quantum_reg *reg);
|
||||
|
||||
extern quantum_reg quantum_matrix2qureg(quantum_matrix *m, int width);
|
||||
extern quantum_matrix quantum_qureg2matrix(quantum_reg reg);
|
||||
|
||||
|
Reference in New Issue
Block a user