4 Commits
v1.2 ... v1.4

Author SHA1 Message Date
469bdc8071 Support MPFR floats in numkondo
Remove '-D' option (error tolerance) in numkondo
2015-10-07 13:00:23 +00:00
e7aa6859f0 Add '-C' flag to meantools-derive
Fix memory leak in meantools-derive
2015-09-21 10:20:35 +00:00
f13eacbc8e Support for non-commuting fields 2015-07-22 13:55:29 +00:00
3b591888b5 Fix a sign error in the definition of A and B in kondo_preprocess
The operators A and B introduced by kondo_preprocess had the wrong sign.
This bug does not affect the beta function for the hierarchical Kondo model.
2015-07-14 13:37:40 +00:00
43 changed files with 1278 additions and 265 deletions

14
Changelog Normal file
View File

@ -0,0 +1,14 @@
1.4:
* Support MPFR floats in numkondo.
* Remove '-D' option (error tolerance) in numkondo.
1.3.1:
* '-C' flag in meantools-derive:
allows to pipe the output of meantools-derive directly into numkondo.
* Fixed memory leak in meantools-derive.

View File

@ -6,6 +6,8 @@
* meankondo should work on any POSIX compliant system, such as GNU/Linux or OSX. * meankondo should work on any POSIX compliant system, such as GNU/Linux or OSX.
* meankondo is linked against the GNU MPFR and GNU GMP libraries.
* Compiling: * Compiling:
Run Run
make make

165
LGPL3 Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -18,7 +18,7 @@
# if static=1 then link libkondo statically but other libraries dynamically # if static=1 then link libkondo statically but other libraries dynamically
STATIC=1 STATIC=1
VERSION=1.2 VERSION=1.4
# products of the compilation # products of the compilation
PROJECT_BINS= meankondo numkondo meantools kondo_preprocess meantools-convert PROJECT_BINS= meankondo numkondo meantools kondo_preprocess meantools-convert
@ -62,9 +62,9 @@ SRCDIR=./src
OBJDIR=./objs OBJDIR=./objs
# objects # objects
LIBKONDO_OBJS = $(addprefix $(OBJDIR)/,array.o cli_parser.o coefficient.o fields.o grouped_polynomial.o idtable.o istring.o number.o parse_file.o polynomial.o rational_float.o rational_int.o rcc.o tools.o) LIBKONDO_OBJS = $(addprefix $(OBJDIR)/,array.o cli_parser.o coefficient.o fields.o grouped_polynomial.o idtable.o istring.o number.o parse_file.o polynomial.o rational_float.o rational_int.o rcc.o rcc_mpfr.o tools.o)
MEANKONDO_OBJS = $(addprefix $(OBJDIR)/,meankondo.o mean.o) MEANKONDO_OBJS = $(addprefix $(OBJDIR)/,meankondo.o mean.o)
NUMKONDO_OBJS = $(addprefix $(OBJDIR)/,numkondo.o flow.o) NUMKONDO_OBJS = $(addprefix $(OBJDIR)/,numkondo.o flow.o flow_mpfr.o)
MEANTOOLS_OBJS = $(addprefix $(OBJDIR)/,meantools.o meantools_exp.o meantools_deriv.o meantools_eval.o) MEANTOOLS_OBJS = $(addprefix $(OBJDIR)/,meantools.o meantools_exp.o meantools_deriv.o meantools_eval.o)
KONDO_PP_OBJS = $(addprefix $(OBJDIR)/,kondo_preprocess.o kondo.o) KONDO_PP_OBJS = $(addprefix $(OBJDIR)/,kondo_preprocess.o kondo.o)
@ -78,8 +78,8 @@ XTRA_LIBS=
ifeq ($(STATIC),1) ifeq ($(STATIC),1)
# compile libkondo.a # compile libkondo.a
PREREQ=static PREREQ=static
# libkondo is linked against libm # libkondo is linked against libm, libmpfr and libgmp
XTRA_LIBS=-lm XTRA_LIBS=-lm -lmpfr -lgmp
# link binaries using the static library # link binaries using the static library
LIBKONDO_FLAG=-l:libkondo.a LIBKONDO_FLAG=-l:libkondo.a
# install static lib # install static lib
@ -87,8 +87,8 @@ ifeq ($(STATIC),1)
else ifeq ($(STATIC),2) else ifeq ($(STATIC),2)
# compile libkondo.a # compile libkondo.a
PREREQ=static PREREQ=static
# libkondo is linked against libm # libkondo is linked against libm, libmpfr and libgmp
XTRA_LIBS=-lm XTRA_LIBS=-lm -lmpfr -lgmp
# link binaries statically # link binaries statically
override LDFLAGS += -static override LDFLAGS += -static
INSTALLLIB=install-static INSTALLLIB=install-static
@ -119,17 +119,17 @@ libkondo.a: $(LIBKONDO_OBJS)
$(AR) -rc $(BUILDDIR)/lib/$@ $^ $(AR) -rc $(BUILDDIR)/lib/$@ $^
libkondo.so.$(VERSION): $(LIBKONDO_OBJS) libkondo.so.$(VERSION): $(LIBKONDO_OBJS)
$(LD) -shared -lm $(LDFLAGS) -o $(BUILDDIR)/lib/$@ $^ $(LD) -shared -lm -lmpfr -lgmp $(LDFLAGS) -o $(BUILDDIR)/lib/$@ $^
ln -fs ./libkondo.so.$(VERSION) $(BUILDDIR)/lib/libkondo.so ln -fs ./libkondo.so.$(VERSION) $(BUILDDIR)/lib/libkondo.so
meankondo: $(MEANKONDO_OBJS) meankondo: $(MEANKONDO_OBJS)
$(LD) -L$(BUILDDIR)/lib $(LDFLAGS) -o $(BUILDDIR)/bin/$@ $^ $(LIBKONDO_FLAG) -lpthread $(XTRA_LIBS) $(LD) -L$(BUILDDIR)/lib $(LDFLAGS) -o $(BUILDDIR)/bin/$@ $^ $(LIBKONDO_FLAG) -lpthread $(XTRA_LIBS)
numkondo: $(NUMKONDO_OBJS) numkondo: $(NUMKONDO_OBJS)
$(LD) -L$(BUILDDIR)/lib $(LDFLAGS) -o $(BUILDDIR)/bin/$@ $^ $(LIBKONDO_FLAG) -lm $(XTRA_LIBS) $(LD) -L$(BUILDDIR)/lib $(LDFLAGS) -o $(BUILDDIR)/bin/$@ $^ $(LIBKONDO_FLAG) -lm -lmpfr -lgmp $(XTRA_LIBS)
meantools: $(MEANTOOLS_OBJS) meantools: $(MEANTOOLS_OBJS)
$(LD) -L$(BUILDDIR)/lib $(LDFLAGS) -o $(BUILDDIR)/bin/$@ $^ $(LIBKONDO_FLAG) $(XTRA_LIBS) $(LD) -L$(BUILDDIR)/lib $(LDFLAGS) -o $(BUILDDIR)/bin/$@ $^ $(LIBKONDO_FLAG) -lmpfr -lgmp $(XTRA_LIBS)
meantools-convert: meantools-convert:
cp scripts/meantools-convert $(BUILDDIR)/bin/ cp scripts/meantools-convert $(BUILDDIR)/bin/

13
NOTICE
View File

@ -1,2 +1,15 @@
meankondo meankondo
Copyright 2015 Ian Jauslin Copyright 2015 Ian Jauslin
The numerical values can be represented as multi-precision floats using
the GNU MPFR library, which is licensed under the GNU Lesser General
Public License (LGPL) version 3 (see LGPL3 for a copy of the license).
See
http://www.mpfr.org/
for details.
The GNU MPFR library is based on the GNU GMP library, which is licensed
under the GNU Lesser General Public License (LGPL) version 3 (see LGPL3
for a copy of the license). See
http://www.gmplib.org/
for details.

View File

@ -69,10 +69,10 @@
</head> </head>
<body> <body>
<h1 style="margin-bottom:50pt;">meankondo <span style="margin-left:10pt;font-size:18pt">v1.2</span></h1> <h1 style="margin-bottom:50pt;">meankondo <span style="margin-left:10pt;font-size:18pt">v1.4</span></h1>
<p> <p>
This is the official documentation for <b>meankondo</b>, version 1.2. The aim of this document is not to give a technical description of how to use the various programs bundled with <b>meankondo</b>, nor is it to explain where hierarchical models come from and what their meaning is, but rather a conceptual overview of how <b>meankondo</b> approaches the computation of flow equations, and how its programs can be made to interact with one another to compute various quantities. For a more technical description, see the man pages included with the <b>meankondo</b> source code. For a more theoretical discussion of Fermionic hierarchical models, see [G.Benfatto, G.Gallavotti, I.Jauslin, 2015]. This is the official documentation for <b>meankondo</b>, version 1.4. The aim of this document is not to give a technical description of how to use the various programs bundled with <b>meankondo</b>, nor is it to explain where hierarchical models come from and what their meaning is, but rather a conceptual overview of how <b>meankondo</b> approaches the computation of flow equations, and how its programs can be made to interact with one another to compute various quantities. For a more technical description, see the man pages included with the <b>meankondo</b> source code. For a more theoretical discussion of Fermionic hierarchical models, see <a href="http://ian.jauslin.org/publications/15bgj">[G.Benfatto, G.Gallavotti, I.Jauslin, 2015]</a>.
</p> </p>
<h2 style="margin-top:50pt;">Table of contents</h2> <h2 style="margin-top:50pt;">Table of contents</h2>
@ -150,7 +150,7 @@
<li><b>external</b>: which are organized in pairs, and are denoted by \((\Psi_i^+,\Psi_i^-)\) for \(i\in\{1,\cdots,E\}\). <li><b>external</b>: which are organized in pairs, and are denoted by \((\Psi_i^+,\Psi_i^-)\) for \(i\in\{1,\cdots,E\}\).
<li><b>super-external</b>: which denoted by \(H_i\) for \(i\in\{1,\cdots,X\}\) (the only difference with external fields is that super-external fields are not in pairs, which is a seemingly innocuous difference; but super-external fields are meant to be used for different purposes as external fields (see <a href="#flow_equation_definition">Definition</a> below)). <li><b>super-external</b>: which denoted by \(H_i\) for \(i\in\{1,\cdots,X\}\) (the only difference with external fields is that super-external fields are not in pairs, which is a seemingly innocuous difference; but super-external fields are meant to be used for different purposes as external fields (see <a href="#flow_equation_definition">Definition</a> below)).
</ul> </ul>
The fields are used as a basis for a complex algebra, so that we can take products and linear combinations of fields (in other words, the concept of <i>polynomials over the fields</i> is well defined). Some of the fields (<i>Fermions</i>) anti-commute with each other (two fields \(a\) and \(b\) are said to anti-commute if \(ab\equiv-ba\)), and the rest (<i>Bosons</i>) commute. Which fields are Fermions and which are Bosons is specified in the <code>#!fields</code> entry in the configuration file. <b>(Warning: As of version 1.2, all internal fields must be Fermions.)</b> The fields are used as a basis for a complex algebra, so that we can take products and linear combinations of fields (in other words, the concept of <i>polynomials over the fields</i> is well defined). Some of the fields (<i>Fermions</i>) anti-commute with each other (two fields \(a\) and \(b\) are said to anti-commute if \(ab\equiv-ba\)), and the rest (<i>Bosons</i>) commute. Which fields are Fermions and which are Bosons is specified in the <code>#!fields</code> entry in the configuration file. <b>(Warning: As of version 1.4, all internal fields must be Fermions.)</b>
</p> </p>
<p> <p>
In the configuration file of the <b>meankondo</b> program, the fields are specified in the <code>#!fields</code> entry. In the configuration file of the <b>meankondo</b> program, the fields are specified in the <code>#!fields</code> entry.
@ -286,7 +286,15 @@
Numerical evaluations are not exact. The numbers manipulated <b>meankondo</b> are double precision floating point numbers ("doubles" for short), which are also system-dependent. On systems that follow the IEEE 754 standard, doubles have a precision of 53 bits, which implies they are accurate to 15 decimal places; and the absolute value of doubles is bounded above by \(2^{1024}-2^{1024-53}\) (that is the number whose binary expansion has \(1023\) digits and whose \(53\) left-most digits are \(1\) whereas the others are \(0\)) and below by \(2^{-1022}\). Numerical evaluations are not exact. The numbers manipulated <b>meankondo</b> are double precision floating point numbers ("doubles" for short), which are also system-dependent. On systems that follow the IEEE 754 standard, doubles have a precision of 53 bits, which implies they are accurate to 15 decimal places; and the absolute value of doubles is bounded above by \(2^{1024}-2^{1024-53}\) (that is the number whose binary expansion has \(1023\) digits and whose \(53\) left-most digits are \(1\) whereas the others are \(0\)) and below by \(2^{-1022}\).
</p>--> </p>-->
<p> <p>
Numerical evaluations are not exact. The numbers manipulated <b>meankondo</b> are "long doubles", which, when compiled for x86 processors, have a precision of 64 bits, which implies they are accurate to 19 decimal places; and the absolute value of doubles is bounded above by \(2^{16384}-2^{16384-64}\) (that is the number whose binary expansion has \(16383\) digits and whose \(64\) left-most digits are \(1\) whereas the others are \(0\)) and below by \(2^{-16382}\). Numerical evaluations are not exact. The numbers manipulated <b>meankondo</b> are either "long doubles" or "MPFR floats", depending on the options passed to <b>numkondo</b> (see <code>man numkondo</code>).
<ul>
<li>
Long doubles: when compiled for x86 processors, have a precision of 64 bits, which implies they are accurate to 19 decimal places; and the absolute value of doubles is bounded above by \(2^{16384}-2^{16384-64}\) (that is the number whose binary expansion has \(16383\) digits and whose \(64\) left-most digits are \(1\) whereas the others are \(0\)) and below by \(2^{-16382}\).
</li>
<li>
MPFR floats: the precision and size of the exponent can be specified as options on the command line. The maximal precision and maximal value of the exponent are, on 64 bit systems, \(2^{63}\) bits and \(2^{62}\) respectively.
</li>
</ul>
</p> </p>

View File

