Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
3f0510629e | |||
|
469bdc8071 | ||
|
e7aa6859f0 | ||
|
f13eacbc8e |
53
Changelog
Normal file
53
Changelog
Normal file
@ -0,0 +1,53 @@
|
||||
1.5:
|
||||
The update to version 1.5 is rather substantial, and introduces some minor
|
||||
backward-incompatibilities:
|
||||
* The header "#!symbols" has been replaced by "#!virtual_fields"
|
||||
* Multiplying polynomials using the '*' symbol is no longer supported (or,
|
||||
rather, the symbolic capabilities of meankondo were enhanced, and the
|
||||
syntax has been changed).
|
||||
* 'meantools exp' has been removed (its functionality is now handled by
|
||||
other means)
|
||||
* 'meantoolds derive' has been replaced by 'meantools differentiate'
|
||||
|
||||
* The symbolic capabilities were enhanced: polynomials can now be
|
||||
multiplied, added, exponentiated, and their logarithms can be taken
|
||||
directly in the configuration file.
|
||||
|
||||
* The flow equation can now be processed after being computed using the
|
||||
various "#!postprocess_*" entries.
|
||||
|
||||
* Deprecated kondo_preprocess.
|
||||
|
||||
* Compute the mean using an LU decomposition if possible.
|
||||
|
||||
* More detailed checks for syntax errors in configuration file.
|
||||
|
||||
* Check that different '#!group' entries are indeed uncorrelated.
|
||||
|
||||
* New flags in meankondo: '-p' and '-A'.
|
||||
|
||||
* New tool: meantools expand.
|
||||
|
||||
* Improve conversion to LaTeX using meantools-convert
|
||||
|
||||
* Assign terms randomly to different threads.
|
||||
|
||||
* Created vim files to implement syntax highlighting for configuration
|
||||
files.
|
||||
|
||||
* Multiple bug fixes
|
||||
|
||||
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.
|
||||
|
||||
|
2
INSTALL
2
INSTALL
@ -6,6 +6,8 @@
|
||||
|
||||
* 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:
|
||||
Run
|
||||
make
|
||||
|
165
LGPL3
Normal file
165
LGPL3
Normal 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.
|
26
Makefile
26
Makefile
@ -1,4 +1,4 @@
|
||||
## Copyright 2015 Ian Jauslin
|
||||
## Copyright 2015-2022 Ian Jauslin
|
||||
##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License");
|
||||
## you may not use this file except in compliance with the License.
|
||||
@ -18,7 +18,7 @@
|
||||
# if static=1 then link libkondo statically but other libraries dynamically
|
||||
STATIC=1
|
||||
|
||||
VERSION=1.2.1
|
||||
VERSION=1.4
|
||||
|
||||
# products of the compilation
|
||||
PROJECT_BINS= meankondo numkondo meantools kondo_preprocess meantools-convert
|
||||
@ -62,10 +62,10 @@ SRCDIR=./src
|
||||
OBJDIR=./objs
|
||||
|
||||
# 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)
|
||||
MEANKONDO_OBJS = $(addprefix $(OBJDIR)/,meankondo.o mean.o)
|
||||
NUMKONDO_OBJS = $(addprefix $(OBJDIR)/,numkondo.o flow.o)
|
||||
MEANTOOLS_OBJS = $(addprefix $(OBJDIR)/,meantools.o meantools_exp.o meantools_deriv.o meantools_eval.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 symbolic_parser.o tree.o tools.o)
|
||||
MEANKONDO_OBJS = $(addprefix $(OBJDIR)/,meankondo.o determinant.o mean.o)
|
||||
NUMKONDO_OBJS = $(addprefix $(OBJDIR)/,numkondo.o flow.o flow_mpfr.o)
|
||||
MEANTOOLS_OBJS = $(addprefix $(OBJDIR)/,meantools.o meantools_deriv.o meantools_eval.o meantools_expand.o)
|
||||
KONDO_PP_OBJS = $(addprefix $(OBJDIR)/,kondo_preprocess.o kondo.o)
|
||||
|
||||
|
||||
@ -78,8 +78,8 @@ XTRA_LIBS=
|
||||
ifeq ($(STATIC),1)
|
||||
# compile libkondo.a
|
||||
PREREQ=static
|
||||
# libkondo is linked against libm
|
||||
XTRA_LIBS=-lm
|
||||
# libkondo is linked against libm, libmpfr and libgmp
|
||||
XTRA_LIBS=-lm -lmpfr -lgmp
|
||||
# link binaries using the static library
|
||||
LIBKONDO_FLAG=-l:libkondo.a
|
||||
# install static lib
|
||||
@ -87,8 +87,8 @@ ifeq ($(STATIC),1)
|
||||
else ifeq ($(STATIC),2)
|
||||
# compile libkondo.a
|
||||
PREREQ=static
|
||||
# libkondo is linked against libm
|
||||
XTRA_LIBS=-lm
|
||||
# libkondo is linked against libm, libmpfr and libgmp
|
||||
XTRA_LIBS=-lm -lmpfr -lgmp
|
||||
# link binaries statically
|
||||
override LDFLAGS += -static
|
||||
INSTALLLIB=install-static
|
||||
@ -119,17 +119,17 @@ libkondo.a: $(LIBKONDO_OBJS)
|
||||
$(AR) -rc $(BUILDDIR)/lib/$@ $^
|
||||
|
||||
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
|
||||
|
||||
meankondo: $(MEANKONDO_OBJS)
|
||||
$(LD) -L$(BUILDDIR)/lib $(LDFLAGS) -o $(BUILDDIR)/bin/$@ $^ $(LIBKONDO_FLAG) -lpthread $(XTRA_LIBS)
|
||||
|
||||
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)
|
||||
$(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:
|
||||
cp scripts/meantools-convert $(BUILDDIR)/bin/
|
||||
|
13
NOTICE
13
NOTICE
@ -1,2 +1,15 @@
|
||||
meankondo
|
||||
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.
|
||||
|
@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
|
||||
<!--<script type="text/javascript" src="/usr/share/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>-->
|
||||
<!--<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>-->
|
||||
<script type="text/javascript" src="/usr/share/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
@ -69,10 +69,10 @@
|
||||
</head>
|
||||
|
||||
<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.5</span></h1>
|
||||
|
||||
<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 <a href="http://ian.jauslin.org/publications/15bgj">[G.Benfatto, G.Gallavotti, I.Jauslin, 2015]</a>.
|
||||
This is the official documentation for <b>meankondo</b>, version 1.5. 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>
|
||||
|
||||
<h2 style="margin-top:50pt;">Table of contents</h2>
|
||||
@ -92,9 +92,9 @@
|
||||
</ul>
|
||||
<li class="toc_sec"><a href="#operations">Operations on flow equations</a></li>
|
||||
<ul>
|
||||
<li class="toc_sub"><a href="#processing">Pre- and post-processing</a></li>
|
||||
<li class="toc_sub"><a href="#numerical_evaluation">Numerical Evaluation</a></li>
|
||||
<li class="toc_sub"><a href="#exponentiation">Exponentiation</a></li>
|
||||
<li class="toc_sub"><a href="#derivation">Derivation</a></li>
|
||||
<li class="toc_sub"><a href="#differentiation">Differentiation</a></li>
|
||||
</ul>
|
||||
<li class="toc_sec"><a href="#exactness">Comments on the exactness of the computation</a></li>
|
||||
<li class="toc_sec"><a href="#authors">Authors</a></li>
|
||||
@ -107,13 +107,9 @@
|
||||
<ul>
|
||||
<li><b>meankondo</b>: computes the flow equation.</li>
|
||||
<li><b>numkondo</b>: iterate the flow equation numerically.</li>
|
||||
<li><b>meantools</b>: tools to exponentiate, derive and evaluate a flow equation.</li>
|
||||
<li><b>meantools</b>: tools to take products, sums, exponentials or logairhtms, differentiate or evaluate a flow equation.</li>
|
||||
<li><b>meantools-convert</b>: python script to convert a flow equation to C, javascript or LaTeX code.</li>
|
||||
</ul>
|
||||
as well as <i>pre-processors</i>, whose purpose is to help with writing configuration files for specific models:
|
||||
<ul>
|
||||
<li><b>kondo_preprocess</b>: hierarchical Kondo model.</li>
|
||||
</ul>
|
||||
In addition, <b>meankondo</b> includes a library, <b>libkondo</b>, which can either be compiled as a <i>shared</i> or a <i>static</i> object, and contains the various structures and functions <b>meankondo</b> is built with.
|
||||
</p>
|
||||
|
||||
@ -127,13 +123,13 @@
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Given a configuration file 'config', the flow equation can be computed by
|
||||
Given a configuration file 'config.mk', the flow equation can be computed by
|
||||
<code class="codeblock">
|
||||
meankondo config
|
||||
meankondo config.mk
|
||||
</code>
|
||||
and it can be iterated for, say, 100 steps starting from \(\ell_0^{[m]}=-0.01\) using
|
||||
<code class="codeblock">
|
||||
meankondo -C config | numkondo -N 100 -I "0:-0.01"
|
||||
meankondo -C config.mk | numkondo -N 100 -I "0:-0.01"
|
||||
</code>
|
||||
</p>
|
||||
|
||||
@ -150,7 +146,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>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>
|
||||
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.5, all internal fields must be Fermions.)</b>
|
||||
</p>
|
||||
<p>
|
||||
In the configuration file of the <b>meankondo</b> program, the fields are specified in the <code>#!fields</code> entry.
|
||||
@ -174,6 +170,16 @@
|
||||
In the configuration file of the <b>meankondo</b> program, the propagator is specified in the <code>#!propagator</code> entry. Note that <b>meankondo</b> recognizes numeric propagators as well as symbolic ones.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
It is convenient to re-expres the Wick rule in determinant form: if \(M\) is the \(n\times n\) matrix whose entries are \(M_{a,b}=\langle\psi_{i_a}^+\psi_{j_b}^-\rangle\), then
|
||||
$$
|
||||
\langle\psi_{i_1}^+\psi_{j_1}^-\cdots\psi_{i_n}^+\psi_{j_n}^-\rangle=
|
||||
\det(M).
|
||||
$$
|
||||
<b>meankondo</b> implements an algorithm, based on an <i>LU decomposition</i>, to compute \(\det(M)\) in \(O(n^3)\) operations. However, when performing the LU decomposition, elements of \(M\) are divided, and since polynomial divisions are not supported in <b>meankondo</b>, the LU decomposition will only be performed if every entry of the propagator is numeric. If the propagator has symbolic entries, then <b>meankondo</b> computes the means summing over permutations, which requires \(O(n!)\) operations but does not require divisions.
|
||||
</p>
|
||||
|
||||
|
||||
<h2 class="section" id="flow_equation">Flow equation</h2>
|
||||
<p>
|
||||
In this section, we discuss what flow equations are, and how <b>meankondo</b> computes them.
|
||||
@ -247,7 +253,16 @@
|
||||
|
||||
<h2 class="section" id="operations">Operations on flow equations</h2>
|
||||
<p>
|
||||
In this section we describe the various operations on flow equations that the tools bundled with <b>meankondo</b> support.
|
||||
In this section we describe the various operations on flow equations that <b>meankondo</b> and the tools bundled with it support.
|
||||
</p>
|
||||
|
||||
<h3 class="subsection" id="processing">Pre- and post-processing</h3>
|
||||
<p>
|
||||
<b>meankondo</b> can perform operations on the effective potential before and after applying the renormalization group transformation. This is useful, for instance, if the effective potential is expressed as an expontential: \(exp(W)\), in which case the input polynomial can be exponentiated before the computation, and the logarithm taken after the computation. To do this, <b>meankondo</b> implements some basic symbolic processing. For the syntax of the symbolic processing, see the <b>man</b> pages bundled with <b>meankondo</b>. The pre-processing is done in the <code>#!input_polynomial</code> configuration entry, and the post-processing can be done in the <code>#!postprocess_operation</code>, <code>#!postprocess_flow_equation</code> or <code>#!numerical_postprocess_operation</code> entries. In addition, <b>meantoolds expand</b> can be used to compute sums, products, exponentials and logarithms of effective potentials.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There are subtle differences between using <code>#!postprocess_operation</code>, <code>#!postprocess_flow_equation</code> and <code>#!numerical_postprocess_operation</code>. With <code>#!postprocess_operation</code>, the post-processing operation is done immediately after having computed the average. With <code>#!postprocess_flow_equation</code> and <code>#!numerical_postprocess_operation</code>, the avergae is first turned into a flow equation, and then the post-processing is applied to each equation. The main difference is in the handling of the constant term of the polynomials, see the <b>man</b> for details. The <code>numerical</code> entry is to be used for the numerical evaluation of the flow only, using <b>numkondo</b>.
|
||||
</p>
|
||||
|
||||
<h3 class="subsection" id="numerical_evaluation">Numerical evaluation</h3>
|
||||
@ -259,34 +274,33 @@
|
||||
Numerical evaluation is handled in a straightforward manner, but for the following consideration. As was mentioned in <a href="#flow_equation_computation">Computation</a>, \(\mathcal R\) is a polynomial in \((\underline\ell,C^{-1}(\underline\ell))\), and when evaluating \(\mathcal R(\underline\ell)\), <b>meankondo</b> first evaluates \(C\) and the computes \(\ell'_n(\underline\ell)\).
|
||||
</p>
|
||||
|
||||
<h3 class="subsection" id="exponentiation">Exponentiation</h3>
|
||||
<h3 class="subsection" id="differentiation">Differentiation</h3>
|
||||
<p>
|
||||
Oftentimes the renormalization group flow is expressed in terms of an exponential of an effective potential \(\exp(W)\), in which case the exponential must be computed before it can be processed by <b>meankondo</b>:
|
||||
$$
|
||||
\exp(W)=1+V.
|
||||
$$
|
||||
This is handled by <b>meantools exp</b>, which computes the running coupling constants appearing in \(V\) in terms of those in \(W\).
|
||||
</p>
|
||||
|
||||
<h3 class="subsection" id="derivation">Derivation</h3>
|
||||
<p>
|
||||
This feature was introduced to compute the susceptibility in the hierarchical Kondo model. In that case, some of the running coupling constants depend on the field, \(h\), and the susceptibility is expressed as a derivative of \(C(\underline\ell(h))\) with respect to \(h\). To that end, we wrote <b>meantools derive</b> to compute the derivatives of a flow equation with respect to an external variable.
|
||||
This feature was introduced to compute the susceptibility in the hierarchical Kondo model. In that case, some of the running coupling constants depend on the field, \(h\), and the susceptibility is expressed as a derivative of \(C(\underline\ell(h))\) with respect to \(h\). To that end, we wrote <b>meantools differentiate</b> to compute the derivatives of a flow equation with respect to an external variable.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The input of <b>meantools derive</b> consists in a flow equation and a collection of variables \(X\subset\{1,\cdots,p\}\). Each running coupling constant \(\ell_i\) for \(i\in X\) is assumed to depend on an external parameter, \(h\). The flow equation is then derived with respect to \(h\): for every \(n\in\{1,\cdots,p\}\), the derivative of \(\ell_n'(\underline\ell)\) with respect to \(h\) in terms of \(\partial_h\ell_i\) for \(i\in X\) is computed. It is then appended to the input flow equation.
|
||||
The input of <b>meantools differentiate</b> consists in a flow equation and a collection of variables \(X\subset\{1,\cdots,p\}\). Each running coupling constant \(\ell_i\) for \(i\in X\) is assumed to depend on an external parameter, \(h\). The flow equation is then differentiated with respect to \(h\): for every \(n\in\{1,\cdots,p\}\), the derivative of \(\ell_n'(\underline\ell)\) with respect to \(h\) in terms of \(\partial_h\ell_i\) for \(i\in X\) is computed. It is then appended to the input flow equation.
|
||||
</p>
|
||||
|
||||
<h2 class="section" id="exactness">Comments on the exactness of the computation</h2>
|
||||
<p>
|
||||
The computation of the flow equation, as well as its exponentiation and derivation, are <i>exact</i> in the sense that they only involve operations on integers and are not subject to truncations. The coefficients appearing in the flow equation are therefore <i>exact</i>. This statement has one major caveat: integer operations are only correct as long as the integers involved are not too large. The precise meaning of "not too large" is system dependent. In the source code, integers relating to flow equation coefficients are declared with the <code>long int</code> type, which, at least using the C library <b>meankondo</b> was tested with (that is <code>glibc 2.21</code>), means integers are encoded on 64 bits on 64-bit systems and 32 bits on 32-bit systems. All operations are therefore exact as long as all integers are in \([-2^{31},2^{31}-1]\) on 64-bit systems and \([-2^{15},2^{15}-1]\) on 32-bit systems.
|
||||
The computation of the flow equation, as well as all the operations done on it, are <i>exact</i> in the sense that they only involve operations on integers and are not subject to truncations. The coefficients appearing in the flow equation are therefore <i>exact</i>. This statement has one major caveat: integer operations are only correct as long as the integers involved are not too large. The precise meaning of "not too large" is system dependent. In the source code, integers relating to flow equation coefficients are declared with the <code>long int</code> type, which, at least using the C library <b>meankondo</b> was tested with (that is <code>glibc 2.21</code>), means integers are encoded on 64 bits on 64-bit systems and 32 bits on 32-bit systems. All operations are therefore exact as long as all integers are in \([-2^{31},2^{31}-1]\) on 64-bit systems and \([-2^{15},2^{15}-1]\) on 32-bit systems.
|
||||
</p>
|
||||
|
||||
<!--<p>
|
||||
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>
|
||||
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>
|
||||
|
||||
|
||||
|
7
editors/vim/ftdetect/meankondo.vim
Normal file
7
editors/vim/ftdetect/meankondo.vim
Normal file
@ -0,0 +1,7 @@
|
||||
" Vim ftdetect file
|
||||
" Language: meankondo
|
||||
" Maintainer: Ian Jauslin <ian.jauslin@roma1.infn.it>
|
||||
" Last Change: 2015-12-09
|
||||
" URL: http://ian.jauslin.org/software/meankondo
|
||||
"
|
||||
au BufRead,BufNewFile *.mk set filetype=meankondo
|
8
editors/vim/ftplugin/meankondo.vim
Normal file
8
editors/vim/ftplugin/meankondo.vim
Normal file
@ -0,0 +1,8 @@
|
||||
" Vim ftplugin file
|
||||
" Language: meankondo
|
||||
" Maintainer: Ian Jauslin <ian.jauslin@roma1.infn.it>
|
||||
" Last Change: 2015-12-09
|
||||
" URL: http://ian.jauslin.org/software/meankondo
|
||||
"
|
||||
|
||||
set mps+=<:>
|
111
editors/vim/syntax/meankondo.vim
Normal file
111
editors/vim/syntax/meankondo.vim
Normal file
@ -0,0 +1,111 @@
|
||||
" Vim syntax file
|
||||
" Language: meankondo
|
||||
" Maintainer: Ian Jauslin <ian.jauslin@roma1.infn.it>
|
||||
" Last Change: 2022-06-06
|
||||
" URL: http://ian.jauslin.org/software/meankondo
|
||||
"
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Comments
|
||||
syn match Comment '#.*'
|
||||
|
||||
" Regions
|
||||
syn region FieldsRegion matchgroup=configHeader start='#!fields' end='&' transparent contains=Comment,Separator,FieldHeader,FieldInField,Equal
|
||||
syn region VariablesRegion matchgroup=configHeader start='#!preprocessor_variables' end='&' transparent contains=@Globals,VariableHeader
|
||||
syn region IdTableRegion matchgroup=configHeader start='#!id_table' end='&' transparent contains=@Globals,RegionHeader
|
||||
syn region SymbolsRegion matchgroup=configHeader start='#!symbols' end='&' transparent contains=@Globals,VariableHeader
|
||||
syn region PolynomialRegion matchgroup=configHeader start='#!input_polynomial' end='&' transparent
|
||||
syn region PolynomialRegion matchgroup=configHeader start='#!postprocess_operation' end='&' transparent
|
||||
syn region PolynomialRegion matchgroup=configHeader start='#!postprocess_flow_equation' end='&' transparent
|
||||
syn region PolynomialRegion matchgroup=configHeader start='#!numerical_postprocess_operation' end='&' transparent
|
||||
syn region PropagatorRegion matchgroup=configHeader start='#!propagator' end='&' transparent contains=Comment,Number,NumberBase,Separator,FieldInProp,Equal,NumberInProp
|
||||
syn region IdentitiesRegion matchgroup=configHeader start='#!identities' end='&' transparent
|
||||
syn region GroupsRegion matchgroup=configHeader start='#!groups' end='&' transparent contains=Comment,Separator,FieldHeader,FieldInField,Equal,GroupParenthesis
|
||||
syn region LabelsRegion matchgroup=configHeader start='#!labels' end='&' transparent contains=String,RegionHeader,Separator,Comment,Equal
|
||||
syn region FlowEquationRegion matchgroup=configHeader start='#!flow_equation' end='&' transparent
|
||||
syn region InitCdRegion matchgroup=configHeader start='#!initial_condition' end='&' transparent contains=Comment,Separator,RegionHeader,Equal,NumberInInit,InitHeader
|
||||
syn region DerivVarsRegion matchgroup=configHeader start='#!variables' end='&' transparent contains=Comment,Separator,FieldHeader,FieldInField,Equal,VarAll
|
||||
|
||||
" Generic syntax
|
||||
syn match Field '\[f[-0-9]\+\]'
|
||||
syn match Factor '\[l[-0-9]\+\]'
|
||||
syn match Factor '\[d*% *[-0-9]\+\]' contains=Deriv
|
||||
syn match ConstantF '\[d*C *[0-9]\+\]' contains=Deriv
|
||||
syn match ConstantD '\[/C *[0-9]\+ *\^ *[0-9]\+\]'
|
||||
syn match Deriv 'd' contained
|
||||
syn match Variables '\$[^>]*'
|
||||
syn match Number '<[-/0-9]*>'
|
||||
syn match Number '([-/0-9]*)'
|
||||
syn match NumberBase 's{[-/0-9]*}'
|
||||
syn match NumberBase '(s{[-/0-9]*})'
|
||||
syn match Operator '[*+]'
|
||||
syn match Operator '%exp'
|
||||
syn match Operator '%log_1'
|
||||
syn match Separator ','
|
||||
syn match Equal '[:=]'
|
||||
|
||||
syn cluster Globals contains=Comment,Field,Factor,Constant,Variables,Number,NumberBase,Operator,Separator,Equal
|
||||
|
||||
" Fields
|
||||
syn keyword FieldHeader i contained
|
||||
syn keyword FieldHeader x contained
|
||||
syn keyword FieldHeader h contained
|
||||
syn keyword FieldHeader f contained
|
||||
syn keyword FieldHeader a contained
|
||||
syn match FieldInField '[-0-9]\+' contained
|
||||
|
||||
" Variables
|
||||
syn match VariableHeader '^[^=,]*='he=e-1 contained contains=Equal
|
||||
|
||||
" Groups
|
||||
syn match GroupParenthesis '[()]' contained
|
||||
|
||||
" Propagator
|
||||
syn match FieldInProp '[0-9]\+ *[;:]'he=e-1 contained contains=Equal,NumberInProp
|
||||
syn match NumberInProp ': *[-/()0-9s{}]*'hs=s+1 contained
|
||||
|
||||
" IdTable
|
||||
syn match RegionHeader '[0-9]\+:'he=e-1 contained contains=Equal
|
||||
|
||||
" Labels
|
||||
syn match String '"[^"]*"'hs=s+1,he=e-1 contained
|
||||
|
||||
" Initial condition
|
||||
syn match InitHeader '[0-9]\+:'he=e-1 contained contains=Equal,NumberInInit
|
||||
syn match NumberInInit ': *[-.e0-9]*'hs=s+1 contained
|
||||
|
||||
" Variables
|
||||
syn keyword VarAll all contained
|
||||
|
||||
|
||||
" Colors
|
||||
hi Comment ctermfg=cyan
|
||||
hi configHeader ctermfg=red
|
||||
hi Field ctermfg=Lightblue
|
||||
hi Factor ctermfg=Lightblue
|
||||
hi ConstantF ctermfg=Lightblue
|
||||
hi ConstantD ctermfg=Lightgreen
|
||||
hi Deriv ctermfg=red
|
||||
hi Header ctermfg=Lightgreen
|
||||
hi Variables ctermfg=yellow
|
||||
hi Number ctermfg=green
|
||||
hi NumberBase ctermfg=green
|
||||
hi Separator ctermfg=red
|
||||
hi Equal ctermfg=Lightred
|
||||
hi Operator ctermfg=magenta
|
||||
hi String ctermfg=magenta
|
||||
hi NumberInInit ctermfg=magenta
|
||||
|
||||
hi def link FieldInField Field
|
||||
hi def link VariableHeader Variables
|
||||
hi def link FieldInProp Field
|
||||
hi def link FieldHeader Header
|
||||
hi def link NumberInProp Number
|
||||
hi def link SeparatorInProp Separator
|
||||
hi def link RegionHeader Header
|
||||
hi def link InitHeader Header
|
||||
hi def link GroupParenthesis Separator
|
||||
hi def link VarAll Field
|
@ -1,5 +1,5 @@
|
||||
.Dd $Mdocdate: April 14 2015 $
|
||||
.Dt kondo_preprocess 1.2.1
|
||||
.Dd $Mdocdate: February 3 2016 $
|
||||
.Dt kondo_preprocess 1.5
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm kondo_preprocess
|
||||
@ -13,11 +13,21 @@ for the Kondo model
|
||||
.Pp
|
||||
.Nm
|
||||
.Fl v
|
||||
.Sh DEPRECATION NOTICE
|
||||
The use of
|
||||
.Nm
|
||||
is deprecated as of
|
||||
.Sy meankondo
|
||||
v1.5.
|
||||
.Pp
|
||||
Similar functionality can be obtained rather easily using the enhanced symbolic capabilities introduced in v1.5, which are more flexible than
|
||||
.Nm .
|
||||
.Pp
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
generates a configuration file to be read by
|
||||
.Sy meankondo
|
||||
for the Kondo model. It generates the '#!fields', '#!symbols', '#!identities', '#!groups', '#!propagator', '#!input_polynomial' and '#!id_table' entries from special '#!propagator', '#!input_polynomial' and '#!id_table' entries, which are much more synthetic than those needed for the Kondo model.
|
||||
for the Kondo model. It generates the '#!fields', '#!virtual_fields', '#!identities', '#!groups', '#!propagator', '#!input_polynomial' and '#!id_table' entries from special '#!propagator', '#!input_polynomial' and '#!id_table' entries, which are much more synthetic than those needed for the Kondo model.
|
||||
.Pp
|
||||
The quantities in the configuration file are expressed in terms of the observables A and B, which we do not define here, as well as the magnetic field h.
|
||||
.Pp
|
||||
@ -32,14 +42,7 @@ is part of a set of tools to compute and manipulate Fermionic hierarchical flows
|
||||
: numerical evaluation of flow equations.
|
||||
.It
|
||||
.Sy meantools, meantools-convert
|
||||
: perform various operations on flow equations (derivation, exponentiation, evaluation and conversion to other formats).
|
||||
.El
|
||||
.Pp
|
||||
as well as the following pre-processors, which generate configuration files for their associated model:
|
||||
.Bl -bullet
|
||||
.It
|
||||
.Sy kondo_proprocess
|
||||
: Kondo model
|
||||
: perform various operations on flow equations (differentiation, products, sums, exponentials and logarithms of flow equations, evaluation and conversion to other formats).
|
||||
.El
|
||||
.Pp
|
||||
.Sh COMMAND-LINE ARGUMENTS
|
||||
@ -73,13 +76,13 @@ up to the following differences.
|
||||
.It
|
||||
The fields can be specified as scalar products of A's and B's. For each n in {1,...,dimension},
|
||||
.Nm
|
||||
defines An and Bn, as well as symbols for scalar products of the form
|
||||
defines An and Bn, as well as virtual fields for scalar products of the form
|
||||
.D1 [f An.An]
|
||||
.D1 [f Bn.Bn]
|
||||
.D1 [f An.Bn]
|
||||
.D1 [f An.h]
|
||||
.D1 [f Bn.h]
|
||||
In addition, a vector product symbol is defined for (AnxBn).h :
|
||||
In addition, a vector product virtual field is defined for (AnxBn).h :
|
||||
.D1 [f AnxBn.h]
|
||||
.Pp
|
||||
.It
|
||||
@ -94,6 +97,30 @@ defines external fields for A and B, denoted by a and b. They can be used as fie
|
||||
.D1 <axb.h>
|
||||
.Pp
|
||||
.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 '#!virtual_fields' 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 '#!virtual_fiields' 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
|
||||
.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
|
||||
@ -118,6 +145,9 @@ in which the polynomial can use the fields
|
||||
.D1 <a.h>
|
||||
.D1 <b.h>
|
||||
.D1 <axb.h>
|
||||
.D1 <t.h>
|
||||
.D1 <a.t>
|
||||
.D1 <b.t>
|
||||
defined above.
|
||||
.Pp
|
||||
Example:
|
||||
@ -134,7 +164,7 @@ Example:
|
||||
.D1 A1;A2: 1 , A2;A1: -1 , B1;B2: s{-1} , B2;B1: (-1)s{-1}
|
||||
.Pp
|
||||
.It Sy extra entries
|
||||
If there is a '#!symbols' or an '#!identities' entry in the configuration file, then they are appended to the end of those entries in the new configuration file.
|
||||
If there is a '#!virtual_fields' or an '#!identities' entry in the configuration file, then they are appended to the end of those entries in the new configuration file.
|
||||
.Pp
|
||||
Any other entry is appended to the new configuration file. This can be useful to pipe the output to tools other than
|
||||
.Sy meankondo
|
||||
|
218
man/meankondo.1
218
man/meankondo.1
@ -1,5 +1,5 @@
|
||||
.Dd $Mdocdate: April 13 2015 $
|
||||
.Dt meankondo 1.2.1
|
||||
.Dd $Mdocdate: June 6 2022 $
|
||||
.Dt meankondo 1.5
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm meankondo
|
||||
@ -8,6 +8,8 @@
|
||||
.Nm
|
||||
.Op Fl t Ar threads
|
||||
.Op Fl C
|
||||
.Op Fl p
|
||||
.Op Fl A
|
||||
.Op Ar config_file
|
||||
.Pp
|
||||
.Nm
|
||||
@ -29,14 +31,7 @@ is part of a set of tools to compute and manipulate Fermionic hierarchical flows
|
||||
: numerical evaluation of flow equations.
|
||||
.It
|
||||
.Sy meantools, meantools-convert
|
||||
: perform various operations on flow equations (derivation, exponentiation, evaluation and conversion to other formats).
|
||||
.El
|
||||
.Pp
|
||||
as well as the following pre-processors, which generate configuration files for their associated model:
|
||||
.Bl -bullet
|
||||
.It
|
||||
.Sy kondo_proprocess
|
||||
: Kondo model
|
||||
: perform various operations on flow equations (differentiation, products, sums, exponentials and logarithms of flow equations, evaluation and conversion to other formats).
|
||||
.El
|
||||
.Pp
|
||||
.Sh COMMAND-LINE ARGUMENTS
|
||||
@ -44,9 +39,13 @@ as well as the following pre-processors, which generate configuration files for
|
||||
.It Fl t Ar threads
|
||||
The number of threads to use for the computation.
|
||||
.It Fl C
|
||||
Format the ouptput so it can be piped to
|
||||
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.
|
||||
.It Fl p
|
||||
Print the progress of the computation.
|
||||
.It Fl A
|
||||
Compute the average of the effective potential, but do not write the result as a flow equation.
|
||||
.It Fl v
|
||||
Print version information and exit.
|
||||
.El
|
||||
@ -67,16 +66,22 @@ recognizes the following entries (unless explicitly mentioned, the entries below
|
||||
.It Sy #!fields
|
||||
A list of the fields of the model.
|
||||
.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
|
||||
.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 two fields whose indices are 101 and -101).
|
||||
.It
|
||||
The indices following 'x' correspond to external fields that are associated conjugate field (e.g. 'x:100' defines a field whose index is -100). External indices may not appear as internal indices.
|
||||
The indices following 'x' correspond to external fields that are associated conjugate field (e.g. 'x:100' defines two fields whose indices are 100 and -100). External indices may not appear as internal indices.
|
||||
.It
|
||||
The indices following 'h' correspond to external fields that are not associated a conjugate field. External indices may not appear as internal indices.
|
||||
.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.
|
||||
.Pp
|
||||
WARNING: 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
|
||||
.Pp
|
||||
.Em Line breaks are not ignored in this entry.
|
||||
@ -84,59 +89,94 @@ The 'f' line specifies which of the internal and external indices are Fermions,
|
||||
Example:
|
||||
.D1 i:101,102,201,202
|
||||
.D1 x:100,200
|
||||
.D1 h:301,302,303
|
||||
.D1 h:301,302,303,401,402,403
|
||||
.D1 f:100,101,102
|
||||
.D1 a:401,402,403
|
||||
.It Sy #!propagator
|
||||
The propagator of the model.
|
||||
.Pp
|
||||
The propagator entry is a ',' separated list whose elements are of the form
|
||||
.D1 index1;index2: polynomial
|
||||
where index1 and index2 are internal indices, and polynomial is a polynomial (see the POLYNOMIALS section below for information on how to format polynomials). The polynomial must not depend on the internal fields. Note that a number is a special type of polynomial, so propagators with numerical entries are handled by
|
||||
where 'index1' and 'index2' are internal indices, and 'polynomial' is a polynomial (see the POLYNOMIALS section below for information on how to format polynomials). The polynomial must not depend on the internal fields. Note that a number is a special type of polynomial, so propagators with numerical entries are handled by
|
||||
.Nm
|
||||
just as easily as propagators with symbolic entries. Such an entry means that
|
||||
.D1 <psi_{index1}^-psi_{index2}^+> = polynomial.
|
||||
.Pp
|
||||
Note that if the entries of the propagator are numbers instead of polynomials, then the Wick rule is implemented using a determinant instead of a sum over permutations, which is a lot faster for large monomials. Since the efficient computation of determinants requires divisions, polynomial entries in the propagator make the computation awkward, and
|
||||
.Nm
|
||||
falls back to implementing the Wick rule as a sum over permutations.
|
||||
.Pp
|
||||
Example:
|
||||
.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.
|
||||
.It Sy #!input_polynomial
|
||||
The polynomial whose mean we wish to compute in order to calculate the flow equation.
|
||||
.Pp
|
||||
The symbols entry is a ',' separated list, whose elements are of the form
|
||||
The format of the polynomial is that specified in the POLYNOMIALS section.
|
||||
.Pp
|
||||
.It Sy #!preprocessor_variables
|
||||
In order to simplify configuration files, symbolic variables can be defined. When
|
||||
.Nm
|
||||
reads the configuration file, it replaces every variable with its value (a process which is referred to as "preprocessing").
|
||||
.Pp
|
||||
The preprocessor_variables entry is a ',' separated list, whose elements are of the form
|
||||
.D1 variable_name=value
|
||||
where 'variable_name' is a string that is not 'OUT', 'FLOW' or 'RCC', and may not contain any of the following characters: '$', '<', '>', '*', '+', '%'; and 'value' is a polynomial, formatted as described in the POLYNOMIALS section. The variable names 'OUT' 'FLOW' and 'RCC' are reserved and cannot be used. Note that 'value' can contain other preprocessor variables. There is no safeguard against self-referencing definitions that may cause infinite loops.
|
||||
.Pp
|
||||
A variable can be used throughout the configuration file by using the format '<$variable_name>'. Whenever '<$variable_name>' is encountered, it is replaced by its corresponding value. The order in which the variables are defined is irrelevant, since
|
||||
.Nm
|
||||
reads all variables definitions before replacing variables in the configuration file.
|
||||
.Pp
|
||||
Spaces surrounding the variable name are ignored.
|
||||
.Pp
|
||||
Example:
|
||||
.D1 psi1 = [f1]+[f-1],
|
||||
.D1 psi2 = [f2]+[f-2],
|
||||
.D1 A = <$psi1>*<$psi2>
|
||||
.Pp
|
||||
.It Sy #!identities
|
||||
Identities satisfied by some of the fields (optional entry).
|
||||
.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, or non-commuting objects may satisfy non-trivial commutation relations), which should be simplified out from the flow equation.
|
||||
.Pp
|
||||
The identities entry is a ',' separated list, whose elements are of the form
|
||||
.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).
|
||||
.Pp
|
||||
Identities could be used to reproduce the functionality of preprocessor variables, though it is less convenient (see COMMENT ON PREPROCESSOR VARIABLES, IDENTITIES AND VIRTUAL FIELDS).
|
||||
.Pp
|
||||
Example:
|
||||
.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 #!virtual_fields
|
||||
Virtual fields are used to keep the memory footprint of
|
||||
.Nm
|
||||
small, even when the input polynomial contains many terms.
|
||||
.Pp
|
||||
Every term of the input polynomial is parsed and stored when the configuration file is read, which may require large amounts of memory. In order to avoid this, some terms of the input polynomial can be grouped together and stored as a single virtual field, which only occupies as much memory as a single field.
|
||||
.Pp
|
||||
A virtual field is identified by an index, which must be different from those of the fields defined in the '#!fields' entry.
|
||||
.Pp
|
||||
The virtual_fields 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.
|
||||
where 'index' is the index of the virtual_field 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 virtual fields. There is no safeguard against self-referencing definitions that may cause infinite loops.
|
||||
.Pp
|
||||
WARNING: Virtual fields 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
|
||||
Virtual fields could be used to reproduce the functionality of commuting preprocessor variables (see COMMENT ON PREPROCESSOR VARIABLES, IDENTITIES AND VIRTUAL FIELDS).
|
||||
.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
|
||||
.It Sy #!identities
|
||||
Identities satisfied by some of the fields (optional entry).
|
||||
.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.
|
||||
.Pp
|
||||
The identities entry is a ',' separated list, whose elements are of the form
|
||||
.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).
|
||||
.Pp
|
||||
Example:
|
||||
.D1 [f301][f301]=(1)+(-1)[f302][f302]+(-1)[f303][f303]
|
||||
.Pp
|
||||
This entry is optional.
|
||||
.Pp
|
||||
.It Sy #!input_polynomial
|
||||
The polynomial whose mean we wish to compute in order to calculate the flow equation.
|
||||
.Pp
|
||||
The format of the polynomial is that specified in the POLYNOMIALS section. In addition, the polynomial can be specified as the product of other polynomials:
|
||||
.D1 polynomial1 * polynomial2 * ...
|
||||
Note that there are no parentheses, and therefore, products cannot be nested, nor can a product of polynomials be summed with another polynomial.
|
||||
.Pp
|
||||
Example:
|
||||
.D1 (1) + (1/2)[l1][f1001] * (1) + (1/2)[l2][f2001]
|
||||
.It Sy #!id_table
|
||||
The idtable used to identify the running coupling constants.
|
||||
The idtable is used to identify the running coupling constants.
|
||||
.Pp
|
||||
Once the mean of the input polynomial has been computed, we are left with a polynomial of the external fields and the running coupling constants that were in the input polynomial. In order to compute a flow equation from this average,
|
||||
.Nm
|
||||
@ -144,7 +184,7 @@ uses an idtable to identify which of the monomials of the average contribute to
|
||||
.Pp
|
||||
The id_table entry is a ',' separated list, whose elements are of the form
|
||||
.D1 rcc: polynomial
|
||||
where rcc is the index of the corresponding running coupling constant, which is a non-negative integer, and polynomial is the polynomial to which rcc refers to (which is a polynomial of the external fields).
|
||||
where 'rcc' is the index of the corresponding running coupling constant, which is a non-negative integer, and 'polynomial' is the polynomial to which 'rcc' refers to (which is a polynomial of the external fields).
|
||||
.Pp
|
||||
Example:
|
||||
.D1 1:(-1)[f-100][f100] , 2:[f-200][f200]
|
||||
@ -163,20 +203,81 @@ The groups entry is a list of collections of fields or symbols of the following
|
||||
Example:
|
||||
.D1 (1001,1002) (2001,2002)
|
||||
.Pp
|
||||
.Em Warning:
|
||||
This entry is optional.
|
||||
.It Sy #!postprocess_operation
|
||||
An operation that is done after having computed the mean of the input polynomial. (optional entry)
|
||||
.Pp
|
||||
The format of this entry is a polynomial, as specified in the POLYNOMIALS section.
|
||||
.Pp
|
||||
When this entry is present in the configuration,
|
||||
.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.
|
||||
creates a preprocessor variable named 'OUT', which contains the mean of the input polynomial, and can be used in the postprocessing.
|
||||
.Pp
|
||||
Example:
|
||||
To multiply the mean of the input polynomial by 8:
|
||||
.D1 <<8>*<$OUT>>
|
||||
.Pp
|
||||
This entry is optional.
|
||||
.It Sy #!postprocess_flow_equation
|
||||
This entry is similar to 'posprocess_operation', except that the operation is performed on the flow equation, that is, it is performed after having grouped the polynomial. (optional entry)
|
||||
.Pp
|
||||
The main difference with carrying out the operation in this way is that the constant term gets handles differently. Whereas 'postprocess_operation' gets applied to the entire polynomial, 'postprocess_flow_equation' is applied to each running coupling constant in the flow equation except the constant term. This is quite useful when the operation is not a polynomial function, such as log_1 or exp.
|
||||
.Pp
|
||||
The format of this entry is a polynomial, as specified in the POLYNOMIALS section.
|
||||
.Pp
|
||||
When this entry is present in the configuration,
|
||||
.Nm
|
||||
creates a preprocessor variable named 'FLOW', which contains the polynomial obtained by adding each term in the id_table, and can be used in the postprocessing.
|
||||
.Pp
|
||||
Example:
|
||||
To take the logarithm of the flow equation:
|
||||
.D1 <%log_1<$FLOW>>
|
||||
.Pp
|
||||
This entry is optional.
|
||||
.It Sy #!numerical_postprocess_operation
|
||||
An operation that is done at each step of an eventual numerical computation done with numkondo. (optional entry)
|
||||
.Pp
|
||||
This is similar in spirit to the 'postprocess_flow_equation' entry, except that the postprocessing is entirely numerical (no symbolic operations are performed).
|
||||
.Pp
|
||||
The format of this entry is a polynomial, as specified in the POLYNOMIALS section.
|
||||
.Pp
|
||||
When this entry is present in the configuration,
|
||||
.Nm
|
||||
creates a preprocessor variable named 'RCC', which contains the polynomial obtained by adding each term in the id_table, and can be used in the postprocessing.
|
||||
.Pp
|
||||
When this entry is present in the configuration along with the -C option,
|
||||
.Nm
|
||||
will add a 'preprocessor_operation' entry in the configuration file to be piped to numkondo.
|
||||
.Pp
|
||||
Example:
|
||||
To take the logarithm of the polynomial:
|
||||
.D1 <%log_1<$RCC>>
|
||||
.Pp
|
||||
This entry is optional.
|
||||
.Pp
|
||||
.El
|
||||
.Pp
|
||||
.Sh COMMENT ON PREPROCESSOR VARIABLES, IDENTITIES AND VIRTUAL FIELDS
|
||||
On the surface, preprocessor variables, identities and virtual fields can be used to perform similar tasks, but
|
||||
.Nm
|
||||
handles them in very different ways.
|
||||
.Pp
|
||||
A preprocessor variable could be replaced by an identity by introducing an extra field corresponding to the variable, and using an identity to make
|
||||
.Nm
|
||||
replace the extra field by its definition. Using a preprocessor variable will, however, be more convenient since no extra field needs to be introduced.
|
||||
.Pp
|
||||
Virtual fields could also play the role of preprocessor variables, in that they can be used to simplify the configuration file. However, virtual fields are not replaced by their corresponding expression until their average is computed, and, in the various manipulations required to carry out the computations, the monomials containing virtual fields will be manipulated and virtual fields commuted with other fields. As a consequence, virtual fields must commute with all other fields, which severely limits their potential role as a preprocessor variable.
|
||||
.Pp
|
||||
In short, preprocessor variables are meant to be used to simplify the configuration file, identities, to implement identities between fields, and virtual fields to reduce the memory footprint of
|
||||
.Nm .
|
||||
.Pp
|
||||
.Sh NUMBERS
|
||||
.Nm
|
||||
can parse rational numbers and linear combinations of square roots of integers (positive or negative (which is how complex numbers are implemented)) with rational coefficients (i.e. elements of the field extension of Q generated by sqrt(Z)).
|
||||
.Pp
|
||||
A number is a '+' separated list whose elements are of the form
|
||||
.D1 (a/b)s{r}
|
||||
where a and r are integers and b is a positive integer. s{r} stands for sqrt(r).
|
||||
where 'a' and 'r' are integers and 'b' is a positive integer. 's{r}' stands for 'sqrt(r)'.
|
||||
.Pp
|
||||
If a=b, then the number may be written as 's{r}'. If b=1, then it can be '(a)s{r}'. If r=1, then it can be 'a/b'. If b=r=1, then it can be 'a'.
|
||||
.Pp
|
||||
@ -184,7 +285,10 @@ Example:
|
||||
.D1 (1/2)s{2} + (-1)s{-1} + 3/2
|
||||
.Pp
|
||||
.Sh POLYNOMIALS
|
||||
Polynomials are '+' separated lists of monomials. Each monomial is a sequence of numbers, rccs and fields.
|
||||
.Nm
|
||||
implements some elementary symbolic algebra in order to parse polynomials.
|
||||
.Pp
|
||||
The format of polynomials is defined recursively. If the polynomial contains no '<', then it is said to be 'terminal'. Terminal polynomials are '+' separated lists of monomials. Each monomial is a sequence of numbers, rccs and fields.
|
||||
.Bl -bullet
|
||||
.It
|
||||
Numbers are enclosed between '(' and ')'. If there are several numbers in a monomial, then they are multiplied.
|
||||
@ -196,8 +300,17 @@ Fields are non-vanishing indices enclosed between '[f' and ']'. Fields must eith
|
||||
.Pp
|
||||
If the numerical factor of a monomial is 1, then it can be dropped. However, even if the numerical factor is a single integer, its '(' and ')' delimiters cannot be omitted.
|
||||
.Pp
|
||||
If the polynomial is not terminal, then it is of the form
|
||||
.D1 <polynomial>operation<polynomial>
|
||||
where 'operation' is either '+' or '*', or
|
||||
.D1 <%func<polynomial>>
|
||||
where 'func' is 'exp' or 'log_1'. '<%exp<P>>' returns the exponential of P, whereas '<%log_1<P>>' returns log(1+P).
|
||||
.Pp
|
||||
.Nm
|
||||
parses polynomials by recursing through this structure, adding and multiplying terminal polynomials when '+' and '*' operations are encountered, and taking exponentials and logarithms when '%exp' or '%log_1' are encountered.
|
||||
.Pp
|
||||
Example:
|
||||
.D1 (1) + ((3/2)s{2} + (-1)s{-1} + 3)[l1][l2][f100][f1001][f101] + [l1][f101] + (3)[l2]
|
||||
.D1 <(1)+((3/2)s{2}+(-1)s{-1}+3)[l1][l2][f100][f1001][f101]>*<%exp<[l1][f101]+(3)[l2]>>
|
||||
.Pp
|
||||
.Sh OUTPUT
|
||||
.Nm
|
||||
@ -217,5 +330,4 @@ returns 0 on success and -1 on error.
|
||||
.Sx numkondo Ns (1) ,
|
||||
.Sx meantools Ns (1) ,
|
||||
.Sx meantools-convert Ns (1) ,
|
||||
.Sx kondo_preprocess Ns (1)
|
||||
.Pp
|
||||
|
@ -1,5 +1,5 @@
|
||||
.Dd $Mdocdate: June 12 2015 $
|
||||
.Dt meantools-convert 1.2.1
|
||||
.Dd $Mdocdate: June 6 2022 $
|
||||
.Dt meantools-convert 1.5
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm meantools-convert
|
||||
@ -43,14 +43,7 @@ is part of a set of tools to compute and manipulate Fermionic hierarchical flows
|
||||
: numerical evaluation of flow equations.
|
||||
.It
|
||||
.Sy meantools, meantools-convert
|
||||
: perform various operations on flow equations (derivation, exponentiation, evaluation and conversion to other formats).
|
||||
.El
|
||||
.Pp
|
||||
as well as the following pre-processors, which generate configuration files for their associated model:
|
||||
.Bl -bullet
|
||||
.It
|
||||
.Sy kondo_proprocess
|
||||
: Kondo model
|
||||
: perform various operations on flow equations (differentiation, products, sums, exponentials and logarithms of flow equations, evaluation and conversion to other formats).
|
||||
.El
|
||||
.Pp
|
||||
.Sh COMMAND-LINE ARGUMENTS
|
||||
@ -133,5 +126,4 @@ returns 0 on success and -1 on error.
|
||||
.Sx meankondo Ns (1)
|
||||
.Sx numkondo Ns (1) ,
|
||||
.Sx meantools Ns (1) ,
|
||||
.Sx kondo_preprocess Ns (1)
|
||||
.Pp
|
||||
|
120
man/meantools.1
120
man/meantools.1
@ -1,30 +1,34 @@
|
||||
.Dd $Mdocdate: April 14 2015 $
|
||||
.Dt meantools 1.2.1
|
||||
.Dd $Mdocdate: June 6 2022 $
|
||||
.Dt meantools 1.5
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm meantools
|
||||
.Nd A tool to manipulate flow equations
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Sy exp
|
||||
.Op Ar config_file
|
||||
.Pp
|
||||
.Nm
|
||||
.Sy derive
|
||||
.Sy differentiate
|
||||
.Op Fl d Ar nderivs
|
||||
.Op Fl V Ar variables
|
||||
.Op Fl C
|
||||
.Op Ar config_file
|
||||
.Pp
|
||||
.Nm
|
||||
.Sy eval
|
||||
.Op Fl R Ar values
|
||||
.Op Fl P Ar precision
|
||||
.Op Fl E Ar max_exponent
|
||||
.Op Ar config_file
|
||||
.Pp
|
||||
.Nm
|
||||
.Sy expand
|
||||
.Op Fl N Ar namespace
|
||||
.OpAr config_file
|
||||
.Pp
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
performs various operations on flow equations generated by
|
||||
.Sy meankondo.
|
||||
Namely, it can exponentiate, derive and evaluate flow equations.
|
||||
Namely, it can differentiate and evaluate flow equations, as well as perform elementary operations on polynomials.
|
||||
.Pp
|
||||
.Nm
|
||||
is part of a set of tools to compute and manipulate Fermionic hierarchical flows:
|
||||
@ -37,45 +41,11 @@ is part of a set of tools to compute and manipulate Fermionic hierarchical flows
|
||||
: numerical evaluation of flow equations.
|
||||
.It
|
||||
.Sy meantools, meantools-convert
|
||||
: perform various operations on flow equations (derivation, exponentiation, evaluation and conversion to other formats).
|
||||
: perform various operations on flow equations (differentiation, products, sums, exponentials and logarithms of flow equations, evaluation and conversion to other formats).
|
||||
.El
|
||||
.Pp
|
||||
as well as the following pre-processors, which generate configuration files for their associated model:
|
||||
.Bl -bullet
|
||||
.It
|
||||
.Sy kondo_proprocess
|
||||
: Kondo model
|
||||
.El
|
||||
.Pp
|
||||
.Sh EXP
|
||||
When run with the 'exp' command,
|
||||
.Nm
|
||||
computes the exponential of a flow equation. All the required parameters are set in the configuration file, which it either reads from the file provided on the command line, or from stdin.
|
||||
.Pp
|
||||
The syntax for the configuration file is the same as for
|
||||
.Sx meankondo Ns (1) ,
|
||||
and will not be belaboured here. The supported entries are
|
||||
.Bl -tag -width Ds
|
||||
.It Sy #!input_polynomial
|
||||
The polynomial whose exponential is to be computed.
|
||||
.Pp
|
||||
.It Sy #!fields
|
||||
The fields appearing in the polynomial
|
||||
.Pp
|
||||
.It Sy #!symbols
|
||||
Symbolic variables (optional entry).
|
||||
.Pp
|
||||
.It Sy #!identities
|
||||
identities between fields (optional entry).
|
||||
.Pp
|
||||
.It Sy #!id_table
|
||||
The idtable used to compute a flow equation from the polynomial.
|
||||
.El
|
||||
.Pp
|
||||
The resulting flow equation is written to stdout.
|
||||
.Pp
|
||||
.Sh DERIVE
|
||||
When run with the 'derive' command,
|
||||
.Sh DIFFERENTIATE
|
||||
When run with the 'differentiate' command,
|
||||
.Nm
|
||||
computes derivatives of a flow equation provided in the configuration file, which can either be passed as a command-line argument or through stdin.
|
||||
.Pp
|
||||
@ -83,7 +53,7 @@ The derivatives are derivatives with respect to an extra virtual parameter, whic
|
||||
.Pp
|
||||
When multiple derivatives are taken, the flow equation becomes a flow equation for the rccs, their derivatives, second derivatives, and so forth...
|
||||
.Pp
|
||||
This operation can be useful, for instance, to compute moments in an interacting system, in which the generating functional can be expressed as an effective potential depending on a parameter with respect to which the result of the integration should be derived. The 'derive' command writes the flow equation for the derived rccs, from which the quantities of interest can be computed.
|
||||
This operation can be useful, for instance, to compute moments in an interacting system, in which the generating functional can be expressed as an effective potential depending on a parameter with respect to which the result of the integration should be differentiated. The 'differentiate' command writes the flow equation for the differentiated rccs, from which the quantities of interest can be computed.
|
||||
.Pp
|
||||
.Sy Command-line arguments:
|
||||
.Bl -tag -width Ds
|
||||
@ -94,15 +64,19 @@ The variables that depend on the extra virtual parameter (defaults to all) (WARN
|
||||
.Nm
|
||||
would interpret the argument as being a flag, for example, write '-V "0,-1"' instead of '-V "-1,0"').
|
||||
.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 differentiate 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
|
||||
.Pp
|
||||
.Sy Configuration file:
|
||||
.Pp
|
||||
The configuration file contains the flow equation to derive, and optionally a list of variables (similar to the '-V' flag). The following entries are supported:
|
||||
The configuration file contains the flow equation to differentiate, and optionally a list of variables (similar to the '-V' flag). The following entries are supported:
|
||||
.Bl -tag -width Ds
|
||||
.It Sy #!flow_equation
|
||||
The flow equation to derive.
|
||||
The flow equation to differentiate.
|
||||
.Pp
|
||||
The syntax is identical to that in
|
||||
.Sx numkondo Ns (1) .
|
||||
@ -131,6 +105,12 @@ The values of the rccs with which to evaluate the flow equation.
|
||||
.Ar values
|
||||
is formatted like an initial_condition (see
|
||||
.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
|
||||
.Pp
|
||||
.Sy Configuration file:
|
||||
@ -156,9 +136,49 @@ If the '-R' flag is provided on the command-line, this entry is ignored.
|
||||
.Pp
|
||||
The result of the evaluation is written to stdout, and is formatted is such a way that it can be used as an initial condition for
|
||||
.Pp
|
||||
.Sh EXPAND
|
||||
When run with the 'expand' command,
|
||||
.Nm
|
||||
expands the preprocessor variables in the input polynomial, provided in the configuration file, which can either be passed as a command-line argument or through stdin, and prints the result.
|
||||
.Pp
|
||||
.Sy Command-line arguments:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl N Ar namespace
|
||||
If the configuration file is to be used to perform other operations, it may be convenient to specify the input polynomial for the 'expand' command alongside another '#!input_polynomial' entry, used for some other computation. This is made possible by namespaces.
|
||||
.Pp
|
||||
If a namespace is provided to
|
||||
.Nm
|
||||
on the command line, then it will search for the entries in the configuration file in the form
|
||||
.D1 #!namespace:header
|
||||
and default to #!header if no such header is present.
|
||||
.Pp
|
||||
In this way, the configuration file can, for instance, contain a '#!namspace:input_polynomial' entry for this computation, as well as a '#!input_polynomial' entry, to be used for some other purpose, all the while using the same '#!fields', '#!preprocessor_variables', '#!virtual_fields' and '#!identities' entries.
|
||||
.El
|
||||
.Pp
|
||||
.Sy Configuration file:
|
||||
.Pp
|
||||
The supported entries are
|
||||
.Bl -tag -width Ds
|
||||
.It Sy #!input_polynomial
|
||||
The polynomial whose exponential is to be computed.
|
||||
.Pp
|
||||
.It Sy #!fields
|
||||
The fields appearing in the polynomial.
|
||||
.Pp
|
||||
.It Sy #!preprocessor_variables
|
||||
Preprocessor variables (optional entry).
|
||||
.Pp
|
||||
.It Sy #!virtual_fields
|
||||
Virtual fields (optional entry).
|
||||
.Pp
|
||||
.It Sy #!identities
|
||||
identities between fields (optional entry).
|
||||
.El
|
||||
.Pp
|
||||
The result is written to stdout.
|
||||
.Pp
|
||||
.Sh SEE ALSO
|
||||
.Sx meankondo Ns (1) ,
|
||||
.Sx numkondo Ns (1) ,
|
||||
.Sx meantools-convert Ns (1) ,
|
||||
.Sx kondo_preprocess Ns (1)
|
||||
.Pp
|
||||
|
@ -1,5 +1,5 @@
|
||||
.Dd $Mdocdate: April 14 2015 $
|
||||
.Dt numkondo 1.2.1
|
||||
.Dd $Mdocdate: June 6 2022 $
|
||||
.Dt numkondo 1.5
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm numkondo
|
||||
@ -8,8 +8,9 @@
|
||||
.Nm
|
||||
.Op Fl F
|
||||
.Op Fl N Ar niter
|
||||
.Op Fl D Ar tolerance
|
||||
.Op Fl I Ar initial_condition
|
||||
.Op Fl P Ar precision
|
||||
.Op Fl E Ar max_exponent
|
||||
.Op Ar config_file
|
||||
.Pp
|
||||
.Nm
|
||||
@ -28,14 +29,7 @@ is part of a set of tools to compute and manipulate Fermionic hierarchical flows
|
||||
: numerical evaluation of flow equations.
|
||||
.It
|
||||
.Sy meantools, meantools-convert
|
||||
: perform various operations on flow equations (derivation, exponentiation, evaluation and conversion to other formats).
|
||||
.El
|
||||
.Pp
|
||||
as well as the following pre-processors, which generate configuration files for their associated model:
|
||||
.Bl -bullet
|
||||
.It
|
||||
.Sy kondo_proprocess
|
||||
: Kondo model
|
||||
: perform various operations on flow equations (differentiation, products, sums, exponentials and logarithms of flow equations, evaluation and conversion to other formats).
|
||||
.El
|
||||
.Pp
|
||||
.Sh COMMAND-LINE ARGUMENTS
|
||||
@ -44,12 +38,12 @@ as well as the following pre-processors, which generate configuration files for
|
||||
Number of iterations
|
||||
.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.
|
||||
.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
|
||||
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
|
||||
Print version information and exit.
|
||||
.El
|
||||
@ -145,6 +139,19 @@ If the '-F' flag is provided,
|
||||
.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.
|
||||
.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
|
||||
.Nm
|
||||
returns 0 on success and -1 on error.
|
||||
@ -153,5 +160,4 @@ returns 0 on success and -1 on error.
|
||||
.Sx meankondo Ns (1) ,
|
||||
.Sx meantools Ns (1) ,
|
||||
.Sx meantools-convert Ns (1) ,
|
||||
.Sx kondo_preprocess Ns (1)
|
||||
.Pp
|
||||
|
@ -1,4 +1,4 @@
|
||||
## Copyright 2015 Ian Jauslin
|
||||
## Copyright 2015-2022 Ian Jauslin
|
||||
##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License");
|
||||
## you may not use this file except in compliance with the License.
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
## Copyright 2015 Ian Jauslin
|
||||
## Copyright 2015-2022 Ian Jauslin
|
||||
##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License");
|
||||
## you may not use this file except in compliance with the License.
|
||||
@ -76,8 +76,8 @@ def latex_engine(argv,text):
|
||||
|
||||
i=1
|
||||
# defaults
|
||||
lsym="\\ell"
|
||||
Lsym="\\ell'"
|
||||
lsym=r'\\ell'
|
||||
Lsym=r'\\ell'
|
||||
Csym="C"
|
||||
oneline=1
|
||||
while (i<argc):
|
||||
@ -105,7 +105,7 @@ def latex_engine(argv,text):
|
||||
oneline=0
|
||||
i=i+1
|
||||
|
||||
return(convert_latex(text,lsym,Lsym,Csym,oneline,columns))
|
||||
return(convert_latex(text,lsym,Lsym,Csym,oneline))
|
||||
|
||||
# convert to C format
|
||||
def convert_C(text, lsym, Lsym, Csym, oneline):
|
||||
@ -160,7 +160,7 @@ def convert_C(text, lsym, Lsym, Csym, oneline):
|
||||
return(text+';')
|
||||
|
||||
# convert to LaTeX format
|
||||
def convert_latex(text, lsym, Lsym, Csym, oneline, columns):
|
||||
def convert_latex(text, lsym, Lsym, Csym, oneline):
|
||||
# remove newlines
|
||||
if (oneline==0):
|
||||
text=text.replace('\n','\\\\\n')
|
||||
@ -171,6 +171,10 @@ def convert_latex(text, lsym, Lsym, Csym, oneline, columns):
|
||||
# remove extra space
|
||||
text=re.sub(r' {2,}',' ',text)
|
||||
|
||||
# remove unnecessary 1's
|
||||
text=re.sub(r'\(-1\)\[',r'-[',text)
|
||||
text=re.sub(r'\(1\)\[',r'[',text)
|
||||
|
||||
# replace left hand side variables
|
||||
text=re.sub(r'\[(d*)C *([0-9]*)\] =',r'@\1'+Csym+r'_{\2} =', text)
|
||||
text=re.sub(r'\[(d*)% *([0-9]*)\] =',r'@\1'+Lsym+r'_{\2} =', text)
|
||||
@ -213,7 +217,11 @@ def convert_latex(text, lsym, Lsym, Csym, oneline, columns):
|
||||
# fractions
|
||||
text=re.sub(r'\((-?)([0-9]*)/([0-9]*)\)',r'\1\\frac{\2}{\3}',text)
|
||||
# numbers
|
||||
text=re.sub(r'\(([-0-9]*)\)',r'\1',text)
|
||||
#text=re.sub(r'\(([-0-9]*)\)',r'\1',text)
|
||||
|
||||
# fix signs
|
||||
text=re.sub(r'\+-',r'-',text)
|
||||
|
||||
|
||||
|
||||
return(text)
|
||||
|
69
src/array.c
69
src/array.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -72,6 +72,14 @@ int int_array_append(int val, Int_Array* output){
|
||||
return(0);
|
||||
}
|
||||
|
||||
// add a value only if it is not already present
|
||||
int int_array_append_unique(int val, Int_Array* output){
|
||||
if(int_array_find(val,*output)<0){
|
||||
int_array_append(val,output);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
// concatenate
|
||||
int int_array_concat(Int_Array input, Int_Array* output){
|
||||
int i;
|
||||
@ -87,6 +95,15 @@ int int_array_concat(Int_Array input, Int_Array* output){
|
||||
return(0);
|
||||
}
|
||||
|
||||
// concat but only add values that are not already present in the array
|
||||
int int_array_concat_unique(Int_Array input, Int_Array* output){
|
||||
int i;
|
||||
for(i=0;i<input.length;i++){
|
||||
int_array_append_unique(input.values[i],output);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
// find (does not assume the array is sorted)
|
||||
int int_array_find(int val, Int_Array array){
|
||||
int i;
|
||||
@ -199,7 +216,12 @@ int int_array_print(Int_Array array){
|
||||
for(i=0;i<array.length-1;i++){
|
||||
printf("%d,",array.values[i]);
|
||||
}
|
||||
printf("%d)",array.values[array.length-1]);
|
||||
if(array.length>0){
|
||||
printf("%d)",array.values[array.length-1]);
|
||||
}
|
||||
else{
|
||||
printf(")");
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -334,6 +356,19 @@ int char_array_concat(Char_Array input, Char_Array* output){
|
||||
return(0);
|
||||
}
|
||||
|
||||
// substring
|
||||
int char_array_substring(Char_Array str, int begin, int end, Char_Array* substr){
|
||||
int i;
|
||||
if(begin>end || begin<0 || end>=str.length){
|
||||
fprintf(stderr,"error: cannot extract a substring [%d,%d] from a string of length %d\n", begin, end, str.length);
|
||||
exit(-1);
|
||||
}
|
||||
init_Char_Array(substr,end-begin);
|
||||
for(i=begin;i<=end;i++){
|
||||
char_array_append(str.str[i],substr);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// convert to char*
|
||||
@ -343,7 +378,7 @@ int char_array_to_str(Char_Array input, char** output){
|
||||
for(i=0;i<input.length;i++){
|
||||
(*output)[i]=input.str[i];
|
||||
}
|
||||
if((*output)[input.length-1]!='\0'){
|
||||
if(input.length==0 || (*output)[input.length-1]!='\0'){
|
||||
(*output)[input.length]='\0';
|
||||
}
|
||||
return(0);
|
||||
@ -371,6 +406,34 @@ int str_to_char_array(char* str, Char_Array* output){
|
||||
return(0);
|
||||
}
|
||||
|
||||
// compare char_array's
|
||||
int char_array_cmp(Char_Array char_array1, Char_Array char_array2){
|
||||
int j;
|
||||
if(char_array1.length!=char_array2.length){
|
||||
return(0);
|
||||
}
|
||||
for(j=0;j<char_array1.length && j<char_array2.length;j++){
|
||||
if(char_array1.str[j]!=char_array2.str[j]){
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
// compare a char_array and a char*
|
||||
int char_array_cmp_str(Char_Array char_array, char* str){
|
||||
int j;
|
||||
for(j=0;j<char_array.length && str[j]!='\0';j++){
|
||||
if(char_array.str[j]!=str[j]){
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if(j==char_array.length && str[j]=='\0'){
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// format strings
|
||||
int char_array_snprintf(Char_Array* output, char* fmt, ...){
|
||||
|
14
src/array.h
14
src/array.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -34,8 +34,12 @@ int int_array_resize(Int_Array* array, int newsize);
|
||||
|
||||
// add a value
|
||||
int int_array_append(int val, Int_Array* output);
|
||||
// add a value only if it is not already present
|
||||
int int_array_append_unique(int val, Int_Array* output);
|
||||
// concatenate
|
||||
int int_array_concat(Int_Array input, Int_Array* output);
|
||||
// concat but only add values that are not already present in the array
|
||||
int int_array_concat_unique(Int_Array input, Int_Array* output);
|
||||
|
||||
// find (does not assume the array is sorted)
|
||||
int int_array_find(int val, Int_Array array);
|
||||
@ -75,6 +79,9 @@ int char_array_append_str(char* str, Char_Array* output);
|
||||
// concatenate
|
||||
int char_array_concat(Char_Array input, Char_Array* output);
|
||||
|
||||
// substring
|
||||
int char_array_substring(Char_Array str, int begin, int end, Char_Array* substr);
|
||||
|
||||
// convert to char*
|
||||
int char_array_to_str(Char_Array input, char** output);
|
||||
// noinit (changes the size of input if needed)
|
||||
@ -82,6 +89,11 @@ char* char_array_to_str_noinit(Char_Array* input);
|
||||
// convert from char*
|
||||
int str_to_char_array(char* str, Char_Array* output);
|
||||
|
||||
// compare char_array's
|
||||
int char_array_cmp(Char_Array char_array1, Char_Array char_array2);
|
||||
// compare a char_array and a char*
|
||||
int char_array_cmp_str(Char_Array char_array, char* str);
|
||||
|
||||
// format strings
|
||||
int char_array_snprintf(Char_Array* output, char* fmt, ...);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -121,3 +121,23 @@ int find_str_arg(char* title, Str_Array str_args){
|
||||
}
|
||||
}
|
||||
|
||||
// find a string argument with the specified title
|
||||
// namespace support
|
||||
int find_str_arg_ns(char* title, Char_Array namespace, Str_Array str_args){
|
||||
Char_Array buffer;
|
||||
int ret;
|
||||
|
||||
// append namespace to title
|
||||
char_array_cpy(namespace,&buffer);
|
||||
char_array_append(':',&buffer);
|
||||
char_array_append_str(title,&buffer);
|
||||
|
||||
// check whether the namespace entry exists
|
||||
ret=find_str_arg(char_array_to_str_noinit(&buffer), str_args);
|
||||
free_Char_Array(buffer);
|
||||
// if not, use global entry
|
||||
if(ret==-1){
|
||||
return(find_str_arg(title, str_args));
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -30,6 +30,8 @@ int read_config_file(Str_Array* str_args, const char* file, int read_from_stdin)
|
||||
int get_str_arg_title(Char_Array str_arg, Char_Array* out);
|
||||
// find a string argument with the specified title
|
||||
int find_str_arg(char* title, Str_Array str_args);
|
||||
// namespace support
|
||||
int find_str_arg_ns(char* title, Char_Array namespace, Str_Array str_args);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -18,6 +18,10 @@ limitations under the License.
|
||||
|
||||
#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
|
||||
#include <mpfr.h>
|
||||
#include "definitions.cpp"
|
||||
#include "rational.h"
|
||||
#include "istring.h"
|
||||
@ -198,6 +202,235 @@ int coefficient_simplify(Coefficient* coefficient){
|
||||
return(0);
|
||||
}
|
||||
|
||||
// put all terms under a common denominator and simplify the resulting fraction
|
||||
int coefficient_simplify_rational(Coefficient constant, Coefficient* coefficient){
|
||||
int ret;
|
||||
Coefficient remainder;
|
||||
Coefficient quotient;
|
||||
Coefficient quotient_prev;
|
||||
Coefficient out;
|
||||
int power;
|
||||
int max_power;
|
||||
|
||||
// common denominator
|
||||
coefficient_common_denominator(constant, coefficient);
|
||||
|
||||
// init
|
||||
init_Coefficient(&out, COEF_SIZE);
|
||||
|
||||
// simplify, one power at a time
|
||||
// largest power (larger powers are at the end)
|
||||
max_power=(*coefficient).denoms[(*coefficient).length-1].power;
|
||||
|
||||
quotient_prev=*coefficient;
|
||||
for(power=max_power;power>=1;power--){
|
||||
ret=coefficient_simplify_fraction(constant, quotient_prev, &remainder, "ient);
|
||||
|
||||
// if fail to simplify, stop
|
||||
if(ret<0){
|
||||
if(power<max_power){
|
||||
coefficient_concat_noinit(quotient_prev, &out);
|
||||
}
|
||||
else{
|
||||
coefficient_concat(quotient_prev, &out);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// add to output
|
||||
coefficient_concat_noinit(remainder, &out);
|
||||
}
|
||||
// if the factorization always succeeded
|
||||
if(max_power>=1 && power==0){
|
||||
coefficient_concat_noinit(quotient, &out);
|
||||
}
|
||||
|
||||
coefficient_simplify(&out);
|
||||
|
||||
// set coefficient to out
|
||||
free_Coefficient(*coefficient);
|
||||
*coefficient=out;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// put all terms under a common denominator
|
||||
// only supports coefficients with only one constant
|
||||
int coefficient_common_denominator(Coefficient constant, Coefficient* coefficient){
|
||||
int max_power;
|
||||
int i,j;
|
||||
Coefficient tmp;
|
||||
Coefficient out;
|
||||
Coefficient* C_n;
|
||||
|
||||
init_Coefficient(&out, COEF_SIZE);
|
||||
|
||||
// largest power (larger powers are at the end)
|
||||
max_power=(*coefficient).denoms[(*coefficient).length-1].power;
|
||||
|
||||
// store powers of the constant
|
||||
C_n=calloc(sizeof(Coefficient), max_power-1);
|
||||
for(i=0;i<max_power-1;i++){
|
||||
// start from previous product
|
||||
if(i==0){
|
||||
coefficient_cpy(constant, C_n+i);
|
||||
}
|
||||
else{
|
||||
coefficient_cpy(C_n[i-1], C_n+i);
|
||||
}
|
||||
// multiply by constant
|
||||
coefficient_prod_chain(constant, C_n+i);
|
||||
}
|
||||
|
||||
// multiply each term
|
||||
for (i=0;i<(*coefficient).length;i++){
|
||||
init_Coefficient(&tmp, COEF_SIZE);
|
||||
// start with numerator
|
||||
coefficient_append_noinit((*coefficient).factors[i], (*coefficient).nums[i], (*coefficient).denoms[i], &tmp);
|
||||
// multiply
|
||||
if((*coefficient).denoms[i].power<max_power){
|
||||
if((*coefficient).denoms[i].power==max_power-1){
|
||||
coefficient_prod_chain(constant, &tmp);
|
||||
}
|
||||
else{
|
||||
coefficient_prod_chain(C_n[max_power-(*coefficient).denoms[i].power-2], &tmp);
|
||||
}
|
||||
}
|
||||
|
||||
// set denom
|
||||
for(j=0;j<tmp.length;j++){
|
||||
tmp.denoms[j].power=max_power;
|
||||
}
|
||||
|
||||
// add to out
|
||||
coefficient_concat_noinit(tmp, &out);
|
||||
}
|
||||
|
||||
// free C_n
|
||||
for(i=0;i<max_power-1;i++){
|
||||
free_Coefficient(C_n[i]);
|
||||
}
|
||||
free(C_n);
|
||||
|
||||
// free coefficient vectors
|
||||
free((*coefficient).factors);
|
||||
free((*coefficient).nums);
|
||||
free((*coefficient).denoms);
|
||||
|
||||
// set output
|
||||
*coefficient=out;
|
||||
|
||||
coefficient_simplify(coefficient);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
// simplify coefficient / constant
|
||||
// returns both the remainder and the quotient
|
||||
// assumes both coefficient and constant are ordered with the highest order terms last
|
||||
int coefficient_simplify_fraction(Coefficient constant, Coefficient coefficient, Coefficient* remainder, Coefficient* out){
|
||||
Coefficient tmp;
|
||||
int step_counter=0;
|
||||
int max_order;
|
||||
int i,j,k;
|
||||
Int_Array rfactors;
|
||||
|
||||
if(constant.length==0){
|
||||
// nothing to do
|
||||
return 0;
|
||||
}
|
||||
|
||||
coefficient_cpy(coefficient, remainder);
|
||||
init_Coefficient(out, COEF_SIZE);
|
||||
|
||||
// continue until (*remainder) is of lower order than constant
|
||||
while((*remainder).length>0 && (*remainder).factors[(*remainder).length-1].length>=constant.factors[constant.length-1].length){
|
||||
step_counter++;
|
||||
|
||||
// interrupt if too long
|
||||
if(step_counter>=coefficient.length*100){
|
||||
free_Coefficient(*remainder);
|
||||
free_Coefficient(*out);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// try to find a term in the constant that divides the last term of the (*remainder)
|
||||
rfactors=(*remainder).factors[(*remainder).length-1];
|
||||
|
||||
// highest order in constant
|
||||
max_order=constant.factors[constant.length-1].length;
|
||||
|
||||
// start from one of the highest order term and look for a common factor
|
||||
for(i=constant.length-1; i>=0; i--){
|
||||
// fail: no highest order terms have been matched
|
||||
if(constant.factors[i].length<max_order){
|
||||
free_Coefficient(*remainder);
|
||||
free_Coefficient(*out);
|
||||
return -2;
|
||||
}
|
||||
|
||||
// check whether the term can be a factor of the last term of the (*remainder)
|
||||
if(int_array_is_subarray_ordered(constant.factors[i], rfactors)==1){
|
||||
// extract the factors that are not in constant
|
||||
init_Coefficient(&tmp, constant.length);
|
||||
|
||||
// init with one term
|
||||
tmp.length=1;
|
||||
init_Int_Array(tmp.factors,MONOMIAL_SIZE);
|
||||
|
||||
for(j=0,k=0;j<rfactors.length;j++){
|
||||
// check that index is not in constant
|
||||
if(k<constant.factors[i].length){
|
||||
if(rfactors.values[j]!=constant.factors[i].values[k]){
|
||||
int_array_append(rfactors.values[j],tmp.factors);
|
||||
}
|
||||
else{
|
||||
// move to next term in constant
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// numerical prefactor: term in the (*remainder) / term in the constant
|
||||
number_quot((*remainder).nums[(*remainder).length-1], constant.nums[i], tmp.nums);
|
||||
// denominator (dummy)
|
||||
tmp.denoms[0]=(*remainder).denoms[(*remainder).length-1];
|
||||
|
||||
// add to out
|
||||
coefficient_concat(tmp, out);
|
||||
|
||||
// multiply by -1
|
||||
Q minus_1;
|
||||
minus_1.numerator=-1;
|
||||
minus_1.denominator=1;
|
||||
number_Qprod_chain(minus_1, tmp.nums);
|
||||
|
||||
// multiply by constant
|
||||
coefficient_prod_chain(constant, &tmp);
|
||||
|
||||
// add to remainder
|
||||
coefficient_concat(tmp, remainder);
|
||||
|
||||
// free memory
|
||||
free_Coefficient(tmp);
|
||||
|
||||
// simplify
|
||||
coefficient_simplify(remainder);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// success!
|
||||
// decrease power of constant
|
||||
for(i=0;i<(*out).length;i++){
|
||||
(*out).denoms[i].power=(*out).denoms[i].power-1;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
// sort the terms in an equation (quicksort algorithm)
|
||||
int sort_coefficient(Coefficient* coefficient, int begin, int end){
|
||||
int i;
|
||||
@ -247,7 +480,7 @@ int exchange_coefficient_terms(int i, int j, Coefficient* coefficient){
|
||||
return(0);
|
||||
}
|
||||
|
||||
// derive a coefficient with respect to an index
|
||||
// differentiate a coefficient with respect to an index
|
||||
int coefficient_deriv_noinit(Coefficient input, int index, Coefficient* output){
|
||||
int i,j;
|
||||
// temp list of indices
|
||||
@ -321,7 +554,7 @@ int coefficient_deriv(Coefficient input, int index, Coefficient* output){
|
||||
}
|
||||
|
||||
/*
|
||||
// derive a coefficient with respect to an index (as a polynomial) (does not derive the 1/(1+C)^p )
|
||||
// differentiate a coefficient with respect to an index (as a polynomial) (does not differentiate the 1/(1+C)^p )
|
||||
int coefficient_deriv_noinit(Coefficient input, int index, Coefficient* output){
|
||||
int i;
|
||||
// temp list of indices
|
||||
@ -361,7 +594,7 @@ int coefficient_deriv_noinit(Coefficient input, int index, Coefficient* output){
|
||||
return(0);
|
||||
}
|
||||
|
||||
// derive a monomial with respect to an index
|
||||
// differentiate a monomial with respect to an index
|
||||
int monomial_deriv(Int_Array factor, int index, Int_Array* out_factor, int* match_count){
|
||||
int j;
|
||||
|
||||
@ -410,14 +643,14 @@ int coefficient_prod(Coefficient coef1, Coefficient coef2, Coefficient* output){
|
||||
int_array_concat(coef2.factors[j],&factor);
|
||||
|
||||
// don't throw an error if the power is 0
|
||||
if(coef2.denoms[i].power==0){
|
||||
coef2.denoms[i].index=coef1.denoms[i].index;
|
||||
if(coef2.denoms[j].power==0){
|
||||
coef2.denoms[j].index=coef1.denoms[i].index;
|
||||
}
|
||||
else if(coef1.denoms[i].power==0){
|
||||
coef1.denoms[i].index=coef2.denoms[i].index;
|
||||
coef1.denoms[i].index=coef2.denoms[j].index;
|
||||
}
|
||||
if(coef1.denoms[i].index!=coef2.denoms[j].index){
|
||||
fprintf(stderr,"error: cannot multiply flow equations with different constants\n");
|
||||
fprintf(stderr,"error: cannot multiply flow equations with different constants: got %d and %d\n", coef1.denoms[i].index, coef2.denoms[j].index);
|
||||
exit(-1);
|
||||
}
|
||||
denom=coef1.denoms[i];
|
||||
@ -721,7 +954,7 @@ int evalcoef(RCC rccs, Coefficient coef, long double* out){
|
||||
int i,j;
|
||||
long double num_factor;
|
||||
|
||||
*out=0;
|
||||
*out=0.;
|
||||
|
||||
// for each monomial
|
||||
for(i=0;i<coef.length;i++){
|
||||
@ -737,3 +970,44 @@ int evalcoef(RCC rccs, Coefficient coef, long double* out){
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -48,12 +48,20 @@ int coefficient_concat_noinit(Coefficient input, Coefficient* output);
|
||||
|
||||
// simplify a Coefficient
|
||||
int coefficient_simplify(Coefficient* coefficient);
|
||||
|
||||
// put all terms under a common denominator and simplify the resulting fraction
|
||||
int coefficient_simplify_rational(Coefficient constant, Coefficient* coefficient);
|
||||
// put all terms under a common denominator
|
||||
int coefficient_common_denominator(Coefficient constant, Coefficient* coefficient);
|
||||
// simplify coefficient / constant
|
||||
int coefficient_simplify_fraction(Coefficient constant, Coefficient coefficient, Coefficient* remainder, Coefficient* out);
|
||||
|
||||
// sort the terms in an equation (quicksort algorithm)
|
||||
int sort_coefficient(Coefficient* coefficient, int begin, int end);
|
||||
// exchange two terms (for the sorting algorithm)
|
||||
int exchange_coefficient_terms(int i, int j, Coefficient* coefficient);
|
||||
|
||||
// derive a coefficient with respect to an index (as a polynomial) (does not derive the 1/(1+C)^p )
|
||||
// differentiate a coefficient with respect to an index (as a polynomial) (does not differentiate the 1/(1+C)^p )
|
||||
int coefficient_deriv_noinit(Coefficient input, int index, Coefficient* output);
|
||||
int coefficient_deriv(Coefficient input, int index, Coefficient* output);
|
||||
|
||||
@ -74,5 +82,7 @@ int coef_denom_cmp(coef_denom denom1, coef_denom denom2);
|
||||
|
||||
// evaluate a coefficient on a vector
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -17,7 +17,7 @@ limitations under the License.
|
||||
#ifndef DEFINITIONS_GCC
|
||||
#define DEFINITIONS_GCC
|
||||
|
||||
#define VERSION "1.2.1"
|
||||
#define VERSION "1.4"
|
||||
|
||||
// number of entries in a configuration file
|
||||
#define ARG_COUNT 10
|
||||
@ -33,10 +33,16 @@ limitations under the License.
|
||||
#define EQUATION_SIZE 20
|
||||
// number of fields
|
||||
#define FIELDS_SIZE 50
|
||||
// number of variables
|
||||
#define VARIABLES_SIZE 10
|
||||
// number of elements in numbers
|
||||
#define NUMBER_SIZE 5
|
||||
// number of elements in a group
|
||||
#define GROUP_SIZE 5
|
||||
// number of children per node in a symbol_tree
|
||||
#define SYMBOL_TREE_SIZE 2
|
||||
// size of character string in symbol tree
|
||||
#define SYMBOL_TREE_LABEL_SIZE 10
|
||||
|
||||
|
||||
// display options
|
||||
@ -55,6 +61,6 @@ limitations under the License.
|
||||
#define FIELD_PARAMETER 1
|
||||
#define FIELD_EXTERNAL 2
|
||||
#define FIELD_INTERNAL 3
|
||||
#define FIELD_SYMBOL 4
|
||||
#define FIELD_VIRTUAL 4
|
||||
|
||||
#endif
|
||||
|
93
src/determinant.c
Normal file
93
src/determinant.c
Normal file
@ -0,0 +1,93 @@
|
||||
#include "determinant.h"
|
||||
|
||||
#include "number.h"
|
||||
#include "rational.h"
|
||||
#include "definitions.cpp"
|
||||
|
||||
// determinant of a matrix
|
||||
// replaces the matrix by its LU decomposition
|
||||
int determinant_inplace(Number_Matrix M, Number* out){
|
||||
int i;
|
||||
int sign_correction;
|
||||
|
||||
LU_dcmp_inplace(M, &sign_correction);
|
||||
|
||||
if(sign_correction==0){
|
||||
*out=number_zero();
|
||||
return(0);
|
||||
}
|
||||
|
||||
*out=number_one();
|
||||
if(sign_correction==-1){
|
||||
number_Qprod_chain(quot(-1,1), out);
|
||||
}
|
||||
|
||||
for(i=0;i<M.length;i++){
|
||||
number_prod_chain(M.matrix[i][i], out);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
// LU decomposition
|
||||
// uses pivoting to avoid dividing by 0
|
||||
// the sign_correction should be multiplied to the determinant to obtain the right value
|
||||
// if dividing by 0 is unavoidable, then the determinant is 0, and sign_correction is set to 0
|
||||
int LU_dcmp_inplace(Number_Matrix M, int* sign_correction){
|
||||
int i,j,k,pivot;
|
||||
Number tmp;
|
||||
|
||||
*sign_correction=1;
|
||||
|
||||
for(j=0;j<M.length;j++){
|
||||
for(i=0;i<=j;i++){
|
||||
for(k=0;k<i;k++){
|
||||
// -M[i][k]*M[k][j]
|
||||
number_prod(M.matrix[i][k], M.matrix[k][j], &tmp);
|
||||
number_Qprod_chain(quot(-1,1), &tmp);
|
||||
number_add_chain(tmp, M.matrix[i]+j);
|
||||
free_Number(tmp);
|
||||
}
|
||||
}
|
||||
for(i=j+1;i<M.length;i++){
|
||||
for(k=0;k<j;k++){
|
||||
// -M[i][k]*M[k][j]
|
||||
number_prod(M.matrix[i][k], M.matrix[k][j], &tmp);
|
||||
number_Qprod_chain(quot(-1,1), &tmp);
|
||||
number_add_chain(tmp, M.matrix[i]+j);
|
||||
free_Number(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
// pivot if M[j][j]==0
|
||||
// find first M[j][j] that is not 0
|
||||
for(pivot=j;pivot<M.length && number_is_zero(M.matrix[pivot][j])==1;pivot++){}
|
||||
|
||||
// no non-zero M[j][j] left: return
|
||||
if(pivot>=M.length){
|
||||
*sign_correction=0;
|
||||
return(0);
|
||||
}
|
||||
// pivot if needed
|
||||
if(pivot!=j){
|
||||
for(k=0;k<M.length;k++){
|
||||
tmp=M.matrix[j][k];
|
||||
M.matrix[j][k]=M.matrix[pivot][k];
|
||||
M.matrix[pivot][k]=tmp;
|
||||
}
|
||||
*sign_correction*=-1;
|
||||
|
||||
}
|
||||
|
||||
for(i=j+1;i<M.length;i++){
|
||||
// do not use the inplace algorithm if M[j][j] has more than one terms, since it would be modified by the inplace function
|
||||
if(M.matrix[j][j].length<=1){
|
||||
number_quot_inplace(M.matrix[i]+j, M.matrix[j]+j);
|
||||
}
|
||||
else{
|
||||
number_quot_chain(M.matrix[i]+j, M.matrix[j][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
17
src/determinant.h
Normal file
17
src/determinant.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
Compute the determinant of a number matrix
|
||||
*/
|
||||
|
||||
#ifndef DETERMINANT_H
|
||||
#define DETERMINANT_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
// determinant of a matrix
|
||||
int determinant_inplace(Number_Matrix M, Number* out);
|
||||
|
||||
// LU decomposition
|
||||
int LU_dcmp_inplace(Number_Matrix M, int* sign_correction);
|
||||
|
||||
|
||||
#endif
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
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 "expansions.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "definitions.cpp"
|
||||
#include "tools.h"
|
||||
#include "array.h"
|
||||
#include "polynomial.h"
|
||||
#include "number.h"
|
||||
#include "rational.h"
|
||||
|
||||
|
396
src/fields.c
396
src/fields.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -23,6 +23,13 @@ limitations under the License.
|
||||
#include "polynomial.h"
|
||||
#include "array.h"
|
||||
#include "rational.h"
|
||||
#include "tree.h"
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// Fields_Table
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
// init and free for Fields_Table
|
||||
int init_Fields_Table(Fields_Table* fields){
|
||||
@ -30,8 +37,9 @@ int init_Fields_Table(Fields_Table* fields){
|
||||
init_Int_Array(&((*fields).external),FIELDS_SIZE);
|
||||
init_Int_Array(&((*fields).internal),FIELDS_SIZE);
|
||||
init_Identities(&((*fields).ids), FIELDS_SIZE);
|
||||
init_Symbols(&((*fields).symbols), FIELDS_SIZE);
|
||||
init_Virtual_fields(&((*fields).virtual_fields), FIELDS_SIZE);
|
||||
init_Int_Array(&((*fields).fermions),FIELDS_SIZE);
|
||||
init_Int_Array(&((*fields).noncommuting),FIELDS_SIZE);
|
||||
return(0);
|
||||
}
|
||||
int free_Fields_Table(Fields_Table fields){
|
||||
@ -39,8 +47,9 @@ int free_Fields_Table(Fields_Table fields){
|
||||
free_Int_Array(fields.external);
|
||||
free_Int_Array(fields.internal);
|
||||
free_Identities(fields.ids);
|
||||
free_Symbols(fields.symbols);
|
||||
free_Virtual_fields(fields.virtual_fields);
|
||||
free_Int_Array(fields.fermions);
|
||||
free_Int_Array(fields.noncommuting);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -55,11 +64,11 @@ int field_type(int index, Fields_Table fields){
|
||||
else if(int_array_find(abs(index), fields.internal)>=0){
|
||||
return(FIELD_INTERNAL);
|
||||
}
|
||||
else if(intlist_find(fields.symbols.indices, fields.symbols.length, index)>=0){
|
||||
return(FIELD_SYMBOL);
|
||||
else if(intlist_find(fields.virtual_fields.indices, fields.virtual_fields.length, index)>=0){
|
||||
return(FIELD_VIRTUAL);
|
||||
}
|
||||
|
||||
fprintf(stderr,"error: index %d is neither a parameter nor an external or an internal field, nor a symbol\n",index);
|
||||
fprintf(stderr,"error: index %d is neither a parameter nor an external or an internal field, nor a virtual field\n",index);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -73,8 +82,22 @@ 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
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
// allocate memory
|
||||
int init_Identities(Identities* identities,int size){
|
||||
@ -180,13 +203,16 @@ int identities_concat(Identities input, Identities* output){
|
||||
|
||||
// resolve the identities
|
||||
// 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 i,j,k,l;
|
||||
int sign;
|
||||
int fermion_count;
|
||||
int first_field;
|
||||
int at_least_one;
|
||||
int security;
|
||||
Int_Array monomial;
|
||||
Int_Array pre_monomial;
|
||||
Int_Array post_monomial;
|
||||
Number num;
|
||||
Number tmp_num;
|
||||
|
||||
@ -207,29 +233,38 @@ int resolve_ids(Polynomial* polynomial, Fields_Table fields){
|
||||
|
||||
// loop over ids
|
||||
for(j=0;j<fields.ids.length;j++){
|
||||
// check whether the monomial matches the id
|
||||
if(int_array_is_subarray_ordered(fields.ids.lhs[j],(*polynomial).monomials[i])==1){
|
||||
init_Int_Array(&monomial, (*polynomial).monomials[i].length);
|
||||
|
||||
// remove lhs from monomial
|
||||
// sign from moving the fields out of the monomial
|
||||
// check whether the monomial matches the id
|
||||
first_field=int_array_is_subarray_noncommuting(fields.ids.lhs[j],(*polynomial).monomials[i],fields);
|
||||
if(first_field>=0){
|
||||
init_Int_Array(&pre_monomial, (*polynomial).monomials[i].length);
|
||||
init_Int_Array(&post_monomial, (*polynomial).monomials[i].length);
|
||||
|
||||
// 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;
|
||||
// number of Fermions to remove from the monomial
|
||||
// number of Fermions to jump over
|
||||
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
|
||||
// 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]){
|
||||
int_array_append((*polynomial).monomials[i].values[k],&monomial);
|
||||
// sign correction
|
||||
if(fermion_count % 2 ==1 && is_fermion((*polynomial).monomials[i].values[k], fields)){
|
||||
sign*=-1;
|
||||
// add to post
|
||||
int_array_append((*polynomial).monomials[i].values[k],&post_monomial);
|
||||
// count Fermions to jump
|
||||
if(is_fermion((*polynomial).monomials[i].values[k],fields)){
|
||||
fermion_count++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
// increment fermion_count
|
||||
if(is_fermion(fields.ids.lhs[j].values[l],fields)){
|
||||
fermion_count++;
|
||||
// sign correction
|
||||
if(is_fermion(fields.ids.lhs[j].values[l],fields) && fermion_count % 2 == 1){
|
||||
sign*=-1;
|
||||
}
|
||||
// increment "current" field in the id
|
||||
l++;
|
||||
@ -240,30 +275,33 @@ int resolve_ids(Polynomial* polynomial, Fields_Table fields){
|
||||
// add extra monomials (if there are more than 1)
|
||||
for(k=1;k<fields.ids.rhs[j].length;k++){
|
||||
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);
|
||||
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
|
||||
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);
|
||||
}
|
||||
// correct i-th monomial
|
||||
free_Number((*polynomial).nums[i]);
|
||||
(*polynomial).nums[i]=number_prod_ret(num,fields.ids.rhs[j].nums[0]);
|
||||
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(post_monomial,(*polynomial).monomials+i);
|
||||
free_Int_Array(post_monomial);
|
||||
// re-sort monomial
|
||||
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);
|
||||
|
||||
// free num
|
||||
free_Number(num);
|
||||
|
||||
// repeat the step (in order to perform all of the replacements if several are necessary)
|
||||
j--;
|
||||
// repeat the replacement (in order to perform all of the replacements if several are necessary)
|
||||
j=0;
|
||||
if(at_least_one==0){
|
||||
at_least_one=1;
|
||||
}
|
||||
@ -275,58 +313,123 @@ int resolve_ids(Polynomial* polynomial, Fields_Table fields){
|
||||
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;
|
||||
|
||||
// ------------------ Symbols --------------------
|
||||
// cannot fit
|
||||
if(test_array.length<input.length){
|
||||
return(-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(i+j>=test_array.length || 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// Virtual_fields
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
// allocate memory
|
||||
int init_Symbols(Symbols* symbols,int size){
|
||||
(*symbols).indices=calloc(size,sizeof(int));
|
||||
(*symbols).expr=calloc(size,sizeof(Polynomial));
|
||||
(*symbols).length=0;
|
||||
(*symbols).memory=size;
|
||||
int init_Virtual_fields(Virtual_fields* virtual_fields,int size){
|
||||
(*virtual_fields).indices=calloc(size,sizeof(int));
|
||||
(*virtual_fields).expr=calloc(size,sizeof(Polynomial));
|
||||
(*virtual_fields).length=0;
|
||||
(*virtual_fields).memory=size;
|
||||
return(0);
|
||||
}
|
||||
|
||||
// free memory
|
||||
int free_Symbols(Symbols symbols){
|
||||
int free_Virtual_fields(Virtual_fields virtual_fields){
|
||||
int i;
|
||||
for(i=0;i<symbols.length;i++){
|
||||
free_Polynomial(symbols.expr[i]);
|
||||
for(i=0;i<virtual_fields.length;i++){
|
||||
free_Polynomial(virtual_fields.expr[i]);
|
||||
}
|
||||
free(symbols.indices);
|
||||
free(symbols.expr);
|
||||
free(virtual_fields.indices);
|
||||
free(virtual_fields.expr);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// resize
|
||||
int resize_symbols(Symbols* symbols,int new_size){
|
||||
Symbols new_symbols;
|
||||
int resize_virtual_fields(Virtual_fields* virtual_fields,int new_size){
|
||||
Virtual_fields new_virtual_fields;
|
||||
int i;
|
||||
|
||||
init_Symbols(&new_symbols,new_size);
|
||||
for(i=0;i<(*symbols).length;i++){
|
||||
new_symbols.indices[i]=(*symbols).indices[i];
|
||||
new_symbols.expr[i]=(*symbols).expr[i];
|
||||
init_Virtual_fields(&new_virtual_fields,new_size);
|
||||
for(i=0;i<(*virtual_fields).length;i++){
|
||||
new_virtual_fields.indices[i]=(*virtual_fields).indices[i];
|
||||
new_virtual_fields.expr[i]=(*virtual_fields).expr[i];
|
||||
}
|
||||
new_symbols.length=(*symbols).length;
|
||||
new_virtual_fields.length=(*virtual_fields).length;
|
||||
|
||||
free((*symbols).indices);
|
||||
free((*symbols).expr);
|
||||
free((*virtual_fields).indices);
|
||||
free((*virtual_fields).expr);
|
||||
|
||||
*symbols=new_symbols;
|
||||
*virtual_fields=new_virtual_fields;
|
||||
return(0);
|
||||
}
|
||||
|
||||
// copy
|
||||
int symbols_cpy(Symbols input, Symbols* output){
|
||||
init_Symbols(output,input.length);
|
||||
symbols_cpy_noinit(input,output);
|
||||
int virtual_fields_cpy(Virtual_fields input, Virtual_fields* output){
|
||||
init_Virtual_fields(output,input.length);
|
||||
virtual_fields_cpy_noinit(input,output);
|
||||
return(0);
|
||||
}
|
||||
int symbols_cpy_noinit(Symbols input, Symbols* output){
|
||||
int virtual_fields_cpy_noinit(Virtual_fields input, Virtual_fields* output){
|
||||
int i;
|
||||
if((*output).memory<input.length){
|
||||
fprintf(stderr,"error: trying to copy a symbols collection of length %d to another with memory %d\n",input.length,(*output).memory);
|
||||
fprintf(stderr,"error: trying to copy a virtual fields collection of length %d to another with memory %d\n",input.length,(*output).memory);
|
||||
exit(-1);
|
||||
}
|
||||
for(i=0;i<input.length;i++){
|
||||
@ -338,12 +441,12 @@ int symbols_cpy_noinit(Symbols input, Symbols* output){
|
||||
return(0);
|
||||
}
|
||||
|
||||
// append an element to a symbols
|
||||
int symbols_append(int index, Polynomial expr, Symbols* output){
|
||||
// append an element to a virtual_fields
|
||||
int virtual_fields_append(int index, Polynomial expr, Virtual_fields* output){
|
||||
int offset=(*output).length;
|
||||
|
||||
if((*output).length>=(*output).memory){
|
||||
resize_symbols(output,2*(*output).memory+1);
|
||||
resize_virtual_fields(output,2*(*output).memory+1);
|
||||
}
|
||||
|
||||
// copy and allocate
|
||||
@ -353,12 +456,12 @@ int symbols_append(int index, Polynomial expr, Symbols* output){
|
||||
(*output).length++;
|
||||
return(0);
|
||||
}
|
||||
// append an element to a symbols without allocating memory
|
||||
int symbols_append_noinit(int index, Polynomial expr, Symbols* output){
|
||||
// append an element to a virtual_fields without allocating memory
|
||||
int virtual_fields_append_noinit(int index, Polynomial expr, Virtual_fields* output){
|
||||
int offset=(*output).length;
|
||||
|
||||
if((*output).length>=(*output).memory){
|
||||
resize_symbols(output,2*(*output).memory+1);
|
||||
resize_virtual_fields(output,2*(*output).memory+1);
|
||||
}
|
||||
|
||||
// copy without allocating
|
||||
@ -369,18 +472,22 @@ int symbols_append_noinit(int index, Polynomial expr, Symbols* output){
|
||||
return(0);
|
||||
}
|
||||
|
||||
// concatenate two symbolss
|
||||
int symbols_concat(Symbols input, Symbols* output){
|
||||
// concatenate two virtual_fields
|
||||
int virtual_fields_concat(Virtual_fields input, Virtual_fields* output){
|
||||
int i;
|
||||
for(i=0;i<input.length;i++){
|
||||
symbols_append(input.indices[i],input.expr[i],output);
|
||||
virtual_fields_append(input.indices[i],input.expr[i],output);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------ Groups --------------------
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// Groups
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
// allocate memory
|
||||
int init_Groups(Groups* groups,int size){
|
||||
@ -487,3 +594,164 @@ int find_group(int index, Groups groups){
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// Variables
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
// allocate memory
|
||||
int init_Variables(Variables* variables,int size){
|
||||
(*variables).var_names=calloc(size,sizeof(Char_Array));
|
||||
(*variables).symbol_trees=calloc(size,sizeof(Tree));
|
||||
(*variables).length=0;
|
||||
(*variables).memory=size;
|
||||
return(0);
|
||||
}
|
||||
|
||||
// free memory
|
||||
int free_Variables(Variables variables){
|
||||
int i;
|
||||
for(i=0;i<variables.length;i++){
|
||||
free_Char_Array(variables.var_names[i]);
|
||||
free_Tree(variables.symbol_trees[i]);
|
||||
}
|
||||
free(variables.var_names);
|
||||
free(variables.symbol_trees);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// resize
|
||||
int resize_variables(Variables* variables,int new_size){
|
||||
Variables new_variables;
|
||||
int i;
|
||||
|
||||
init_Variables(&new_variables,new_size);
|
||||
for(i=0;i<(*variables).length;i++){
|
||||
new_variables.var_names[i]=(*variables).var_names[i];
|
||||
new_variables.symbol_trees[i]=(*variables).symbol_trees[i];
|
||||
}
|
||||
new_variables.length=(*variables).length;
|
||||
|
||||
free((*variables).var_names);
|
||||
free((*variables).symbol_trees);
|
||||
|
||||
*variables=new_variables;
|
||||
return(0);
|
||||
}
|
||||
|
||||
// copy
|
||||
int variables_cpy(Variables input, Variables* output){
|
||||
init_Variables(output,input.length);
|
||||
variables_cpy_noinit(input,output);
|
||||
return(0);
|
||||
}
|
||||
int variables_cpy_noinit(Variables input, Variables* output){
|
||||
int i;
|
||||
if((*output).memory<input.length){
|
||||
fprintf(stderr,"error: trying to copy a variables collection of length %d to another with memory %d\n",input.length,(*output).memory);
|
||||
exit(-1);
|
||||
}
|
||||
for(i=0;i<input.length;i++){
|
||||
char_array_cpy(input.var_names[i], (*output).var_names+i);
|
||||
tree_cpy(input.symbol_trees[i],(*output).symbol_trees+i);
|
||||
}
|
||||
(*output).length=input.length;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
// append an element to a variables collection
|
||||
int variables_append(Char_Array var_name, Tree symbol_tree, Variables* output){
|
||||
int offset=(*output).length;
|
||||
|
||||
if((*output).length>=(*output).memory){
|
||||
resize_variables(output,2*(*output).memory+1);
|
||||
}
|
||||
|
||||
// copy and allocate
|
||||
char_array_cpy(var_name,(*output).var_names+offset);
|
||||
tree_cpy(symbol_tree,(*output).symbol_trees+offset);
|
||||
// increment length
|
||||
(*output).length++;
|
||||
return(0);
|
||||
}
|
||||
// append an element to a variables collection without allocating memory
|
||||
int variables_append_noinit(Char_Array var_name, Tree symbol_tree, Variables* output){
|
||||
int offset=(*output).length;
|
||||
|
||||
if((*output).length>=(*output).memory){
|
||||
resize_variables(output,2*(*output).memory+1);
|
||||
}
|
||||
|
||||
// copy without allocating
|
||||
(*output).var_names[offset]=var_name;
|
||||
(*output).symbol_trees[offset]=symbol_tree;
|
||||
// increment length
|
||||
(*output).length++;
|
||||
return(0);
|
||||
}
|
||||
|
||||
// concatenate two variables collections
|
||||
int variables_concat(Variables input, Variables* output){
|
||||
int i;
|
||||
for(i=0;i<input.length;i++){
|
||||
variables_append(input.var_names[i], input.symbol_trees[i], output);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// find a variable matching a var_name
|
||||
int variables_find_var(Char_Array name, Variables variables, Tree* output){
|
||||
Char_Array varname;
|
||||
int i;
|
||||
|
||||
// drop inital '$'
|
||||
char_array_substring(name, 1, name.length-1, &varname);
|
||||
for(i=0;i<variables.length;i++){
|
||||
if(char_array_cmp(varname, variables.var_names[i])==1){
|
||||
tree_cpy(variables.symbol_trees[i], output);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// error if no variable was found
|
||||
if(i==variables.length){
|
||||
fprintf(stderr, "error: variable '$%s' not found\n",char_array_to_str_noinit(&varname));
|
||||
exit(-1);
|
||||
}
|
||||
free_Char_Array(varname);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// add a polynomials as a new named variable
|
||||
int add_polynomial_to_variables(char* name, Polynomial polynomial, Variables* variables){
|
||||
// save polynomial to string (to convert it to a variable, it must first be a string)
|
||||
Char_Array poly_str;
|
||||
Char_Array out_name;
|
||||
Tree out_tree;
|
||||
|
||||
init_Char_Array(&poly_str, STR_SIZE);
|
||||
polynomial_sprint(polynomial, &poly_str);
|
||||
|
||||
// convert name to Char_Array
|
||||
init_Char_Array(&out_name,STR_SIZE);
|
||||
char_array_append_str(name, &out_name);
|
||||
|
||||
// trivial tree containing the polynomial
|
||||
init_Tree(&out_tree,0,poly_str.length);
|
||||
tree_set_label(poly_str, &out_tree);
|
||||
free_Char_Array(poly_str);
|
||||
|
||||
// add variable
|
||||
variables_append(out_name, out_tree, variables);
|
||||
free_Tree(out_tree);
|
||||
free_Char_Array(out_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
62
src/fields.h
62
src/fields.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -21,6 +21,9 @@ limitations under the License.
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
// Fields_Table
|
||||
|
||||
// init
|
||||
int init_Fields_Table(Fields_Table* fields);
|
||||
int free_Fields_Table(Fields_Table fields);
|
||||
@ -29,8 +32,12 @@ int free_Fields_Table(Fields_Table fields);
|
||||
int field_type(int index, Fields_Table fields);
|
||||
// check whether a field anticommutes
|
||||
int is_fermion(int index, Fields_Table fields);
|
||||
// check whether a field is non-commuting
|
||||
int is_noncommuting(int index, Fields_Table fields);
|
||||
|
||||
|
||||
// Identities
|
||||
|
||||
// init
|
||||
int init_Identities(Identities* identities,int size);
|
||||
int free_Identities(Identities identities);
|
||||
@ -51,27 +58,33 @@ int identities_concat(Identities input, Identities* output);
|
||||
|
||||
// resolve the identities
|
||||
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);
|
||||
|
||||
|
||||
// Virtual_fields
|
||||
|
||||
// init
|
||||
int init_Symbols(Symbols* symbols,int size);
|
||||
int free_Symbols(Symbols symbols);
|
||||
int init_Virtual_fields(Virtual_fields* virtual_fields,int size);
|
||||
int free_Virtual_fields(Virtual_fields virtual_fields);
|
||||
|
||||
// resize
|
||||
int resize_symbols(Symbols* symbols,int new_size);
|
||||
int resize_virtual_fields(Virtual_fields* virtual_fields,int new_size);
|
||||
|
||||
// copy
|
||||
int symbols_cpy(Symbols input, Symbols* output);
|
||||
int symbols_cpy_noinit(Symbols input, Symbols* output);
|
||||
int virtual_fields_cpy(Virtual_fields input, Virtual_fields* output);
|
||||
int virtual_fields_cpy_noinit(Virtual_fields input, Virtual_fields* output);
|
||||
|
||||
// append an element to a symbols
|
||||
int symbols_append(int index, Polynomial expr, Symbols* output);
|
||||
int symbols_append_noinit(int index, Polynomial expr, Symbols* output);
|
||||
// append an element to a virtual_fields
|
||||
int virtual_fields_append(int index, Polynomial expr, Virtual_fields* output);
|
||||
int virtual_fields_append_noinit(int index, Polynomial expr, Virtual_fields* output);
|
||||
|
||||
// concatenate two symbolss
|
||||
int symbols_concat(Symbols input, Symbols* output);
|
||||
// concatenate two virtual_fields
|
||||
int virtual_fields_concat(Virtual_fields input, Virtual_fields* output);
|
||||
|
||||
|
||||
// Groups
|
||||
|
||||
// init
|
||||
int init_Groups(Groups* groups,int size);
|
||||
int free_Groups(Groups groups);
|
||||
@ -94,5 +107,32 @@ int groups_concat(Groups input, Groups* output);
|
||||
int find_group(int index, Groups groups);
|
||||
|
||||
|
||||
// Variables
|
||||
|
||||
// allocate memory
|
||||
int init_Variables(Variables* variables,int size);
|
||||
// free memory
|
||||
int free_Variables(Variables variables);
|
||||
|
||||
// resize
|
||||
int resize_variables(Variables* variables,int new_size);
|
||||
|
||||
// copy
|
||||
int variables_cpy(Variables input, Variables* output);
|
||||
int variables_cpy_noinit(Variables input, Variables* output);
|
||||
|
||||
// append an element to a variables collection
|
||||
int variables_append(Char_Array var_name, Tree symbol_tree, Variables* output);
|
||||
int variables_append_noinit(Char_Array var_name, Tree symbol_tree, Variables* output);
|
||||
|
||||
// concatenate two variables collections
|
||||
int variables_concat(Variables input, Variables* output);
|
||||
|
||||
// find a variable matching a var_name
|
||||
int variables_find_var(Char_Array name, Variables variables, Tree* output);
|
||||
|
||||
// add a polynomials as a new named variable
|
||||
int add_polynomial_to_variables(char* name, Polynomial polynomial, Variables* variables);
|
||||
|
||||
#define FIELDS_H_DONE
|
||||
#endif
|
||||
|
95
src/flow.c
95
src/flow.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -24,17 +24,21 @@ limitations under the License.
|
||||
#include "number.h"
|
||||
#include "array.h"
|
||||
#include "coefficient.h"
|
||||
|
||||
#include "rcc.h"
|
||||
#include "grouped_polynomial.h"
|
||||
|
||||
|
||||
// compute flow numerically, no exponentials
|
||||
// inputs: flow_equation
|
||||
// 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){
|
||||
int numerical_flow(Grouped_Polynomial flow_equation, RCC init, Grouped_Polynomial postprocess_flow_equation, Labels labels, int niter, int display_mode){
|
||||
// running coupling contants
|
||||
RCC rccs=init;
|
||||
// for printing
|
||||
RCC rcc_print;
|
||||
int i,j;
|
||||
|
||||
// init printing rcc
|
||||
init_RCC(&rcc_print, rccs.length);
|
||||
|
||||
if(display_mode==DISPLAY_NUMERICAL){
|
||||
// print labels
|
||||
printf("%5s ","n");
|
||||
@ -44,22 +48,58 @@ int numerical_flow(Grouped_Polynomial flow_equation, RCC init, Labels labels, in
|
||||
printf("\n\n");
|
||||
|
||||
// print initial values
|
||||
RCC_cpy_noinit(rccs,&rcc_print);
|
||||
if(postprocess_flow_equation.length>0){
|
||||
// ignore constants
|
||||
for(j=0;j<rcc_print.length;j++){
|
||||
if(rcc_print.indices[j]<0){
|
||||
rcc_print.values[j]=1.;
|
||||
}
|
||||
}
|
||||
evaleq(rcc_print, rcc_print, postprocess_flow_equation);
|
||||
}
|
||||
printf("%5d ",0);
|
||||
for(j=0;j<rccs.length;j++){
|
||||
printf("% 14.7Le ",rccs.values[j]);
|
||||
for(j=0;j<rcc_print.length;j++){
|
||||
// use constants from rcc
|
||||
if(rcc_print.indices[j]<0){
|
||||
printf("% 14.7Le ",rccs.values[j]);
|
||||
}
|
||||
else{
|
||||
printf("% 14.7Le ",rcc_print.values[j]);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
for(i=0;i<niter;i++){
|
||||
// compute a single step
|
||||
step_flow(&rccs, flow_equation, tol);
|
||||
// convert ls to alphas
|
||||
step_flow(&rccs, flow_equation);
|
||||
|
||||
// print
|
||||
if(postprocess_flow_equation.length>0){
|
||||
RCC_cpy_noinit(rccs,&rcc_print);
|
||||
// ignore constants
|
||||
for(j=0;j<rcc_print.length;j++){
|
||||
if(rcc_print.indices[j]<0){
|
||||
rcc_print.values[j]=1.;
|
||||
}
|
||||
}
|
||||
evaleq(rcc_print, rcc_print, postprocess_flow_equation);
|
||||
}
|
||||
else{
|
||||
RCC_cpy_noinit(rccs,&rcc_print);
|
||||
}
|
||||
if(display_mode==DISPLAY_NUMERICAL){
|
||||
// print the result
|
||||
printf("%5d ",i+1);
|
||||
for(j=0;j<rccs.length;j++){
|
||||
printf("% 14.7Le ",rccs.values[j]);
|
||||
for(j=0;j<rcc_print.length;j++){
|
||||
// use constants from rcc
|
||||
if(rcc_print.indices[j]<0){
|
||||
printf("% 14.7Le ",rccs.values[j]);
|
||||
}
|
||||
else{
|
||||
printf("% 14.7Le ",rcc_print.values[j]);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
@ -76,21 +116,31 @@ int numerical_flow(Grouped_Polynomial flow_equation, RCC init, Labels labels, in
|
||||
}
|
||||
|
||||
if(display_mode==DISPLAY_FINAL){
|
||||
RCC_print(rccs);
|
||||
if(postprocess_flow_equation.length>0){
|
||||
RCC_cpy_noinit(rccs,&rcc_print);
|
||||
// ignore constants
|
||||
for(j=0;j<rcc_print.length;j++){
|
||||
if(rcc_print.indices[j]<0){
|
||||
rcc_print.values[j]=1.;
|
||||
}
|
||||
}
|
||||
evaleq(rcc_print, rcc_print, postprocess_flow_equation);
|
||||
}
|
||||
else{
|
||||
RCC_cpy_noinit(rccs,&rcc_print);
|
||||
}
|
||||
RCC_print(rcc_print);
|
||||
}
|
||||
|
||||
free_RCC(rcc_print);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
// single step in the flow no exponentials
|
||||
// inputs: flow_equation, tol
|
||||
// input/outputs: rccs
|
||||
int step_flow(RCC* rccs, Grouped_Polynomial flow_equation, long double tol){
|
||||
int step_flow(RCC* rccs, Grouped_Polynomial flow_equation){
|
||||
int i;
|
||||
long double* new_rccs=calloc((*rccs).length,sizeof(long double));
|
||||
Int_Array computed;
|
||||
|
||||
init_Int_Array(&computed, (*rccs).length);
|
||||
|
||||
// initialize vectors to 0
|
||||
for(i=0;i<(*rccs).length;i++){
|
||||
@ -101,10 +151,6 @@ int step_flow(RCC* rccs, Grouped_Polynomial flow_equation, long double tol){
|
||||
for(i=0;i<flow_equation.length;i++){
|
||||
if(flow_equation.indices[i]<0){
|
||||
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];
|
||||
}
|
||||
}
|
||||
@ -113,10 +159,6 @@ int step_flow(RCC* rccs, Grouped_Polynomial flow_equation, long double tol){
|
||||
for(i=0;i<flow_equation.length;i++){
|
||||
if(flow_equation.indices[i]>=0){
|
||||
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 +168,6 @@ int step_flow(RCC* rccs, Grouped_Polynomial flow_equation, long double tol){
|
||||
}
|
||||
|
||||
// free memory
|
||||
free_Int_Array(computed);
|
||||
free(new_rccs);
|
||||
return(0);
|
||||
}
|
||||
|
10
src/flow.h
10
src/flow.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -21,14 +21,12 @@ Compute flow numerically
|
||||
#ifndef NUMERICAL_FLOW_H
|
||||
#define NUMERICAL_FLOW_H
|
||||
|
||||
|
||||
#include "grouped_polynomial.h"
|
||||
#include "rcc.h"
|
||||
#include "types.h"
|
||||
|
||||
// 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, Grouped_Polynomial postprocess_flow_equation, Labels labels, int niter, int display_mode);
|
||||
// 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)
|
||||
int print_label(int index, Labels labels);
|
||||
|
175
src/flow_mpfr.c
Normal file
175
src/flow_mpfr.c
Normal file
@ -0,0 +1,175 @@
|
||||
/*
|
||||
Copyright 2015-2022 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"
|
||||
#include "grouped_polynomial.h"
|
||||
|
||||
|
||||
|
||||
// compute flow numerically
|
||||
int numerical_flow_mpfr(Grouped_Polynomial flow_equation, RCC_mpfr init, Grouped_Polynomial postprocess_flow_equation, Labels labels, int niter, int display_mode){
|
||||
// running coupling contants
|
||||
RCC_mpfr rccs=init;
|
||||
int i,j;
|
||||
// for printing
|
||||
RCC_mpfr rcc_print;
|
||||
|
||||
|
||||
// init printing rcc
|
||||
init_RCC_mpfr(&rcc_print, rccs.length);
|
||||
|
||||
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
|
||||
RCC_mpfr_cpy_noinit(rccs,&rcc_print);
|
||||
if(postprocess_flow_equation.length>0){
|
||||
// ignore constants
|
||||
for(j=0;j<rcc_print.length;j++){
|
||||
if(rcc_print.indices[j]<0){
|
||||
mpfr_set_ui(rcc_print.values[j], 1, MPFR_RNDN);
|
||||
}
|
||||
}
|
||||
evaleq_mpfr(rcc_print, rccs, postprocess_flow_equation);
|
||||
}
|
||||
printf("%5d ",0);
|
||||
for(j=0;j<rcc_print.length;j++){
|
||||
// use constants from rcc
|
||||
if(rcc_print.indices[j]<0){
|
||||
mpfr_printf("% 14.7Re ",rccs.values[j]);
|
||||
}
|
||||
else{
|
||||
mpfr_printf("% 14.7Re ",rcc_print.values[j]);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
for(i=0;i<niter;i++){
|
||||
// compute a single step
|
||||
step_flow_mpfr(&rccs, flow_equation);
|
||||
|
||||
// print
|
||||
RCC_mpfr_cpy_noinit(rccs,&rcc_print);
|
||||
if(postprocess_flow_equation.length>0){
|
||||
// ignore constants
|
||||
for(j=0;j<rcc_print.length;j++){
|
||||
if(rcc_print.indices[j]<0){
|
||||
mpfr_set_ui(rcc_print.values[j], 1, MPFR_RNDN);
|
||||
}
|
||||
}
|
||||
evaleq_mpfr(rcc_print, rccs, postprocess_flow_equation);
|
||||
}
|
||||
if(display_mode==DISPLAY_NUMERICAL){
|
||||
// print the result
|
||||
printf("%5d ",i+1);
|
||||
for(j=0;j<rcc_print.length;j++){
|
||||
// use constants from rcc
|
||||
if(rcc_print.indices[j]<0){
|
||||
mpfr_printf("% 14.7Re ",rccs.values[j]);
|
||||
}
|
||||
else{
|
||||
mpfr_printf("% 14.7Re ",rcc_print.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){
|
||||
if(postprocess_flow_equation.length>0){
|
||||
evaleq_mpfr(rcc_print, rccs, postprocess_flow_equation);
|
||||
}
|
||||
else{
|
||||
rcc_print=rccs;
|
||||
}
|
||||
RCC_mpfr_print(rcc_print);
|
||||
}
|
||||
|
||||
free_RCC_mpfr(rcc_print);
|
||||
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);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -15,20 +15,18 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Compute exp(V) and log(1+W)
|
||||
Compute flow numerically
|
||||
*/
|
||||
|
||||
#ifndef EXPANSIONS_H
|
||||
#define EXPANSIONS_H
|
||||
#ifndef NUMERICAL_FLOW_MPFR_H
|
||||
#define NUMERICAL_FLOW_MPFR_H
|
||||
|
||||
#include "polynomial.h"
|
||||
#include "fields.h"
|
||||
|
||||
// exp(V)
|
||||
int expand_exponential(Polynomial input_polynomial,Polynomial* output, Fields_Table fields);
|
||||
|
||||
// log(1+W)
|
||||
int expand_logarithm(Polynomial input_polynomial, Polynomial* output, Fields_Table fields);
|
||||
#include "types.h"
|
||||
|
||||
// compute flow
|
||||
int numerical_flow_mpfr(Grouped_Polynomial flow_equation, RCC_mpfr init, Grouped_Polynomial postprocess_flow_equation, Labels labels, int niter, int display_mode);
|
||||
// single step
|
||||
int step_flow_mpfr(RCC_mpfr* rccs, Grouped_Polynomial flow_equation);
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -205,9 +205,9 @@ int group_polynomial(Polynomial polynomial, Grouped_Polynomial* grouped_polynomi
|
||||
|
||||
if(index==-2){
|
||||
fprintf(stderr,"error: monomial (");
|
||||
for(j=0;j<polynomial.monomials[i].length;j++){
|
||||
fprintf(stderr,"%d", polynomial.monomials[i].values[j]);
|
||||
if(j<polynomial.monomials[i].length-1){
|
||||
for(j=0;j<remainder.monomials[i].length;j++){
|
||||
fprintf(stderr,"%d", remainder.monomials[i].values[j]);
|
||||
if(j<remainder.monomials[i].length-1){
|
||||
fprintf(stderr,",");
|
||||
}
|
||||
}
|
||||
@ -436,7 +436,7 @@ int simplify_grouped_polynomial(Grouped_Polynomial* polynomial){
|
||||
}
|
||||
|
||||
|
||||
// derive a flow equation with respect to an unknown variable
|
||||
// differentiate a flow equation with respect to an unknown variable
|
||||
// equivalent to DB.dl where dl are symbols for the derivatives of the indices in the flow equation with respect to the unknown variable
|
||||
// indices specifies the list of indices that depend on the variable
|
||||
int flow_equation_derivx(Grouped_Polynomial flow_equation, Int_Array indices, Grouped_Polynomial* dflow){
|
||||
@ -487,7 +487,7 @@ int flow_equation_derivx(Grouped_Polynomial flow_equation, Int_Array indices, Gr
|
||||
|
||||
|
||||
/*
|
||||
// derive a flow equation with respect to an index
|
||||
// differentiate a flow equation with respect to an index
|
||||
int flow_equation_deriv(Grouped_Polynomial flow_equation, int index, Grouped_Polynomial* output){
|
||||
int i,k;
|
||||
// temp list of indices
|
||||
@ -603,7 +603,7 @@ int grouped_polynomial_print(Grouped_Polynomial grouped_polynomial, char lhs_pre
|
||||
init_Char_Array(&buffer, STR_SIZE);
|
||||
coefficient_sprint(grouped_polynomial.coefs[i],&buffer,9,rhs_pre);
|
||||
if(buffer.length>0){
|
||||
printf("%s",buffer.str);
|
||||
printf("%s",char_array_to_str_noinit(&buffer));
|
||||
}
|
||||
free_Char_Array(buffer);
|
||||
|
||||
@ -733,28 +733,32 @@ int char_array_to_Grouped_Polynomial(Char_Array str, Grouped_Polynomial* output)
|
||||
|
||||
|
||||
// evaluate an equation on a vector
|
||||
int evaleq(RCC* rccs, Grouped_Polynomial poly){
|
||||
int evaleq(RCC out, RCC in, Grouped_Polynomial poly){
|
||||
int i;
|
||||
long double* res=calloc((*rccs).length,sizeof(long double));
|
||||
long double* res=calloc(out.length,sizeof(long double));
|
||||
|
||||
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);
|
||||
if(in.length!=poly.length){
|
||||
fprintf(stderr, "error: trying to evaluate a flow equation with %d components on an rcc with %d\n",poly.length,in.length);
|
||||
exit(-1);
|
||||
}
|
||||
if(out.length!=poly.length){
|
||||
fprintf(stderr, "error: trying to write the output of a flow equation with %d components on an rcc with %d\n",poly.length,out.length);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// initialize vectors to 0
|
||||
for(i=0;i<(*rccs).length;i++){
|
||||
// initialize vectors to 0 in an auxiliary vector (to allow for out=in without interference)
|
||||
for(i=0;i<in.length;i++){
|
||||
res[i]=0.;
|
||||
}
|
||||
|
||||
// for each equation
|
||||
for(i=0;i<poly.length;i++){
|
||||
evalcoef(*rccs, poly.coefs[i], res+i);
|
||||
evalcoef(in, poly.coefs[i], res+i);
|
||||
}
|
||||
|
||||
// copy res to rccs
|
||||
for(i=0;i<(*rccs).length;i++){
|
||||
(*rccs).values[i]=res[i];
|
||||
for(i=0;i<out.length;i++){
|
||||
out.values[i]=res[i];
|
||||
}
|
||||
|
||||
// free memory
|
||||
@ -762,4 +766,118 @@ int evaleq(RCC* rccs, Grouped_Polynomial poly){
|
||||
return(0);
|
||||
|
||||
}
|
||||
// evaluate an equation on a vector (using mpfr floats)
|
||||
int evaleq_mpfr(RCC_mpfr out, RCC_mpfr in, Grouped_Polynomial poly){
|
||||
int i;
|
||||
mpfr_t* res;
|
||||
|
||||
if(in.length!=poly.length){
|
||||
fprintf(stderr, "error: trying to evaluate a flow equation with %d components on an rcc with %d\n",poly.length,in.length);
|
||||
exit(-1);
|
||||
}
|
||||
if(out.length!=poly.length){
|
||||
fprintf(stderr, "error: trying to write the output of a flow equation with %d components on an rcc with %d\n",poly.length,out.length);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
res=calloc(out.length,sizeof(mpfr_t));
|
||||
|
||||
// for each equation
|
||||
for(i=0;i<poly.length;i++){
|
||||
evalcoef_mpfr(in, poly.coefs[i], res[i]);
|
||||
}
|
||||
|
||||
// copy res to rccs
|
||||
for(i=0;i<out.length;i++){
|
||||
mpfr_set(out.values[i], res[i], MPFR_RNDN);
|
||||
mpfr_clear(res[i]);
|
||||
}
|
||||
|
||||
// free memory
|
||||
free(res);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// compose two flow equations (replace the rcc's of flow1 by the right hand side of flow2)
|
||||
int compose_flow_equations(Grouped_Polynomial flow1, Grouped_Polynomial flow2, Grouped_Polynomial* out){
|
||||
if(flow1.length!=flow2.length){
|
||||
fprintf(stderr, "error: trying to compose two flow equations of different size\n");
|
||||
exit(-1);
|
||||
}
|
||||
int i,j,k;
|
||||
Coefficient constant;
|
||||
|
||||
// init
|
||||
init_Grouped_Polynomial(out, flow1.length);
|
||||
(*out).length=flow1.length;
|
||||
|
||||
// init constant (so we can tell when the constant was not found)
|
||||
constant.length=0;
|
||||
|
||||
// loop over rcc's
|
||||
for(i=0;i<flow1.length;i++){
|
||||
// set indices
|
||||
(*out).indices[i]=flow1.indices[i];
|
||||
|
||||
// passthrough constant terms
|
||||
if((*out).indices[i]<0){
|
||||
int index=intlist_find_err(flow2.indices,flow2.length,(*out).indices[i]);
|
||||
coefficient_cpy(flow2.coefs[index], (*out).coefs+i);
|
||||
constant=flow2.coefs[index];
|
||||
continue;
|
||||
}
|
||||
|
||||
// init
|
||||
init_Coefficient((*out).coefs+i, COEF_SIZE);
|
||||
|
||||
// loop over terms
|
||||
for(j=0;j<flow1.coefs[i].length;j++){
|
||||
Coefficient tmp_coef;
|
||||
|
||||
// init
|
||||
init_Coefficient(&tmp_coef, COEF_SIZE);
|
||||
// init factor
|
||||
Int_Array tmp_factor;
|
||||
init_Int_Array(&tmp_factor, MONOMIAL_SIZE);
|
||||
// init denom
|
||||
coef_denom denom;
|
||||
// index should be that appearing in flow2
|
||||
if(flow2.coefs[i].length<1){
|
||||
fprintf(stderr,"error: composing two flow equations: the %d-th term in the flow equation is empty\n",flow1.indices[i]);
|
||||
exit(-1);
|
||||
}
|
||||
denom.index=flow2.coefs[i].denoms[0].index;
|
||||
denom.power=0;
|
||||
// init num
|
||||
Number tmp_num;
|
||||
number_cpy(flow1.coefs[i].nums[j], &tmp_num);
|
||||
|
||||
// init coefficient with numerical prefactor
|
||||
coefficient_append_noinit(tmp_factor, tmp_num, denom, &tmp_coef);
|
||||
|
||||
// loop over factors
|
||||
for(k=0;k<flow1.coefs[i].factors[j].length;k++){
|
||||
// multiply factors together
|
||||
coefficient_prod_chain(flow2.coefs[intlist_find_err(flow2.indices,flow2.length,flow1.coefs[i].factors[j].values[k])], &tmp_coef);
|
||||
}
|
||||
|
||||
// add to out
|
||||
coefficient_concat_noinit(tmp_coef, (*out).coefs+i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// simplify fractions
|
||||
if(constant.length!=0){
|
||||
for(i=0;i<(*out).length;i++){
|
||||
if((*out).indices[i]>=0){
|
||||
// reduce them to a common denominator (not much is gained from trying to simplify them)
|
||||
coefficient_common_denominator(constant, (*out).coefs+i);
|
||||
//coefficient_simplify_rational(constant, (*out).coefs+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -59,7 +59,7 @@ int find_id(Int_Array monomial, Id_Table idtable, int start);
|
||||
// simplify grouped polynomial
|
||||
int simplify_grouped_polynomial(Grouped_Polynomial* polynomial);
|
||||
|
||||
// derive a flow equation with respect to an unknown variable
|
||||
// differentiate a flow equation with respect to an unknown variable
|
||||
int flow_equation_derivx(Grouped_Polynomial flow_equation, Int_Array indices, Grouped_Polynomial* dflow);
|
||||
|
||||
// print a grouped polynomial
|
||||
@ -69,6 +69,10 @@ int grouped_polynomial_print(Grouped_Polynomial grouped_polynomial, char lhs_pre
|
||||
int char_array_to_Grouped_Polynomial(Char_Array str, Grouped_Polynomial* output);
|
||||
|
||||
// evaluate an equation on an RCC
|
||||
int evaleq(RCC* rccs, Grouped_Polynomial poly);
|
||||
int evaleq(RCC out, RCC in, Grouped_Polynomial poly);
|
||||
// evaluate an equation on a vector (using mpfr floats)
|
||||
int evaleq_mpfr(RCC_mpfr out, RCC_mpfr in, Grouped_Polynomial poly);
|
||||
|
||||
// compose two flow equations (replace the rcc's of flow1 by the right hand side of flow2)
|
||||
int compose_flow_equations(Grouped_Polynomial flow1, Grouped_Polynomial flow2, Grouped_Polynomial* out);
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
217
src/kondo.c
217
src/kondo.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -29,16 +29,17 @@ limitations under the License.
|
||||
#include "definitions.cpp"
|
||||
#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
|
||||
// number of spin components
|
||||
#define KONDO_SPIN 2
|
||||
|
||||
// offsets for indices of A, B and h
|
||||
// order matters for symbols table
|
||||
// offsets for indices of A, B, h and t
|
||||
// order matters for virtual_fields table
|
||||
#define KONDO_A_OFFSET 1
|
||||
#define KONDO_B_OFFSET 2
|
||||
#define KONDO_H_OFFSET 3
|
||||
#define KONDO_T_OFFSET 4
|
||||
|
||||
// parsing modes (from parse_file.c)
|
||||
#define PP_NULL_MODE 0
|
||||
@ -71,6 +72,7 @@ limitations under the License.
|
||||
int kondo_generate_conf(Str_Array* str_args, int box_count){
|
||||
Str_Array new_args;
|
||||
Fields_Table fields;
|
||||
Variables variables;
|
||||
Char_Array tmp_str;
|
||||
int arg_index;
|
||||
int i;
|
||||
@ -82,16 +84,19 @@ int kondo_generate_conf(Str_Array* str_args, int box_count){
|
||||
kondo_fields_table(box_count, &tmp_str, &fields);
|
||||
str_array_append_noinit(tmp_str, &new_args);
|
||||
|
||||
// symbols
|
||||
kondo_symbols(&tmp_str, box_count, &fields);
|
||||
arg_index=find_str_arg("symbols", *str_args);
|
||||
// dummy variables
|
||||
init_Variables(&variables,1);
|
||||
|
||||
// virtual fields
|
||||
kondo_virtual_fields(&tmp_str, box_count, &fields);
|
||||
arg_index=find_str_arg("virtual_fields", *str_args);
|
||||
if(arg_index>=0){
|
||||
if(tmp_str.length>0){
|
||||
char_array_snprintf(&tmp_str,",\n");
|
||||
}
|
||||
char_array_concat((*str_args).strs[arg_index], &tmp_str);
|
||||
}
|
||||
parse_input_symbols(tmp_str, &fields);
|
||||
parse_input_virtual_fields(tmp_str, &fields, variables);
|
||||
str_array_append_noinit(tmp_str, &new_args);
|
||||
|
||||
// identities
|
||||
@ -103,7 +108,7 @@ int kondo_generate_conf(Str_Array* str_args, int box_count){
|
||||
}
|
||||
char_array_concat((*str_args).strs[arg_index], &tmp_str);
|
||||
}
|
||||
parse_input_identities(tmp_str, &fields);
|
||||
parse_input_identities(tmp_str, &fields, variables);
|
||||
str_array_append_noinit(tmp_str, &new_args);
|
||||
|
||||
// groups
|
||||
@ -135,7 +140,7 @@ int kondo_generate_conf(Str_Array* str_args, int box_count){
|
||||
// copy remaining entries
|
||||
for(i=0;i<(*str_args).length;i++){
|
||||
get_str_arg_title((*str_args).strs[i], &title);
|
||||
if(str_cmp(title.str, "symbols")==0 &&\
|
||||
if(str_cmp(title.str, "virtual_fields")==0 &&\
|
||||
str_cmp(title.str, "identities")==0 &&\
|
||||
str_cmp(title.str, "propagator")==0 &&\
|
||||
str_cmp(title.str, "input_polynomial")==0 &&\
|
||||
@ -148,6 +153,7 @@ int kondo_generate_conf(Str_Array* str_args, int box_count){
|
||||
}
|
||||
|
||||
free_Fields_Table(fields);
|
||||
free_Variables(variables);
|
||||
free_Str_Array(*str_args);
|
||||
*str_args=new_args;
|
||||
|
||||
@ -193,13 +199,19 @@ int kondo_fields_table(int box_count, Char_Array* str_fields, Fields_Table* fiel
|
||||
|
||||
// parameters
|
||||
char_array_append_str("h:",str_fields);
|
||||
// h
|
||||
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){
|
||||
char_array_append(',',str_fields);
|
||||
char_array_append(',', str_fields);
|
||||
}
|
||||
}
|
||||
char_array_append('\n',str_fields);
|
||||
char_array_append('\n', str_fields);
|
||||
|
||||
|
||||
// declare Fermions
|
||||
char_array_append_str("f:",str_fields);
|
||||
@ -226,6 +238,16 @@ int kondo_fields_table(int box_count, Char_Array* str_fields, Fields_Table* fiel
|
||||
}
|
||||
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_input_fields(*str_fields, fields);
|
||||
|
||||
@ -233,35 +255,35 @@ int kondo_fields_table(int box_count, Char_Array* str_fields, Fields_Table* fiel
|
||||
}
|
||||
|
||||
|
||||
// generate Kondo symbols
|
||||
int kondo_symbols(Char_Array* str_symbols, int box_count, Fields_Table* fields){
|
||||
// generate Kondo virtual_fields
|
||||
int kondo_virtual_fields(Char_Array* str_virtual_fields, int box_count, Fields_Table* fields){
|
||||
int i,j,k,l;
|
||||
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");
|
||||
init_Char_Array(str_virtual_fields, STR_SIZE);
|
||||
char_array_snprintf(str_virtual_fields, "#!virtual_fields\n");
|
||||
|
||||
// loop over box index
|
||||
for(i=1;i<=box_count;i++){
|
||||
// loop over letters
|
||||
// loop over letters (A and B)
|
||||
for(j=0;j<2;j++){
|
||||
// loop over space dimension
|
||||
for(k=0;k<KONDO_DIM;k++){
|
||||
// write index
|
||||
char_array_snprintf(str_symbols, "%d=", 100*(10*(KONDO_A_OFFSET+j)+k)+i);
|
||||
char_array_snprintf(str_virtual_fields, "%d=", 100*(10*(KONDO_A_OFFSET+j)+k)+i);
|
||||
// write the name of the scalar product
|
||||
init_Char_Array(&tmp_str, 6);
|
||||
char_array_snprintf(&tmp_str, "%c%d%d", letters[j], k, i);
|
||||
// compute corresponding polynomial
|
||||
kondo_resolve_ABh(tmp_str.str, &poly, *fields);
|
||||
kondo_resolve_ABht(tmp_str.str, &poly, *fields);
|
||||
free_Char_Array(tmp_str);
|
||||
// write to output
|
||||
polynomial_sprint(poly, str_symbols);
|
||||
polynomial_sprint(poly, str_virtual_fields);
|
||||
free_Polynomial(poly);
|
||||
// add ,
|
||||
char_array_snprintf(str_symbols,",\n");
|
||||
char_array_snprintf(str_virtual_fields,",\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -273,46 +295,46 @@ int kondo_symbols(Char_Array* str_symbols, int box_count, Fields_Table* fields){
|
||||
for(j=0;j<3;j++){
|
||||
for(k=0;k<3;k++){
|
||||
// write index
|
||||
char_array_snprintf(str_symbols, "%d=", 1000*(10*(KONDO_A_OFFSET+j)+KONDO_A_OFFSET+k)+i);
|
||||
char_array_snprintf(str_virtual_fields, "%d=", 1000*(10*(KONDO_A_OFFSET+j)+KONDO_A_OFFSET+k)+i);
|
||||
for(l=0;l<KONDO_DIM;l++){
|
||||
char_array_snprintf(str_symbols, "(1)");
|
||||
char_array_snprintf(str_virtual_fields, "(1)");
|
||||
if(j<2){
|
||||
char_array_snprintf(str_symbols,"[f%d]", 100*(10*(KONDO_A_OFFSET+j)+l)+i);
|
||||
char_array_snprintf(str_virtual_fields,"[f%d]", 100*(10*(KONDO_A_OFFSET+j)+l)+i);
|
||||
}
|
||||
else{
|
||||
char_array_snprintf(str_symbols,"[f%d]", 10*(10*(KONDO_A_OFFSET+j)+l));
|
||||
char_array_snprintf(str_virtual_fields,"[f%d]", 10*(10*(KONDO_A_OFFSET+j)+l));
|
||||
}
|
||||
if(k<2){
|
||||
char_array_snprintf(str_symbols,"[f%d]", 100*(10*(KONDO_A_OFFSET+k)+l)+i);
|
||||
char_array_snprintf(str_virtual_fields,"[f%d]", 100*(10*(KONDO_A_OFFSET+k)+l)+i);
|
||||
}
|
||||
else{
|
||||
char_array_snprintf(str_symbols,"[f%d]", 10*(10*(KONDO_A_OFFSET+k)+l));
|
||||
char_array_snprintf(str_virtual_fields,"[f%d]", 10*(10*(KONDO_A_OFFSET+k)+l));
|
||||
}
|
||||
|
||||
if(l<KONDO_DIM-1){
|
||||
char_array_append('+',str_symbols);
|
||||
char_array_append('+',str_virtual_fields);
|
||||
}
|
||||
}
|
||||
// add ,
|
||||
char_array_snprintf(str_symbols,",\n");
|
||||
char_array_snprintf(str_virtual_fields,",\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vector products
|
||||
for(i=1;i<=box_count;i++){
|
||||
char_array_snprintf(str_symbols, "%d=", 100*(100*(KONDO_A_OFFSET)+10*KONDO_B_OFFSET+KONDO_H_OFFSET)+i);
|
||||
char_array_snprintf(str_virtual_fields, "%d=", 100*(100*(KONDO_A_OFFSET)+10*KONDO_B_OFFSET+KONDO_H_OFFSET)+i);
|
||||
for(l=0;l<KONDO_DIM;l++){
|
||||
// remember (-1 %3 = -1)
|
||||
char_array_snprintf(str_symbols, "(1)[f%d][f%d][f%d]+(-1)[f%d][f%d][f%d]", 100*(10*KONDO_A_OFFSET+((l+1)%KONDO_DIM))+i, 100*(10*KONDO_B_OFFSET+((l+2)%KONDO_DIM))+i, 10*(10*KONDO_H_OFFSET+l), 100*(10*KONDO_A_OFFSET+((l+2)%KONDO_DIM))+i, 100*(10*KONDO_B_OFFSET+((l+1)%KONDO_DIM))+i, 10*(10*KONDO_H_OFFSET+l));
|
||||
char_array_snprintf(str_virtual_fields, "(1)[f%d][f%d][f%d]+(-1)[f%d][f%d][f%d]", 100*(10*KONDO_A_OFFSET+((l+1)%KONDO_DIM))+i, 100*(10*KONDO_B_OFFSET+((l+2)%KONDO_DIM))+i, 10*(10*KONDO_H_OFFSET+l), 100*(10*KONDO_A_OFFSET+((l+2)%KONDO_DIM))+i, 100*(10*KONDO_B_OFFSET+((l+1)%KONDO_DIM))+i, 10*(10*KONDO_H_OFFSET+l));
|
||||
if(l<KONDO_DIM-1){
|
||||
char_array_append('+',str_symbols);
|
||||
char_array_append('+',str_virtual_fields);
|
||||
}
|
||||
}
|
||||
|
||||
// add ,
|
||||
if(i<box_count){
|
||||
char_array_snprintf(str_symbols,",\n");
|
||||
char_array_snprintf(str_virtual_fields,",\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,45 +342,6 @@ int kondo_symbols(Char_Array* str_symbols, int box_count, Fields_Table* fields){
|
||||
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)
|
||||
int kondo_groups(Char_Array* str_groups, int box_count){
|
||||
@ -395,12 +378,21 @@ int kondo_groups(Char_Array* str_groups, int box_count){
|
||||
|
||||
// generate Kondo identities
|
||||
// h_3^2=1-h_1^2-h_2^2
|
||||
// and Pauli matrices
|
||||
int kondo_identities(Char_Array* str_identities){
|
||||
int i;
|
||||
|
||||
init_Char_Array(str_identities,STR_SIZE);
|
||||
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));
|
||||
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));
|
||||
@ -791,13 +783,13 @@ int parse_kondo_polynomial_str(char* str_polynomial, Polynomial* output, Fields_
|
||||
// if polynomial exists, add to each monomial
|
||||
if(tmp_poly.length>0){
|
||||
for(i=0;i<tmp_poly.length;i++){
|
||||
int_array_append(get_symbol_index(buffer), tmp_poly.monomials+i);
|
||||
int_array_append(get_virtual_field_index(buffer), tmp_poly.monomials+i);
|
||||
}
|
||||
}
|
||||
// if not, create a new term in the polynomial
|
||||
else{
|
||||
init_Int_Array(&tmp_monomial, MONOMIAL_SIZE);
|
||||
int_array_append(get_symbol_index(buffer), &tmp_monomial);
|
||||
int_array_append(get_virtual_field_index(buffer), &tmp_monomial);
|
||||
init_Int_Array(&dummy_factor, 1);
|
||||
polynomial_append_noinit(tmp_monomial, dummy_factor, number_one(), &tmp_poly);
|
||||
}
|
||||
@ -809,11 +801,10 @@ int parse_kondo_polynomial_str(char* str_polynomial, Polynomial* output, Fields_
|
||||
if(tmp_poly.length>0){
|
||||
for(i=0;i<tmp_poly.length;i++){
|
||||
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{
|
||||
// vector product
|
||||
int_array_append(100*(100*KONDO_A_OFFSET+10*KONDO_B_OFFSET+KONDO_H_OFFSET)+index, tmp_poly.monomials+i);
|
||||
}
|
||||
}
|
||||
@ -822,28 +813,15 @@ int parse_kondo_polynomial_str(char* str_polynomial, Polynomial* output, Fields_
|
||||
else{
|
||||
init_Int_Array(&tmp_monomial, MONOMIAL_SIZE);
|
||||
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{
|
||||
// vector product
|
||||
int_array_append(100*(100*KONDO_A_OFFSET+10*KONDO_B_OFFSET+KONDO_H_OFFSET)+index, &tmp_monomial);
|
||||
}
|
||||
init_Int_Array(&dummy_factor, 1);
|
||||
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
|
||||
mode=PP_NULL_MODE;
|
||||
@ -941,10 +919,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
|
||||
int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){
|
||||
// read Aij, Bij, hi, ti where i is a space dimension and j is a box index
|
||||
int kondo_resolve_ABht(char* str, Polynomial* output, Fields_Table fields){
|
||||
char* ptr;
|
||||
// offset (A,B or H)
|
||||
// offset (A,B, H or T)
|
||||
int offset=-1;
|
||||
// dimension
|
||||
int dim=-1;
|
||||
@ -978,6 +956,9 @@ int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){
|
||||
case 'h':
|
||||
offset=KONDO_H_OFFSET;
|
||||
break;
|
||||
case 't':
|
||||
offset=KONDO_T_OFFSET;
|
||||
break;
|
||||
default:
|
||||
// set index if dim was already set
|
||||
if(dim>=0){
|
||||
@ -1001,8 +982,8 @@ int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){
|
||||
}
|
||||
}
|
||||
|
||||
// h's
|
||||
if(offset==KONDO_H_OFFSET){
|
||||
// h's and t's
|
||||
if(offset==KONDO_H_OFFSET || offset==KONDO_T_OFFSET){
|
||||
// external field
|
||||
init_Int_Array(&monomial,1);
|
||||
init_Int_Array(&factor,1);
|
||||
@ -1062,7 +1043,7 @@ int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){
|
||||
// read a Kondo scalar product (generalized to vector products as well)
|
||||
int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields){
|
||||
char* ptr;
|
||||
// offset of each term (A,B or H)
|
||||
// offset of each term (A,B,H or T)
|
||||
int offset=-1;
|
||||
// index of each term (0,...,box_count)
|
||||
int index=0;
|
||||
@ -1091,6 +1072,9 @@ int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields
|
||||
case 'h':
|
||||
offset=KONDO_H_OFFSET;
|
||||
break;
|
||||
case 't':
|
||||
offset=KONDO_T_OFFSET;
|
||||
break;
|
||||
|
||||
// scalar product
|
||||
case '.':
|
||||
@ -1195,8 +1179,8 @@ int kondo_polynomial_vector(int offset, int index, Polynomial (*polys)[3], Field
|
||||
init_Polynomial((*polys)+i,POLY_SIZE);
|
||||
}
|
||||
|
||||
// h's
|
||||
if(offset==KONDO_H_OFFSET){
|
||||
// h's and t's
|
||||
if(offset==KONDO_H_OFFSET || offset==KONDO_T_OFFSET){
|
||||
// construct every component field
|
||||
for(i=0;i<KONDO_DIM;i++){
|
||||
// external field
|
||||
@ -1261,7 +1245,7 @@ int kondo_resolve_scalar_prod_symbols(char* str, Polynomial* output){
|
||||
char* ptr;
|
||||
// first or second term
|
||||
int term=0;
|
||||
// offset of each term (A,B or H)
|
||||
// offset of each term (A,B,H or T)
|
||||
int offset[2];
|
||||
// index of each term (0,...,box_count)
|
||||
int index[2]={0,0};
|
||||
@ -1289,6 +1273,9 @@ int kondo_resolve_scalar_prod_symbols(char* str, Polynomial* output){
|
||||
case 'h':
|
||||
offset[term]=KONDO_H_OFFSET;
|
||||
break;
|
||||
case 't':
|
||||
offset[term]=KONDO_T_OFFSET;
|
||||
break;
|
||||
// switch term
|
||||
case '.':
|
||||
term=1-term;
|
||||
@ -1304,13 +1291,13 @@ int kondo_resolve_scalar_prod_symbols(char* str, Polynomial* output){
|
||||
init_Int_Array(&monomial,2);
|
||||
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);
|
||||
}
|
||||
else{
|
||||
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);
|
||||
}
|
||||
else{
|
||||
@ -1344,6 +1331,9 @@ int get_offset_index(char* str, int* offset, int* index){
|
||||
case 'h':
|
||||
*offset=KONDO_H_OFFSET;
|
||||
break;
|
||||
case 't':
|
||||
*offset=KONDO_T_OFFSET;
|
||||
break;
|
||||
default:
|
||||
// char to int
|
||||
*index=*ptr-'0';
|
||||
@ -1378,6 +1368,9 @@ int get_offsets_index(char* str, int* offset1, int* offset2, int* index){
|
||||
case 'h':
|
||||
offset[term]=KONDO_H_OFFSET;
|
||||
break;
|
||||
case 't':
|
||||
offset[term]=KONDO_T_OFFSET;
|
||||
break;
|
||||
// switch term
|
||||
case '.':
|
||||
term=1-term;
|
||||
@ -1391,11 +1384,16 @@ int get_offsets_index(char* str, int* offset1, int* offset2, int* index){
|
||||
*offset1=offset[0];
|
||||
*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);
|
||||
}
|
||||
|
||||
// get the index of the symbol corresponding to a given string
|
||||
int get_symbol_index(char* str){
|
||||
// get the index of the virtual_field corresponding to a given string
|
||||
int get_virtual_field_index(char* str){
|
||||
char* ptr;
|
||||
int offset=-1;
|
||||
int index=0;
|
||||
@ -1429,6 +1427,9 @@ int get_symbol_index(char* str){
|
||||
case 'h':
|
||||
offset=KONDO_H_OFFSET;
|
||||
break;
|
||||
case 't':
|
||||
offset=KONDO_T_OFFSET;
|
||||
break;
|
||||
default:
|
||||
// set index if dim was already set
|
||||
if(dim>=0){
|
||||
@ -1443,8 +1444,8 @@ int get_symbol_index(char* str){
|
||||
if(offset==-1){
|
||||
return(-1);
|
||||
}
|
||||
// no symbol for h
|
||||
if(offset==KONDO_H_OFFSET){
|
||||
// no virtual field for h or t
|
||||
if(offset==KONDO_H_OFFSET || offset==KONDO_T_OFFSET){
|
||||
return(10*(10*offset+dim));
|
||||
}
|
||||
else{
|
||||
|
16
src/kondo.h
16
src/kondo.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -27,10 +27,10 @@ int kondo_generate_conf(Str_Array* str_args, int box_count);
|
||||
// generate the Kondo fields table
|
||||
int kondo_fields_table(int box_count, Char_Array* str_fields, Fields_Table* fields);
|
||||
|
||||
// generate Kondo symbols
|
||||
int kondo_symbols(Char_Array* str_symbols, int box_count, Fields_Table* fields);
|
||||
// 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);
|
||||
// generate Kondo virtual_fields
|
||||
int kondo_virtual_fields(Char_Array* str_virtual_fields, int box_count, Fields_Table* fields);
|
||||
// generate Kondo virtual_fields (older method: one virtual_field for each scalar product)
|
||||
int kondo_virtual_fields_scalarprod(Char_Array* str_virtual_fields, int box_count, Fields_Table* fields);
|
||||
|
||||
// generate Kondo groups (groups of independent variables)
|
||||
int kondo_groups(Char_Array* str_groups, int box_count);
|
||||
@ -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);
|
||||
|
||||
// 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
|
||||
int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields);
|
||||
// compute a scalar product of polynomial vectors
|
||||
@ -71,6 +71,6 @@ int kondo_resolve_scalar_prod_symbols(char* str, Polynomial* output);
|
||||
int get_offset_index(char* str, int* offset, int* index);
|
||||
// get the offsets and index of a scalar product
|
||||
int get_offsets_index(char* str, int* offset1, int* offset2, int* index);
|
||||
// get the index of the symbol corresponding to a given string
|
||||
int get_symbol_index(char* str);
|
||||
// get the index of the virtual_field corresponding to a given string
|
||||
int get_virtual_field_index(char* str);
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -104,6 +104,11 @@ for(i=1;i<argc;i++){
|
||||
// number of dimensions
|
||||
else if (flag==CP_FLAG_DIMENSION){
|
||||
sscanf(argv[i],"%d",&((*opts).dimension));
|
||||
// check value of the dimension
|
||||
if((*opts).dimension<=0 || (*opts).dimension>=4){
|
||||
fprintf(stderr,"error: kondo_preprocess only supports dimensions 1, 2 and 3 (got %d)\n",(*opts).dimension);
|
||||
exit(-1);
|
||||
}
|
||||
flag=0;
|
||||
}
|
||||
// read file name from command-line
|
||||
|
147
src/mean.c
147
src/mean.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -30,6 +30,7 @@ As of version 1.0, the mean of a monomial is computed directly
|
||||
#include "array.h"
|
||||
#include "fields.h"
|
||||
#include "number.h"
|
||||
#include "determinant.h"
|
||||
|
||||
// mean of a monomial
|
||||
int mean(Int_Array monomial, Polynomial* out, Fields_Table fields, Polynomial_Matrix propagator){
|
||||
@ -42,7 +43,7 @@ int mean(Int_Array monomial, Polynomial* out, Fields_Table fields, Polynomial_Ma
|
||||
*out=polynomial_one();
|
||||
|
||||
// sort first
|
||||
monomial_sort(monomial, 0, monomial.length-1, fields, &sign);
|
||||
monomial_sort(monomial, fields, &sign);
|
||||
polynomial_multiply_Qscalar(*out, quot(sign,1));
|
||||
// get internals
|
||||
// (*out).monomials is the first element of out but it only has 1 element
|
||||
@ -61,10 +62,79 @@ int mean(Int_Array monomial, Polynomial* out, Fields_Table fields, Polynomial_Ma
|
||||
|
||||
// compute the mean of a monomial of internal fields (with split + and -)
|
||||
int mean_internal(Int_Array internal_plus, Int_Array internal_minus, Polynomial* out, Polynomial_Matrix propagator, Fields_Table fields){
|
||||
int ret;
|
||||
Number num;
|
||||
|
||||
if(internal_plus.length!=internal_minus.length){
|
||||
fprintf(stderr,"error: monomial contains unmatched +/- fields\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
ret=mean_determinant(internal_plus, internal_minus, &num, propagator, fields);
|
||||
// cannot compute the mean as a determinant, use permutations
|
||||
// can be because some fields are not Fermions
|
||||
// can be because the propagator has non-numeric values (inverting polynomials is not implemented, and would be required for the computation of the determinant)
|
||||
if(ret==-1){
|
||||
mean_permutations(internal_plus, internal_minus, out, propagator, fields);
|
||||
}
|
||||
else{
|
||||
polynomial_multiply_scalar(*out, num);
|
||||
free_Number(num);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
// compute the mean of a monomial by computing a determinant
|
||||
// can only be used if all of the propagators are numbers
|
||||
int mean_determinant(Int_Array internal_plus, Int_Array internal_minus, Number* out, Polynomial_Matrix propagator, Fields_Table fields){
|
||||
Number_Matrix M;
|
||||
int n=internal_minus.length;
|
||||
int i,j;
|
||||
int a,b;
|
||||
int sign;
|
||||
|
||||
init_Number_Matrix(&M,n);
|
||||
|
||||
// extra sign: the monomial is sorted in such a way that minus fields are on the left of plus fields, but the determinant formula requires the fields to be alternated +-
|
||||
if((n+1)/2%2==1){
|
||||
sign=-1;
|
||||
}
|
||||
else{
|
||||
sign=1;
|
||||
}
|
||||
|
||||
// construct matrix
|
||||
for(i=0;i<n;i++){
|
||||
a=intlist_find_err(propagator.indices, propagator.length, internal_plus.values[i]);
|
||||
for(j=0;j<n;j++){
|
||||
b=intlist_find_err(propagator.indices, propagator.length, -internal_minus.values[j]);
|
||||
// ignore 0
|
||||
if(propagator.matrix[a][b].length!=0){
|
||||
// check whether the fields are Fermions, and whether the entry is a number
|
||||
if(is_fermion(internal_plus.values[i], fields)==0 || is_fermion(internal_minus.values[j], fields)==0 || polynomial_is_number(propagator.matrix[a][b])==0){
|
||||
free_Number_Matrix(M);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
number_add_chain(propagator.matrix[a][b].nums[0], M.matrix[i]+j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// compute determinant
|
||||
determinant_inplace(M, out);
|
||||
|
||||
number_Qprod_chain(quot(sign,1), out);
|
||||
|
||||
free_Number_Matrix(M);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// compute the mean of a monomial by summing over permutations
|
||||
int mean_permutations(Int_Array internal_plus, Int_Array internal_minus, Polynomial* out, Polynomial_Matrix propagator, Fields_Table fields){
|
||||
int n=internal_minus.length;
|
||||
// pairing as an array of positions
|
||||
int* pairing=calloc(n,sizeof(int));
|
||||
@ -118,7 +188,7 @@ int mean_internal(Int_Array internal_plus, Int_Array internal_minus, Polynomial*
|
||||
pairing_sign=permutation_signature(pairing,n);
|
||||
}
|
||||
|
||||
// only simplify in mean_symbols
|
||||
// only simplify in mean_virtual_fields
|
||||
polynomial_prod_chain_nosimplify(num_summed,out,fields);
|
||||
free_Polynomial(num_summed);
|
||||
free(pairing);
|
||||
@ -346,10 +416,10 @@ int get_internals(Int_Array monomial, Int_Array* internal_plus, Int_Array* inter
|
||||
}
|
||||
|
||||
|
||||
// compute the mean of a monomial containing symbolic expressions
|
||||
// compute the mean of a monomial containing virtual fields
|
||||
// keep track of which means were already computed
|
||||
int mean_symbols(Int_Array monomial, Polynomial* output, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, Identities* computed){
|
||||
Int_Array symbol_list;
|
||||
int mean_virtual_fields(Int_Array monomial, Polynomial* output, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, Identities* computed){
|
||||
Int_Array virtual_field_list;
|
||||
int i;
|
||||
int power;
|
||||
int* current_term;
|
||||
@ -375,49 +445,49 @@ int mean_symbols(Int_Array monomial, Polynomial* output, Fields_Table fields, Po
|
||||
}
|
||||
}
|
||||
|
||||
init_Int_Array(&symbol_list, monomial.length);
|
||||
init_Int_Array(&virtual_field_list, monomial.length);
|
||||
init_Int_Array(&base_monomial, monomial.length);
|
||||
|
||||
// generate symbols list
|
||||
// generate virtual_fields list
|
||||
for(i=0;i<monomial.length;i++){
|
||||
if(field_type(monomial.values[i], fields)==FIELD_SYMBOL){
|
||||
int_array_append(intlist_find_err(fields.symbols.indices, fields.symbols.length, monomial.values[i]), &symbol_list);
|
||||
if(field_type(monomial.values[i], fields)==FIELD_VIRTUAL){
|
||||
int_array_append(intlist_find_err(fields.virtual_fields.indices, fields.virtual_fields.length, monomial.values[i]), &virtual_field_list);
|
||||
}
|
||||
else{
|
||||
int_array_append(monomial.values[i], &base_monomial);
|
||||
}
|
||||
}
|
||||
power=symbol_list.length;
|
||||
power=virtual_field_list.length;
|
||||
|
||||
// trivial case
|
||||
if(power==0){
|
||||
mean(monomial, &mean_num, fields, propagator);
|
||||
polynomial_concat_noinit(mean_num, output);
|
||||
|
||||
free_Int_Array(symbol_list);
|
||||
free_Int_Array(virtual_field_list);
|
||||
free_Int_Array(base_monomial);
|
||||
return(0);
|
||||
}
|
||||
else{
|
||||
// initialize current term to a position that has no repetitions
|
||||
current_term=calloc(power,sizeof(int));
|
||||
exists_next=init_prod(current_term, symbol_list, fields, power, base_monomial)+1;
|
||||
exists_next=init_prod(current_term, virtual_field_list, fields, power, base_monomial)+1;
|
||||
}
|
||||
|
||||
// loop over terms; the loop stops when all the pointers are at the end of the first symbol
|
||||
// loop over terms; the loop stops when all the pointers are at the end of the first virtual field
|
||||
while(exists_next==1){
|
||||
// construct monomial
|
||||
int_array_cpy(base_monomial, &tmp_monomial);
|
||||
tmp_num=number_one();
|
||||
for(i=0;i<power;i++){
|
||||
int_array_concat(fields.symbols.expr[symbol_list.values[i]].monomials[current_term[i]], &tmp_monomial);
|
||||
number_prod_chain(fields.symbols.expr[symbol_list.values[i]].nums[current_term[i]], &tmp_num);
|
||||
int_array_concat(fields.virtual_fields.expr[virtual_field_list.values[i]].monomials[current_term[i]], &tmp_monomial);
|
||||
number_prod_chain(fields.virtual_fields.expr[virtual_field_list.values[i]].nums[current_term[i]], &tmp_num);
|
||||
}
|
||||
// check whether the monomial vanishes
|
||||
if(check_monomial_match(tmp_monomial, fields)==1){
|
||||
// sort monomial
|
||||
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);
|
||||
|
||||
// mean
|
||||
@ -432,7 +502,7 @@ int mean_symbols(Int_Array monomial, Polynomial* output, Fields_Table fields, Po
|
||||
free_Int_Array(tmp_monomial);
|
||||
|
||||
// next term
|
||||
exists_next=next_prod(current_term, symbol_list, fields, power, base_monomial)+1;
|
||||
exists_next=next_prod(current_term, virtual_field_list, fields, power, base_monomial)+1;
|
||||
|
||||
|
||||
// simplfiy every 25 steps (improves both memory usage and performance)
|
||||
@ -451,13 +521,13 @@ int mean_symbols(Int_Array monomial, Polynomial* output, Fields_Table fields, Po
|
||||
|
||||
// free memory
|
||||
free(current_term);
|
||||
free_Int_Array(symbol_list);
|
||||
free_Int_Array(virtual_field_list);
|
||||
free_Int_Array(base_monomial);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// first term in product with no repetitions
|
||||
int init_prod(int* current_term, Int_Array symbol_list, Fields_Table fields, int power, Int_Array base_monomial){
|
||||
int init_prod(int* current_term, Int_Array virtual_field_list, Fields_Table fields, int power, Int_Array base_monomial){
|
||||
// index we want to increment
|
||||
int move=0;
|
||||
// tmp monomial
|
||||
@ -474,7 +544,7 @@ int init_prod(int* current_term, Int_Array symbol_list, Fields_Table fields, int
|
||||
// loop until move is out of range
|
||||
while(move>=0 && move<power){
|
||||
// move
|
||||
current_term[move]=next_term_norepeat(current_term[move], fields.symbols.expr[symbol_list.values[move]], &monomial, fields);
|
||||
current_term[move]=next_term_norepeat(current_term[move], fields.virtual_fields.expr[virtual_field_list.values[move]], &monomial, fields);
|
||||
// if the next term does not exist, then move previous index
|
||||
if(current_term[move]==-1){
|
||||
move--;
|
||||
@ -495,7 +565,7 @@ int init_prod(int* current_term, Int_Array symbol_list, Fields_Table fields, int
|
||||
}
|
||||
|
||||
// next term in product with no repetitions
|
||||
int next_prod(int* current_term, Int_Array symbol_list, Fields_Table fields, int power, Int_Array base_monomial){
|
||||
int next_prod(int* current_term, Int_Array virtual_field_list, Fields_Table fields, int power, Int_Array base_monomial){
|
||||
// index we want to increment
|
||||
int move=power-1;
|
||||
// tmp monomial
|
||||
@ -506,13 +576,13 @@ int next_prod(int* current_term, Int_Array symbol_list, Fields_Table fields, int
|
||||
init_Int_Array(&monomial, base_monomial.length+5*power);
|
||||
int_array_cpy_noinit(base_monomial, &monomial);
|
||||
for(i=0;i<=move;i++){
|
||||
int_array_concat(fields.symbols.expr[symbol_list.values[i]].monomials[current_term[i]],&monomial);
|
||||
int_array_concat(fields.virtual_fields.expr[virtual_field_list.values[i]].monomials[current_term[i]],&monomial);
|
||||
}
|
||||
|
||||
// loop until move is out of range
|
||||
while(move>=0 && move<power){
|
||||
// move
|
||||
current_term[move]=next_term_norepeat(current_term[move], fields.symbols.expr[symbol_list.values[move]], &monomial, fields);
|
||||
current_term[move]=next_term_norepeat(current_term[move], fields.virtual_fields.expr[virtual_field_list.values[move]], &monomial, fields);
|
||||
// if the next term does not exist, then move previous index
|
||||
if(current_term[move]==-1){
|
||||
move--;
|
||||
@ -623,13 +693,13 @@ int mean_groups(Int_Array monomial, Polynomial* output, Fields_Table fields, Pol
|
||||
int group=-2;
|
||||
int next_group=-2;
|
||||
Polynomial tmp_poly;
|
||||
int sign;
|
||||
int sign=1;
|
||||
|
||||
init_Polynomial(output, MONOMIAL_SIZE);
|
||||
|
||||
// check whether there are symbols
|
||||
// requires the symbols to be at the end of the monomial
|
||||
if(monomial.length==0 || field_type(monomial.values[monomial.length-1], fields)!=FIELD_SYMBOL){
|
||||
// check whether there are virtual fields
|
||||
// IMPORTANT: the virtual fields must be at the end of the monomial
|
||||
if(monomial.length==0 || field_type(monomial.values[monomial.length-1], fields)!=FIELD_VIRTUAL){
|
||||
// mean
|
||||
mean(monomial, &num_mean, fields, propagator);
|
||||
// add to output
|
||||
@ -639,7 +709,7 @@ int mean_groups(Int_Array monomial, Polynomial* output, Fields_Table fields, Pol
|
||||
// sort into groups
|
||||
if(groups.length>0){
|
||||
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
|
||||
init_Int_Array(&tmp_monomial, MONOMIAL_SIZE);
|
||||
@ -650,7 +720,7 @@ int mean_groups(Int_Array monomial, Polynomial* output, Fields_Table fields, Pol
|
||||
}
|
||||
// if group changes, take mean
|
||||
if((i>0 && next_group!=group) || i==monomial.length){
|
||||
mean_symbols(tmp_monomial, &tmp_poly, fields, propagator, groups, computed);
|
||||
mean_virtual_fields(tmp_monomial, &tmp_poly, fields, propagator, groups, computed);
|
||||
// if zero
|
||||
if(polynomial_is_zero(tmp_poly)==1){
|
||||
// set output to 0
|
||||
@ -702,10 +772,11 @@ struct mean_args{
|
||||
Fields_Table fields;
|
||||
Polynomial_Matrix propagator;
|
||||
Groups groups;
|
||||
int print_progress;
|
||||
};
|
||||
|
||||
// multithreaded
|
||||
int polynomial_mean_multithread(Polynomial* polynomial, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads){
|
||||
int polynomial_mean_multithread(Polynomial* polynomial, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads, int print_progress){
|
||||
int i;
|
||||
Polynomial thread_polys[threads];
|
||||
pthread_t thread_ids[threads];
|
||||
@ -720,11 +791,15 @@ int polynomial_mean_multithread(Polynomial* polynomial, Fields_Table fields, Pol
|
||||
args[i].fields=fields;
|
||||
args[i].propagator=propagator;
|
||||
args[i].groups=groups;
|
||||
args[i].print_progress=print_progress;
|
||||
}
|
||||
|
||||
// split polynomial
|
||||
// randomly choose the thread
|
||||
// see random number generator
|
||||
srand(time(NULL));
|
||||
for(i=0;i<len;i++){
|
||||
polynomial_append((*polynomial).monomials[i], (*polynomial).factors[i], (*polynomial).nums[i], thread_polys+(i % threads));
|
||||
polynomial_append((*polynomial).monomials[i], (*polynomial).factors[i], (*polynomial).nums[i], thread_polys+(rand() % threads));
|
||||
}
|
||||
|
||||
// start threads
|
||||
@ -750,12 +825,12 @@ int polynomial_mean_multithread(Polynomial* polynomial, Fields_Table fields, Pol
|
||||
// mean for one of the threads
|
||||
void* polynomial_mean_thread(void* mean_args){
|
||||
struct mean_args *args=mean_args;
|
||||
polynomial_mean((*args).polynomial,(*args).fields,(*args).propagator,(*args).groups);
|
||||
polynomial_mean((*args).polynomial,(*args).fields,(*args).propagator,(*args).groups, (*args).print_progress);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// single threaded version
|
||||
int polynomial_mean(Polynomial* polynomial, Fields_Table fields, Polynomial_Matrix propagator, Groups groups){
|
||||
int polynomial_mean(Polynomial* polynomial, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int print_progress){
|
||||
int i,j;
|
||||
Polynomial output;
|
||||
Polynomial tmp_poly;
|
||||
@ -769,7 +844,9 @@ int polynomial_mean(Polynomial* polynomial, Fields_Table fields, Polynomial_Matr
|
||||
|
||||
// mean of each monomial
|
||||
for(i=0;i<(*polynomial).length;i++){
|
||||
fprintf(stderr,"computing %d of %d means\n",i,(*polynomial).length-1);
|
||||
if(print_progress==1){
|
||||
fprintf(stderr,"computing %d of %d means\n",i,(*polynomial).length-1);
|
||||
}
|
||||
mean_groups((*polynomial).monomials[i], &tmp_poly, fields, propagator, groups, &computed);
|
||||
|
||||
// write factors
|
||||
|
20
src/mean.h
20
src/mean.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -28,6 +28,12 @@ int mean(Int_Array monomial, Polynomial* out, Fields_Table fields, Polynomial_Ma
|
||||
|
||||
// compute the mean of a monomial of internal fields (with split + and -)
|
||||
int mean_internal(Int_Array internal_plus, Int_Array internal_minus, Polynomial* out, Polynomial_Matrix propagator, Fields_Table fields);
|
||||
|
||||
// compute the mean of a monomial by computing a determinant
|
||||
int mean_determinant(Int_Array internal_plus, Int_Array internal_minus, Number* out, Polynomial_Matrix propagator,Fields_Table fields);
|
||||
|
||||
// compute the mean of a monomial by summing over permutations
|
||||
int mean_permutations(Int_Array internal_plus, Int_Array internal_minus, Polynomial* out, Polynomial_Matrix propagator, Fields_Table fields);
|
||||
// first pairing with a non-vanishing propagator
|
||||
int init_pairing(int* pairing, int* mask, int n, Polynomial_Matrix propagator, int* indices_plus, int* indices_minus);
|
||||
// next pairing with a non-vanishing propagator
|
||||
@ -43,12 +49,12 @@ int mean_internal_slow(Int_Array internal_plus, Int_Array internal_minus, Number
|
||||
// requires the monomial to be sorted (for the sign to be correct)
|
||||
int get_internals(Int_Array monomial, Int_Array* internal_plus, Int_Array* internal_minus, Int_Array* others, Fields_Table fields);
|
||||
|
||||
// compute the mean of a monomial containing symbolic expressions
|
||||
int mean_symbols(Int_Array monomial, Polynomial* output, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, Identities* computed);
|
||||
// compute the mean of a monomial containing virtual fields
|
||||
int mean_virtual_fields(Int_Array monomial, Polynomial* output, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, Identities* computed);
|
||||
// first term in product with no repetitions
|
||||
int init_prod(int* current_term, Int_Array symbol_list, Fields_Table fields, int power, Int_Array base_monomial);
|
||||
int init_prod(int* current_term, Int_Array virtual_field_list, Fields_Table fields, int power, Int_Array base_monomial);
|
||||
// next term in product with no repetitions
|
||||
int next_prod(int* current_term, Int_Array symbol_list, Fields_Table fields, int power, Int_Array base_monomial);
|
||||
int next_prod(int* current_term, Int_Array virtual_field_list, Fields_Table fields, int power, Int_Array base_monomial);
|
||||
// find the next term in a polynomial that can be multiplied to a given monomial and add it to the monomial
|
||||
int next_term_norepeat(int start, Polynomial polynomial, Int_Array* monomial, Fields_Table fields);
|
||||
|
||||
@ -62,9 +68,9 @@ int sort_fermions(int* array, int begin, int end, int* sign);
|
||||
int mean_groups(Int_Array monomial, Polynomial* output, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, Identities* computed);
|
||||
|
||||
// compute the mean of a polynomial
|
||||
int polynomial_mean(Polynomial* polynomial, Fields_Table fields, Polynomial_Matrix propagator, Groups groups);
|
||||
int polynomial_mean(Polynomial* polynomial, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int print_progress);
|
||||
// multithreaded
|
||||
int polynomial_mean_multithread(Polynomial* polynomial, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads);
|
||||
int polynomial_mean_multithread(Polynomial* polynomial, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads, int print_progress);
|
||||
// single thread mean
|
||||
void* polynomial_mean_thread(void* mean_args);
|
||||
#endif
|
||||
|
213
src/meankondo.c
213
src/meankondo.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -17,7 +17,7 @@ limitations under the License.
|
||||
/*
|
||||
meankondo
|
||||
|
||||
A simple tool to compute the renormalization group flow for Fermionic hierarchical models
|
||||
A tool to compute the renormalization group flow for Fermionic hierarchical models
|
||||
|
||||
*/
|
||||
|
||||
@ -49,15 +49,19 @@ A simple tool to compute the renormalization group flow for Fermionic hierarchic
|
||||
#include "mean.h"
|
||||
// various string operations
|
||||
#include "istring.h"
|
||||
// symbolic trees
|
||||
# include "tree.h"
|
||||
|
||||
// read cli arguments
|
||||
int read_args_meankondo(int argc,const char* argv[], Str_Array* str_args, Meankondo_Options* opts);
|
||||
// print usage message
|
||||
int print_usage_meankondo();
|
||||
// check consistency of options
|
||||
int check_meankondo_opts(Meankondo_Options opts);
|
||||
// compute flow
|
||||
int compute_flow(Str_Array str_args, Meankondo_Options opts);
|
||||
// compute the flow equation
|
||||
int compute_flow_equation(Polynomial init_poly, Id_Table idtable, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads, Grouped_Polynomial* flow_equation);
|
||||
// compute average
|
||||
int compute_average(Polynomial init_poly, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads, int print_progress, Polynomial* exp_poly);
|
||||
|
||||
|
||||
int main (int argc, const char* argv[]){
|
||||
@ -69,6 +73,9 @@ int main (int argc, const char* argv[]){
|
||||
// read command-line arguments
|
||||
read_args_meankondo(argc,argv,&str_args,&opts);
|
||||
|
||||
// check command-line arguments
|
||||
check_meankondo_opts(opts);
|
||||
|
||||
// warning message if representing rational numbers as floats
|
||||
#ifdef RATIONAL_AS_FLOAT
|
||||
fprintf(stderr,"info: representing rational numbers using floats\n");
|
||||
@ -101,6 +108,10 @@ int read_args_meankondo(int argc,const char* argv[], Str_Array* str_args, Meanko
|
||||
(*opts).threads=1;
|
||||
// do not chain
|
||||
(*opts).chain=0;
|
||||
// do not print progress
|
||||
(*opts).print_progress=0;
|
||||
// print the flow equation
|
||||
(*opts).group_poly=1;
|
||||
|
||||
// loop over arguments
|
||||
for(i=1;i<argc;i++){
|
||||
@ -116,6 +127,13 @@ int read_args_meankondo(int argc,const char* argv[], Str_Array* str_args, Meanko
|
||||
case 'C':
|
||||
(*opts).chain=1;
|
||||
break;
|
||||
// print progress
|
||||
case 'p':
|
||||
(*opts).print_progress=1;
|
||||
break;
|
||||
case 'A':
|
||||
(*opts).group_poly=0;
|
||||
break;
|
||||
// print version
|
||||
case 'v':
|
||||
printf("meankondo " VERSION "\n");
|
||||
@ -147,7 +165,16 @@ int read_args_meankondo(int argc,const char* argv[], Str_Array* str_args, Meanko
|
||||
|
||||
// print usage message
|
||||
int print_usage_meankondo(){
|
||||
printf("\nusage:\n meankondo [-t threads] [-C] <filename>\n\n");
|
||||
printf("\nusage:\n meankondo [-t threads] [-C] [-p] [-A] <filename>\n\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
// check consistency of options
|
||||
int check_meankondo_opts(Meankondo_Options opts){
|
||||
if(opts.chain==1 && opts.group_poly==0){
|
||||
fprintf(stderr,"aborting: the '-C' and '-A' options are incompatible\n");
|
||||
exit(-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -163,6 +190,8 @@ int compute_flow(Str_Array str_args, Meankondo_Options opts){
|
||||
Fields_Table fields;
|
||||
// their propagator
|
||||
Polynomial_Matrix propagator;
|
||||
// preprocessor variables
|
||||
Variables variables;
|
||||
// initial polynomial
|
||||
Polynomial init_poly;
|
||||
// list of rccs
|
||||
@ -171,6 +200,8 @@ int compute_flow(Str_Array str_args, Meankondo_Options opts){
|
||||
Groups groups;
|
||||
// flow equation
|
||||
Grouped_Polynomial flow_equation;
|
||||
// polynomial produced by the averaging operation
|
||||
Polynomial exp_poly;
|
||||
|
||||
|
||||
// parse fields
|
||||
@ -183,29 +214,38 @@ int compute_flow(Str_Array str_args, Meankondo_Options opts){
|
||||
parse_input_fields(str_args.strs[arg_index],&fields);
|
||||
}
|
||||
|
||||
// parse id table
|
||||
arg_index=find_str_arg("id_table", str_args);
|
||||
if(arg_index<0){
|
||||
fprintf(stderr,"error: no id table entry in the configuration file\n");
|
||||
exit(-1);
|
||||
// parse variables
|
||||
// must precede id_table, virtual_fields, identities and input_polynomial
|
||||
arg_index=find_str_arg("preprocessor_variables", str_args);
|
||||
if(arg_index>=0){
|
||||
parse_input_variables(str_args.strs[arg_index],&variables);
|
||||
}
|
||||
else{
|
||||
parse_input_id_table(str_args.strs[arg_index],&idtable, fields);
|
||||
init_Variables(&variables,1);
|
||||
}
|
||||
|
||||
// parse symbols
|
||||
arg_index=find_str_arg("symbols", str_args);
|
||||
if(arg_index>=0){
|
||||
parse_input_symbols(str_args.strs[arg_index],&fields);
|
||||
// parse id table
|
||||
if(opts.group_poly==1){
|
||||
arg_index=find_str_arg("id_table", str_args);
|
||||
if(arg_index<0){
|
||||
fprintf(stderr,"error: no id table entry in the configuration file\n");
|
||||
exit(-1);
|
||||
}
|
||||
else{
|
||||
parse_input_id_table(str_args.strs[arg_index],&idtable, fields, variables);
|
||||
}
|
||||
}
|
||||
else{
|
||||
init_Symbols(&(fields.symbols),1);
|
||||
|
||||
// parse virtual_fields
|
||||
arg_index=find_str_arg("virtual_fields", str_args);
|
||||
if(arg_index>=0){
|
||||
parse_input_virtual_fields(str_args.strs[arg_index], &fields, variables);
|
||||
}
|
||||
|
||||
// parse input polynomial
|
||||
arg_index=find_str_arg("input_polynomial", str_args);
|
||||
if(arg_index>=0){
|
||||
parse_input_polynomial(str_args.strs[arg_index],&init_poly, fields);
|
||||
parse_input_polynomial(str_args.strs[arg_index],&init_poly, fields, variables);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"error: no input polynomial entry in the configuration file\n");
|
||||
@ -225,41 +265,90 @@ int compute_flow(Str_Array str_args, Meankondo_Options opts){
|
||||
// parse identities
|
||||
arg_index=find_str_arg("identities", str_args);
|
||||
if(arg_index>=0){
|
||||
parse_input_identities(str_args.strs[arg_index],&fields);
|
||||
}
|
||||
else{
|
||||
init_Identities(&(fields.ids),1);
|
||||
parse_input_identities(str_args.strs[arg_index],&fields, variables);
|
||||
}
|
||||
|
||||
// parse groups
|
||||
// parse groups (must come after virtual_fields and propagator)
|
||||
arg_index=find_str_arg("groups", str_args);
|
||||
if(arg_index>=0){
|
||||
parse_input_groups(str_args.strs[arg_index],&groups);
|
||||
parse_input_groups(str_args.strs[arg_index],&groups, propagator, fields);
|
||||
}
|
||||
else{
|
||||
init_Groups(&groups, 1);
|
||||
}
|
||||
|
||||
// flow equation
|
||||
compute_flow_equation(init_poly, idtable, fields, propagator, groups, opts.threads, &flow_equation);
|
||||
// compute the average
|
||||
compute_average(init_poly, fields, propagator, groups, opts.threads, opts.print_progress, &exp_poly);
|
||||
|
||||
free_Polynomial(init_poly);
|
||||
free_Polynomial_Matrix(propagator);
|
||||
free_Fields_Table(fields);
|
||||
free_Groups(groups);
|
||||
|
||||
// parse postprocessing entry
|
||||
arg_index=find_str_arg("postprocess_operation", str_args);
|
||||
if(arg_index>=0){
|
||||
add_polynomial_to_variables("OUT", exp_poly, &variables);
|
||||
// parse postprocess entry
|
||||
Polynomial postprocess_operation;
|
||||
parse_input_polynomial(str_args.strs[arg_index], &postprocess_operation, fields, variables);
|
||||
// replace exp_poly
|
||||
free_Polynomial(exp_poly);
|
||||
exp_poly=postprocess_operation;
|
||||
}
|
||||
|
||||
if(opts.group_poly==1){
|
||||
// flow equation
|
||||
group_polynomial(exp_poly, &flow_equation, idtable, fields);
|
||||
}
|
||||
|
||||
// postprocess flow equation
|
||||
arg_index=find_str_arg("postprocess_flow_equation", str_args);
|
||||
if(arg_index>=0){
|
||||
Polynomial flow_polynomial;
|
||||
// polynomial made of the rcc's multiplied by the corresponding fields (parsed from idtable)
|
||||
idtable_to_polynomial(idtable, &flow_polynomial);
|
||||
|
||||
// add to variables
|
||||
add_polynomial_to_variables("FLOW", flow_polynomial, &variables);
|
||||
free_Polynomial(flow_polynomial);
|
||||
|
||||
// parse postprocess entry
|
||||
Polynomial postprocess_polynomial;
|
||||
parse_input_polynomial(str_args.strs[arg_index], &postprocess_polynomial, fields, variables);
|
||||
|
||||
// convert to flow equation
|
||||
Grouped_Polynomial postprocess_flow_equation;
|
||||
group_polynomial(postprocess_polynomial, &postprocess_flow_equation, idtable, fields);
|
||||
free_Polynomial(postprocess_polynomial);
|
||||
|
||||
// apply postprocessing to flow equation
|
||||
Grouped_Polynomial new_flow;
|
||||
compose_flow_equations(postprocess_flow_equation, flow_equation, &new_flow);
|
||||
free_Grouped_Polynomial(postprocess_flow_equation);
|
||||
|
||||
// replace flow_equation
|
||||
free_Grouped_Polynomial(flow_equation);
|
||||
flow_equation=new_flow;
|
||||
}
|
||||
|
||||
|
||||
// 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, "symbols")==0 &&\
|
||||
str_cmp(arg_header.str, "variables")==0 &&\
|
||||
str_cmp(arg_header.str, "virtual_fields")==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 ){
|
||||
str_cmp(arg_header.str, "id_table")==0 &&\
|
||||
str_cmp(arg_header.str, "postprocess_operation")==0 &&\
|
||||
str_cmp(arg_header.str, "numerical_postprocess_operation")==0
|
||||
){
|
||||
printf("%s\n&\n",str_args.strs[i].str);
|
||||
}
|
||||
free_Char_Array(arg_header);
|
||||
@ -268,34 +357,66 @@ int compute_flow(Str_Array str_args, Meankondo_Options opts){
|
||||
printf("#!flow_equation\n");
|
||||
}
|
||||
|
||||
// print flow equation
|
||||
grouped_polynomial_print(flow_equation,'%','%');
|
||||
// print result
|
||||
if(opts.group_poly==1){
|
||||
grouped_polynomial_print(flow_equation,'%','%');
|
||||
|
||||
// free memory
|
||||
free_Grouped_Polynomial(flow_equation);
|
||||
}
|
||||
else{
|
||||
polynomial_print(exp_poly);
|
||||
}
|
||||
|
||||
// free memory
|
||||
free_Id_Table(idtable);
|
||||
free_Grouped_Polynomial(flow_equation);
|
||||
free_Polynomial(exp_poly);
|
||||
|
||||
// parse numerical_postprocessing entry
|
||||
arg_index=find_str_arg("numerical_postprocess_operation", str_args);
|
||||
if(arg_index>=0){
|
||||
Polynomial rcc_polynomial;
|
||||
// polynomial made of the rcc's multiplied by the corresponding fields (parsed from idtable)
|
||||
idtable_to_polynomial(idtable, &rcc_polynomial);
|
||||
|
||||
// add to variables
|
||||
add_polynomial_to_variables("RCC", rcc_polynomial, &variables);
|
||||
free_Polynomial(rcc_polynomial);
|
||||
|
||||
// parse postprocess entry
|
||||
Polynomial numerical_postprocess_operation;
|
||||
parse_input_polynomial(str_args.strs[arg_index], &numerical_postprocess_operation, fields, variables);
|
||||
|
||||
// convert to flow equation
|
||||
Grouped_Polynomial numerical_postprocess_flow_equation;
|
||||
group_polynomial(numerical_postprocess_operation, &numerical_postprocess_flow_equation, idtable, fields);
|
||||
free_Polynomial(numerical_postprocess_operation);
|
||||
|
||||
// print postprocessing flow equation
|
||||
printf("\n&\n#!postprocess_operation\n");
|
||||
grouped_polynomial_print(numerical_postprocess_flow_equation,'%','%');
|
||||
free_Grouped_Polynomial(numerical_postprocess_flow_equation);
|
||||
}
|
||||
|
||||
if(opts.group_poly==1){
|
||||
free_Id_Table(idtable);
|
||||
}
|
||||
free_Fields_Table(fields);
|
||||
free_Variables(variables);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// compute the flow equation
|
||||
int compute_flow_equation(Polynomial init_poly, Id_Table idtable, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads, Grouped_Polynomial* flow_equation){
|
||||
// expectation
|
||||
Polynomial exp_poly;
|
||||
|
||||
polynomial_cpy(init_poly,&exp_poly);
|
||||
// compute average
|
||||
int compute_average(Polynomial init_poly, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads, int print_progress, Polynomial* exp_poly){
|
||||
polynomial_cpy(init_poly,exp_poly);
|
||||
|
||||
// average
|
||||
if(threads>1){
|
||||
polynomial_mean_multithread(&exp_poly, fields, propagator, groups, threads);
|
||||
polynomial_mean_multithread(exp_poly, fields, propagator, groups, threads, print_progress);
|
||||
}
|
||||
else{
|
||||
polynomial_mean(&exp_poly, fields, propagator, groups);
|
||||
polynomial_mean(exp_poly, fields, propagator, groups, print_progress);
|
||||
}
|
||||
|
||||
// grouped representation of expanded_poly
|
||||
group_polynomial(exp_poly,flow_equation,idtable, fields);
|
||||
free_Polynomial(exp_poly);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -39,13 +39,13 @@ Utility to perform various operations on flow equations
|
||||
// string functions
|
||||
#include "istring.h"
|
||||
// tools
|
||||
#include "meantools_exp.h"
|
||||
#include "meantools_deriv.h"
|
||||
#include "meantools_eval.h"
|
||||
#include "meantools_expand.h"
|
||||
|
||||
#define EXP_COMMAND 1
|
||||
#define DERIV_COMMAND 2
|
||||
#define EVAL_COMMAND 3
|
||||
#define DERIV_COMMAND 1
|
||||
#define EVAL_COMMAND 2
|
||||
#define EXPAND_COMMAND 3
|
||||
|
||||
// read cli arguments
|
||||
int read_args_meantools(int argc,const char* argv[], Str_Array* str_args, Meantools_Options* opts);
|
||||
@ -63,12 +63,12 @@ int main (int argc, const char* argv[]){
|
||||
read_args_meantools(argc,argv,&str_args, &opts);
|
||||
|
||||
switch(opts.command){
|
||||
case EXP_COMMAND: tool_exp(str_args);
|
||||
break;
|
||||
case DERIV_COMMAND: tool_deriv(str_args,opts);
|
||||
break;
|
||||
case EVAL_COMMAND: tool_eval(str_args,opts);
|
||||
break;
|
||||
case EXPAND_COMMAND: tool_expand(str_args,opts);
|
||||
break;
|
||||
}
|
||||
|
||||
//free memory
|
||||
@ -86,11 +86,7 @@ int read_args_meantools(int argc,const char* argv[], Str_Array* str_args, Meanto
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(str_cmp((char*)argv[1],"exp")==1){
|
||||
(*opts).command=EXP_COMMAND;
|
||||
tool_exp_read_args(argc, argv, str_args);
|
||||
}
|
||||
else if(str_cmp((char*)argv[1],"derive")==1){
|
||||
if(str_cmp((char*)argv[1],"differentiate")==1){
|
||||
(*opts).command=DERIV_COMMAND;
|
||||
tool_deriv_read_args(argc, argv, str_args, opts);
|
||||
}
|
||||
@ -98,6 +94,10 @@ int read_args_meantools(int argc,const char* argv[], Str_Array* str_args, Meanto
|
||||
(*opts).command=EVAL_COMMAND;
|
||||
tool_eval_read_args(argc, argv, str_args, opts);
|
||||
}
|
||||
else if(str_cmp((char*)argv[1],"expand")==1){
|
||||
(*opts).command=EXPAND_COMMAND;
|
||||
tool_expand_read_args(argc, argv, str_args, opts);
|
||||
}
|
||||
else{
|
||||
print_usage_meantools();
|
||||
exit(-1);
|
||||
@ -108,9 +108,6 @@ int read_args_meantools(int argc,const char* argv[], Str_Array* str_args, Meanto
|
||||
|
||||
// print usage message
|
||||
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 differentiate [-d derivatives] [-V variables] [-C] [config_file]\n meantools eval [-R values] [-P precision] [-E max_exponent] [config_file]\n meantools expand [-N namespace] [config_file]\n\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -42,10 +42,12 @@ int tool_deriv_read_args(int argc, const char* argv[], Str_Array* str_args, Mean
|
||||
char* ptr;
|
||||
|
||||
// defaults
|
||||
// derive once
|
||||
// differentiate once
|
||||
(*opts).deriv_derivs=1;
|
||||
// derive with respect to all variables
|
||||
// differentiate with respect to all variables
|
||||
(*opts).deriv_vars.length=-1;
|
||||
// do not chain
|
||||
(*opts).chain=0;
|
||||
|
||||
|
||||
// loop over arguments
|
||||
@ -61,6 +63,10 @@ int tool_deriv_read_args(int argc, const char* argv[], Str_Array* str_args, Mean
|
||||
case 'V':
|
||||
flag=CP_FLAG_VARS;
|
||||
break;
|
||||
// chain
|
||||
case 'C':
|
||||
(*opts).chain=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,7 +77,7 @@ int tool_deriv_read_args(int argc, const char* argv[], Str_Array* str_args, Mean
|
||||
}
|
||||
// variables
|
||||
else if(flag==CP_FLAG_VARS){
|
||||
// if the argument is "all" then derive wrt all variables
|
||||
// if the argument is "all" then differentiate wrt all variables
|
||||
if(str_cmp((char*)argv[i],"all")){
|
||||
(*opts).deriv_vars.length=-2;
|
||||
}
|
||||
@ -95,7 +101,7 @@ int tool_deriv_read_args(int argc, const char* argv[], Str_Array* str_args, Mean
|
||||
}
|
||||
|
||||
|
||||
// derive a flow equation
|
||||
// differentiate a flow equation
|
||||
int tool_deriv(Str_Array str_args, Meantools_Options opts){
|
||||
// index of the entry in the input file
|
||||
int arg_index;
|
||||
@ -104,6 +110,8 @@ int tool_deriv(Str_Array str_args, Meantools_Options opts){
|
||||
// flow equation for the derivatives
|
||||
Grouped_Polynomial flow_equation_deriv;
|
||||
int i;
|
||||
// header of the entry
|
||||
Char_Array arg_header;
|
||||
|
||||
|
||||
// parse flow equation
|
||||
@ -142,6 +150,29 @@ int tool_deriv(Str_Array str_args, Meantools_Options opts){
|
||||
// compute derivatives
|
||||
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, "virtual_fields")==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,'%','%');
|
||||
|
||||
// free memory
|
||||
@ -164,15 +195,20 @@ int flow_equation_derivative(int n, Int_Array variables, Grouped_Polynomial flow
|
||||
// output polynomial
|
||||
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
|
||||
grouped_polynomial_cpy(dflow, &tmpflow);
|
||||
// derive
|
||||
// free dflow
|
||||
free_Grouped_Polynomial(dflow);
|
||||
// next derivative
|
||||
flow_equation_derivx(tmpflow, indices, &dflow);
|
||||
// free
|
||||
// free tmpflow
|
||||
free_Grouped_Polynomial(tmpflow);
|
||||
|
||||
// add the derived indices as variables for the next derivative
|
||||
// add the differentiated indices as variables for the next derivative
|
||||
for(i=0;i<variables.length;i++){
|
||||
if(variables.values[i]>=0){
|
||||
int_array_append((j+1)*DOFFSET+variables.values[i], &indices);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -21,7 +21,7 @@ limitations under the License.
|
||||
|
||||
// read arguments
|
||||
int tool_deriv_read_args(int argc, const char* argv[], Str_Array* str_args, Meantools_Options* opts);
|
||||
// derive a flow equation
|
||||
// differentiate a flow equation
|
||||
int tool_deriv(Str_Array str_args, Meantools_Options opts);
|
||||
// n first derivatives of a flow equation wrt to variables
|
||||
int flow_equation_derivative(int n, Int_Array variables, Grouped_Polynomial flow_equation, Grouped_Polynomial* flow_equation_derivs);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -18,16 +18,22 @@ limitations under the License.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <mpfr.h>
|
||||
#include "parse_file.h"
|
||||
#include "cli_parser.h"
|
||||
#include "grouped_polynomial.h"
|
||||
#include "array.h"
|
||||
#include "rcc.h"
|
||||
#include "rcc_mpfr.h"
|
||||
|
||||
|
||||
#define CP_FLAG_RCCS 1
|
||||
#define CP_FLAG_MPFR_PREC 2
|
||||
#define CP_FLAG_MPFR_EXP 3
|
||||
// read command line arguments
|
||||
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
|
||||
const char* file="";
|
||||
// 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
|
||||
// mark rccstring so that it can be recognized whether it has been set or not
|
||||
(*opts).eval_rccstring.length=-1;
|
||||
// no mpfr
|
||||
(*opts).mpfr_prec=0;
|
||||
(*opts).mpfr_emax=0;
|
||||
|
||||
// loop over arguments
|
||||
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':
|
||||
flag=CP_FLAG_RCCS;
|
||||
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));
|
||||
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
|
||||
else{
|
||||
file=argv[i];
|
||||
@ -78,9 +107,21 @@ int tool_eval(Str_Array str_args, Meantools_Options opts){
|
||||
int arg_index;
|
||||
// rccs
|
||||
RCC rccs;
|
||||
RCC_mpfr rccs_mpfr;
|
||||
// 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
|
||||
// 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
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
// evaluate
|
||||
evaleq(&rccs, flow_equation);
|
||||
if(mpfr_flag==0){
|
||||
evaleq(rccs, rccs, flow_equation);
|
||||
RCC_print(rccs);
|
||||
free_RCC(rccs);
|
||||
}
|
||||
else{
|
||||
evaleq_mpfr(rccs_mpfr, rccs_mpfr, flow_equation);
|
||||
RCC_mpfr_print(rccs_mpfr);
|
||||
free_RCC_mpfr(rccs_mpfr);
|
||||
}
|
||||
|
||||
// print
|
||||
RCC_print(rccs);
|
||||
|
||||
// free memory
|
||||
free_Grouped_Polynomial(flow_equation);
|
||||
free_RCC(rccs);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -1,130 +0,0 @@
|
||||
/*
|
||||
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 "meantools_exp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "parse_file.h"
|
||||
#include "cli_parser.h"
|
||||
#include "polynomial.h"
|
||||
#include "fields.h"
|
||||
#include "grouped_polynomial.h"
|
||||
#include "idtable.h"
|
||||
|
||||
// read command line arguments
|
||||
int tool_exp_read_args(int argc, const char* argv[], Str_Array* str_args){
|
||||
// file to read the polynomial from in flow mode
|
||||
const char* file="";
|
||||
// whether a file was specified on the command-line
|
||||
int exists_file=0;
|
||||
|
||||
if(argc>=3){
|
||||
file=argv[2];
|
||||
exists_file=1;
|
||||
}
|
||||
read_config_file(str_args, file, 1-exists_file);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// compute the exponential of the input polynomial
|
||||
int tool_exp(Str_Array str_args){
|
||||
// index of the entry in the input file
|
||||
int arg_index;
|
||||
// list of fields
|
||||
Fields_Table fields;
|
||||
// input polynomial
|
||||
Polynomial poly;
|
||||
// exp as a polynomial
|
||||
Polynomial exp_poly;
|
||||
// list of rccs
|
||||
Id_Table idtable;
|
||||
// exp
|
||||
Grouped_Polynomial exp;
|
||||
int i,j;
|
||||
|
||||
// parse fields
|
||||
arg_index=find_str_arg("fields", str_args);
|
||||
if(arg_index<0){
|
||||
fprintf(stderr,"error: no fields entry in the configuration file\n");
|
||||
exit(-1);
|
||||
}
|
||||
else{
|
||||
parse_input_fields(str_args.strs[arg_index],&fields);
|
||||
}
|
||||
|
||||
// parse id table
|
||||
arg_index=find_str_arg("id_table", str_args);
|
||||
if(arg_index<0){
|
||||
fprintf(stderr,"error: no id table entry in the configuration file\n");
|
||||
exit(-1);
|
||||
}
|
||||
else{
|
||||
parse_input_id_table(str_args.strs[arg_index],&idtable, fields);
|
||||
}
|
||||
|
||||
// parse input polynomial
|
||||
arg_index=find_str_arg("input_polynomial", str_args);
|
||||
if(arg_index>=0){
|
||||
parse_input_polynomial(str_args.strs[arg_index],&poly, fields);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"error: no input polynomial entry in the configuration file\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// parse symbols
|
||||
arg_index=find_str_arg("symbols", str_args);
|
||||
if(arg_index>=0){
|
||||
parse_input_symbols(str_args.strs[arg_index],&fields);
|
||||
}
|
||||
else{
|
||||
init_Symbols(&(fields.symbols),1);
|
||||
}
|
||||
|
||||
// parse identities
|
||||
arg_index=find_str_arg("identities", str_args);
|
||||
if(arg_index>=0){
|
||||
parse_input_identities(str_args.strs[arg_index],&fields);
|
||||
}
|
||||
else{
|
||||
init_Identities(&(fields.ids),1);
|
||||
}
|
||||
|
||||
// exp(V)
|
||||
polynomial_exponential(poly,&exp_poly, fields);
|
||||
// grouped representation
|
||||
group_polynomial(exp_poly, &exp, idtable, fields);
|
||||
free_Polynomial(exp_poly);
|
||||
free_Polynomial(poly);
|
||||
|
||||
// no denominators
|
||||
for(i=0;i<exp.length;i++){
|
||||
for(j=0;j<exp.coefs[i].length;j++){
|
||||
exp.coefs[i].denoms[j].power=0;
|
||||
}
|
||||
}
|
||||
|
||||
grouped_polynomial_print(exp,'%','%');
|
||||
|
||||
// free memory
|
||||
free_Fields_Table(fields);
|
||||
free_Id_Table(idtable);
|
||||
free_Grouped_Polynomial(exp);
|
||||
return(0);
|
||||
}
|
166
src/meantools_expand.c
Normal file
166
src/meantools_expand.c
Normal file
@ -0,0 +1,166 @@
|
||||
/*
|
||||
Copyright 2015-2022 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 "meantools_expand.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "cli_parser.h"
|
||||
#include "parse_file.h"
|
||||
#include "polynomial.h"
|
||||
#include "array.h"
|
||||
#include "fields.h"
|
||||
|
||||
|
||||
#define CP_FLAG_NAMESPACE 1
|
||||
// read command line arguments
|
||||
int tool_expand_read_args(int argc, const char* argv[], Str_Array* str_args, Meantools_Options* opts){
|
||||
// file to read the polynomial from in flow mode
|
||||
const char* file="";
|
||||
// whether a file was specified on the command-line
|
||||
int exists_file=0;
|
||||
// flag
|
||||
int flag=0;
|
||||
int i;
|
||||
char* ptr;
|
||||
|
||||
// defaults
|
||||
// no namespace
|
||||
(*opts).namespace.length=-1;
|
||||
|
||||
|
||||
// loop over arguments
|
||||
for(i=2;i<argc;i++){
|
||||
// flag
|
||||
if(argv[i][0]=='-'){
|
||||
for(ptr=((char*)argv[i])+1;*ptr!='\0';ptr++){
|
||||
switch(*ptr){
|
||||
// number of derivatives
|
||||
case 'N':
|
||||
flag=CP_FLAG_NAMESPACE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// namespace
|
||||
else if(flag==CP_FLAG_NAMESPACE){
|
||||
str_to_char_array((char*)argv[i], &(opts->namespace));
|
||||
flag=0;
|
||||
}
|
||||
// read file name from command-line
|
||||
else{
|
||||
file=argv[i];
|
||||
exists_file=1;
|
||||
}
|
||||
}
|
||||
|
||||
read_config_file(str_args, file, 1-exists_file);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// expand a polynomial
|
||||
int tool_expand(Str_Array str_args, Meantools_Options opts){
|
||||
// index of the entry in the input file
|
||||
int arg_index;
|
||||
// input polynomial
|
||||
Polynomial polynomial;
|
||||
// fields table
|
||||
Fields_Table fields;
|
||||
// preprocessor variables
|
||||
Variables variables;
|
||||
|
||||
// parse fields
|
||||
if(opts.namespace.length>=0){
|
||||
arg_index=find_str_arg_ns("fields", opts.namespace, str_args);
|
||||
}
|
||||
else{
|
||||
arg_index=find_str_arg("fields", str_args);
|
||||
}
|
||||
if(arg_index<0){
|
||||
fprintf(stderr,"error: no fields entry in the configuration file\n");
|
||||
exit(-1);
|
||||
}
|
||||
else{
|
||||
parse_input_fields(str_args.strs[arg_index],&fields);
|
||||
}
|
||||
|
||||
// parse variables
|
||||
// must precede id_table, virtual_fields, identities and input_polynomial
|
||||
if(opts.namespace.length>=0){
|
||||
arg_index=find_str_arg_ns("preprocessor_variables", opts.namespace, str_args);
|
||||
}
|
||||
else{
|
||||
arg_index=find_str_arg("preprocessor_variables", str_args);
|
||||
}
|
||||
if(arg_index>=0){
|
||||
parse_input_variables(str_args.strs[arg_index],&variables);
|
||||
}
|
||||
else{
|
||||
init_Variables(&variables,1);
|
||||
}
|
||||
|
||||
// parse virtual_fields
|
||||
if(opts.namespace.length>=0){
|
||||
arg_index=find_str_arg_ns("virtual_fields", opts.namespace, str_args);
|
||||
}
|
||||
else{
|
||||
arg_index=find_str_arg("virtual_fields", str_args);
|
||||
}
|
||||
if(arg_index>=0){
|
||||
parse_input_virtual_fields(str_args.strs[arg_index], &fields, variables);
|
||||
}
|
||||
|
||||
// parse identities
|
||||
if(opts.namespace.length>=0){
|
||||
arg_index=find_str_arg_ns("identities", opts.namespace, str_args);
|
||||
}
|
||||
else{
|
||||
arg_index=find_str_arg("identities", str_args);
|
||||
}
|
||||
if(arg_index>=0){
|
||||
parse_input_identities(str_args.strs[arg_index],&fields, variables);
|
||||
}
|
||||
|
||||
// parse input polynomial
|
||||
if(opts.namespace.length>=0){
|
||||
arg_index=find_str_arg_ns("input_polynomial", opts.namespace, str_args);
|
||||
}
|
||||
else{
|
||||
arg_index=find_str_arg("input_polynomial", str_args);
|
||||
}
|
||||
if(arg_index>=0){
|
||||
parse_input_polynomial(str_args.strs[arg_index], &polynomial, fields, variables);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"error: no input polynomial entry in the configuration file\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// print polynomial
|
||||
polynomial_print(polynomial);
|
||||
|
||||
// free memory
|
||||
free_Variables(variables);
|
||||
free_Fields_Table(fields);
|
||||
free_Polynomial(polynomial);
|
||||
|
||||
if(opts.namespace.length>=0){
|
||||
free_Char_Array(opts.namespace);
|
||||
}
|
||||
return(0);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -14,14 +14,16 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MEANTOOLS_EXP_H
|
||||
#define MEANTOOLS_EXP_H
|
||||
#ifndef MEANTOOLS_EXPAND_H
|
||||
#define MEANTOOLS_EXPAND_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
// read arguments
|
||||
int tool_exp_read_args(int argc, const char* argv[], Str_Array* str_args);
|
||||
// compute the exponential of the input polynomial
|
||||
int tool_exp(Str_Array str_args);
|
||||
int tool_expand_read_args(int argc, const char* argv[], Str_Array* str_args, Meantools_Options* opts);
|
||||
// expand a flow equation
|
||||
int tool_expand(Str_Array str_args, Meantools_Options opts);
|
||||
|
||||
#endif
|
||||
|
||||
|
251
src/number.c
251
src/number.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -18,11 +18,16 @@ limitations under the License.
|
||||
#include <stdlib.h>
|
||||
#include <stdio.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 "definitions.cpp"
|
||||
#include "tools.h"
|
||||
#include "rational.h"
|
||||
#include "array.h"
|
||||
#include "parse_file.h"
|
||||
|
||||
// init
|
||||
int init_Number(Number* number, int memory){
|
||||
@ -267,50 +272,107 @@ Number number_Qprod_ret(Q q, Number x){
|
||||
return(ret);
|
||||
}
|
||||
|
||||
// inverse
|
||||
int number_inverse_inplace(Number* inout){
|
||||
int i;
|
||||
for(i=0;i<(*inout).length;i++){
|
||||
if((*inout).base[i]>0){
|
||||
(*inout).scalars[i]=Q_inverse((*inout).scalars[i]);
|
||||
(*inout).scalars[i].denominator*=(*inout).base[i];
|
||||
// quotient of two numbers
|
||||
// recursively simplify numerator/denominator until denominator only has one term
|
||||
// the output is set to 'numerator'
|
||||
// both numerator and denominator may be changed by this function
|
||||
// this algorithm is not optimal in cases where denominator has several terms, in particular if their bases are large
|
||||
// it is optimal if denominator only has one term
|
||||
int number_quot_inplace(Number* numerator, Number* denominator){
|
||||
Number tmp;
|
||||
int i,factor;
|
||||
|
||||
switch((*denominator).length){
|
||||
// error
|
||||
case 0:
|
||||
fprintf(stderr,"error: attempting to invert 0\n");
|
||||
exit(-1);
|
||||
break;
|
||||
|
||||
// trivial case
|
||||
case 1:
|
||||
// trivial base
|
||||
if((*denominator).base[0]==1){
|
||||
number_Qprod_chain(Q_inverse((*denominator).scalars[0]), numerator);
|
||||
}
|
||||
else if((*inout).base[i]<0){
|
||||
(*inout).scalars[i]=Q_inverse((*inout).scalars[i]);
|
||||
(*inout).scalars[i].denominator*=-(*inout).base[i];
|
||||
(*inout).scalars[i].numerator*=-1;
|
||||
// non-trivial base
|
||||
else{
|
||||
// set tmp=1/denominator
|
||||
tmp=number_one();
|
||||
tmp.base[0]=(*denominator).base[0];
|
||||
tmp.scalars[0].denominator=(*denominator).scalars[0].numerator*abs((*denominator).base[0]);
|
||||
if((*denominator).base[0]>0){
|
||||
tmp.scalars[0].numerator=(*denominator).scalars[0].denominator;
|
||||
}
|
||||
else if((*denominator).base[0]<0){
|
||||
tmp.scalars[0].numerator=-(*denominator).scalars[0].denominator;
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"error: attempting to invert 0\n");
|
||||
exit(-1);
|
||||
}
|
||||
number_prod_chain(tmp, numerator);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// find non-trivial basis
|
||||
for(i=0;(*denominator).base[i]==1;i++){}
|
||||
|
||||
// smallest prime factor of the base
|
||||
if((*denominator).base[i]<0){
|
||||
factor=-1;
|
||||
}
|
||||
else if((*denominator).base[i]==2){
|
||||
factor=2;
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"error: attempting to invert 0\n");
|
||||
exit(-1);
|
||||
// COMMENT: this is not optimal, but, provided the basis is not too large, this should not be a problem
|
||||
for(factor=3;is_factor(factor, (*denominator).base[i])==0;factor=factor+2){}
|
||||
}
|
||||
|
||||
// tmp is set to ((terms that k does not divide)-(terms that k divides))
|
||||
// tmp will be multiplied to numerator and denominator
|
||||
init_Number(&tmp,(*denominator).length);
|
||||
|
||||
// find all terms whose base is a multiple of k
|
||||
for(i=0;i<(*denominator).length;i++){
|
||||
if(is_factor(factor, (*denominator).base[i])){
|
||||
// add to tmp with a - sign
|
||||
number_add_elem(quot(-(*denominator).scalars[i].numerator,(*denominator).scalars[i].denominator), (*denominator).base[i], &tmp);
|
||||
}
|
||||
else{
|
||||
// add to tmp
|
||||
number_add_elem((*denominator).scalars[i], (*denominator).base[i], &tmp);
|
||||
}
|
||||
}
|
||||
|
||||
number_prod_chain(tmp, numerator);
|
||||
number_prod_chain(tmp, denominator);
|
||||
free_Number(tmp);
|
||||
|
||||
// recurse
|
||||
number_quot_inplace(numerator, denominator);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
// write to output
|
||||
int number_inverse(Number input, Number* output){
|
||||
number_cpy(input,output);
|
||||
number_inverse_inplace(output);
|
||||
return(0);
|
||||
}
|
||||
// return result
|
||||
Number number_inverse_ret(Number x){
|
||||
Number ret;
|
||||
number_inverse(x,&ret);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
// quotient
|
||||
// not inplace
|
||||
int number_quot(Number x1, Number x2, Number* output){
|
||||
Number inv;
|
||||
number_inverse(x2, &inv);
|
||||
number_prod(x1, inv, output);
|
||||
free_Number(inv);
|
||||
Number numerator, denominator;
|
||||
number_cpy(x1, &numerator);
|
||||
number_cpy(x2, &denominator);
|
||||
number_quot_inplace(&numerator, &denominator);
|
||||
*output=numerator;
|
||||
free_Number(denominator);
|
||||
return(0);
|
||||
}
|
||||
int number_quot_chain(Number x1, Number* inout){
|
||||
number_inverse_inplace(inout);
|
||||
number_prod_chain(x1, inout);
|
||||
int number_quot_chain(Number* inout, Number x2){
|
||||
Number tmp;
|
||||
number_quot(*inout,x2,&tmp);
|
||||
free_Number(*inout);
|
||||
*inout=tmp;
|
||||
return(0);
|
||||
}
|
||||
Number number_quot_ret(Number x1, Number x2){
|
||||
@ -358,6 +420,30 @@ long double number_double_val(Number x){
|
||||
}
|
||||
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
|
||||
@ -391,7 +477,7 @@ int number_print(Number number){
|
||||
Char_Array buffer;
|
||||
init_Char_Array(&buffer,5*number.length);
|
||||
number_sprint(number, &buffer);
|
||||
printf("%s",buffer.str);
|
||||
printf("%s",char_array_to_str_noinit(&buffer));
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -406,18 +492,54 @@ int str_to_Number(char* str, Number* number){
|
||||
char* buffer_ptr=buffer;
|
||||
Q num;
|
||||
int base;
|
||||
// whether there are parentheses in the string
|
||||
int exist_parenthesis=0;
|
||||
int ret;
|
||||
int j;
|
||||
char* aux_str;
|
||||
int aux_free=0;
|
||||
|
||||
init_Number(number, NUMBER_SIZE);
|
||||
|
||||
// check whether the string is blank (return 0 in that case)
|
||||
for(ptr=str;*ptr!='\0';ptr++){
|
||||
if(*ptr!=' ' && *ptr!='\n'){
|
||||
break;
|
||||
}
|
||||
}
|
||||
// blank string
|
||||
if(*ptr=='\0'){
|
||||
number_add_elem(quot(0,1), 1, number);
|
||||
free(buffer);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// init num and base
|
||||
// init to 0 so that if str is empty, then the number is set to 0
|
||||
num=quot(0,1);
|
||||
num=quot(1,1);
|
||||
base=1;
|
||||
|
||||
// check whether the str only contains a rational number, and add parentheses
|
||||
// keep rtack of the length of str
|
||||
for(j=0,ptr=str;*ptr!='\0';j++,ptr++){
|
||||
if((*ptr<'0' || *ptr>'9') && *ptr!='-' && *ptr!='/'){
|
||||
break;
|
||||
}
|
||||
}
|
||||
// only rational
|
||||
if(*ptr=='\0'){
|
||||
aux_str=calloc(j+3,sizeof(char));
|
||||
aux_str[0]='(';
|
||||
for(j=0,ptr=str;*ptr!='\0';ptr++,j++){
|
||||
aux_str[j+1]=*ptr;
|
||||
}
|
||||
aux_str[j+1]=')';
|
||||
aux_str[j+2]='\0';
|
||||
aux_free=1;
|
||||
}
|
||||
else{
|
||||
aux_str=str;
|
||||
}
|
||||
|
||||
mode=PP_NULL_MODE;
|
||||
for(ptr=str;*ptr!='\0';ptr++){
|
||||
for(ptr=aux_str;*ptr!='\0';ptr++){
|
||||
switch(*ptr){
|
||||
// read number
|
||||
case '(':
|
||||
@ -425,7 +547,10 @@ int str_to_Number(char* str, Number* number){
|
||||
// init base
|
||||
base=1;
|
||||
mode=PP_NUM_MODE;
|
||||
exist_parenthesis=1;
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: misplaced '(' in number '%s'\n",str);
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
case ')':
|
||||
@ -435,6 +560,10 @@ int str_to_Number(char* str, Number* number){
|
||||
*buffer_ptr='\0';
|
||||
mode=PP_NULL_MODE;
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: mismatched ')' in number '%s'\n",str);
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
|
||||
// read sqrt
|
||||
@ -446,16 +575,26 @@ int str_to_Number(char* str, Number* number){
|
||||
if(mode==PP_NULL_MODE){
|
||||
mode=PP_SQRT_MODE;
|
||||
}
|
||||
// if there is a square root, then do not read a fraction (see end of loop)
|
||||
exist_parenthesis=1;
|
||||
else{
|
||||
fprintf(stderr,"syntax error: misplaced '{' in number '%s'\n",str);
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
case '}':
|
||||
if(mode==PP_SQRT_MODE){
|
||||
sscanf(buffer,"%d",&base);
|
||||
ret=read_int(buffer,&base);
|
||||
if(ret<0){
|
||||
fprintf(stderr,"syntax error: number base should be an integer, got '%s' in '%s'",buffer,str);
|
||||
exit(-1);
|
||||
}
|
||||
buffer_ptr=buffer;
|
||||
*buffer_ptr='\0';
|
||||
mode=PP_NULL_MODE;
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: mismatched '}' in number '%s'\n",str);
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
|
||||
// write num
|
||||
@ -466,24 +605,40 @@ int str_to_Number(char* str, Number* number){
|
||||
num=quot(0,1);
|
||||
base=1;
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: misplaced '+' in number '%s'\n",str);
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
|
||||
// ignore 's', ' ' and '\n'
|
||||
case 's':break;
|
||||
case ' ':break;
|
||||
case '\n':break;
|
||||
default:
|
||||
if(mode!=PP_NULL_MODE){
|
||||
buffer_ptr=str_addchar(buffer_ptr,*ptr);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: unrecognized character '%c' in number '%s'\n",*ptr,str);
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// last step
|
||||
if(mode==PP_NULL_MODE){
|
||||
if(exist_parenthesis==0){
|
||||
str_to_Q(str, &num);
|
||||
}
|
||||
number_add_elem(num, base, number);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: mismatched '(' in number '%s'\n",str);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
if(aux_free==1){
|
||||
free(aux_str);
|
||||
}
|
||||
free(buffer);
|
||||
return(0);
|
||||
}
|
||||
|
17
src/number.h
17
src/number.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -78,16 +78,11 @@ int number_Qprod(Q q, Number x, Number* inout);
|
||||
// return result
|
||||
Number number_Qprod_ret(Q q, Number x);
|
||||
|
||||
// inverse
|
||||
int number_inverse_inplace(Number* inout);
|
||||
// write to output
|
||||
int number_inverse(Number input, Number* output);
|
||||
// return result
|
||||
Number number_inverse_ret(Number x);
|
||||
|
||||
// quotient
|
||||
// quotient of two numbers
|
||||
int number_quot_inplace(Number* numerator, Number* denominator);
|
||||
// not inplace
|
||||
int number_quot(Number x1, Number x2, Number* output);
|
||||
int number_quot_chain(Number x1, Number* inout);
|
||||
int number_quot_chain(Number* inout, Number x2);
|
||||
Number number_quot_ret(Number x1, Number x2);
|
||||
|
||||
// remove 0's
|
||||
@ -98,6 +93,8 @@ int number_is_zero(Number x);
|
||||
|
||||
// approximate numerical expression
|
||||
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
|
||||
int number_sprint(Number number, Char_Array* out);
|
||||
|
103
src/numkondo.c
103
src/numkondo.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -30,6 +30,7 @@ Compute the flow of a flow equation numerically
|
||||
|
||||
// rccs
|
||||
#include "rcc.h"
|
||||
#include "rcc_mpfr.h"
|
||||
// grouped representation of polynomials
|
||||
#include "grouped_polynomial.h"
|
||||
// command line parser
|
||||
@ -38,6 +39,7 @@ Compute the flow of a flow equation numerically
|
||||
#include "parse_file.h"
|
||||
// numerical flow
|
||||
#include "flow.h"
|
||||
#include "flow_mpfr.h"
|
||||
// arrays
|
||||
#include "array.h"
|
||||
|
||||
@ -68,10 +70,13 @@ int main (int argc, const char* argv[]){
|
||||
|
||||
// parse command-line arguments
|
||||
#define CP_FLAG_NITER 1
|
||||
#define CP_FLAG_TOL 2
|
||||
#define CP_FLAG_RCCS 3
|
||||
#define CP_FLAG_RCCS 2
|
||||
#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 i;
|
||||
// temporary long int
|
||||
long int tmp_lint;
|
||||
// pointers
|
||||
char* ptr;
|
||||
// file to read the polynomial from in flow mode
|
||||
@ -81,21 +86,16 @@ int read_args_numkondo(int argc,const char* argv[], Str_Array* str_args, Numkond
|
||||
// whether a file was specified on the command-line
|
||||
int exists_file=0;
|
||||
|
||||
// if there are no arguments
|
||||
if(argc==1){
|
||||
print_usage_numkondo();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// defaults
|
||||
// display entire flow
|
||||
(*opts).display_mode=DISPLAY_NUMERICAL;
|
||||
// default niter
|
||||
(*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
|
||||
(*opts).eval_rccstring.length=-1;
|
||||
// no mpfr
|
||||
(*opts).mpfr_prec=0;
|
||||
(*opts).mpfr_emax=0;
|
||||
|
||||
// loop over arguments
|
||||
for(i=1;i<argc;i++){
|
||||
@ -111,14 +111,18 @@ for(i=1;i<argc;i++){
|
||||
case 'N':
|
||||
flag=CP_FLAG_NITER;
|
||||
break;
|
||||
// tolerance
|
||||
case 'D':
|
||||
flag=CP_FLAG_TOL;
|
||||
break;
|
||||
// initial condition
|
||||
case 'I':
|
||||
flag=CP_FLAG_RCCS;
|
||||
break;
|
||||
// mpfr precision
|
||||
case 'P':
|
||||
flag=CP_FLAG_MPFR_PREC;
|
||||
break;
|
||||
// mpfr emax
|
||||
case 'E':
|
||||
flag=CP_FLAG_MPFR_EXP;
|
||||
break;
|
||||
// print version
|
||||
case 'v':
|
||||
printf("numkondo " VERSION "\n");
|
||||
@ -134,16 +138,23 @@ for(i=1;i<argc;i++){
|
||||
// reset flag
|
||||
flag=0;
|
||||
}
|
||||
// tolerance
|
||||
else if (flag==CP_FLAG_TOL){
|
||||
sscanf(argv[i],"%Lf",&((*opts).tol));
|
||||
flag=0;
|
||||
}
|
||||
// init condition
|
||||
else if(flag==CP_FLAG_RCCS){
|
||||
str_to_char_array((char*)argv[i], &((*opts).eval_rccstring));
|
||||
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
|
||||
else{
|
||||
file=argv[i];
|
||||
@ -158,7 +169,7 @@ for(i=1;i<argc;i++){
|
||||
|
||||
// print usage message
|
||||
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);
|
||||
}
|
||||
|
||||
@ -171,10 +182,26 @@ int numflow(Str_Array str_args, Numkondo_Options opts){
|
||||
Labels labels;
|
||||
// initial condition
|
||||
RCC init_cd;
|
||||
RCC_mpfr init_cd_mpfr;
|
||||
// flow equation
|
||||
Grouped_Polynomial flow_equation;
|
||||
// whether or not to use mpfr floats
|
||||
int mpfr_flag=0;
|
||||
// postprocess flow equation
|
||||
Grouped_Polynomial postprocess_flow_equation;
|
||||
|
||||
// parse id table
|
||||
// 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 labels
|
||||
arg_index=find_str_arg("labels", str_args);
|
||||
if(arg_index<0){
|
||||
fprintf(stderr,"error: no labels entry in the configuration file\n");
|
||||
@ -194,6 +221,16 @@ int numflow(Str_Array str_args, Numkondo_Options opts){
|
||||
char_array_to_Grouped_Polynomial(str_args.strs[arg_index], &flow_equation);
|
||||
}
|
||||
|
||||
// parse postprocess operation
|
||||
arg_index=find_str_arg("postprocess_operation", str_args);
|
||||
if(arg_index>=0){
|
||||
char_array_to_Grouped_Polynomial(str_args.strs[arg_index], &postprocess_flow_equation);
|
||||
}
|
||||
else{
|
||||
init_Grouped_Polynomial(&postprocess_flow_equation,1);
|
||||
}
|
||||
|
||||
|
||||
// initial conditions
|
||||
// check they were not specified on the command line
|
||||
if(opts.eval_rccstring.length==-1){
|
||||
@ -207,20 +244,32 @@ int numflow(Str_Array str_args, Numkondo_Options opts){
|
||||
}
|
||||
}
|
||||
// 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
|
||||
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);
|
||||
}
|
||||
|
||||
numerical_flow(flow_equation, init_cd, labels, opts.niter, opts.tol, opts.display_mode);
|
||||
if(mpfr_flag==0){
|
||||
numerical_flow(flow_equation, init_cd, postprocess_flow_equation, labels, opts.niter, opts.display_mode);
|
||||
free_RCC(init_cd);
|
||||
}
|
||||
else{
|
||||
numerical_flow_mpfr(flow_equation, init_cd_mpfr, postprocess_flow_equation, labels, opts.niter, opts.display_mode);
|
||||
free_RCC_mpfr(init_cd_mpfr);
|
||||
}
|
||||
|
||||
free_RCC(init_cd);
|
||||
|
||||
// free memory
|
||||
free_Labels(labels);
|
||||
free_Grouped_Polynomial(postprocess_flow_equation);
|
||||
free_Grouped_Polynomial(flow_equation);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
768
src/parse_file.c
768
src/parse_file.c
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -23,34 +23,53 @@ Parse the input file
|
||||
|
||||
#include "types.h"
|
||||
|
||||
// read a positive integer from a string
|
||||
int read_positive_int(char* str, int* out);
|
||||
// read an integer from a string
|
||||
int read_int(char* str, int* out);
|
||||
// read an long int from a string
|
||||
int read_long_int(char* str, long int* out);
|
||||
// read a long double
|
||||
int read_long_double(char* str, long double* out);
|
||||
|
||||
|
||||
// parse fields list
|
||||
int parse_input_fields(Char_Array str_fields, Fields_Table* fields);
|
||||
|
||||
// parse symbols list
|
||||
int parse_input_symbols(Char_Array str_symbols, Fields_Table* fields);
|
||||
// parse virtual_fields list
|
||||
int parse_input_virtual_fields(Char_Array str_virtual_fields, Fields_Table* fields, Variables variables);
|
||||
|
||||
// parse groups of independent fields
|
||||
int parse_input_groups(Char_Array str_groups, Groups* groups);
|
||||
int parse_input_groups(Char_Array str_groups, Groups* groups, Polynomial_Matrix propagator, Fields_Table fields);
|
||||
// check that the members of groups are independent (assuming the virtual_fields and propagator were already parsed)
|
||||
int check_groups(Groups groups, Polynomial_Matrix propagator, Fields_Table fields);
|
||||
// list of fields involved in a list of virtual_fields
|
||||
int fields_in_virtual_field_list(Int_Array indices, Fields_Table fields, Int_Array* output);
|
||||
|
||||
// parse variables list
|
||||
int parse_input_variables(Char_Array str_variables, Variables* variables);
|
||||
|
||||
// parse identities between fields
|
||||
int parse_input_identities(Char_Array str_identities, Fields_Table* fields);
|
||||
int parse_input_identities(Char_Array str_identities, Fields_Table* fields, Variables variables);
|
||||
|
||||
// parse propagator
|
||||
int parse_input_propagator(Char_Array str_propagator, Polynomial_Matrix* propagator, Fields_Table fields);
|
||||
|
||||
// parse input polynomial
|
||||
int parse_input_polynomial(Char_Array str_polynomial, Polynomial* output, Fields_Table fields);
|
||||
int parse_input_polynomial(Char_Array str_polynomial, Polynomial* output, Fields_Table fields, Variables variables);
|
||||
|
||||
// parse id table
|
||||
int parse_input_id_table(Char_Array str_idtable, Id_Table* idtable, Fields_Table fields);
|
||||
int parse_input_id_table(Char_Array str_idtable, Id_Table* idtable, Fields_Table fields, Variables variables);
|
||||
|
||||
// parse a list of labels
|
||||
int parse_labels(Char_Array str_labels, Labels* labels);
|
||||
|
||||
// parse the initial condition
|
||||
int parse_init_cd(Char_Array init_cd, RCC* init);
|
||||
// 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, RCC_mpfr* init_mpfr, int mpfr_flag);
|
||||
|
||||
// set indices and length of 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
|
||||
|
137
src/polynomial.c
137
src/polynomial.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -27,6 +27,7 @@ limitations under the License.
|
||||
#include "array.h"
|
||||
#include "number.h"
|
||||
#include "fields.h"
|
||||
#include "parse_file.h"
|
||||
|
||||
|
||||
// allocate memory
|
||||
@ -368,7 +369,7 @@ int polynomial_prod_chain_nosimplify(Polynomial input, Polynomial* inout, Fields
|
||||
Int_Array out_monomial;
|
||||
Int_Array out_factor;
|
||||
Number out_num;
|
||||
// save length of inout (which changes during the loop
|
||||
// save length of inout (which changes during the loop)
|
||||
int inout_length=(*inout).length;
|
||||
// first position in input which can multiply a term of inout without vanishing
|
||||
int firstpos;
|
||||
@ -630,8 +631,8 @@ int remove_unmatched_plusminus(Polynomial* polynomial, Fields_Table fields){
|
||||
match_internals--;
|
||||
}
|
||||
}
|
||||
// don't remove a term containing symbols
|
||||
else if(type==FIELD_SYMBOL){
|
||||
// don't remove a term containing virtual_field
|
||||
else if(type==FIELD_VIRTUAL){
|
||||
match_internals=0;
|
||||
break;
|
||||
}
|
||||
@ -688,7 +689,7 @@ int polynomial_simplify(Polynomial* polynomial, Fields_Table fields){
|
||||
// sort monomials and factors
|
||||
for(i=0;i<(*polynomial).length;i++){
|
||||
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);
|
||||
int_array_sort((*polynomial).factors[i],0,(*polynomial).factors[i].length-1);
|
||||
}
|
||||
@ -787,7 +788,30 @@ int exchange_polynomial_terms(int i, int j, Polynomial* polynomial){
|
||||
}
|
||||
|
||||
// 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 index;
|
||||
// the pivot: middle of the monomial
|
||||
@ -812,8 +836,8 @@ int monomial_sort(Int_Array monomial, int begin, int end, Fields_Table fields, i
|
||||
exchange_monomial_terms(monomial, index, end, fields, sign);
|
||||
|
||||
// recurse
|
||||
monomial_sort(monomial, begin, index-1, fields, sign);
|
||||
monomial_sort(monomial, index+1, end, fields, sign);
|
||||
monomial_sort_nonc(monomial, begin, index-1, fields, sign);
|
||||
monomial_sort_nonc(monomial, index+1, end, fields, sign);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@ -872,7 +896,30 @@ int exchange_monomial_terms(Int_Array monomial, int pos1, int pos2, Fields_Table
|
||||
|
||||
|
||||
// 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 index;
|
||||
// the pivot: middle of the monomial
|
||||
@ -897,8 +944,8 @@ int monomial_sort_groups(Int_Array monomial, int begin, int end, Fields_Table fi
|
||||
exchange_monomial_terms(monomial, index, end, fields, sign);
|
||||
|
||||
// recurse
|
||||
monomial_sort(monomial, begin, index-1, fields, sign);
|
||||
monomial_sort(monomial, index+1, end, fields, sign);
|
||||
monomial_sort_groups_nonc(monomial, begin, index-1, fields, groups, sign);
|
||||
monomial_sort_groups_nonc(monomial, index+1, end, fields, groups, sign);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@ -1047,7 +1094,7 @@ int polynomial_print(Polynomial polynomial){
|
||||
Char_Array buffer;
|
||||
init_Char_Array(&buffer, STR_SIZE);
|
||||
polynomial_sprint(polynomial, &buffer);
|
||||
printf("%s",buffer.str);
|
||||
printf("%s",char_array_to_str_noinit(&buffer));
|
||||
free_Char_Array(buffer);
|
||||
return(0);
|
||||
}
|
||||
@ -1058,7 +1105,7 @@ int polynomial_print(Polynomial polynomial){
|
||||
#define PP_MONOMIAL_MODE 2
|
||||
#define PP_FACTOR_MODE 3
|
||||
#define PP_NUMBER_MODE 4
|
||||
int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output){
|
||||
int Char_Array_to_Polynomial(Char_Array str_polynomial, Polynomial* output){
|
||||
// buffer
|
||||
char* buffer=calloc(str_polynomial.length+1,sizeof(char));
|
||||
char* buffer_ptr=buffer;
|
||||
@ -1069,6 +1116,7 @@ int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output){
|
||||
int comment=0;
|
||||
int i,j;
|
||||
int parenthesis_count=0;
|
||||
int ret;
|
||||
|
||||
// allocate memory
|
||||
init_Polynomial(output,POLY_SIZE);
|
||||
@ -1128,6 +1176,10 @@ int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output){
|
||||
init_Int_Array(&factor, MONOMIAL_SIZE);
|
||||
num=number_one();
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: misplaced '+' in polynomial\n");
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
|
||||
// enter monomial or factor mode
|
||||
@ -1135,6 +1187,10 @@ int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output){
|
||||
if(mode==PP_NULL_MODE){
|
||||
mode=PP_BRACKET_MODE;
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: misplaced '[' in polynomial\n");
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
// factor mode
|
||||
case 'l':
|
||||
@ -1143,6 +1199,10 @@ int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output){
|
||||
buffer_ptr=buffer;
|
||||
*buffer_ptr='\0';
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: misplaced 'l' in polynomial\n");
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
// monomial mode
|
||||
case 'f':
|
||||
@ -1151,16 +1211,30 @@ int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output){
|
||||
buffer_ptr=buffer;
|
||||
*buffer_ptr='\0';
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: misplaced 'j' in polynomial\n");
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
// read monomial or factor
|
||||
case ']':
|
||||
sscanf(buffer,"%d",&i);
|
||||
ret=read_int(buffer,&i);
|
||||
if(ret<0){
|
||||
fprintf(stderr,"syntax error: in polynomial, expected integer field or factor index, got '%s'\n",buffer);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(mode==PP_FACTOR_MODE){
|
||||
int_array_append(i,&factor);
|
||||
}
|
||||
else if(mode==PP_MONOMIAL_MODE){
|
||||
int_array_append(i,&monomial);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: mismatched ']' in polynomial\n");
|
||||
exit(-1);
|
||||
}
|
||||
// switch back to null mode
|
||||
mode=PP_NULL_MODE;
|
||||
break;
|
||||
@ -1178,6 +1252,10 @@ int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output){
|
||||
parenthesis_count++;
|
||||
buffer_ptr=str_addchar(buffer_ptr,str_polynomial.str[j]);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: misplaced '(' in polynomial\n");
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
case ')':
|
||||
if(mode==PP_NUMBER_MODE){
|
||||
@ -1194,11 +1272,14 @@ int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output){
|
||||
buffer_ptr=str_addchar(buffer_ptr,str_polynomial.str[j]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: mismatched ')' in polynomial\n");
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
|
||||
// characters to ignore
|
||||
case ' ':break;
|
||||
case '&':break;
|
||||
case '\n':break;
|
||||
|
||||
// comments
|
||||
@ -1211,6 +1292,10 @@ int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output){
|
||||
// write to buffer
|
||||
buffer_ptr=str_addchar(buffer_ptr,str_polynomial.str[j]);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr,"syntax error: in polynomial, unrecognized character '%c'\n",str_polynomial.str[j]);
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1224,7 +1309,7 @@ int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output){
|
||||
}
|
||||
|
||||
// with str input
|
||||
int str_to_Polynomial(char* str_polynomial,Polynomial* output){
|
||||
int str_to_Polynomial(char* str_polynomial, Polynomial* output){
|
||||
Char_Array buffer;
|
||||
str_to_char_array(str_polynomial, &buffer);
|
||||
Char_Array_to_Polynomial(buffer, output);
|
||||
@ -1232,6 +1317,15 @@ int str_to_Polynomial(char* str_polynomial,Polynomial* output){
|
||||
return(0);
|
||||
}
|
||||
|
||||
// check whether the polynomial is a constant
|
||||
int polynomial_is_number(Polynomial poly){
|
||||
if(poly.length==0 || (poly.length==1 && poly.monomials[0].length==0 && poly.factors[0].length==0)){
|
||||
return(1);
|
||||
}
|
||||
else{
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------- Polynomial_Matrix ---------------------
|
||||
|
||||
@ -1261,3 +1355,16 @@ int free_Polynomial_Matrix(Polynomial_Matrix matrix){
|
||||
free(matrix.indices);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// check whether the entries are numbers
|
||||
int polynomial_matrix_is_numeric(Polynomial_Matrix matrix){
|
||||
int i,j;
|
||||
for(i=0;i<matrix.length;i++){
|
||||
for(j=0;j<matrix.length;j++){
|
||||
if(polynomial_is_number(matrix.matrix[i][j])==0){
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -99,14 +99,18 @@ int polynomial_sort(Polynomial* polynomial, int begin, int end);
|
||||
int exchange_polynomial_terms(int i, int j, Polynomial* polynomial);
|
||||
|
||||
// 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
|
||||
int compare_monomial_terms(Int_Array monomial, int pos1, int pos2, Fields_Table fields);
|
||||
// exchange two fields (with 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
|
||||
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
|
||||
int compare_monomial_terms_groups(Int_Array monomial, int pos1, int pos2, Fields_Table fields, Groups groups);
|
||||
|
||||
@ -120,12 +124,18 @@ int replace_factors(Grouped_Polynomial equations, Polynomial* polynomial);
|
||||
int polynomial_sprint(Polynomial polynomial, Char_Array* output);
|
||||
int polynomial_print(Polynomial polynomial);
|
||||
// read a polynomial
|
||||
int Char_Array_to_Polynomial(Char_Array str_polynomial,Polynomial* output);
|
||||
int str_to_Polynomial(char* str_polynomial,Polynomial* output);
|
||||
int Char_Array_to_Polynomial(Char_Array str_polynomial, Polynomial* output);
|
||||
int str_to_Polynomial(char* str_polynomial, Polynomial* output);
|
||||
|
||||
// check whether the polynomial is a constant
|
||||
int polynomial_is_number(Polynomial poly);
|
||||
|
||||
//------------------------ Polynomial_Matrix --------------------------
|
||||
// init
|
||||
int init_Polynomial_Matrix(Polynomial_Matrix* matrix, int length);
|
||||
int free_Polynomial_Matrix(Polynomial_Matrix matrix);
|
||||
|
||||
// check whether the entries are numbers
|
||||
int polynomial_matrix_is_numeric(Polynomial_Matrix matrix);
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -19,21 +19,14 @@ limitations under the License.
|
||||
#include "rational_float.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
|
||||
#include <mpfr.h>
|
||||
#include "istring.h"
|
||||
#include "array.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
|
||||
Q Q_add(Q x1,Q x2){
|
||||
Q ret;
|
||||
@ -141,6 +134,16 @@ long double lcm(long double x,long double y){
|
||||
double Q_double_value(Q q){
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -54,6 +54,8 @@ long double lcm(long double x,long double y);
|
||||
|
||||
// approximate value as double
|
||||
double Q_double_value(Q q);
|
||||
// approximate value as mpfr float
|
||||
int Q_mpfr_value(mpfr_t out, Q q);
|
||||
|
||||
// print to string
|
||||
int Q_sprint(Q num, Char_Array* out);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -19,8 +19,13 @@ limitations under the License.
|
||||
#include "rational_int.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
|
||||
#include <mpfr.h>
|
||||
#include "istring.h"
|
||||
#include "array.h"
|
||||
#include "parse_file.h"
|
||||
|
||||
Q quot(long int p, long int q){
|
||||
Q ret;
|
||||
@ -135,6 +140,16 @@ long int lcm(long int x,long int y){
|
||||
double Q_double_value(Q q){
|
||||
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
|
||||
@ -157,13 +172,18 @@ int str_to_Q(char* str, Q* num){
|
||||
int mode;
|
||||
char* buffer=calloc(str_len(str)+1,sizeof(char));
|
||||
char* buffer_ptr=buffer;
|
||||
int ret;
|
||||
|
||||
*num=quot(0,1);
|
||||
|
||||
mode=PP_NUMERATOR_MODE;
|
||||
for(ptr=str;*ptr!='\0';ptr++){
|
||||
if(*ptr=='/'){
|
||||
sscanf(buffer,"%ld",&((*num).numerator));
|
||||
ret=read_long_int(buffer,&((*num).numerator));
|
||||
if(ret<0){
|
||||
fprintf(stderr,"syntax error: numerator should be an integer, got '%s' in '%s'\n",buffer,str);
|
||||
exit(-1);
|
||||
}
|
||||
buffer_ptr=buffer;
|
||||
*buffer_ptr='\0';
|
||||
mode=PP_DENOMINATOR_MODE;
|
||||
@ -175,10 +195,18 @@ int str_to_Q(char* str, Q* num){
|
||||
|
||||
// last step
|
||||
if(mode==PP_NUMERATOR_MODE){
|
||||
sscanf(buffer,"%ld",&((*num).numerator));
|
||||
ret=read_long_int(buffer,&((*num).numerator));
|
||||
if(ret<0){
|
||||
fprintf(stderr,"syntax error: numerator should be an integer, got '%s' in '%s'\n",buffer,str);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
else if(mode==PP_DENOMINATOR_MODE){
|
||||
sscanf(buffer,"%ld",&((*num).denominator));
|
||||
ret=read_long_int(buffer,&((*num).denominator));
|
||||
if(ret<0){
|
||||
fprintf(stderr,"syntax error: numerator should be an integer, got '%s' in '%s'\n",buffer,str);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -49,6 +49,8 @@ long int lcm(long int x,long int y);
|
||||
|
||||
// approximate value as double
|
||||
double Q_double_value(Q q);
|
||||
// approximate value as mpfr float
|
||||
int Q_mpfr_value(mpfr_t out, Q q);
|
||||
|
||||
// print to string
|
||||
int Q_sprint(Q num, Char_Array* out);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -49,6 +49,13 @@ int RCC_cpy(RCC input,RCC* output){
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
int RCC_cpy_noinit(RCC input,RCC* output){
|
||||
int i;
|
||||
for(i=0;i<input.length;i++){
|
||||
RCC_set_elem(input.values[i], input.indices[i], output, i);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
// concatenate rccs
|
||||
int RCC_concat(RCC rccs1, RCC rccs2, RCC* output){
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -28,6 +28,7 @@ int free_RCC(RCC rccs);
|
||||
int RCC_set_elem(long double value, int index, RCC* rcc, int pos);
|
||||
// copy
|
||||
int RCC_cpy(RCC input,RCC* output);
|
||||
int RCC_cpy_noinit(RCC input,RCC* output);
|
||||
// concatenate 2 rccs
|
||||
int RCC_concat(RCC rccs1, RCC rccs2, RCC* output);
|
||||
// append an rcc to another
|
||||
|
131
src/rcc_mpfr.c
Normal file
131
src/rcc_mpfr.c
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
Copyright 2015-2022 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);
|
||||
}
|
||||
int RCC_mpfr_cpy_noinit(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);
|
||||
}
|
||||
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);
|
||||
}
|
44
src/rcc_mpfr.h
Normal file
44
src/rcc_mpfr.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
Copyright 2015-2022 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);
|
||||
int RCC_mpfr_cpy_noinit(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
|
330
src/symbolic_parser.c
Normal file
330
src/symbolic_parser.c
Normal file
@ -0,0 +1,330 @@
|
||||
/*
|
||||
Copyright 2015-2022 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 "symbolic_parser.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "tree.h"
|
||||
#include "definitions.cpp"
|
||||
#include "array.h"
|
||||
#include "istring.h"
|
||||
#include "fields.h"
|
||||
#include "polynomial.h"
|
||||
|
||||
#define SP_NULL_MODE 0
|
||||
#define SP_FUNCTION_MODE 1
|
||||
|
||||
// parse a symbolic expression from a char_array
|
||||
int parse_symbolic_expression(Char_Array str, Fields_Table fields, Variables variables, Polynomial* polynomial){
|
||||
Tree symbol_tree;
|
||||
char_array_to_symbol_tree(str, &symbol_tree);
|
||||
resolve_symbol_tree(symbol_tree, fields, variables, polynomial);
|
||||
free_Tree(symbol_tree);
|
||||
return(0);
|
||||
}
|
||||
// from char*
|
||||
int parse_symbolic_expression_str(char* str, Fields_Table fields, Variables variables, Polynomial* polynomial){
|
||||
Char_Array char_array;
|
||||
str_to_char_array(str,&char_array);
|
||||
parse_symbolic_expression(char_array, fields, variables, polynomial);
|
||||
free_Char_Array(char_array);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// compute the symbol tree from a string
|
||||
int char_array_to_symbol_tree(Char_Array str, Tree* symbol_tree){
|
||||
// buffer
|
||||
char* buffer=calloc(str.length+1,sizeof(char));
|
||||
char* buffer_ptr=buffer;
|
||||
Tree child;
|
||||
int match;
|
||||
Char_Array nodestr;
|
||||
Char_Array label;
|
||||
Char_Array str_clean;
|
||||
int mode;
|
||||
int comment=0;
|
||||
int j;
|
||||
int gotanode=0;
|
||||
|
||||
// allocate memory
|
||||
init_Tree(symbol_tree,SYMBOL_TREE_SIZE, SYMBOL_TREE_LABEL_SIZE);
|
||||
|
||||
// remove comments, ' ' and '\n'
|
||||
init_Char_Array(&str_clean,str.length);
|
||||
for(j=0;j<str.length;j++){
|
||||
if(comment==1){
|
||||
if(str.str[j]=='\n'){
|
||||
comment=0;
|
||||
}
|
||||
}
|
||||
else{
|
||||
switch(str.str[j]){
|
||||
case ' ':break;
|
||||
case '\n':break;
|
||||
// comments
|
||||
case '#':
|
||||
comment=1;
|
||||
break;
|
||||
default:
|
||||
char_array_append(str.str[j],&str_clean);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if the string contains no '<', then trivial tree
|
||||
for(j=0;j<str_clean.length;j++){
|
||||
if(str_clean.str[j]=='<'){
|
||||
break;
|
||||
}
|
||||
}
|
||||
// no '<': trivial tree
|
||||
if(j==str_clean.length){
|
||||
tree_set_label(str_clean, symbol_tree);
|
||||
free(buffer);
|
||||
free_Char_Array(str_clean);
|
||||
return(0);
|
||||
}
|
||||
|
||||
*buffer_ptr='\0';
|
||||
// loop over the input string
|
||||
// start in null mode
|
||||
mode=SP_NULL_MODE;
|
||||
for(j=0;j<str_clean.length;j++){
|
||||
switch(str_clean.str[j]){
|
||||
// new node
|
||||
case '<':
|
||||
// find matching bracket
|
||||
match=matching_bracket(str_clean,j);
|
||||
// check whether it exists
|
||||
if(match<0){
|
||||
fprintf(stderr,"syntax error: unmatched brackets in %s\n",char_array_to_str_noinit(&str));
|
||||
exit(-1);
|
||||
}
|
||||
// extract substring until bracket
|
||||
char_array_substring(str_clean,j+1,match-1,&nodestr);
|
||||
|
||||
// check whether node is trivial
|
||||
if(j==0 && match==str_clean.length-1){
|
||||
free_Tree(*symbol_tree);
|
||||
char_array_to_symbol_tree(nodestr, symbol_tree);
|
||||
free_Char_Array(nodestr);
|
||||
j=match;
|
||||
break;
|
||||
}
|
||||
|
||||
// parse subexpression
|
||||
char_array_to_symbol_tree(nodestr, &child);
|
||||
free_Char_Array(nodestr);
|
||||
// add child to tree
|
||||
tree_append_child_noinit(child, symbol_tree);
|
||||
// boolean indicating a node has been found
|
||||
gotanode=1;
|
||||
// set next position after the node
|
||||
j=match;
|
||||
|
||||
// if function mode, then check that the match is at the end of the node
|
||||
if(mode==SP_FUNCTION_MODE){
|
||||
if(match<str_clean.length-1){
|
||||
fprintf(stderr,"syntax error: functions must occupy an entire node (e.g. <%%exp<...>>), got %s\n",char_array_to_str_noinit(&str));
|
||||
exit(-1);
|
||||
}
|
||||
else{
|
||||
// set label
|
||||
str_to_char_array(buffer,&label);
|
||||
tree_set_label(label,symbol_tree);
|
||||
free_Char_Array(label);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// function
|
||||
case '%':
|
||||
if(j>0){
|
||||
fprintf(stderr,"syntax error: functions must occupy an entire node (e.g. <%%exp<...>>), got %s\n",char_array_to_str_noinit(&str));
|
||||
exit(-1);
|
||||
}
|
||||
mode=SP_FUNCTION_MODE;
|
||||
break;
|
||||
|
||||
// product
|
||||
case '*':
|
||||
if(gotanode==0){
|
||||
fprintf(stderr,"syntax error: '*' is not preceded by a node in %s\n",char_array_to_str_noinit(&str));
|
||||
exit(-1);
|
||||
}
|
||||
if(j>=str_clean.length-1){
|
||||
fprintf(stderr,"syntax error: '*' cannot be at the end of an expression, got %s\n",char_array_to_str_noinit(&str));
|
||||
exit(-1);
|
||||
}
|
||||
// set label
|
||||
init_Char_Array(&label,1);
|
||||
char_array_append('*',&label);
|
||||
tree_set_label(label,symbol_tree);
|
||||
free_Char_Array(label);
|
||||
// next child
|
||||
char_array_substring(str_clean,j+1,str_clean.length-1,&nodestr);
|
||||
// parse subexpression
|
||||
char_array_to_symbol_tree(nodestr, &child);
|
||||
free_Char_Array(nodestr);
|
||||
// append next child
|
||||
tree_append_child_noinit(child, symbol_tree);
|
||||
|
||||
// make it stop
|
||||
j=str_clean.length-1;
|
||||
break;
|
||||
|
||||
// sum
|
||||
case '+':
|
||||
if(gotanode==0){
|
||||
fprintf(stderr,"syntax error: '+' is not preceded by a node in %s\n",char_array_to_str_noinit(&str));
|
||||
exit(-1);
|
||||
}
|
||||
if(j>=str_clean.length-1){
|
||||
fprintf(stderr,"syntax error: '+' cannot be at the end of an expression, got %s\n",char_array_to_str_noinit(&str));
|
||||
exit(-1);
|
||||
}
|
||||
// set label
|
||||
init_Char_Array(&label,1);
|
||||
char_array_append('+',&label);
|
||||
tree_set_label(label,symbol_tree);
|
||||
free_Char_Array(label);
|
||||
// next child
|
||||
char_array_substring(str_clean,j+1,str_clean.length-1,&nodestr);
|
||||
// parse subexpression
|
||||
char_array_to_symbol_tree(nodestr, &child);
|
||||
free_Char_Array(nodestr);
|
||||
// append next child
|
||||
tree_append_child_noinit(child, symbol_tree);
|
||||
|
||||
// make it stop
|
||||
j=str_clean.length-1;
|
||||
break;
|
||||
|
||||
default:
|
||||
if(mode!=SP_NULL_MODE){
|
||||
// write to buffer
|
||||
buffer_ptr=str_addchar(buffer_ptr,str_clean.str[j]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free_Char_Array(str_clean);
|
||||
free(buffer);
|
||||
return(0);
|
||||
}
|
||||
// from char*
|
||||
int str_to_symbol_tree(char* str, Tree* symbol_tree){
|
||||
Char_Array char_array;
|
||||
str_to_char_array(str,&char_array);
|
||||
char_array_to_symbol_tree(char_array,symbol_tree);
|
||||
free_Char_Array(char_array);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// find matching '<' and '>'
|
||||
int matching_bracket(Char_Array str, int start){
|
||||
int bracket_count=0;
|
||||
int i;
|
||||
for(i=start;i<str.length;i++){
|
||||
if(str.str[i]=='<'){
|
||||
bracket_count++;
|
||||
}
|
||||
else if(str.str[i]=='>'){
|
||||
bracket_count--;
|
||||
if(bracket_count==0){
|
||||
return(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if the function has not returned, then no matching bracket
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
// resolve a symbol tree to its corresponding polynomial
|
||||
int resolve_symbol_tree(Tree symbol_tree, Fields_Table fields, Variables variables, Polynomial* output){
|
||||
Polynomial poly;
|
||||
Tree variable_tree;
|
||||
|
||||
// trivial tree
|
||||
if(symbol_tree.length==0){
|
||||
// variable
|
||||
if(symbol_tree.root_label.length>0 && symbol_tree.root_label.str[0]=='$'){
|
||||
variables_find_var(symbol_tree.root_label, variables, &variable_tree);
|
||||
resolve_symbol_tree(variable_tree, fields, variables, output);
|
||||
free_Tree(variable_tree);
|
||||
}
|
||||
//polynomial
|
||||
else{
|
||||
Char_Array_to_Polynomial(symbol_tree.root_label, output);
|
||||
}
|
||||
}
|
||||
|
||||
// exp
|
||||
else if (char_array_cmp_str(symbol_tree.root_label,"exp")==1){
|
||||
if(symbol_tree.length!=1){
|
||||
fprintf(stderr,"syntax error: exp must have 1 argument\n");
|
||||
exit(-1);
|
||||
}
|
||||
resolve_symbol_tree(symbol_tree.children[0], fields, variables, &poly);
|
||||
polynomial_exponential(poly, output, fields);
|
||||
free_Polynomial(poly);
|
||||
}
|
||||
|
||||
// log
|
||||
else if (char_array_cmp_str(symbol_tree.root_label,"log_1")==1){
|
||||
if(symbol_tree.length!=1){
|
||||
fprintf(stderr,"syntax error: log_1 must have 1 argument\n");
|
||||
exit(-1);
|
||||
}
|
||||
resolve_symbol_tree(symbol_tree.children[0], fields, variables, &poly);
|
||||
polynomial_logarithm(poly, output, fields);
|
||||
free_Polynomial(poly);
|
||||
}
|
||||
|
||||
// product
|
||||
else if (char_array_cmp_str(symbol_tree.root_label,"*")==1){
|
||||
if(symbol_tree.length!=2){
|
||||
fprintf(stderr,"syntax error: '*' must have 2 arguments\n");
|
||||
exit(-1);
|
||||
}
|
||||
resolve_symbol_tree(symbol_tree.children[0], fields, variables, output);
|
||||
resolve_symbol_tree(symbol_tree.children[1], fields, variables, &poly);
|
||||
polynomial_prod_chain(poly, output, fields);
|
||||
free_Polynomial(poly);
|
||||
}
|
||||
|
||||
// sum
|
||||
else if (char_array_cmp_str(symbol_tree.root_label,"+")==1){
|
||||
if(symbol_tree.length!=2){
|
||||
fprintf(stderr,"syntax error: '+' must have 2 arguments\n");
|
||||
exit(-1);
|
||||
}
|
||||
resolve_symbol_tree(symbol_tree.children[0], fields, variables, output);
|
||||
resolve_symbol_tree(symbol_tree.children[1], fields, variables, &poly);
|
||||
polynomial_add_chain_noinit(poly, output, fields);
|
||||
}
|
||||
|
||||
else{
|
||||
fprintf(stderr,"syntax error: unrecognized operation '%s'\n",char_array_to_str_noinit(&(symbol_tree.root_label)));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
42
src/symbolic_parser.h
Normal file
42
src/symbolic_parser.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright 2015-2022 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
parse symbolic expressions
|
||||
*/
|
||||
|
||||
#ifndef SYMBOLIC_PARSER_H
|
||||
#define SYMBOLIC_PARSER_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
// parse a symbolic expression from a char_array
|
||||
int parse_symbolic_expression(Char_Array str, Fields_Table fields, Variables variables, Polynomial* polynomial);
|
||||
// from char*
|
||||
int parse_symbolic_expression_str(char* str, Fields_Table fields, Variables variables, Polynomial* polynomial);
|
||||
|
||||
// compute the symbol tree from a string
|
||||
int char_array_to_symbol_tree(Char_Array str, Tree* symbol_tree);
|
||||
// from char*
|
||||
int str_to_symbol_tree(char* str, Tree* symbol_tree);
|
||||
|
||||
// find matching '<' and '>'
|
||||
int matching_bracket(Char_Array str, int start);
|
||||
|
||||
// resolve a symbol tree to its corresponding polynomial
|
||||
int resolve_symbol_tree(Tree symbol_tree, Fields_Table fields, Variables variables, Polynomial* output);
|
||||
|
||||
#endif
|
12
src/tools.c
12
src/tools.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -140,3 +140,13 @@ int min(int x1, int x2){
|
||||
return(x2);
|
||||
}
|
||||
}
|
||||
|
||||
// check whether a divides b
|
||||
int is_factor(int a, int b){
|
||||
if(b-a*(b/a)==0){
|
||||
return(1);
|
||||
}
|
||||
else{
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -46,4 +46,7 @@ int intlist_find_err(int* list, int size, int x);
|
||||
int max(int x1, int x2);
|
||||
int min(int x1, int x2);
|
||||
|
||||
// check whether a divides b
|
||||
int is_factor(int a, int b);
|
||||
|
||||
#endif
|
||||
|
117
src/tree.c
Normal file
117
src/tree.c
Normal file
@ -0,0 +1,117 @@
|
||||
/*
|
||||
Copyright 2015-2022 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 "tree.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "array.h"
|
||||
|
||||
// init
|
||||
int init_Tree(Tree* tree, int memory_children, int memory_label){
|
||||
init_Char_Array(&(tree->root_label),memory_label);
|
||||
(*tree).children=calloc(memory_children,sizeof(Tree));
|
||||
(*tree).memory=memory_children;
|
||||
(*tree).length=0;
|
||||
return(0);
|
||||
}
|
||||
int free_Tree(Tree tree){
|
||||
int i;
|
||||
free_Char_Array(tree.root_label);
|
||||
for(i=0;i<tree.length;i++){
|
||||
free_Tree(tree.children[i]);
|
||||
}
|
||||
free(tree.children);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// copy
|
||||
int tree_cpy(Tree input, Tree* output){
|
||||
init_Tree(output,input.length, input.root_label.length);
|
||||
tree_cpy_noinit(input,output);
|
||||
return(0);
|
||||
}
|
||||
int tree_cpy_noinit(Tree input, Tree* output){
|
||||
int i;
|
||||
if((*output).memory<input.length){
|
||||
fprintf(stderr,"error: trying to copy a tree of length %d to another with memory %d\n",input.length, (*output).memory);
|
||||
exit(-1);
|
||||
}
|
||||
char_array_cpy_noinit(input.root_label,&(output->root_label));
|
||||
for(i=0;i<input.length;i++){
|
||||
tree_cpy(input.children[i],(*output).children+i);
|
||||
}
|
||||
|
||||
(*output).length=input.length;
|
||||
return(0);
|
||||
}
|
||||
|
||||
// resize memory
|
||||
int tree_resize(Tree* tree, int newsize){
|
||||
Tree new_tree;
|
||||
init_Tree(&new_tree,newsize,tree->root_label.memory);
|
||||
tree_cpy_noinit(*tree,&new_tree);
|
||||
free_Tree(*tree);
|
||||
*tree=new_tree;
|
||||
return(0);
|
||||
}
|
||||
|
||||
// set label
|
||||
int tree_set_label(Char_Array label, Tree* tree){
|
||||
if(label.length > tree->root_label.memory){
|
||||
char_array_resize(&(tree->root_label),label.length);
|
||||
}
|
||||
char_array_cpy_noinit(label,&(tree->root_label));
|
||||
return(0);
|
||||
}
|
||||
|
||||
// add a child to a tree
|
||||
int tree_append_child(Tree child, Tree* output){
|
||||
if((*output).length>=(*output).memory){
|
||||
tree_resize(output,2*(*output).memory+1);
|
||||
}
|
||||
tree_cpy(child,(*output).children+(*output).length);
|
||||
(*output).length++;
|
||||
return(0);
|
||||
}
|
||||
// add a child to a tree without allocating memory for the new child
|
||||
int tree_append_child_noinit(Tree child, Tree* output){
|
||||
if((*output).length>=(*output).memory){
|
||||
tree_resize(output,2*(*output).memory+1);
|
||||
}
|
||||
(*output).children[(*output).length]=child;
|
||||
(*output).length++;
|
||||
return(0);
|
||||
}
|
||||
|
||||
// concatenate the children of two trees
|
||||
int tree_concat_children(Tree input, Tree* output){
|
||||
int i;
|
||||
for(i=0;i<input.length;i++){
|
||||
tree_append_child(input.children[i],output);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
// noinit
|
||||
int tree_concat_children_noinit(Tree input, Tree* output){
|
||||
int i;
|
||||
for(i=0;i<input.length;i++){
|
||||
tree_append_child_noinit(input.children[i],output);
|
||||
}
|
||||
// free input array
|
||||
free(input.children);
|
||||
return(0);
|
||||
}
|
||||
|
48
src/tree.h
Normal file
48
src/tree.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright 2015-2022 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.
|
||||
*/
|
||||
|
||||
/* Trees */
|
||||
|
||||
#ifndef TREE_H
|
||||
#define TREE_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
int init_Tree(Tree* tree, int memory_children, int memory_label);
|
||||
int free_Tree(Tree tree);
|
||||
|
||||
// copy
|
||||
int tree_cpy(Tree input, Tree* output);
|
||||
int tree_cpy_noinit(Tree input, Tree* output);
|
||||
|
||||
// resize memory
|
||||
int tree_resize(Tree* tree, int newsize);
|
||||
|
||||
// set label
|
||||
int tree_set_label(Char_Array label, Tree* tree);
|
||||
|
||||
// add a child to a tree
|
||||
int tree_append_child(Tree tree, Tree* output);
|
||||
// add a child to a tree without allocating memory for the new child
|
||||
int tree_append_child_noinit(Tree tree, Tree* output);
|
||||
|
||||
// concatenate the children of two trees
|
||||
int tree_concat_children(Tree input, Tree* output);
|
||||
// noinit
|
||||
int tree_concat_children_noinit(Tree input, Tree* output);
|
||||
|
||||
#endif
|
||||
|
67
src/types.h
67
src/types.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 Ian Jauslin
|
||||
Copyright 2015-2022 Ian Jauslin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -21,6 +21,8 @@ limitations under the License.
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
#include <mpfr.h>
|
||||
|
||||
|
||||
// rational number
|
||||
typedef struct Q{
|
||||
@ -69,6 +71,15 @@ typedef struct Str_Array{
|
||||
int memory;
|
||||
} Str_Array;
|
||||
|
||||
// tree
|
||||
typedef struct Tree Tree;
|
||||
struct Tree{
|
||||
Char_Array root_label;
|
||||
Tree* children;
|
||||
int length;
|
||||
int memory;
|
||||
};
|
||||
|
||||
// polynomial
|
||||
typedef struct Polynomial{
|
||||
Int_Array* monomials;
|
||||
@ -114,6 +125,12 @@ typedef struct RCC{
|
||||
int* indices;
|
||||
int length;
|
||||
} RCC;
|
||||
// rcc using mpfr floats
|
||||
typedef struct RCC_mpfr{
|
||||
mpfr_t* values;
|
||||
int* indices;
|
||||
int length;
|
||||
} RCC_mpfr;
|
||||
|
||||
// identities between fields
|
||||
typedef struct Identities{
|
||||
@ -125,13 +142,21 @@ typedef struct Identities{
|
||||
int memory;
|
||||
} Identities;
|
||||
|
||||
// symbolic expressions
|
||||
typedef struct Symbols{
|
||||
// virtual_fields
|
||||
typedef struct Virtual_fields{
|
||||
int* indices;
|
||||
Polynomial* expr;
|
||||
int length;
|
||||
int memory;
|
||||
} Symbols;
|
||||
} Virtual_fields;
|
||||
|
||||
// variables used in symbolic expressions
|
||||
typedef struct Variables{
|
||||
Char_Array* var_names;
|
||||
Tree* symbol_trees;
|
||||
int length;
|
||||
int memory;
|
||||
} Variables;
|
||||
|
||||
// groups of independent fields
|
||||
typedef struct Groups{
|
||||
@ -151,9 +176,11 @@ typedef struct Fields_Table{
|
||||
// identities between fields
|
||||
Identities ids;
|
||||
// symbolic expressions (commuting)
|
||||
Symbols symbols;
|
||||
// list of anti-commuting variables (fields or symbols)
|
||||
Virtual_fields virtual_fields;
|
||||
// list of anti-commuting variables
|
||||
Int_Array fermions;
|
||||
// list of non-commuting variables
|
||||
Int_Array noncommuting;
|
||||
} Fields_Table;
|
||||
|
||||
// index labels
|
||||
@ -172,37 +199,21 @@ typedef struct Id_Table{
|
||||
int memory;
|
||||
} 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
|
||||
typedef struct Meankondo_Options{
|
||||
int threads;
|
||||
int chain;
|
||||
int print_progress;
|
||||
int group_poly;
|
||||
} Meankondo_Options;
|
||||
|
||||
typedef struct Numkondo_Options{
|
||||
int display_mode;
|
||||
int niter;
|
||||
long double tol;
|
||||
Char_Array eval_rccstring;
|
||||
mpfr_prec_t mpfr_prec;
|
||||
mpfr_exp_t mpfr_emax;
|
||||
} Numkondo_Options;
|
||||
|
||||
typedef struct Meantools_Options{
|
||||
@ -210,6 +221,10 @@ typedef struct Meantools_Options{
|
||||
int deriv_derivs;
|
||||
Int_Array deriv_vars;
|
||||
Char_Array eval_rccstring;
|
||||
int chain;
|
||||
Char_Array namespace;
|
||||
mpfr_prec_t mpfr_prec;
|
||||
mpfr_exp_t mpfr_emax;
|
||||
} Meantools_Options;
|
||||
|
||||
typedef struct Kondopp_Options{
|
||||
|
Loading…
x
Reference in New Issue
Block a user