Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jauslin <ian.jauslin@roma1.infn.it>2015-06-14 00:52:45 +0000
committerIan Jauslin <ian.jauslin@roma1.infn.it>2015-06-14 00:52:45 +0000
commitaa0f3ae2988d372b190b9bde2e75a6d17e744e93 (patch)
tree14482245c2fca27fcdad3078e97d0871352d52a7 /src/polynomial.h
Initial commitv1.2
Diffstat (limited to 'src/polynomial.h')
-rw-r--r--src/polynomial.h131
1 files changed, 131 insertions, 0 deletions
diff --git a/src/polynomial.h b/src/polynomial.h
new file mode 100644
index 0000000..ec50227
--- /dev/null
+++ b/src/polynomial.h
@@ -0,0 +1,131 @@
+/*
+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.
+*/
+
+/*
+Represent a polynomial as a list of monomials with factors
+*/
+
+#ifndef POLYNOMIAL_H
+#define POLYNOMIAL_H
+
+#include "types.h"
+
+// allocate memory
+int init_Polynomial(Polynomial* polynomial,int size);
+// free memory
+int free_Polynomial(Polynomial polynomial);
+
+// resize the memory allocated to a polynomial
+int resize_polynomial(Polynomial* polynomial,int new_size);
+
+// copy a polynomial
+int polynomial_cpy(Polynomial input, Polynomial* output);
+int polynomial_cpy_noinit(Polynomial input, Polynomial* output);
+
+// append an element to a polynomial
+int polynomial_append(Int_Array monomial, Int_Array factor, Number num, Polynomial* output);
+int polynomial_append_noinit(Int_Array monomial, Int_Array factor, Number num, Polynomial* output);
+// noinit, and if there already exists an element with the same monomial and factor, then just add numbers
+int polynomial_append_noinit_inplace(Int_Array monomial, Int_Array factor, Number num, Polynomial* output);
+
+// concatenate two polynomials
+int polynomial_concat(Polynomial input, Polynomial* output);
+int polynomial_concat_noinit(Polynomial input, Polynomial* output);
+int polynomial_concat_noinit_inplace(Polynomial input, Polynomial* output);
+
+// add polynomials
+int polynomial_add_chain(Polynomial input, Polynomial* inout, Fields_Table fields);
+// add polynomials (noinit)
+int polynomial_add_chain_noinit(Polynomial input, Polynomial* inout, Fields_Table fields);
+
+// multiply a polynomial by a scalar
+int polynomial_multiply_scalar(Polynomial polynomial, Number num);
+int polynomial_multiply_Qscalar(Polynomial polynomial, Q q);
+
+// change the sign of the monomials in a polynomial
+int polynomial_conjugate(Polynomial polynomial);
+
+// returns an initialized polynomial, equal to 1
+Polynomial polynomial_one();
+// returns an initialized polynomial, equal to 0
+Polynomial polynomial_zero();
+
+// check whether a polynomial is 0
+int polynomial_is_zero(Polynomial poly);
+
+// compute V^p
+int polynomial_power(Polynomial input_polynomial, Polynomial* output, int power, Fields_Table fields);
+// compute V*W
+int polynomial_prod(Polynomial input1, Polynomial input2, Polynomial* output, Fields_Table fields);
+int polynomial_prod_chain_nosimplify(Polynomial input, Polynomial* inout, Fields_Table fields);
+int polynomial_prod_chain(Polynomial input, Polynomial* inout, Fields_Table fields);
+// exp(V)
+int polynomial_exponential(Polynomial input_polynomial,Polynomial* output, Fields_Table fields);
+// log(1+W)
+int polynomial_logarithm(Polynomial input_polynomial, Polynomial* output, Fields_Table fields);
+
+// check whether a monomial vanishes
+int check_monomial(Int_Array monomial, Fields_Table fields);
+// check whether the product of two monomials will vanish
+int check_monomial_willnot_vanish(Int_Array monomial1, Int_Array monomial2, Fields_Table fields);
+// check whether one can add a term to a monomial without creating repetitions
+int check_monomial_addterm(Int_Array monomial, Int_Array term, Fields_Table fields);
+// check whether a monomial vanishes or has unmatched +/- fields
+int check_monomial_match(Int_Array monomial, Fields_Table fields);
+// remove terms with more plus internal fields than minus ones
+int remove_unmatched_plusminus(Polynomial* polynomial, Fields_Table fields);
+
+// denominator of a multinomal factor: m1!m2!...
+int multinomial(int power,int* terms);
+
+// simplify a Polynomial
+int polynomial_simplify(Polynomial* polynomial, Fields_Table fields);
+// sort a polynomial
+int polynomial_sort(Polynomial* polynomial, int begin, int end);
+// exchange two terms (for the sorting algorithm)
+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);
+// 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);
+// order fields: group, then parameter, external, internal
+int compare_monomial_terms_groups(Int_Array monomial, int pos1, int pos2, Fields_Table fields, Groups groups);
+
+// convert and idtable to a polynomial
+int idtable_to_polynomial(Id_Table idtable, Polynomial* polynomial);
+
+// replace the factors in a polynomial as prescribed by an equation in the form of a Grouped_Polynomial
+int replace_factors(Grouped_Polynomial equations, Polynomial* polynomial);
+
+// print a 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);
+
+//------------------------ Polynomial_Matrix --------------------------
+// init
+int init_Polynomial_Matrix(Polynomial_Matrix* matrix, int length);
+int free_Polynomial_Matrix(Polynomial_Matrix matrix);
+
+#endif