@ -1,5 +1,5 @@
.Dd $Mdocdate: April 14 2015 $ .Dd $Mdocdate: September 22 2015 $
.Dt kondo_preprocess 1.2 .Dt kondo_preprocess 1.4
.Os .Os
.Sh NAME .Sh NAME
.Nm kondo_preprocess .Nm kondo_preprocess
@ -94,6 +94,30 @@ defines external fields for A and B, denoted by a and b. They can be used as fie
.D1 <axb.h> .D1 <axb.h>
.Pp .Pp
.It .It
Scalar products of A's and B's may also be specified using the '<#.#>' syntax:
.D1 <An.An>
.D1 <Bn.Bn>
.D1 <An.Bn>
.D1 <An.h>
.D1 <Bn.h>
.Pp
The difference between '[f #.#]' and '<#.#>' is that the former corresponds to a '#!symbols' entry whereas the latter is replaced by its corresponding polynomial when
.Nm
reads it (see
.Sx meankondo Ns (1)).
.Pp
.It
A vector 't=(t1,t2,t3)' of Pauli matrices (satisfying the Pauli commutation relations [ti,tj]=\\delta_{i,j}1+\\epsilon_{i,j,k}tk) is introduced as a non-commuting object. It can be used in scalar producs:
.D1 <An.t>
.D1 <Bn.t>
.D1 <t.h>
.D1 <a.t>
.D1 <b.t>
.Pp
Note that the '<#,#>' must be used since these scalar products do not commute whereas '#!symbols' entries must commute (see
.Sx meankondo Ns (1)).
.Pp
.It
Furthermore, in order to simplify writing products of polynomials over each box index, if the polynomial contains a '%', then Furthermore, in order to simplify writing products of polynomials over each box index, if the polynomial contains a '%', then
.Nm .Nm
multiplies the polynomial by itself as many times as there are boxes (2^dimension times), replacing '%' with the appropriate box index. For example, if dimension=1 multiplies the polynomial by itself as many times as there are boxes (2^dimension times), replacing '%' with the appropriate box index. For example, if dimension=1
@ -118,6 +142,9 @@ in which the polynomial can use the fields
.D1 <a.h> .D1 <a.h>
.D1 <b.h> .D1 <b.h>
.D1 <axb.h> .D1 <axb.h>
.D1 <t.h>
.D1 <a.t>
.D1 <b.t>
defined above. defined above.
.Pp .Pp
Example: Example:

View File

@ -1,5 +1,5 @@
.Dd $Mdocdate: April 13 2015 $ .Dd $Mdocdate: September 22 2015 $
.Dt meankondo 1.2 .Dt meankondo 1.4
.Os .Os
.Sh NAME .Sh NAME
.Nm meankondo .Nm meankondo
@ -44,7 +44,7 @@ as well as the following pre-processors, which generate configuration files for
.It Fl t Ar threads .It Fl t Ar threads
The number of threads to use for the computation. The number of threads to use for the computation.
.It Fl C .It Fl C
Format the ouptput so it can be piped to Format the output so it can be piped to
.Sy numkondo , .Sy numkondo ,
that is, instead of printing the flow equation, print a full configuration file containing the flow equation as well as all the other entries of the configuration file that do not pertain to the computation of the flow equation. that is, instead of printing the flow equation, print a full configuration file containing the flow equation as well as all the other entries of the configuration file that do not pertain to the computation of the flow equation.
.It Fl v .It Fl v
@ -67,7 +67,7 @@ recognizes the following entries (unless explicitly mentioned, the entries below
.It Sy #!fields .It Sy #!fields
A list of the fields of the model. A list of the fields of the model.
.Pp .Pp
The fields entry contains 4 lines which start with 'i:', 'x:', 'h:' and 'f:'. Each of these is followed by a ',' separated list of field indices, which are positive integers. The fields entry contains 5 lines which start with 'i:', 'x:', 'h:', 'f:' and 'a:'. Each of these is followed by a ',' separated list of field indices, which are positive integers.
.Bl -bullet .Bl -bullet
.It .It
The indices following 'i' correspond to internal fields, which are integrated out using the Wick rule and the propagator provided in the '#!propagator' entry. Each internal field is associated a conjugate field, whose index is the opposite of the field's index (e.g. 'i:101' defines a field whose index is -101) The indices following 'i' correspond to internal fields, which are integrated out using the Wick rule and the propagator provided in the '#!propagator' entry. Each internal field is associated a conjugate field, whose index is the opposite of the field's index (e.g. 'i:101' defines a field whose index is -101)
@ -77,6 +77,10 @@ The indices following 'x' correspond to external fields that are associated conj
The indices following 'h' correspond to external fields that are not associated a conjugate field. External indices may not appear as internal indices. The indices following 'h' correspond to external fields that are not associated a conjugate field. External indices may not appear as internal indices.
.It .It
The 'f' line specifies which of the internal and external indices are Fermions, i.e. which fields anti-commute. The fields appearing in the 'f' line should also either appear in the 'i' or 'x' line. WARNING: for the moment, only cases in which all of the internal fields are Fermions are supported. The 'f' line specifies which of the internal and external indices are Fermions, i.e. which fields anti-commute. The fields appearing in the 'f' line should also either appear in the 'i' or 'x' line. WARNING: for the moment, only cases in which all of the internal fields are Fermions are supported.
.It
The 'a' line specifies a list of external fields listed in the 'h' entry that do not commute with each other. Specifying fields in this entry will prevent
.Nm
from sorting them. These fields may not be in the 'i', 'x' or 'f' entries. This entry can be used to treat cases in which the coefficients of the input polynomial are operators that do not commute. Their commutation relations may be specified in the '#!identities' entries (see below).
.El .El
.Pp .Pp
.Em Line breaks are not ignored in this entry. .Em Line breaks are not ignored in this entry.
@ -84,8 +88,9 @@ The 'f' line specifies which of the internal and external indices are Fermions,
Example: Example:
.D1 i:101,102,201,202 .D1 i:101,102,201,202
.D1 x:100,200 .D1 x:100,200
.D1 h:301,302,303 .D1 h:301,302,303,401,402,403
.D1 f:100,101,102 .D1 f:100,101,102
.D1 a:401,402,403
.It Sy #!propagator .It Sy #!propagator
The propagator of the model. The propagator of the model.
.Pp .Pp
@ -98,31 +103,41 @@ just as easily as propagators with symbolic entries. Such an entry means that
.Pp .Pp
Example: Example:
.D1 101;102: 1 , 102;101: -1 , 201;202: s{-1} + (-1)[l10] , 202;201: (-1)s{-1} + [l10] .D1 101;102: 1 , 102;101: -1 , 201;202: s{-1} + (-1)[l10] , 202;201: (-1)s{-1} + [l10]
.It Sy #!symbols
Symbolic variables used as shortcuts for more complicated expressions (optional entry).
.Pp
In order to simplify long expressions, symbolic variables can be defined in this entry. Each variable is assigned an index, which is a positive integer that must be different from any of the internel and external indices defined in the '#!fields' entry.
.Pp
The symbols entry is a ',' separated list, whose elements are of the form
.D1 index= polynomial
where index is the index of the variable and polynomial is the expression it stands for (see the POLYNOMIALS section below for information on how to format polynomials). Note that polynomial can contain other symbolic variables. There is no safeguard against self-referencing definitions that may cause infinite loops.
.Pp
Example:
.D1 1001= (-1)[f-100][f100] + (-1)[f-101][f101] , 2001=[f-100][f100] + [f-201][f201]
.Pp
This entry is optional.
.Pp .Pp
.It Sy #!identities .It Sy #!identities
Identities satisfied by some of the fields (optional entry). Identities satisfied by some of the fields (optional entry).
.Pp .Pp
In some cases, some of the quantities involved in a model will satisfy an identity (e.g. a vector may be of unit-norm), which should simplified out from the flow equation. In some cases, some of the quantities involved in a model will satisfy an identity (e.g. a vector may be of unit-norm, or non-commuting objects may satisfy non-trivial commutation relations), which should be simplified out from the flow equation.
.Pp .Pp
The identities entry is a ',' separated list, whose elements are of the form The identities entry is a ',' separated list, whose elements are of the form
.D1 monomial=polynomial .D1 monomial=polynomial
where monomial represents the left side of the identity and is a sequence of field indices of the form '[f index1][f index2]...' and polynomial represents the right side of the identity (see the POLYNOMIALS section below for information on how to format polynomials). where monomial represents the left side of the identity and is a sequence of field indices of the form '[f index1][f index2]...' and polynomial represents the right side of the identity (see the POLYNOMIALS section below for information on how to format polynomials).
.Pp .Pp
Example: Example:
.D1 [f301][f301]=(1)+(-1)[f302][f302]+(-1)[f303][f303] .D1 [f301][f301]=(1)+(-1)[f302][f302]+(-1)[f303][f303],
.D1 [f401][f401]=(1),
.D1 [f401][f402]=(s{-1})[f403],
.D1 [f401][f403]=((-1)s{-1})[f402]
.Pp
This entry is optional.
.Pp
.It Sy #!symbols
Symbolic variables used as shortcuts for more complicated expressions (optional entry).
.Pp
In order to simplify long expressions, symbolic variables can be defined in this entry. Each variable is assigned an index, which is a positive integer that must be different from any of the internal and external indices defined in the '#!fields' entry.
.Pp
Seemingly similar functionality can be achieved using an '#!identity' entry (see above), though symbols are handled differently from identities. Indeed, while identities are simplified out of the polynomials as soon as they occur, symbols are only resolved when
.Nm
computes the mean of the input polynomial. Using symbols can thereby be a lot faster than using identities. However, as is mentioned below, symbols must commute with each other and all other fields, whereas identities can be made to be fermionic or non-commuting.
.Pp
The symbols entry is a ',' separated list, whose elements are of the form
.D1 index= polynomial
where index is the index of the variable and polynomial is the expression it stands for (see the POLYNOMIALS section below for information on how to format polynomials). Note that polynomial can contain other symbolic variables. There is no safeguard against self-referencing definitions that may cause infinite loops.
.Pp
WARNING: Symbols are assumed to commute with each other and all other Fermions. They should therefore not represent quantities that do not commute (e.g. odd monomials of fermions or non-commuting objects specified in the 'a:' entry in the '#!fields' entry).
.Pp
Example:
.D1 1001= (-1)[f-100][f100] + (-1)[f-101][f101] , 2001=[f-100][f100] + [f-201][f201]
.Pp .Pp
This entry is optional. This entry is optional.
.Pp .Pp
@ -157,16 +172,16 @@ computes the mean of a monomial containing elements of different groups, it fact
.Nm .Nm
does not repeatedly try to pair independent fields. does not repeatedly try to pair independent fields.
.Pp .Pp
WARNING:
.Nm
assumes that the symbols and fields in each group are independent but does not check that they are. If symbols or fields that are not independent are put in different groups, or if some are in a group while others are not in any group, then the resulting flow equation may be wrong.
.Pp
The groups entry is a list of collections of fields or symbols of the following form The groups entry is a list of collections of fields or symbols of the following form
.D1 (index1,index2,...) .D1 (index1,index2,...)
.Pp .Pp
Example: Example:
.D1 (1001,1002) (2001,2002) .D1 (1001,1002) (2001,2002)
.Pp .Pp
.Em Warning:
.Nm
does not check that the fields in different groups are truly independent, so cases in which fields in different group have a non-vanishing propagator entry may give unexpected results.
.Pp
This entry is optional. This entry is optional.
.El .El
.Pp .Pp

View File

@ -1,5 +1,5 @@
.Dd $Mdocdate: June 12 2015 $ .Dd $Mdocdate: September 22 2015 $
.Dt meantools-convert 1.2 .Dt meantools-convert 1.4
.Os .Os
.Sh NAME .Sh NAME
.Nm meantools-convert .Nm meantools-convert

View File

@ -1,5 +1,5 @@
.Dd $Mdocdate: April 14 2015 $ .Dd $Mdocdate: September 22 2015 $
.Dt meantools 1.2 .Dt meantools 1.4
.Os .Os
.Sh NAME .Sh NAME
.Nm meantools .Nm meantools
@ -13,11 +13,14 @@
.Sy derive .Sy derive
.Op Fl d Ar nderivs .Op Fl d Ar nderivs
.Op Fl V Ar variables .Op Fl V Ar variables
.Op Fl C
.Op Ar config_file .Op Ar config_file
.Pp .Pp
.Nm .Nm
.Sy eval .Sy eval
.Op Fl R Ar values .Op Fl R Ar values
.Op Fl P Ar precision
.Op Fl E Ar max_exponent
.Op Ar config_file .Op Ar config_file
.Pp .Pp
.Sh DESCRIPTION .Sh DESCRIPTION
@ -95,6 +98,10 @@ The variables that depend on the extra virtual parameter (defaults to all) (WARN
would interpret the argument as being a flag, for example, write '-V "0,-1"' instead of '-V "-1,0"'). would interpret the argument as being a flag, for example, write '-V "0,-1"' instead of '-V "-1,0"').
.Pp .Pp
Can either be a ',' separated list if indices or 'all' to derive with respect to all available variables. Can either be a ',' separated list if indices or 'all' to derive with respect to all available variables.
.It Fl C
Format the output so it can be piped to
.Sy numkondo ,
that is, instead of printing the flow equation, print a full configuration file containing the flow equation as well as all the other entries of the configuration file that do not pertain to the computation of the flow equation.
.El .El
.Pp .Pp
.Sy Configuration file: .Sy Configuration file:
@ -131,6 +138,12 @@ The values of the rccs with which to evaluate the flow equation.
.Ar values .Ar values
is formatted like an initial_condition (see is formatted like an initial_condition (see
.Sx numkondo Ns (1) ) . .Sx numkondo Ns (1) ) .
.It Fl P Ar precision
Number of bits used for the significand of numerical values (see
.Sx numkondo Ns (1) ) .
.It Fl E Ar max_exponent
Largest allowed value for the exponent of numerical values (see
.Sx numkondo Ns (1) ) .
.El .El
.Pp .Pp
.Sy Configuration file: .Sy Configuration file:

View File

@ -1,5 +1,5 @@
.Dd $Mdocdate: April 14 2015 $ .Dd $Mdocdate: September 22 2015 $
.Dt numkondo 1.2 .Dt numkondo 1.4
.Os .Os
.Sh NAME .Sh NAME
.Nm numkondo .Nm numkondo
@ -8,8 +8,9 @@
.Nm .Nm
.Op Fl F .Op Fl F
.Op Fl N Ar niter .Op Fl N Ar niter
.Op Fl D Ar tolerance
.Op Fl I Ar initial_condition .Op Fl I Ar initial_condition
.Op Fl P Ar precision
.Op Fl E Ar max_exponent
.Op Ar config_file .Op Ar config_file
.Pp .Pp
.Nm .Nm
@ -44,12 +45,12 @@ as well as the following pre-processors, which generate configuration files for
Number of iterations Number of iterations
.It Fl F .It Fl F
Only print the last step of the computation, with full precision. The output can be used as an initial condition for further iterations. Only print the last step of the computation, with full precision. The output can be used as an initial condition for further iterations.
.It Fl D Ar tolerance
If this option is provided, any number smaller than
.Ar tolerance
is set to 0.
.It Fl I Ar initial_condition .It Fl I Ar initial_condition
Set the initial condition from the command-line (overrides the initial condition in the configuration file). The format is the same as the '#!initial_configuration' entry, see below. Set the initial condition from the command-line (overrides the initial condition in the configuration file). The format is the same as the '#!initial_configuration' entry, see below.
.It Fl P Ar precision
Number of bits used for the significand of numerical values (see the NUMERICAL PRECISION section). If this option is specified, then numerical values are represented as MPFR floats instead of long doubles, which requires more computating time.
.It Fl E Ar max_exponent
Largest allowed value for the exponent of numerical values (see the NUMERICAL PRECISION section). If this option is specified, then numerical values are represented as MPFR floats instead of long doubles, which requires more computating time.
.It Fl v .It Fl v
Print version information and exit. Print version information and exit.
.El .El
@ -145,6 +146,19 @@ If the '-F' flag is provided,
.Nm .Nm
prints the last step of the iteration to stdout in a format that can be re-used as an initial condition for subsequent iterations. prints the last step of the iteration to stdout in a format that can be re-used as an initial condition for subsequent iterations.
.Pp .Pp
.Sh NUMERICAL PRECISION
Numerical values are represented as floating point numbers, which consist in a significand (or mantissa) and an exponent. The number is given by
.D1 significand * 2^exponent
.Pp
If neither the '-P' nor the '-E' flags are specified, then numerical values are implemented using the 'long double' type, which allocates 64 bits to the significand and 15 to the exponent (this may change depending on the implementation of the C compiler used to compile
.Nm ) .
Numbers are therefore accurate to 19 decimal places, and the exponent must be in the interval [-16382 , 16383].
.Pp
If one of the '-P' or '-E' flags are specified, then numerical values are implemented using the GNU MPFR library. The number of bits allocated to the significand and exponent can be set by the '-P' and '-E' flags, within the limits set by the MPFR library. These values depend on the implementation of the library. On 64-bit systems, the maximal precision and maximal value of the exponent should be of the order of 2^63 and 2^62 respectively.
.Pp
Note that using MPFR floats increases the computing time required to run
.Nm
.Pp
.Sh RETURN CODE .Sh RETURN CODE
.Nm .Nm
returns 0 on success and -1 on error. returns 0 on success and -1 on error.

View File

@ -105,7 +105,7 @@ def latex_engine(argv,text):
oneline=0 oneline=0
i=i+1 i=i+1
return(convert_latex(text,lsym,Lsym,Csym,oneline,columns)) return(convert_latex(text,lsym,Lsym,Csym,oneline))
# convert to C format # convert to C format
def convert_C(text, lsym, Lsym, Csym, oneline): def convert_C(text, lsym, Lsym, Csym, oneline):
@ -160,7 +160,7 @@ def convert_C(text, lsym, Lsym, Csym, oneline):
return(text+';') return(text+';')
# convert to LaTeX format # convert to LaTeX format
def convert_latex(text, lsym, Lsym, Csym, oneline, columns): def convert_latex(text, lsym, Lsym, Csym, oneline):
# remove newlines # remove newlines
if (oneline==0): if (oneline==0):
text=text.replace('\n','\\\\\n') text=text.replace('\n','\\\\\n')

View File

@ -18,6 +18,10 @@ limitations under the License.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
// define MPFR_USE_VA_LIST to enable the use of mpfr_inits and mpfr_clears
#define MPFR_USE_VA_LIST
#include <mpfr.h>
#include "definitions.cpp" #include "definitions.cpp"
#include "rational.h" #include "rational.h"
#include "istring.h" #include "istring.h"
@ -721,7 +725,7 @@ int evalcoef(RCC rccs, Coefficient coef, long double* out){
int i,j; int i,j;
long double num_factor; long double num_factor;
*out=0; *out=0.;
// for each monomial // for each monomial
for(i=0;i<coef.length;i++){ for(i=0;i<coef.length;i++){
@ -737,3 +741,44 @@ int evalcoef(RCC rccs, Coefficient coef, long double* out){
} }
return(0); return(0);
} }
// evaluate a coefficient on a vector (using mpfr floats)
int evalcoef_mpfr(RCC_mpfr rccs, Coefficient coef, mpfr_t out){
int i,j;
mpfr_t num_factor;
// tmp number (do not initialize Z)
mpfr_t x, y, Z;
// init numbers
mpfr_inits(num_factor, x, y, (mpfr_ptr) NULL);
mpfr_init(out);
mpfr_set_zero(out, 1);
// for each monomial
for(i=0;i<coef.length;i++){
// product of factors
mpfr_set_flt(num_factor, 1., MPFR_RNDN);
for(j=0;j<coef.factors[i].length;j++){
mpfr_mul(x,num_factor,rccs.values[intlist_find_err(rccs.indices,rccs.length,coef.factors[i].values[j])], MPFR_RNDN);
mpfr_set(num_factor,x, MPFR_RNDN);
}
// denominator
if(coef.denoms[i].power>0){
mpfr_pow_si(y, rccs.values[intlist_find_err(rccs.indices,rccs.length,coef.denoms[i].index)], coef.denoms[i].power, MPFR_RNDN);
mpfr_div(x, num_factor, y, MPFR_RNDN);
mpfr_set(num_factor, x, MPFR_RNDN);
}
number_mpfr_val(Z, coef.nums[i]);
mpfr_mul(x, num_factor, Z, MPFR_RNDN);
mpfr_add(y, x, out, MPFR_RNDN);
mpfr_set(out, y, MPFR_RNDN);
mpfr_clear(Z);
}
// free numbers
mpfr_clears(num_factor, x, y, (mpfr_ptr)NULL);
return(0);
}

View File

@ -74,5 +74,7 @@ int coef_denom_cmp(coef_denom denom1, coef_denom denom2);
// evaluate a coefficient on a vector // evaluate a coefficient on a vector
int evalcoef(RCC rccs, Coefficient coef, long double* out); int evalcoef(RCC rccs, Coefficient coef, long double* out);
// evaluate a coefficient on a vector (using mpfr floats)
int evalcoef_mpfr(RCC_mpfr rccs, Coefficient coef, mpfr_t out);
#endif #endif

View File

@ -17,7 +17,7 @@ limitations under the License.
#ifndef DEFINITIONS_GCC #ifndef DEFINITIONS_GCC
#define DEFINITIONS_GCC #define DEFINITIONS_GCC
#define VERSION "1.2" #define VERSION "1.4"
// number of entries in a configuration file // number of entries in a configuration file
#define ARG_COUNT 10 #define ARG_COUNT 10

View File

@ -32,6 +32,7 @@ int init_Fields_Table(Fields_Table* fields){
init_Identities(&((*fields).ids), FIELDS_SIZE); init_Identities(&((*fields).ids), FIELDS_SIZE);
init_Symbols(&((*fields).symbols), FIELDS_SIZE); init_Symbols(&((*fields).symbols), FIELDS_SIZE);
init_Int_Array(&((*fields).fermions),FIELDS_SIZE); init_Int_Array(&((*fields).fermions),FIELDS_SIZE);
init_Int_Array(&((*fields).noncommuting),FIELDS_SIZE);
return(0); return(0);
} }
int free_Fields_Table(Fields_Table fields){ int free_Fields_Table(Fields_Table fields){
@ -41,6 +42,7 @@ int free_Fields_Table(Fields_Table fields){
free_Identities(fields.ids); free_Identities(fields.ids);
free_Symbols(fields.symbols); free_Symbols(fields.symbols);
free_Int_Array(fields.fermions); free_Int_Array(fields.fermions);
free_Int_Array(fields.noncommuting);
return(0); return(0);
} }
@ -73,6 +75,16 @@ int is_fermion(int index, Fields_Table fields){
} }
} }
// check whether a field is non-commuting
int is_noncommuting(int index, Fields_Table fields){
if(int_array_find(abs(index), fields.noncommuting)>=0){
return(1);
}
else{
return(0);
}
}
// ------------------ Identities -------------------- // ------------------ Identities --------------------
@ -180,13 +192,16 @@ int identities_concat(Identities input, Identities* output){
// resolve the identities // resolve the identities
// requires both the monomials in polynomial and the ids in fields to be sorted // requires both the monomials in polynomial and the ids in fields to be sorted
// IMPORTANT: the sorting must be such that noncommuting fields must come before the other fields
int resolve_ids(Polynomial* polynomial, Fields_Table fields){ int resolve_ids(Polynomial* polynomial, Fields_Table fields){
int i,j,k,l; int i,j,k,l;
int sign; int sign;
int fermion_count; int fermion_count;
int first_field;
int at_least_one; int at_least_one;
int security; int security;
Int_Array monomial; Int_Array pre_monomial;
Int_Array post_monomial;
Number num; Number num;
Number tmp_num; Number tmp_num;
@ -207,29 +222,38 @@ int resolve_ids(Polynomial* polynomial, Fields_Table fields){
// loop over ids // loop over ids
for(j=0;j<fields.ids.length;j++){ for(j=0;j<fields.ids.length;j++){
// check whether the monomial matches the id // check whether the monomial matches the id
if(int_array_is_subarray_ordered(fields.ids.lhs[j],(*polynomial).monomials[i])==1){ first_field=int_array_is_subarray_noncommuting(fields.ids.lhs[j],(*polynomial).monomials[i],fields);
init_Int_Array(&monomial, (*polynomial).monomials[i].length); if(first_field>=0){
init_Int_Array(&pre_monomial, (*polynomial).monomials[i].length);
// remove lhs from monomial init_Int_Array(&post_monomial, (*polynomial).monomials[i].length);
// sign from moving the fields out of the monomial
// add whatever is before the first field to pre
for(k=0;k<first_field;k++){
int_array_append((*polynomial).monomials[i].values[k],&pre_monomial);
}
// find others and move them together
// sign from moving the fields
sign=1; sign=1;
// number of Fermions to remove from the monomial // number of Fermions to jump over
fermion_count=0; fermion_count=0;
for(k=0,l=0;k<(*polynomial).monomials[i].length;k++){ for(l=1,k=first_field+1;k<(*polynomial).monomials[i].length;k++){
// check whether the field is identical to the "current" one in the id // check whether the field is identical to the "current" one in the id
// if l is too large, then keep the field // if l is too large, then keep the field
if(l>=fields.ids.lhs[j].length || (*polynomial).monomials[i].values[k]!=fields.ids.lhs[j].values[l]){ if(l>=fields.ids.lhs[j].length || (*polynomial).monomials[i].values[k]!=fields.ids.lhs[j].values[l]){
int_array_append((*polynomial).monomials[i].values[k],&monomial); // add to post
// sign correction int_array_append((*polynomial).monomials[i].values[k],&post_monomial);
if(fermion_count % 2 ==1 && is_fermion((*polynomial).monomials[i].values[k], fields)){ // count Fermions to jump
sign*=-1; if(is_fermion((*polynomial).monomials[i].values[k],fields)){
fermion_count++;
} }
} }
else{ else{
// increment fermion_count // sign correction
if(is_fermion(fields.ids.lhs[j].values[l],fields)){ if(is_fermion(fields.ids.lhs[j].values[l],fields) && fermion_count % 2 == 1){
fermion_count++; sign*=-1;
} }
// increment "current" field in the id // increment "current" field in the id
l++; l++;
@ -240,30 +264,33 @@ int resolve_ids(Polynomial* polynomial, Fields_Table fields){
// add extra monomials (if there are more than 1) // add extra monomials (if there are more than 1)
for(k=1;k<fields.ids.rhs[j].length;k++){ for(k=1;k<fields.ids.rhs[j].length;k++){
number_prod(num, fields.ids.rhs[j].nums[k], &tmp_num); number_prod(num, fields.ids.rhs[j].nums[k], &tmp_num);
polynomial_append(monomial, (*polynomial).factors[i], tmp_num, polynomial); polynomial_append(pre_monomial, (*polynomial).factors[i], tmp_num, polynomial);
free_Number(tmp_num); free_Number(tmp_num);
int_array_concat(fields.ids.rhs[j].monomials[k],(*polynomial).monomials+(*polynomial).length-1); int_array_concat(fields.ids.rhs[j].monomials[k],(*polynomial).monomials+(*polynomial).length-1);
int_array_concat(post_monomial,(*polynomial).monomials+(*polynomial).length-1);
// re-sort monomial // re-sort monomial
sign=1; sign=1;
monomial_sort((*polynomial).monomials[(*polynomial).length-1],0,(*polynomial).monomials[(*polynomial).length-1].length-1,fields,&sign); monomial_sort((*polynomial).monomials[(*polynomial).length-1],fields,&sign);
number_Qprod_chain(quot(sign,1),(*polynomial).nums+(*polynomial).length-1); number_Qprod_chain(quot(sign,1),(*polynomial).nums+(*polynomial).length-1);
} }
// correct i-th monomial // correct i-th monomial
free_Number((*polynomial).nums[i]); free_Number((*polynomial).nums[i]);
(*polynomial).nums[i]=number_prod_ret(num,fields.ids.rhs[j].nums[0]); (*polynomial).nums[i]=number_prod_ret(num,fields.ids.rhs[j].nums[0]);
free_Int_Array((*polynomial).monomials[i]); free_Int_Array((*polynomial).monomials[i]);
(*polynomial).monomials[i]=monomial; (*polynomial).monomials[i]=pre_monomial;
int_array_concat(fields.ids.rhs[j].monomials[0],(*polynomial).monomials+i); int_array_concat(fields.ids.rhs[j].monomials[0],(*polynomial).monomials+i);
int_array_concat(post_monomial,(*polynomial).monomials+i);
free_Int_Array(post_monomial);
// re-sort monomial // re-sort monomial
sign=1; sign=1;
monomial_sort((*polynomial).monomials[i],0,(*polynomial).monomials[i].length-1,fields,&sign); monomial_sort((*polynomial).monomials[i],fields,&sign);
number_Qprod_chain(quot(sign,1),(*polynomial).nums+i); number_Qprod_chain(quot(sign,1),(*polynomial).nums+i);
// free num // free num
free_Number(num); free_Number(num);
// repeat the step (in order to perform all of the replacements if several are necessary) // repeat the replacement (in order to perform all of the replacements if several are necessary)
j--; j=0;
if(at_least_one==0){ if(at_least_one==0){
at_least_one=1; at_least_one=1;
} }
@ -275,6 +302,62 @@ int resolve_ids(Polynomial* polynomial, Fields_Table fields){
return(0); return(0);
} }
// check whether an array is a sub-array of another
// requires noncommuting elements to be next to each other
// other elements may be separated, but the order must be respected
// returns the first index of the sub-array
// IMPORTANT: the noncommuting elements must precede all others in input and in test_array
int int_array_is_subarray_noncommuting(Int_Array input, Int_Array test_array, Fields_Table fields){
int i,j;
int matches=0;
int post_nc=0;
int match_nc;
int first=-1;
// bound noncommuting elements
while(is_noncommuting(input.values[post_nc], fields)==1){
post_nc++;
}
for(i=0,match_nc=0;i<test_array.length;i++){
if(test_array.values[i]==input.values[0]){
match_nc=1;
}
for(j=1;j<post_nc;j++){
if(test_array.values[i+j]!=input.values[j]){
match_nc=0;
}
}
if(match_nc==1){
first=i;
break;
}
}
if(first<0){
return(-1);
}
if(post_nc>0){
matches=post_nc;
}
else{
matches=1;
}
for(i=first+1;i<test_array.length && matches<input.length;i++){
if(input.values[matches]==test_array.values[i]){
matches++;
}
}
if(matches==input.length){
return(first);
}
else{
return(-1);
}
}
// ------------------ Symbols -------------------- // ------------------ Symbols --------------------

View File

@ -29,6 +29,8 @@ int free_Fields_Table(Fields_Table fields);
int field_type(int index, Fields_Table fields); int field_type(int index, Fields_Table fields);
// check whether a field anticommutes // check whether a field anticommutes
int is_fermion(int index, Fields_Table fields); int is_fermion(int index, Fields_Table fields);
// check whether a field is non-commuting
int is_noncommuting(int index, Fields_Table fields);
// init // init
@ -51,6 +53,8 @@ int identities_concat(Identities input, Identities* output);
// resolve the identities // resolve the identities
int resolve_ids(Polynomial* polynomial, Fields_Table fields); int resolve_ids(Polynomial* polynomial, Fields_Table fields);
// check whether an array is a sub-array of another, support for noncommuting elements
int int_array_is_subarray_noncommuting(Int_Array input, Int_Array test_array, Fields_Table fields);
// init // init

View File

@ -24,13 +24,11 @@ limitations under the License.
#include "number.h" #include "number.h"
#include "array.h" #include "array.h"
#include "coefficient.h" #include "coefficient.h"
#include "rcc.h"
// compute flow numerically, no exponentials // compute flow numerically, no exponentials
// inputs: flow_equation int numerical_flow(Grouped_Polynomial flow_equation, RCC init, Labels labels, int niter, int display_mode){
// init, niter, tol (the allowed error at each step), ls (whether to display the results in terms of ls), display_mode (what to print)
int numerical_flow(Grouped_Polynomial flow_equation, RCC init, Labels labels, int niter, long double tol, int display_mode){
// running coupling contants // running coupling contants
RCC rccs=init; RCC rccs=init;
int i,j; int i,j;
@ -53,7 +51,7 @@ int numerical_flow(Grouped_Polynomial flow_equation, RCC init, Labels labels, in
for(i=0;i<niter;i++){ for(i=0;i<niter;i++){
// compute a single step // compute a single step
step_flow(&rccs, flow_equation, tol); step_flow(&rccs, flow_equation);
// convert ls to alphas // convert ls to alphas
if(display_mode==DISPLAY_NUMERICAL){ if(display_mode==DISPLAY_NUMERICAL){
// print the result // print the result
@ -83,14 +81,9 @@ int numerical_flow(Grouped_Polynomial flow_equation, RCC init, Labels labels, in
} }
// single step in the flow no exponentials // single step in the flow no exponentials
// inputs: flow_equation, tol int step_flow(RCC* rccs, Grouped_Polynomial flow_equation){
// input/outputs: rccs
int step_flow(RCC* rccs, Grouped_Polynomial flow_equation, long double tol){
int i; int i;
long double* new_rccs=calloc((*rccs).length,sizeof(long double)); long double* new_rccs=calloc((*rccs).length,sizeof(long double));
Int_Array computed;
init_Int_Array(&computed, (*rccs).length);
// initialize vectors to 0 // initialize vectors to 0
for(i=0;i<(*rccs).length;i++){ for(i=0;i<(*rccs).length;i++){
@ -101,10 +94,6 @@ int step_flow(RCC* rccs, Grouped_Polynomial flow_equation, long double tol){
for(i=0;i<flow_equation.length;i++){ for(i=0;i<flow_equation.length;i++){
if(flow_equation.indices[i]<0){ if(flow_equation.indices[i]<0){
evalcoef(*rccs, flow_equation.coefs[i], new_rccs+i); evalcoef(*rccs, flow_equation.coefs[i], new_rccs+i);
// if the new rcc is too small, then ignore it
if(fabs(new_rccs[i])<tol){
new_rccs[i]=0.;
}
(*rccs).values[i]=new_rccs[i]; (*rccs).values[i]=new_rccs[i];
} }
} }
@ -113,10 +102,6 @@ int step_flow(RCC* rccs, Grouped_Polynomial flow_equation, long double tol){
for(i=0;i<flow_equation.length;i++){ for(i=0;i<flow_equation.length;i++){
if(flow_equation.indices[i]>=0){ if(flow_equation.indices[i]>=0){
evalcoef(*rccs, flow_equation.coefs[i], new_rccs+i); evalcoef(*rccs, flow_equation.coefs[i], new_rccs+i);
// if the new rcc is too small, then ignore it
if(fabs(new_rccs[i])<tol){
new_rccs[i]=0.;
}
} }
} }
@ -126,7 +111,6 @@ int step_flow(RCC* rccs, Grouped_Polynomial flow_equation, long double tol){
} }
// free memory // free memory
free_Int_Array(computed);
free(new_rccs); free(new_rccs);
return(0); return(0);
} }

View File

@ -21,14 +21,12 @@ Compute flow numerically
#ifndef NUMERICAL_FLOW_H #ifndef NUMERICAL_FLOW_H
#define NUMERICAL_FLOW_H #define NUMERICAL_FLOW_H
#include "types.h"
#include "grouped_polynomial.h"
#include "rcc.h"
// compute flow // compute flow
int numerical_flow(Grouped_Polynomial flow_equation, RCC init, Labels labels, int niter, long double tol, int display_mode); int numerical_flow(Grouped_Polynomial flow_equation, RCC init, Labels labels, int niter, int display_mode);
// single step // single step
int step_flow(RCC* rccs, Grouped_Polynomial flow_equation, long double tol); int step_flow(RCC* rccs, Grouped_Polynomial flow_equation);
// print the label of an rcc (takes constants and derivatives into account) // print the label of an rcc (takes constants and derivatives into account)
int print_label(int index, Labels labels); int print_label(int index, Labels labels);

128
src/flow_mpfr.c Normal file
View File

@ -0,0 +1,128 @@
/*
Copyright 2015 Ian Jauslin
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "flow_mpfr.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
// define MPFR_USE_VA_LIST to enable the use of mpfr_inits and mpfr_clears
#define MPFR_USE_VA_LIST
// define MPFR_USE_FILE to enable the use of mpfr_printf
#define MPFR_USE_FILE
#include <mpfr.h>
#include "tools.h"
#include "math.h"
#include "definitions.cpp"
#include "number.h"
#include "array.h"
#include "coefficient.h"
#include "flow.h"
#include "rcc_mpfr.h"
// compute flow numerically
int numerical_flow_mpfr(Grouped_Polynomial flow_equation, RCC_mpfr init, Labels labels, int niter, int display_mode){
// running coupling contants
RCC_mpfr rccs=init;
int i,j;
if(display_mode==DISPLAY_NUMERICAL){
// print labels
printf("%5s ","n");
for(j=0;j<rccs.length;j++){
print_label(rccs.indices[j], labels);
}
printf("\n\n");
// print initial values
printf("%5d ",0);
for(j=0;j<rccs.length;j++){
mpfr_printf("% 14.7Re ",rccs.values[j]);
}
printf("\n");
}
for(i=0;i<niter;i++){
// compute a single step
step_flow_mpfr(&rccs, flow_equation);
// convert ls to alphas
if(display_mode==DISPLAY_NUMERICAL){
// print the result
printf("%5d ",i+1);
for(j=0;j<rccs.length;j++){
mpfr_printf("% 14.7Re ",rccs.values[j]);
}
printf("\n");
}
}
if(display_mode==DISPLAY_NUMERICAL){
// print labels
printf("\n");
printf("%5s ","n");
for(j=0;j<rccs.length;j++){
print_label(rccs.indices[j], labels);
}
printf("\n\n");
}
if(display_mode==DISPLAY_FINAL){
RCC_mpfr_print(rccs);
}
return(0);
}
// single step in the flow
int step_flow_mpfr(RCC_mpfr* rccs, Grouped_Polynomial flow_equation){
int i;
mpfr_t* res;
// security: this function assumes that the length of the rcc and the flow_equation are the same
if((*rccs).length!=flow_equation.length){
fprintf(stderr,"error: mismatch in the size of the flow equation and the rccs");
exit(-1);
}
res=calloc((*rccs).length,sizeof(mpfr_t));
// compute the constants first
for(i=0;i<flow_equation.length;i++){
if(flow_equation.indices[i]<0){
evalcoef_mpfr(*rccs, flow_equation.coefs[i], res[i]);
mpfr_set((*rccs).values[i], res[i], MPFR_RNDN);
}
}
// for each equation
for(i=0;i<flow_equation.length;i++){
if(flow_equation.indices[i]>=0){
evalcoef_mpfr(*rccs, flow_equation.coefs[i], res[i]);
}
}
// set new rccs
for(i=0;i<flow_equation.length;i++){
mpfr_set((*rccs).values[i], res[i], MPFR_RNDN);
mpfr_clear(res[i]);
}
// free memory
free(res);
return(0);
}

32
src/flow_mpfr.h Normal file
View File

@ -0,0 +1,32 @@
/*
Copyright 2015 Ian Jauslin
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Compute flow numerically
*/
#ifndef NUMERICAL_FLOW_MPFR_H
#define NUMERICAL_FLOW_MPFR_H
#include "types.h"
// compute flow
int numerical_flow_mpfr(Grouped_Polynomial flow_equation, RCC_mpfr init, Labels labels, int niter, int display_mode);
// single step
int step_flow_mpfr(RCC_mpfr* rccs, Grouped_Polynomial flow_equation);
#endif

View File

@ -732,7 +732,7 @@ int char_array_to_Grouped_Polynomial(Char_Array str, Grouped_Polynomial* output)
} }
// evaluate an equation on a vector // eValuate an equation on a vector
int evaleq(RCC* rccs, Grouped_Polynomial poly){ int evaleq(RCC* rccs, Grouped_Polynomial poly){
int i; int i;
long double* res=calloc((*rccs).length,sizeof(long double)); long double* res=calloc((*rccs).length,sizeof(long double));
@ -762,4 +762,32 @@ int evaleq(RCC* rccs, Grouped_Polynomial poly){
return(0); return(0);
} }
// evaluate an equation on a vector (using mpfr floats)
int evaleq_mpfr(RCC_mpfr* rccs, Grouped_Polynomial poly){
int i;
mpfr_t* res;
if((*rccs).length!=poly.length){
fprintf(stderr, "error: trying to evaluate an flow equation with %d components on an rcc with %d\n",poly.length,(*rccs).length);
exit(-1);
}
res=calloc((*rccs).length,sizeof(mpfr_t));
// for each equation
for(i=0;i<poly.length;i++){
evalcoef_mpfr(*rccs, poly.coefs[i], res[i]);
}
// copy res to rccs
for(i=0;i<(*rccs).length;i++){
mpfr_set((*rccs).values[i], res[i], MPFR_RNDN);
mpfr_clear(res[i]);
}
// free memory
free(res);
return(0);
}

View File

@ -70,5 +70,7 @@ int char_array_to_Grouped_Polynomial(Char_Array str, Grouped_Polynomial* output)
// evaluate an equation on an RCC // evaluate an equation on an RCC
int evaleq(RCC* rccs, Grouped_Polynomial poly); int evaleq(RCC* rccs, Grouped_Polynomial poly);
// evaluate an equation on a vector (using mpfr floats)
int evaleq_mpfr(RCC_mpfr* rccs, Grouped_Polynomial poly);
#endif #endif

View File

@ -29,16 +29,17 @@ limitations under the License.
#include "definitions.cpp" #include "definitions.cpp"
#include "rational.h" #include "rational.h"
// dimension of A, B and h (must be <10) // dimension of A, B, h and t (must be <10)
#define KONDO_DIM 3 #define KONDO_DIM 3
// number of spin components // number of spin components
#define KONDO_SPIN 2 #define KONDO_SPIN 2
// offsets for indices of A, B and h // offsets for indices of A, B, h and t
// order matters for symbols table // order matters for symbols table
#define KONDO_A_OFFSET 1 #define KONDO_A_OFFSET 1
#define KONDO_B_OFFSET 2 #define KONDO_B_OFFSET 2
#define KONDO_H_OFFSET 3 #define KONDO_H_OFFSET 3
#define KONDO_T_OFFSET 4
// parsing modes (from parse_file.c) // parsing modes (from parse_file.c)
#define PP_NULL_MODE 0 #define PP_NULL_MODE 0
@ -193,13 +194,19 @@ int kondo_fields_table(int box_count, Char_Array* str_fields, Fields_Table* fiel
// parameters // parameters
char_array_append_str("h:",str_fields); char_array_append_str("h:",str_fields);
// h
for(i=0;i<KONDO_DIM;i++){ for(i=0;i<KONDO_DIM;i++){
char_array_snprintf(str_fields, "%d", 10*(i+10*KONDO_H_OFFSET)); char_array_snprintf(str_fields, "%d,", 10*(i+10*KONDO_H_OFFSET));
}
// t
for(i=0;i<KONDO_DIM;i++){
char_array_snprintf(str_fields, "%d", 10*(i+10*KONDO_T_OFFSET));
if(i<KONDO_DIM-1){ if(i<KONDO_DIM-1){
char_array_append(',',str_fields); char_array_append(',', str_fields);
} }
} }
char_array_append('\n',str_fields); char_array_append('\n', str_fields);
// declare Fermions // declare Fermions
char_array_append_str("f:",str_fields); char_array_append_str("f:",str_fields);
@ -226,6 +233,16 @@ int kondo_fields_table(int box_count, Char_Array* str_fields, Fields_Table* fiel
} }
char_array_append('\n',str_fields); char_array_append('\n',str_fields);
// declare noncommuting
char_array_append_str("a:",str_fields);
for(i=0;i<KONDO_DIM;i++){
char_array_snprintf(str_fields, "%d", 10*(i+10*KONDO_T_OFFSET));
if(i<KONDO_DIM-1){
char_array_append(',',str_fields);
}
}
char_array_append('\n', str_fields);
// parse fields table // parse fields table
parse_input_fields(*str_fields, fields); parse_input_fields(*str_fields, fields);
@ -245,7 +262,7 @@ int kondo_symbols(Char_Array* str_symbols, int box_count, Fields_Table* fields){
// loop over box index // loop over box index
for(i=1;i<=box_count;i++){ for(i=1;i<=box_count;i++){
// loop over letters // loop over letters (A and B)
for(j=0;j<2;j++){ for(j=0;j<2;j++){
// loop over space dimension // loop over space dimension
for(k=0;k<KONDO_DIM;k++){ for(k=0;k<KONDO_DIM;k++){
@ -255,7 +272,7 @@ int kondo_symbols(Char_Array* str_symbols, int box_count, Fields_Table* fields){
init_Char_Array(&tmp_str, 6); init_Char_Array(&tmp_str, 6);
char_array_snprintf(&tmp_str, "%c%d%d", letters[j], k, i); char_array_snprintf(&tmp_str, "%c%d%d", letters[j], k, i);
// compute corresponding polynomial // compute corresponding polynomial
kondo_resolve_ABh(tmp_str.str, &poly, *fields); kondo_resolve_ABht(tmp_str.str, &poly, *fields);
free_Char_Array(tmp_str); free_Char_Array(tmp_str);
// write to output // write to output
polynomial_sprint(poly, str_symbols); polynomial_sprint(poly, str_symbols);
@ -320,45 +337,6 @@ int kondo_symbols(Char_Array* str_symbols, int box_count, Fields_Table* fields){
return(0); return(0);
} }
// generate Kondo symbols (older method: one symbol for each scalar product)
int kondo_symbols_scalarprod(Char_Array* str_symbols, int box_count, Fields_Table* fields){
int i,j,k;
Char_Array tmp_str;
Polynomial poly;
char letters[3]={'A','B','h'};
init_Char_Array(str_symbols, STR_SIZE);
char_array_snprintf(str_symbols, "#!symbols\n");
// loop over box index
for(i=1;i<=box_count;i++){
// loop over letters
for(j=0;j<3;j++){
for(k=0;k<3;k++){
// write index
char_array_snprintf(str_symbols, "%d=", 100*(10*(KONDO_A_OFFSET+j)+KONDO_A_OFFSET+k)+i);
// write the name of the scalar product
init_Char_Array(&tmp_str, 6);
char_array_snprintf(&tmp_str, "%c%d.%c%d", letters[j], i, letters[k], i);
// compute corresponding polynomial
kondo_resolve_scalar_prod(tmp_str.str, &poly, *fields);
free_Char_Array(tmp_str);
// write to output
polynomial_sprint(poly, str_symbols);
free_Polynomial(poly);
// add ,
if(i<box_count || j<2 || k<2){
char_array_snprintf(str_symbols,",\n");
}
}
}
}
parse_input_symbols(*str_symbols, fields);
return(0);
}
// generate Kondo groups (groups of independent variables) // generate Kondo groups (groups of independent variables)
int kondo_groups(Char_Array* str_groups, int box_count){ int kondo_groups(Char_Array* str_groups, int box_count){
@ -395,12 +373,21 @@ int kondo_groups(Char_Array* str_groups, int box_count){
// generate Kondo identities // generate Kondo identities
// h_3^2=1-h_1^2-h_2^2 // h_3^2=1-h_1^2-h_2^2
// and Pauli matrices
int kondo_identities(Char_Array* str_identities){ int kondo_identities(Char_Array* str_identities){
int i; int i;
init_Char_Array(str_identities,STR_SIZE); init_Char_Array(str_identities,STR_SIZE);
char_array_snprintf(str_identities, "#!identities\n"); char_array_snprintf(str_identities, "#!identities\n");
// Pauli matrices
for(i=0;i<KONDO_DIM;i++){
char_array_snprintf(str_identities,"[f%d][f%d]=(1),\n",10*(10*KONDO_T_OFFSET+i),10*(10*KONDO_T_OFFSET+i));
char_array_snprintf(str_identities,"[f%d][f%d]=(s{-1})[f%d],\n",10*(10*KONDO_T_OFFSET+i),10*(10*KONDO_T_OFFSET+(i+1)%3),10*(10*KONDO_T_OFFSET+(i+2)%3));
char_array_snprintf(str_identities,"[f%d][f%d]=((-1)s{-1})[f%d],\n",10*(10*KONDO_T_OFFSET+(i+2)%3),10*(10*KONDO_T_OFFSET+(i+1)%3),10*(10*KONDO_T_OFFSET+i));
}
// h
char_array_snprintf(str_identities, "[f%d][f%d]=(1)",10*(KONDO_DIM-1+10*KONDO_H_OFFSET),10*(KONDO_DIM-1+10*KONDO_H_OFFSET)); char_array_snprintf(str_identities, "[f%d][f%d]=(1)",10*(KONDO_DIM-1+10*KONDO_H_OFFSET),10*(KONDO_DIM-1+10*KONDO_H_OFFSET));
for(i=0;i<KONDO_DIM-1;i++){ for(i=0;i<KONDO_DIM-1;i++){
char_array_snprintf(str_identities, "+(-1)[f%d][f%d]",10*(i+10*KONDO_H_OFFSET),10*(i+10*KONDO_H_OFFSET)); char_array_snprintf(str_identities, "+(-1)[f%d][f%d]",10*(i+10*KONDO_H_OFFSET),10*(i+10*KONDO_H_OFFSET));
@ -809,11 +796,10 @@ int parse_kondo_polynomial_str(char* str_polynomial, Polynomial* output, Fields_
if(tmp_poly.length>0){ if(tmp_poly.length>0){
for(i=0;i<tmp_poly.length;i++){ for(i=0;i<tmp_poly.length;i++){
if(mode==PP_FIELD_SCALAR_MODE){ if(mode==PP_FIELD_SCALAR_MODE){
if(offset1!=KONDO_H_OFFSET || offset2!=KONDO_H_OFFSET){ int_array_append(1000*(10*offset1+offset2)+index, tmp_poly.monomials+i);
int_array_append(1000*(10*offset1+offset2)+index, tmp_poly.monomials+i);
}
} }
else{ else{
// vector product
int_array_append(100*(100*KONDO_A_OFFSET+10*KONDO_B_OFFSET+KONDO_H_OFFSET)+index, tmp_poly.monomials+i); int_array_append(100*(100*KONDO_A_OFFSET+10*KONDO_B_OFFSET+KONDO_H_OFFSET)+index, tmp_poly.monomials+i);
} }
} }
@ -822,28 +808,15 @@ int parse_kondo_polynomial_str(char* str_polynomial, Polynomial* output, Fields_
else{ else{
init_Int_Array(&tmp_monomial, MONOMIAL_SIZE); init_Int_Array(&tmp_monomial, MONOMIAL_SIZE);
if(mode==PP_FIELD_SCALAR_MODE){ if(mode==PP_FIELD_SCALAR_MODE){
if(offset1!=KONDO_H_OFFSET || offset2!=KONDO_H_OFFSET){ int_array_append(1000*(10*offset1+offset2)+index, &tmp_monomial);
int_array_append(1000*(10*offset1+offset2)+index, &tmp_monomial);
}
} }
else{ else{
// vector product
int_array_append(100*(100*KONDO_A_OFFSET+10*KONDO_B_OFFSET+KONDO_H_OFFSET)+index, &tmp_monomial); int_array_append(100*(100*KONDO_A_OFFSET+10*KONDO_B_OFFSET+KONDO_H_OFFSET)+index, &tmp_monomial);
} }
init_Int_Array(&dummy_factor, 1); init_Int_Array(&dummy_factor, 1);
polynomial_append_noinit(tmp_monomial, dummy_factor, number_one(), &tmp_poly); polynomial_append_noinit(tmp_monomial, dummy_factor, number_one(), &tmp_poly);
} }
/* // older method in which a scalar product was expanded in A, B and h
// resolve scalar product
kondo_resolve_scalar_prod_symbols(buffer, &scalar_prod_poly);
// add to tmp_poly
if(tmp_poly.length==0){
polynomial_concat(scalar_prod_poly,&tmp_poly);
}
else{
polynomial_prod_chain(scalar_prod_poly,&tmp_poly,fields);
}
free_Polynomial(scalar_prod_poly);
*/
} }
// switch back to null mode // switch back to null mode
mode=PP_NULL_MODE; mode=PP_NULL_MODE;
@ -941,10 +914,10 @@ int parse_kondo_polynomial(Char_Array kondo_polynomial_str, Polynomial* polynomi
} }
// read Aij, Bij, hi where i is a space dimension and j is a box index // read Aij, Bij, hi, ti where i is a space dimension and j is a box index
int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){ int kondo_resolve_ABht(char* str, Polynomial* output, Fields_Table fields){
char* ptr; char* ptr;
// offset (A,B or H) // offset (A,B, H or T)
int offset=-1; int offset=-1;
// dimension // dimension
int dim=-1; int dim=-1;
@ -978,6 +951,9 @@ int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){
case 'h': case 'h':
offset=KONDO_H_OFFSET; offset=KONDO_H_OFFSET;
break; break;
case 't':
offset=KONDO_T_OFFSET;
break;
default: default:
// set index if dim was already set // set index if dim was already set
if(dim>=0){ if(dim>=0){
@ -1001,8 +977,8 @@ int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){
} }
} }
// h's // h's and t's
if(offset==KONDO_H_OFFSET){ if(offset==KONDO_H_OFFSET || offset==KONDO_T_OFFSET){
// external field // external field
init_Int_Array(&monomial,1); init_Int_Array(&monomial,1);
init_Int_Array(&factor,1); init_Int_Array(&factor,1);
@ -1039,6 +1015,8 @@ int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){
polynomial_conjugate(poly_conjugate); polynomial_conjugate(poly_conjugate);
polynomial_multiply_scalar(poly_conjugate, pauli_mat.matrix[a][b]); polynomial_multiply_scalar(poly_conjugate, pauli_mat.matrix[a][b]);
polynomial_prod_chain(psi[a],&poly_conjugate,fields); polynomial_prod_chain(psi[a],&poly_conjugate,fields);
// correct sign: psi[a]^+ should be on the left of psi[b]^-
polynomial_multiply_Qscalar(poly_conjugate,quot(-1,1));
// add to poly // add to poly
polynomial_concat_noinit(poly_conjugate, output); polynomial_concat_noinit(poly_conjugate, output);
} }
@ -1060,7 +1038,7 @@ int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){
// read a Kondo scalar product (generalized to vector products as well) // read a Kondo scalar product (generalized to vector products as well)
int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields){ int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields){
char* ptr; char* ptr;
// offset of each term (A,B or H) // offset of each term (A,B,H or T)
int offset=-1; int offset=-1;
// index of each term (0,...,box_count) // index of each term (0,...,box_count)
int index=0; int index=0;
@ -1089,6 +1067,9 @@ int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields
case 'h': case 'h':
offset=KONDO_H_OFFSET; offset=KONDO_H_OFFSET;
break; break;
case 't':
offset=KONDO_T_OFFSET;
break;
// scalar product // scalar product
case '.': case '.':
@ -1193,8 +1174,8 @@ int kondo_polynomial_vector(int offset, int index, Polynomial (*polys)[3], Field
init_Polynomial((*polys)+i,POLY_SIZE); init_Polynomial((*polys)+i,POLY_SIZE);
} }
// h's // h's and t's
if(offset==KONDO_H_OFFSET){ if(offset==KONDO_H_OFFSET || offset==KONDO_T_OFFSET){
// construct every component field // construct every component field
for(i=0;i<KONDO_DIM;i++){ for(i=0;i<KONDO_DIM;i++){
// external field // external field
@ -1235,6 +1216,8 @@ int kondo_polynomial_vector(int offset, int index, Polynomial (*polys)[3], Field
polynomial_conjugate(poly_conjugate); polynomial_conjugate(poly_conjugate);
polynomial_multiply_scalar(poly_conjugate, pauli_mat.matrix[a][b]); polynomial_multiply_scalar(poly_conjugate, pauli_mat.matrix[a][b]);
polynomial_prod_chain(psi[a],&poly_conjugate,fields); polynomial_prod_chain(psi[a],&poly_conjugate,fields);
// correct sign: psi[a]^+ should be on the left of psi[b]^-
polynomial_multiply_Qscalar(poly_conjugate,quot(-1,1));
// add to polys[j] // add to polys[j]
polynomial_concat_noinit(poly_conjugate, (*polys)+i); polynomial_concat_noinit(poly_conjugate, (*polys)+i);
} }
@ -1257,7 +1240,7 @@ int kondo_resolve_scalar_prod_symbols(char* str, Polynomial* output){
char* ptr; char* ptr;
// first or second term // first or second term
int term=0; int term=0;
// offset of each term (A,B or H) // offset of each term (A,B,H or T)
int offset[2]; int offset[2];
// index of each term (0,...,box_count) // index of each term (0,...,box_count)
int index[2]={0,0}; int index[2]={0,0};
@ -1285,6 +1268,9 @@ int kondo_resolve_scalar_prod_symbols(char* str, Polynomial* output){
case 'h': case 'h':
offset[term]=KONDO_H_OFFSET; offset[term]=KONDO_H_OFFSET;
break; break;
case 't':
offset[term]=KONDO_T_OFFSET;
break;
// switch term // switch term
case '.': case '.':
term=1-term; term=1-term;
@ -1300,13 +1286,13 @@ int kondo_resolve_scalar_prod_symbols(char* str, Polynomial* output){
init_Int_Array(&monomial,2); init_Int_Array(&monomial,2);
init_Int_Array(&factor, 1); init_Int_Array(&factor, 1);
if(offset[0]==KONDO_H_OFFSET){ if(offset[0]==KONDO_H_OFFSET || offset[0]==KONDO_T_OFFSET){
int_array_append(10*(10*offset[0]+i)+index[0], &monomial); int_array_append(10*(10*offset[0]+i)+index[0], &monomial);
} }
else{ else{
int_array_append(100*(10*offset[0]+i)+index[0], &monomial); int_array_append(100*(10*offset[0]+i)+index[0], &monomial);
} }
if(offset[1]==KONDO_H_OFFSET){ if(offset[1]==KONDO_H_OFFSET || offset[1]==KONDO_T_OFFSET){
int_array_append(10*(10*offset[1]+i)+index[1], &monomial); int_array_append(10*(10*offset[1]+i)+index[1], &monomial);
} }
else{ else{
@ -1340,6 +1326,9 @@ int get_offset_index(char* str, int* offset, int* index){
case 'h': case 'h':
*offset=KONDO_H_OFFSET; *offset=KONDO_H_OFFSET;
break; break;
case 't':
*offset=KONDO_T_OFFSET;
break;
default: default:
// char to int // char to int
*index=*ptr-'0'; *index=*ptr-'0';
@ -1374,6 +1363,9 @@ int get_offsets_index(char* str, int* offset1, int* offset2, int* index){
case 'h': case 'h':
offset[term]=KONDO_H_OFFSET; offset[term]=KONDO_H_OFFSET;
break; break;
case 't':
offset[term]=KONDO_T_OFFSET;
break;
// switch term // switch term
case '.': case '.':
term=1-term; term=1-term;
@ -1387,6 +1379,11 @@ int get_offsets_index(char* str, int* offset1, int* offset2, int* index){
*offset1=offset[0]; *offset1=offset[0];
*offset2=offset[1]; *offset2=offset[1];
// if no A's or B's, then index=0
if((offset[0]==KONDO_H_OFFSET || offset[0]==KONDO_T_OFFSET) && (offset[1]==KONDO_H_OFFSET || offset[1]==KONDO_T_OFFSET)){
*index=0;
}
return(0); return(0);
} }
@ -1425,6 +1422,9 @@ int get_symbol_index(char* str){
case 'h': case 'h':
offset=KONDO_H_OFFSET; offset=KONDO_H_OFFSET;
break; break;
case 't':
offset=KONDO_T_OFFSET;
break;
default: default:
// set index if dim was already set // set index if dim was already set
if(dim>=0){ if(dim>=0){
@ -1439,8 +1439,8 @@ int get_symbol_index(char* str){
if(offset==-1){ if(offset==-1){
return(-1); return(-1);
} }
// no symbol for h // no symbol for h or t
if(offset==KONDO_H_OFFSET){ if(offset==KONDO_H_OFFSET || offset==KONDO_T_OFFSET){
return(10*(10*offset+dim)); return(10*(10*offset+dim));
} }
else{ else{

View File

@ -55,7 +55,7 @@ int parse_kondo_polynomial_str(char* str_polynomial, Polynomial* output, Fields_
int parse_kondo_polynomial(Char_Array kondo_polynomial_str, Polynomial* polynomial, Fields_Table fields); int parse_kondo_polynomial(Char_Array kondo_polynomial_str, Polynomial* polynomial, Fields_Table fields);
// read Aij, Bij, hi where i is a space dimension and j is a box index // read Aij, Bij, hi where i is a space dimension and j is a box index
int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields); int kondo_resolve_ABht(char* str, Polynomial* output, Fields_Table fields);
// read a Kondo scalar product // read a Kondo scalar product
int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields); int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields);
// compute a scalar product of polynomial vectors // compute a scalar product of polynomial vectors

View File

@ -42,7 +42,7 @@ int mean(Int_Array monomial, Polynomial* out, Fields_Table fields, Polynomial_Ma
*out=polynomial_one(); *out=polynomial_one();
// sort first // sort first
monomial_sort(monomial, 0, monomial.length-1, fields, &sign); monomial_sort(monomial, fields, &sign);
polynomial_multiply_Qscalar(*out, quot(sign,1)); polynomial_multiply_Qscalar(*out, quot(sign,1));
// get internals // get internals
// (*out).monomials is the first element of out but it only has 1 element // (*out).monomials is the first element of out but it only has 1 element
@ -417,7 +417,7 @@ int mean_symbols(Int_Array monomial, Polynomial* output, Fields_Table fields, Po
if(check_monomial_match(tmp_monomial, fields)==1){ if(check_monomial_match(tmp_monomial, fields)==1){
// sort monomial // sort monomial
sign=1; sign=1;
monomial_sort(tmp_monomial, 0, tmp_monomial.length-1, fields, &sign); monomial_sort(tmp_monomial, fields, &sign);
number_Qprod_chain(quot(sign,1), &tmp_num); number_Qprod_chain(quot(sign,1), &tmp_num);
// mean // mean
@ -628,7 +628,7 @@ int mean_groups(Int_Array monomial, Polynomial* output, Fields_Table fields, Pol
init_Polynomial(output, MONOMIAL_SIZE); init_Polynomial(output, MONOMIAL_SIZE);
// check whether there are symbols // check whether there are symbols
// requires the symbols to be at the end of the monomial // IMPORTANT: the symbols must be at the end of the monomial
if(monomial.length==0 || field_type(monomial.values[monomial.length-1], fields)!=FIELD_SYMBOL){ if(monomial.length==0 || field_type(monomial.values[monomial.length-1], fields)!=FIELD_SYMBOL){
// mean // mean
mean(monomial, &num_mean, fields, propagator); mean(monomial, &num_mean, fields, propagator);
@ -639,7 +639,7 @@ int mean_groups(Int_Array monomial, Polynomial* output, Fields_Table fields, Pol
// sort into groups // sort into groups
if(groups.length>0){ if(groups.length>0){
sign=1; sign=1;
monomial_sort_groups(monomial, 0, monomial.length-1, fields, groups, &sign); monomial_sort_groups(monomial, fields, groups, &sign);
} }
// construct groups and take mean // construct groups and take mean
init_Int_Array(&tmp_monomial, MONOMIAL_SIZE); init_Int_Array(&tmp_monomial, MONOMIAL_SIZE);

View File

@ -108,7 +108,7 @@ int read_args_meantools(int argc,const char* argv[], Str_Array* str_args, Meanto
// print usage message // print usage message
int print_usage_meantools(){ int print_usage_meantools(){
printf("\nusage:\n meantools exp <filename>\n meantools derive [-d derivatives] -V <variables> <filename>\n meantools eval -R <rccs> <filename>\n\n"); printf("\nusage:\n meantools exp [config_file]\n meantools derive [-d derivatives] [-V variables] [-C] [config_file]\n meantools eval [-R values] [-P precision] [-E max_exponent] [config_file]\n\n");
return(0); return(0);
} }

View File

@ -46,6 +46,8 @@ int tool_deriv_read_args(int argc, const char* argv[], Str_Array* str_args, Mean
(*opts).deriv_derivs=1; (*opts).deriv_derivs=1;
// derive with respect to all variables // derive with respect to all variables
(*opts).deriv_vars.length=-1; (*opts).deriv_vars.length=-1;
// do not chain
(*opts).chain=0;
// loop over arguments // loop over arguments
@ -61,6 +63,10 @@ int tool_deriv_read_args(int argc, const char* argv[], Str_Array* str_args, Mean
case 'V': case 'V':
flag=CP_FLAG_VARS; flag=CP_FLAG_VARS;
break; break;
// chain
case 'C':
(*opts).chain=1;
break;
} }
} }
} }
@ -104,6 +110,8 @@ int tool_deriv(Str_Array str_args, Meantools_Options opts){
// flow equation for the derivatives // flow equation for the derivatives
Grouped_Polynomial flow_equation_deriv; Grouped_Polynomial flow_equation_deriv;
int i; int i;
// header of the entry
Char_Array arg_header;
// parse flow equation // parse flow equation
@ -142,6 +150,29 @@ int tool_deriv(Str_Array str_args, Meantools_Options opts){
// compute derivatives // compute derivatives
flow_equation_derivative(opts.deriv_derivs, opts.deriv_vars, flow_equation, &flow_equation_deriv); flow_equation_derivative(opts.deriv_derivs, opts.deriv_vars, flow_equation, &flow_equation_deriv);
// print
// if chain then print config file
if(opts.chain==1){
for(i=0;i<str_args.length;i++){
// check whether to print the str_arg
get_str_arg_title(str_args.strs[i], &arg_header);
if (\
str_cmp(arg_header.str, "flow_equation")==0 &&\
str_cmp(arg_header.str, "symbols")==0 &&\
str_cmp(arg_header.str, "groups")==0 &&\
str_cmp(arg_header.str, "fields")==0 &&\
str_cmp(arg_header.str, "identities")==0 &&\
str_cmp(arg_header.str, "propagator")==0 &&\
str_cmp(arg_header.str, "input_polynomial")==0 &&\
str_cmp(arg_header.str, "id_table")==0 ){
printf("%s\n&\n",str_args.strs[i].str);
}
free_Char_Array(arg_header);
}
// print flow equation
printf("#!flow_equation\n");
}
grouped_polynomial_print(flow_equation_deriv,'%','%'); grouped_polynomial_print(flow_equation_deriv,'%','%');
// free memory // free memory
@ -164,12 +195,17 @@ int flow_equation_derivative(int n, Int_Array variables, Grouped_Polynomial flow
// output polynomial // output polynomial
grouped_polynomial_cpy(flow_equation, flow_equation_derivs); grouped_polynomial_cpy(flow_equation, flow_equation_derivs);
for(j=0,dflow=flow_equation;j<n;j++){ // init dflow to flow_equation
grouped_polynomial_cpy(flow_equation, &dflow);
for(j=0;j<n;j++){
// tmp flow contains the result of the previous derivative // tmp flow contains the result of the previous derivative
grouped_polynomial_cpy(dflow, &tmpflow); grouped_polynomial_cpy(dflow, &tmpflow);
// derive // free dflow
free_Grouped_Polynomial(dflow);
// next derivative
flow_equation_derivx(tmpflow, indices, &dflow); flow_equation_derivx(tmpflow, indices, &dflow);
// free // free tmpflow
free_Grouped_Polynomial(tmpflow); free_Grouped_Polynomial(tmpflow);
// add the derived indices as variables for the next derivative // add the derived indices as variables for the next derivative

View File

@ -18,16 +18,22 @@ limitations under the License.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <mpfr.h>
#include "parse_file.h" #include "parse_file.h"
#include "cli_parser.h" #include "cli_parser.h"
#include "grouped_polynomial.h" #include "grouped_polynomial.h"
#include "array.h" #include "array.h"
#include "rcc.h" #include "rcc.h"
#include "rcc_mpfr.h"
#define CP_FLAG_RCCS 1 #define CP_FLAG_RCCS 1
#define CP_FLAG_MPFR_PREC 2
#define CP_FLAG_MPFR_EXP 3
// read command line arguments // read command line arguments
int tool_eval_read_args(int argc, const char* argv[], Str_Array* str_args, Meantools_Options* opts){ int tool_eval_read_args(int argc, const char* argv[], Str_Array* str_args, Meantools_Options* opts){
// temporary long int
long int tmp_lint;
// file to read the polynomial from in flow mode // file to read the polynomial from in flow mode
const char* file=""; const char* file="";
// whether a file was specified on the command-line // whether a file was specified on the command-line
@ -40,6 +46,9 @@ int tool_eval_read_args(int argc, const char* argv[], Str_Array* str_args, Meant
// defaults // defaults
// mark rccstring so that it can be recognized whether it has been set or not // mark rccstring so that it can be recognized whether it has been set or not
(*opts).eval_rccstring.length=-1; (*opts).eval_rccstring.length=-1;
// no mpfr
(*opts).mpfr_prec=0;
(*opts).mpfr_emax=0;
// loop over arguments // loop over arguments
for(i=2;i<argc;i++){ for(i=2;i<argc;i++){
@ -51,6 +60,14 @@ int tool_eval_read_args(int argc, const char* argv[], Str_Array* str_args, Meant
case 'R': case 'R':
flag=CP_FLAG_RCCS; flag=CP_FLAG_RCCS;
break; break;
// mpfr precision
case 'P':
flag=CP_FLAG_MPFR_PREC;
break;
// mpfr emax
case 'E':
flag=CP_FLAG_MPFR_EXP;
break;
} }
} }
} }
@ -59,6 +76,18 @@ int tool_eval_read_args(int argc, const char* argv[], Str_Array* str_args, Meant
str_to_char_array((char*)argv[i], &((*opts).eval_rccstring)); str_to_char_array((char*)argv[i], &((*opts).eval_rccstring));
flag=0; flag=0;
} }
// mpfr precision
else if(flag==CP_FLAG_MPFR_PREC){
sscanf(argv[i],"%ld",&tmp_lint);
(*opts).mpfr_prec=(mpfr_prec_t)tmp_lint;
flag=0;
}
// mpfr emax
else if(flag==CP_FLAG_MPFR_EXP){
sscanf(argv[i],"%ld",&tmp_lint);
(*opts).mpfr_emax=(mpfr_exp_t)tmp_lint;
flag=0;
}
// read file name from command-line // read file name from command-line
else{ else{
file=argv[i]; file=argv[i];
@ -78,9 +107,21 @@ int tool_eval(Str_Array str_args, Meantools_Options opts){
int arg_index; int arg_index;
// rccs // rccs
RCC rccs; RCC rccs;
RCC_mpfr rccs_mpfr;
// flow equation // flow equation
Grouped_Polynomial flow_equation; Grouped_Polynomial flow_equation;
// whether or not to use mpfr floats
int mpfr_flag=0;
// set mpfr defaults
if(opts.mpfr_prec!=0){
mpfr_set_default_prec(opts.mpfr_prec);
mpfr_flag=1;
}
if(opts.mpfr_emax!=0){
mpfr_set_emax(opts.mpfr_emax);
mpfr_flag=1;
}
// parse flow equation // parse flow equation
// if there is a unique argument, assume it is the flow equation // if there is a unique argument, assume it is the flow equation
@ -108,22 +149,33 @@ int tool_eval(Str_Array str_args, Meantools_Options opts){
} }
// initialize the rccs // initialize the rccs
prepare_init(flow_equation.indices,flow_equation.length,&rccs); if(mpfr_flag==0){
prepare_init(flow_equation.indices,flow_equation.length,&rccs);
}
else{
prepare_init_mpfr(flow_equation.indices,flow_equation.length,&rccs_mpfr);
}
// read rccs from string // read rccs from string
if(opts.eval_rccstring.length!=-1){ if(opts.eval_rccstring.length!=-1){
parse_init_cd(opts.eval_rccstring, &rccs); parse_init_cd(opts.eval_rccstring, &rccs, &rccs_mpfr, mpfr_flag);
free_Char_Array(opts.eval_rccstring); free_Char_Array(opts.eval_rccstring);
} }
// evaluate // evaluate
evaleq(&rccs, flow_equation); if(mpfr_flag==0){
evaleq(&rccs, flow_equation);
RCC_print(rccs);
free_RCC(rccs);
}
else{
evaleq_mpfr(&rccs_mpfr, flow_equation);
RCC_mpfr_print(rccs_mpfr);
free_RCC_mpfr(rccs_mpfr);
}
// print
RCC_print(rccs);
// free memory // free memory
free_Grouped_Polynomial(flow_equation); free_Grouped_Polynomial(flow_equation);
free_RCC(rccs);
return(0); return(0);
} }

View File

@ -18,6 +18,10 @@ limitations under the License.
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <stdarg.h>
// define MPFR_USE_VA_LIST to enable the use of mpfr_inits and mpfr_clears
#define MPFR_USE_VA_LIST
#include <mpfr.h>
#include "istring.h" #include "istring.h"
#include "definitions.cpp" #include "definitions.cpp"
#include "tools.h" #include "tools.h"
@ -358,6 +362,30 @@ long double number_double_val(Number x){
} }
return(ret); return(ret);
} }
// approximate numerical expression (as mpfr float)
int number_mpfr_val(mpfr_t out, Number x){
int i;
// auxiliary variables (do not initialize A)
mpfr_t A,b,c;
mpfr_inits(b,c, (mpfr_ptr)NULL);
mpfr_init(out);
mpfr_set_zero(out,1);
for(i=0;i<x.length;i++){
if(x.scalars[i].numerator!=0){
mpfr_sqrt_ui(b, x.base[i], MPFR_RNDN);
Q_mpfr_value(A, x.scalars[i]);
mpfr_mul(c, A, b, MPFR_RNDN);
mpfr_add(b, out, c, MPFR_RNDN);
mpfr_set(out, b, MPFR_RNDN);
}
}
mpfr_clears(A,b,c, (mpfr_ptr)NULL);
return(0);
}
// print to string // print to string

View File

@ -98,6 +98,8 @@ int number_is_zero(Number x);
// approximate numerical expression // approximate numerical expression
long double number_double_val(Number x); long double number_double_val(Number x);
// approximate numerical expression (as mpfr float)
int number_mpfr_val(mpfr_t out, Number x);
// print to string // print to string
int number_sprint(Number number, Char_Array* out); int number_sprint(Number number, Char_Array* out);

View File

@ -30,6 +30,7 @@ Compute the flow of a flow equation numerically
// rccs // rccs
#include "rcc.h" #include "rcc.h"
#include "rcc_mpfr.h"
// grouped representation of polynomials // grouped representation of polynomials
#include "grouped_polynomial.h" #include "grouped_polynomial.h"
// command line parser // command line parser
@ -38,6 +39,7 @@ Compute the flow of a flow equation numerically
#include "parse_file.h" #include "parse_file.h"
// numerical flow // numerical flow
#include "flow.h" #include "flow.h"
#include "flow_mpfr.h"
// arrays // arrays
#include "array.h" #include "array.h"
@ -68,10 +70,13 @@ int main (int argc, const char* argv[]){
// parse command-line arguments // parse command-line arguments
#define CP_FLAG_NITER 1 #define CP_FLAG_NITER 1
#define CP_FLAG_TOL 2 #define CP_FLAG_RCCS 2
#define CP_FLAG_RCCS 3 #define CP_FLAG_MPFR_PREC 3
#define CP_FLAG_MPFR_EXP 4
int read_args_numkondo(int argc,const char* argv[], Str_Array* str_args, Numkondo_Options* opts){ int read_args_numkondo(int argc,const char* argv[], Str_Array* str_args, Numkondo_Options* opts){
int i; int i;
// temporary long int
long int tmp_lint;
// pointers // pointers
char* ptr; char* ptr;
// file to read the polynomial from in flow mode // file to read the polynomial from in flow mode
@ -92,10 +97,11 @@ int read_args_numkondo(int argc,const char* argv[], Str_Array* str_args, Numkond
(*opts).display_mode=DISPLAY_NUMERICAL; (*opts).display_mode=DISPLAY_NUMERICAL;
// default niter // default niter
(*opts).niter=100; (*opts).niter=100;
// default to 0 tolerance
(*opts).tol=0;
// mark rccstring so that it can be recognized whether it has been set or not // mark rccstring so that it can be recognized whether it has been set or not
(*opts).eval_rccstring.length=-1; (*opts).eval_rccstring.length=-1;
// no mpfr
(*opts).mpfr_prec=0;
(*opts).mpfr_emax=0;
// loop over arguments // loop over arguments
for(i=1;i<argc;i++){ for(i=1;i<argc;i++){
@ -111,14 +117,18 @@ for(i=1;i<argc;i++){
case 'N': case 'N':
flag=CP_FLAG_NITER; flag=CP_FLAG_NITER;
break; break;
// tolerance
case 'D':
flag=CP_FLAG_TOL;
break;
// initial condition // initial condition
case 'I': case 'I':
flag=CP_FLAG_RCCS; flag=CP_FLAG_RCCS;
break; break;
// mpfr precision
case 'P':
flag=CP_FLAG_MPFR_PREC;
break;
// mpfr emax
case 'E':
flag=CP_FLAG_MPFR_EXP;
break;
// print version // print version
case 'v': case 'v':
printf("numkondo " VERSION "\n"); printf("numkondo " VERSION "\n");
@ -134,16 +144,23 @@ for(i=1;i<argc;i++){
// reset flag // reset flag
flag=0; flag=0;
} }
// tolerance
else if (flag==CP_FLAG_TOL){
sscanf(argv[i],"%Lf",&((*opts).tol));
flag=0;
}
// init condition // init condition
else if(flag==CP_FLAG_RCCS){ else if(flag==CP_FLAG_RCCS){
str_to_char_array((char*)argv[i], &((*opts).eval_rccstring)); str_to_char_array((char*)argv[i], &((*opts).eval_rccstring));
flag=0; flag=0;
} }
// mpfr precision
else if(flag==CP_FLAG_MPFR_PREC){
sscanf(argv[i],"%ld",&tmp_lint);
(*opts).mpfr_prec=(mpfr_prec_t)tmp_lint;
flag=0;
}
// mpfr emax
else if(flag==CP_FLAG_MPFR_EXP){
sscanf(argv[i],"%ld",&tmp_lint);
(*opts).mpfr_emax=(mpfr_exp_t)tmp_lint;
flag=0;
}
// read file name from command-line // read file name from command-line
else{ else{
file=argv[i]; file=argv[i];
@ -158,7 +175,7 @@ for(i=1;i<argc;i++){
// print usage message // print usage message
int print_usage_numkondo(){ int print_usage_numkondo(){
printf("\nusage:\n numkondo [-F] [-N niter] [-D tolerance] [-I initial_condition] <filename>\n\n"); printf("\nusage:\n numkondo [-F] [-N niter] [-I initial_condition] [-P precision] [-E exponent_range] <filename>\n\n");
return(0); return(0);
} }
@ -171,8 +188,22 @@ int numflow(Str_Array str_args, Numkondo_Options opts){
Labels labels; Labels labels;
// initial condition // initial condition
RCC init_cd; RCC init_cd;
RCC_mpfr init_cd_mpfr;
// flow equation // flow equation
Grouped_Polynomial flow_equation; Grouped_Polynomial flow_equation;
// whether or not to use mpfr floats
int mpfr_flag=0;
// set mpfr defaults
if(opts.mpfr_prec!=0){
mpfr_set_default_prec(opts.mpfr_prec);
mpfr_flag=1;
}
if(opts.mpfr_emax!=0){
mpfr_set_emax(opts.mpfr_emax);
mpfr_flag=1;
}
// parse id table // parse id table
arg_index=find_str_arg("labels", str_args); arg_index=find_str_arg("labels", str_args);
@ -207,20 +238,31 @@ int numflow(Str_Array str_args, Numkondo_Options opts){
} }
} }
// initialize the rccs // initialize the rccs
prepare_init(flow_equation.indices,flow_equation.length,&init_cd); if(mpfr_flag==0){
prepare_init(flow_equation.indices,flow_equation.length,&init_cd);
}
else{
prepare_init_mpfr(flow_equation.indices,flow_equation.length,&init_cd_mpfr);
}
// read rccs from string // read rccs from string
if(opts.eval_rccstring.length!=-1){ if(opts.eval_rccstring.length!=-1){
parse_init_cd(opts.eval_rccstring, &init_cd); parse_init_cd(opts.eval_rccstring, &init_cd, &init_cd_mpfr, mpfr_flag);
free_Char_Array(opts.eval_rccstring); free_Char_Array(opts.eval_rccstring);
} }
numerical_flow(flow_equation, init_cd, labels, opts.niter, opts.tol, opts.display_mode); if(mpfr_flag==0){
numerical_flow(flow_equation, init_cd, labels, opts.niter, opts.display_mode);
free_RCC(init_cd);
}
else{
numerical_flow_mpfr(flow_equation, init_cd_mpfr, labels, opts.niter, opts.display_mode);
free_RCC_mpfr(init_cd_mpfr);
}
free_RCC(init_cd);
// free memory // free memory
free_Labels(labels); free_Labels(labels);
free_Grouped_Polynomial(flow_equation); free_Grouped_Polynomial(flow_equation);
return(0); return(0);
} }

View File

@ -18,12 +18,14 @@ limitations under the License.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <mpfr.h>
#include "array.h" #include "array.h"
#include "fields.h" #include "fields.h"
#include "rational.h" #include "rational.h"
#include "number.h" #include "number.h"
#include "polynomial.h" #include "polynomial.h"
#include "rcc.h" #include "rcc.h"
#include "rcc_mpfr.h"
#include "definitions.cpp" #include "definitions.cpp"
#include "istring.h" #include "istring.h"
#include "tools.h" #include "tools.h"
@ -44,16 +46,17 @@ limitations under the License.
#define PP_EXTERNAL_MODE 8 #define PP_EXTERNAL_MODE 8
#define PP_INTERNAL_MODE 9 #define PP_INTERNAL_MODE 9
#define PP_FERMIONS_MODE 10 #define PP_FERMIONS_MODE 10
#define PP_NONCOMMUTING_MODE 11
// indices // indices
#define PP_INDEX_MODE 11 #define PP_INDEX_MODE 12
// factors or monomials // factors or monomials
#define PP_BRACKET_MODE 12 #define PP_BRACKET_MODE 13
// labels // labels
#define PP_LABEL_MODE 13 #define PP_LABEL_MODE 14
// polynomial // polynomial
#define PP_POLYNOMIAL_MODE 14 #define PP_POLYNOMIAL_MODE 15
// group // group
#define PP_GROUP_MODE 15 #define PP_GROUP_MODE 16
// parse fields list // parse fields list
@ -101,6 +104,11 @@ int parse_input_fields(Char_Array str_fields, Fields_Table* fields){
mode=PP_FERMIONS_MODE; mode=PP_FERMIONS_MODE;
} }
break; break;
case 'a':
if(mode==PP_NULL_MODE){
mode=PP_NONCOMMUTING_MODE;
}
break;
// reset buffer // reset buffer
case ':': case ':':
@ -123,6 +131,9 @@ int parse_input_fields(Char_Array str_fields, Fields_Table* fields){
else if(mode==PP_FERMIONS_MODE){ else if(mode==PP_FERMIONS_MODE){
int_array_append(i,&((*fields).fermions)); int_array_append(i,&((*fields).fermions));
} }
else if(mode==PP_NONCOMMUTING_MODE){
int_array_append(i,&((*fields).noncommuting));
}
buffer_ptr=buffer; buffer_ptr=buffer;
*buffer_ptr='\0'; *buffer_ptr='\0';
break; break;
@ -142,6 +153,9 @@ int parse_input_fields(Char_Array str_fields, Fields_Table* fields){
else if(mode==PP_FERMIONS_MODE){ else if(mode==PP_FERMIONS_MODE){
int_array_append(i,&((*fields).fermions)); int_array_append(i,&((*fields).fermions));
} }
else if(mode==PP_NONCOMMUTING_MODE){
int_array_append(i,&((*fields).noncommuting));
}
mode=PP_NULL_MODE; mode=PP_NULL_MODE;
break; break;
@ -417,7 +431,7 @@ int parse_input_identities(Char_Array str_identities, Fields_Table* fields){
(*fields).ids.length=0; (*fields).ids.length=0;
for(i=0;i<tmp;i++){ for(i=0;i<tmp;i++){
sign=1; sign=1;
monomial_sort((*fields).ids.lhs[i], 0, (*fields).ids.lhs[i].length-1, *fields, &sign); monomial_sort((*fields).ids.lhs[i], *fields, &sign);
polynomial_simplify((*fields).ids.rhs+i, *fields); polynomial_simplify((*fields).ids.rhs+i, *fields);
polynomial_multiply_Qscalar((*fields).ids.rhs[i],quot(sign,1)); polynomial_multiply_Qscalar((*fields).ids.rhs[i],quot(sign,1));
} }
@ -704,8 +718,8 @@ int parse_labels(Char_Array str_labels, Labels* labels){
} }
// read initial condition for numerical computation // read initial condition for numerical computation (using either RCC or RCC_mpfr, as specified by mpfr_flag)
int parse_init_cd(Char_Array init_cd, RCC* init){ int parse_init_cd(Char_Array init_cd, RCC* init, RCC_mpfr* init_mpfr, int mpfr_flag){
char* buffer=calloc(init_cd.length+1,sizeof(char)); char* buffer=calloc(init_cd.length+1,sizeof(char));
char* buffer_ptr=buffer; char* buffer_ptr=buffer;
int index=0; int index=0;
@ -726,7 +740,12 @@ int parse_init_cd(Char_Array init_cd, RCC* init){
// new term // new term
case ',': case ',':
// write init // write init
sscanf(buffer,"%Lf",(*init).values+intlist_find_err((*init).indices,(*init).length,index)); if(mpfr_flag==0){
sscanf(buffer,"%Lf",(*init).values+intlist_find_err((*init).indices,(*init).length,index));
}
else{
mpfr_strtofr((*init_mpfr).values[intlist_find_err((*init_mpfr).indices,(*init_mpfr).length,index)], buffer, &buffer_ptr, 10, MPFR_RNDN);
}
// reset buffer // reset buffer
buffer_ptr=buffer; buffer_ptr=buffer;
*buffer_ptr='\0'; *buffer_ptr='\0';
@ -770,7 +789,12 @@ int parse_init_cd(Char_Array init_cd, RCC* init){
} }
// write init // write init
sscanf(buffer,"%Lf",(*init).values+unlist_find((*init).indices,(*init).length,index)); if(mpfr_flag==0){
sscanf(buffer,"%Lf",(*init).values+intlist_find_err((*init).indices,(*init).length,index));
}
else{
mpfr_strtofr((*init_mpfr).values[intlist_find_err((*init_mpfr).indices,(*init_mpfr).length,index)], buffer, &buffer_ptr, 10, MPFR_RNDN);
}
free(buffer); free(buffer);
return(0); return(0);
@ -794,3 +818,20 @@ int prepare_init(int* indices, int length, RCC* init){
} }
return(0); return(0);
} }
// set indices and length of init for RCC_mpfr
int prepare_init_mpfr(int* indices, int length, RCC_mpfr* init){
int i;
init_RCC_mpfr(init, length);
for(i=0;i<length;i++){
(*init).indices[i]=indices[i];
// set constants to 1
if(indices[i]<0 && indices[i]>-DOFFSET){
mpfr_set_ui((*init).values[i],1,MPFR_RNDN);
}
else{
mpfr_set_zero((*init).values[i],1);
}
}
return(0);
}

View File

@ -47,10 +47,12 @@ int parse_input_id_table(Char_Array str_idtable, Id_Table* idtable, Fields_Table
// parse a list of labels // parse a list of labels
int parse_labels(Char_Array str_labels, Labels* labels); int parse_labels(Char_Array str_labels, Labels* labels);
// parse the initial condition // read initial condition for numerical computation (using either RCC or RCC_mpfr, as specified by mpfr_flag)
int parse_init_cd(Char_Array init_cd, RCC* init); int parse_init_cd(Char_Array init_cd, RCC* init, RCC_mpfr* init_mpfr, int mpfr_flag);
// set indices and length of init // set indices and length of init
int prepare_init(int* indices, int length, RCC* init); int prepare_init(int* indices, int length, RCC* init);
// set indices and length of init for RCC_mpfr
int prepare_init_mpfr(int* indices, int length, RCC_mpfr* init);
#endif #endif

View File

@ -688,7 +688,7 @@ int polynomial_simplify(Polynomial* polynomial, Fields_Table fields){
// sort monomials and factors // sort monomials and factors
for(i=0;i<(*polynomial).length;i++){ for(i=0;i<(*polynomial).length;i++){
sign=1; sign=1;
monomial_sort((*polynomial).monomials[i],0,(*polynomial).monomials[i].length-1,fields,&sign); monomial_sort((*polynomial).monomials[i],fields,&sign);
number_Qprod_chain(quot(sign,1),(*polynomial).nums+i); number_Qprod_chain(quot(sign,1),(*polynomial).nums+i);
int_array_sort((*polynomial).factors[i],0,(*polynomial).factors[i].length-1); int_array_sort((*polynomial).factors[i],0,(*polynomial).factors[i].length-1);
} }
@ -787,7 +787,30 @@ int exchange_polynomial_terms(int i, int j, Polynomial* polynomial){
} }
// sort a monomial (with sign coming from exchanging two Fermions) // sort a monomial (with sign coming from exchanging two Fermions)
int monomial_sort(Int_Array monomial, int begin, int end, Fields_Table fields, int* sign){ // if the monomial contains noncommuting elements, put them at the beginning of the monomial
int monomial_sort(Int_Array monomial, Fields_Table fields, int* sign){
int i,j;
int tmp;
// first index after noncommuting indices
int post_nc=0;
for(i=0;i<monomial.length;i++){
if(is_noncommuting(monomial.values[i], fields)){
tmp=monomial.values[i];
for(j=i;j>post_nc;j--){
monomial.values[j]=monomial.values[j-1];
}
monomial.values[post_nc]=tmp;
post_nc++;
}
}
monomial_sort_nonc(monomial, post_nc, monomial.length-1, fields, sign);
return(0);
}
// without noncommuting terms
int monomial_sort_nonc(Int_Array monomial, int begin, int end, Fields_Table fields, int* sign){
int i; int i;
int index; int index;
// the pivot: middle of the monomial // the pivot: middle of the monomial
@ -812,8 +835,8 @@ int monomial_sort(Int_Array monomial, int begin, int end, Fields_Table fields, i
exchange_monomial_terms(monomial, index, end, fields, sign); exchange_monomial_terms(monomial, index, end, fields, sign);
// recurse // recurse
monomial_sort(monomial, begin, index-1, fields, sign); monomial_sort_nonc(monomial, begin, index-1, fields, sign);
monomial_sort(monomial, index+1, end, fields, sign); monomial_sort_nonc(monomial, index+1, end, fields, sign);
} }
return(0); return(0);
} }
@ -872,7 +895,30 @@ int exchange_monomial_terms(Int_Array monomial, int pos1, int pos2, Fields_Table
// sort a monomial by putting each group together // sort a monomial by putting each group together
int monomial_sort_groups(Int_Array monomial, int begin, int end, Fields_Table fields, Groups groups, int* sign){ // if the monomial contains noncommuting elements, put them at the beginning of the monomial
int monomial_sort_groups(Int_Array monomial, Fields_Table fields, Groups groups, int* sign){
int i,j;
int tmp;
// first index after noncommuting indices
int post_nc=0;
for(i=0;i<monomial.length;i++){
if(is_noncommuting(monomial.values[i], fields)){
tmp=monomial.values[i];
for(j=post_nc;j<i;j++){
monomial.values[j+1]=monomial.values[j];
}
monomial.values[post_nc]=tmp;
post_nc++;
}
}
monomial_sort_groups_nonc(monomial, post_nc, monomial.length-1, fields, groups, sign);
return(0);
}
// without noncommuting terms
int monomial_sort_groups_nonc(Int_Array monomial, int begin, int end, Fields_Table fields, Groups groups, int* sign){
int i; int i;
int index; int index;
// the pivot: middle of the monomial // the pivot: middle of the monomial
@ -897,8 +943,8 @@ int monomial_sort_groups(Int_Array monomial, int begin, int end, Fields_Table fi
exchange_monomial_terms(monomial, index, end, fields, sign); exchange_monomial_terms(monomial, index, end, fields, sign);
// recurse // recurse
monomial_sort(monomial, begin, index-1, fields, sign); monomial_sort_groups_nonc(monomial, begin, index-1, fields, groups, sign);
monomial_sort(monomial, index+1, end, fields, sign); monomial_sort_groups_nonc(monomial, index+1, end, fields, groups, sign);
} }
return(0); return(0);
} }

View File

@ -99,14 +99,18 @@ int polynomial_sort(Polynomial* polynomial, int begin, int end);
int exchange_polynomial_terms(int i, int j, Polynomial* polynomial); int exchange_polynomial_terms(int i, int j, Polynomial* polynomial);
// sort a monomial (with sign coming from exchanging two Fermions) // sort a monomial (with sign coming from exchanging two Fermions)
int monomial_sort(Int_Array monomial, int begin, int end, Fields_Table fields, int* sign); int monomial_sort(Int_Array monomial, Fields_Table fields, int* sign);
// without noncommuting terms
int monomial_sort_nonc(Int_Array monomial, int begin, int end, Fields_Table fields, int* sign);
// order fields: parameter, external, internal // order fields: parameter, external, internal
int compare_monomial_terms(Int_Array monomial, int pos1, int pos2, Fields_Table fields); int compare_monomial_terms(Int_Array monomial, int pos1, int pos2, Fields_Table fields);
// exchange two fields (with sign) // exchange two fields (with sign)
int exchange_monomial_terms(Int_Array monomial, int pos1, int pos2, Fields_Table fields, int* sign); int exchange_monomial_terms(Int_Array monomial, int pos1, int pos2, Fields_Table fields, int* sign);
// sort a monomial by putting each group together // sort a monomial by putting each group together
int monomial_sort_groups(Int_Array monomial, int begin, int end, Fields_Table fields, Groups groups, int* sign); int monomial_sort_groups(Int_Array monomial, Fields_Table fields, Groups groups, int* sign);
// without noncommuting terms
int monomial_sort_groups_nonc(Int_Array monomial, int begin, int end, Fields_Table fields, Groups groups, int* sign);
// order fields: group, then parameter, external, internal // order fields: group, then parameter, external, internal
int compare_monomial_terms_groups(Int_Array monomial, int pos1, int pos2, Fields_Table fields, Groups groups); int compare_monomial_terms_groups(Int_Array monomial, int pos1, int pos2, Fields_Table fields, Groups groups);

View File

@ -19,21 +19,14 @@ limitations under the License.
#include "rational_float.h" #include "rational_float.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
// define MPFR_USE_VA_LIST to enable the use of mpfr_inits and mpfr_clears
#define MPFR_USE_VA_LIST
#include <mpfr.h>
#include "istring.h" #include "istring.h"
#include "array.h" #include "array.h"
#include "math.h" #include "math.h"
Q quot(long double p, long double q){
Q ret;
if(q==0){
fprintf(stderr,"error: %Lf/%Lf is ill defined\n",p,q);
exit(-1);
}
ret.numerator=p;
ret.denominator=q;
return(ret);
}
// add // add
Q Q_add(Q x1,Q x2){ Q Q_add(Q x1,Q x2){
Q ret; Q ret;
@ -141,6 +134,16 @@ long double lcm(long double x,long double y){
double Q_double_value(Q q){ double Q_double_value(Q q){
return(1.0*q.numerator/q.denominator); return(1.0*q.numerator/q.denominator);
} }
// approximate value as mpfr float
int Q_mpfr_value(mpfr_t out, Q q){
mpfr_t x;
mpfr_init(out);
mpfr_init(x);
mpfr_set_ld(x, q.denominator, MPFR_RNDN);
mpfr_ld_div(out, q.numerator, x, MPFR_RNDN);
mpfr_clear(x);
return(0);
}
// print to string // print to string

View File

@ -54,6 +54,8 @@ long double lcm(long double x,long double y);
// approximate value as double // approximate value as double
double Q_double_value(Q q); double Q_double_value(Q q);
// approximate value as mpfr float
int Q_mpfr_value(mpfr_t out, Q q);
// print to string // print to string
int Q_sprint(Q num, Char_Array* out); int Q_sprint(Q num, Char_Array* out);

View File

@ -19,6 +19,10 @@ limitations under the License.
#include "rational_int.h" #include "rational_int.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
// define MPFR_USE_VA_LIST to enable the use of mpfr_inits and mpfr_clears
#define MPFR_USE_VA_LIST
#include <mpfr.h>
#include "istring.h" #include "istring.h"
#include "array.h" #include "array.h"
@ -135,6 +139,16 @@ long int lcm(long int x,long int y){
double Q_double_value(Q q){ double Q_double_value(Q q){
return(1.0*q.numerator/q.denominator); return(1.0*q.numerator/q.denominator);
} }
// approximate value as mpfr float
int Q_mpfr_value(mpfr_t out, Q q){
mpfr_t x;
mpfr_init(out);
mpfr_init(x);
mpfr_set_si(x, q.denominator, MPFR_RNDN);
mpfr_si_div(out, q.numerator, x, MPFR_RNDN);
mpfr_clear(x);
return(0);
}
// print to string // print to string

View File

@ -49,6 +49,8 @@ long int lcm(long int x,long int y);
// approximate value as double // approximate value as double
double Q_double_value(Q q); double Q_double_value(Q q);
// approximate value as mpfr float
int Q_mpfr_value(mpfr_t out, Q q);
// print to string // print to string
int Q_sprint(Q num, Char_Array* out); int Q_sprint(Q num, Char_Array* out);

124
src/rcc_mpfr.c Normal file
View File

@ -0,0 +1,124 @@
/*
Copyright 2015 Ian Jauslin
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "rcc_mpfr.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
// define MPFR_USE_VA_LIST to enable the use of mpfr_inits and mpfr_clears
#define MPFR_USE_VA_LIST
// define MPFR_USE_FILE to enable the use of mpfr_printf
#define MPFR_USE_FILE
#include <mpfr.h>
#include <math.h>
#include "array.h"
// init
int init_RCC_mpfr(RCC_mpfr* rcc_mpfr, int size){
int i;
(*rcc_mpfr).values=calloc(size,sizeof(mpfr_t));
(*rcc_mpfr).indices=calloc(size,sizeof(int));
(*rcc_mpfr).length=size;
for(i=0;i<size;i++){
mpfr_init((*rcc_mpfr).values[i]);
}
return(0);
}
int free_RCC_mpfr(RCC_mpfr rcc_mpfr){
int i;
for(i=0;i<rcc_mpfr.length;i++){
mpfr_clear(rcc_mpfr.values[i]);
}
free(rcc_mpfr.values);
free(rcc_mpfr.indices);
return(0);
}
// set a given element of an rcc_mpfr
int RCC_mpfr_set_elem(mpfr_t value, int index, RCC_mpfr* rcc_mpfr, int pos){
mpfr_set((*rcc_mpfr).values[pos], value, MPFR_RNDN);
(*rcc_mpfr).indices[pos]=index;
return(0);
}
int RCC_mpfr_cpy(RCC_mpfr input,RCC_mpfr* output){
int i;
init_RCC_mpfr(output,input.length);
for(i=0;i<input.length;i++){
RCC_mpfr_set_elem(input.values[i], input.indices[i], output, i);
}
return(0);
}
// concatenate rcc_mpfr
int RCC_mpfr_concat(RCC_mpfr rcc_mpfr1, RCC_mpfr rcc_mpfr2, RCC_mpfr* output){
int i;
init_RCC_mpfr(output,rcc_mpfr1.length+rcc_mpfr2.length);
for(i=0;i<rcc_mpfr1.length;i++){
RCC_mpfr_set_elem(rcc_mpfr1.values[i], rcc_mpfr1.indices[i], output, i);
}
for(i=0;i<rcc_mpfr2.length;i++){
RCC_mpfr_set_elem(rcc_mpfr2.values[i], rcc_mpfr2.indices[i], output, i+rcc_mpfr1.length);
}
return(0);
}
// append an rcc_mpfr at the end of another
int RCC_mpfr_append(RCC_mpfr input, RCC_mpfr* output){
int i;
for(i=0;i<input.length;i++){
RCC_mpfr_set_elem(input.values[i], input.indices[i], output, i+(*output).length);
}
(*output).length+=input.length;
return(0);
}
// print an rcc_mpfr vector with maximal precision
int RCC_mpfr_print(RCC_mpfr rcc_mpfr){
int j;
// the printf format
Char_Array printf_format;
// number of digits in output
int size;
// compute size
// WARNING: assumes mpfr_default_prec is an int
size=mpfr_get_default_prec()*log10(2)-1;
init_Char_Array(&printf_format,12);
char_array_snprintf(&printf_format,"%%d:%%.%dRe",size);
for(j=0;j<rcc_mpfr.length;j++){
mpfr_printf(printf_format.str,rcc_mpfr.indices[j],rcc_mpfr.values[j]);
if(j<rcc_mpfr.length-1){
printf(",\n");
}
else{
printf("\n");
}
}
free_Char_Array(printf_format);
return(0);
}

43
src/rcc_mpfr.h Normal file
View File

@ -0,0 +1,43 @@
/*
Copyright 2015 Ian Jauslin
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
RCC_mpfr struct
This data type is similar to RCC but the values of the rcc's are specified as mpfr floats
*/
#ifndef RCC_MPFR_H
#define RCC_MPFR_H
#include "types.h"
// init
int init_RCC_mpfr(RCC_mpfr* rcc_mpfr, int size);
int free_RCC_mpfr(RCC_mpfr rcc_mpfr);
// set an element of an rcc_mpfr
int RCC_mpfr_set_elem(mpfr_t value, int index, RCC_mpfr* rcc_mpfr, int pos);
// copy
int RCC_mpfr_cpy(RCC_mpfr input,RCC_mpfr* output);
// concatenate 2 rcc_mpfr_mpfr
int RCC_mpfr_concat(RCC_mpfr rcc_mpfr_mpfr1, RCC_mpfr rcc_mpfr_mpfr2, RCC_mpfr* output);
// append an rcc_mpfr to another
int RCC_mpfr_append(RCC_mpfr input, RCC_mpfr* output);
// print an rcc_mpfr vector with maximal precision
int RCC_mpfr_print(RCC_mpfr rcc_mpfr_mpfr);
#endif

View File

@ -21,6 +21,8 @@ limitations under the License.
#ifndef TYPES_H #ifndef TYPES_H
#define TYPES_H #define TYPES_H
#include <mpfr.h>
// rational number // rational number
typedef struct Q{ typedef struct Q{
@ -114,6 +116,12 @@ typedef struct RCC{
int* indices; int* indices;
int length; int length;
} RCC; } RCC;
// rcc using mpfr floats
typedef struct RCC_mpfr{
mpfr_t* values;
int* indices;
int length;
} RCC_mpfr;
// identities between fields // identities between fields
typedef struct Identities{ typedef struct Identities{
@ -154,6 +162,8 @@ typedef struct Fields_Table{
Symbols symbols; Symbols symbols;
// list of anti-commuting variables (fields or symbols) // list of anti-commuting variables (fields or symbols)
Int_Array fermions; Int_Array fermions;
// list of non-commuting variables (fields or symbols)
Int_Array noncommuting;
} Fields_Table; } Fields_Table;
// index labels // index labels
@ -172,25 +182,6 @@ typedef struct Id_Table{
int memory; int memory;
} Id_Table; } Id_Table;
/*
// polynomial scalar and vectors
typedef struct Polynomial_Scalar{
Coefficient coef;
int* indices;
int length;
} Polynomial_Scalar;
typedef struct Polynomial_Vector{
Coefficient* coefv;
int* indices;
int length;
} Polynomial_Vector;
typedef struct Polynomial_Matrix{
Coefficient** coefm;
int* indices;
int length;
} Polynomial_Matrix;
*/
// command line options // command line options
typedef struct Meankondo_Options{ typedef struct Meankondo_Options{
@ -201,8 +192,9 @@ typedef struct Meankondo_Options{
typedef struct Numkondo_Options{ typedef struct Numkondo_Options{
int display_mode; int display_mode;
int niter; int niter;
long double tol;
Char_Array eval_rccstring; Char_Array eval_rccstring;
mpfr_prec_t mpfr_prec;
mpfr_exp_t mpfr_emax;
} Numkondo_Options; } Numkondo_Options;
typedef struct Meantools_Options{ typedef struct Meantools_Options{
@ -210,6 +202,9 @@ typedef struct Meantools_Options{
int deriv_derivs; int deriv_derivs;
Int_Array deriv_vars; Int_Array deriv_vars;
Char_Array eval_rccstring; Char_Array eval_rccstring;
int chain;
mpfr_prec_t mpfr_prec;
mpfr_exp_t mpfr_emax;
} Meantools_Options; } Meantools_Options;
typedef struct Kondopp_Options{ typedef struct Kondopp_Options{